JV-ODE Physics Module (Win32)
BlitzMax Forums/BlitzMax Module Tweaks/JV-ODE Physics Module (Win32)
| ||
Current JV-ODE Version: 1.32 Now available for BlitzMax (Win32) & Blitz3D The JV-ODE Physics Wrapper is an advanced user library supporting almost all of the Open Dynamics Engine functions wrapped inside a DLL (Dynamic Link Library). The library can be used with any programming language that supports DLL's, including Blitz3D and BlitzMax (Win32). The Euler rotation system in JV-ODE has been adapted to match the left-handed Euler rotation used in Blitz3D, however functions for accessing Quaternion and Axis Angle rotation systems are also included. The full versions contain all of the necessary files to get you started, including over 40 demos showing the various features found in ODE and a complete Function Reference document. The BlitzMax (Win32) version also features a built-in 'bare-bones' OpenGL 3D engine module and B3D mesh loader module for demo purposes. To view more information and screenshots click here. Options are now available to purchase the wrapper using either PayPal or Share*it. The BlitzMax (Win32) restricted demo version is now available for download here (376KB) The Blitz3D restricted demo version is now available for download here (207KB) Have Fun :) Useful Links: ODE.org Website - ODE Wiki - ODE User Guide (PDF) - ODE User Guide (HTML) |
| ||
Very nice! Thanks for doing this. Russell |
| ||
Cheers Russell, you're welcome :) |
| ||
Hello VIP3R Maybe you should add some 2D examples with MAX JV-ODE. And also extending the running time of the demo cause 3 secondes is too short (or the simulation running too fast ;) |
| ||
Gasp! I have about 5 second to 'see' what the demo does!!!! |
| ||
huu?? I've 30 seconds, perhaps you should enable VSync then ^^ (and no my system isn't weak. CoreDuo 2Ghz with 7600GT and 2GB RAM :) ) |
| ||
The demos are limited to 4000 steps, this means 4000 iterations of the main loop. As Dreamora rightly points out, because there is no timing code included in the demos they will run at whatever speed your monitor refresh rate is running (eg. 85Hz), but -only- provided that your video card VSync option is ENABLED. With VSync disabled they will not be limited to the refresh rate and the main loop will execute with no timing restrictions at all (400+Hz?). [edit] The Flip default mode has changed to zero in the latest release of BlitzMax which could also affect the speed of the JV-ODE demos. To correct the problem change 'Flip' in the main loop to 'Flip 1', this will be fixed in the next JV-ODE release. @Armitage 1982: No problem, I'll prepare a 2D spheres demo for you shortly and post it here when done ;) |
| ||
Here's a 2D Spheres demo that you can try with the demo version of JV-ODE... [removed] The demo version of JV-ODE now includes the 2D Spheres demo / 2D Joint Support |
| ||
VIP3R, have you given any thought to writing this as a module, rather than a dll so that it could (theoretically) be more easily converted to Linux and Mac BMax? (Probably would mean massive re-writing, though...) Russell |
| ||
Yep, I gave it lots of careful thought. Linux isn't much of a problem but the Mac is, mostly due to the lack of required hardware. Now that there are two versions (PPC & Intel), doesn't that mean I would need both? Anyway, it's irrelevant really as I decided that it wasn't worth pursuing at this stage even with the purchase of one MacMini. You're right though, if I did make an ODE module, it would need to be a complete re-write from scratch rather than another version of JV-ODE. The BlitzMax version of JV-ODE is primarily aimed at developers who are only interested in supporting the Win32 platform and for users who wish to migrate their existing JV-ODE projects over from Blitz3D. |
| ||
Thanks for your efforts, anyway! Who knows, maybe Mark is adding physics to Max3D and that's why it's taking so long (*crosses fingers*). ;) Russell |
| ||
you mean like this? (scroll down a few logs to see the physics screeneis...) http://www.blitzbasic.com/logs/userlog.php?user=1&log=1043 |
| ||
JV-ODE V1.18 Update Released Please check your inbox :) The new update corrects an issue found in the Joint Feedback feature of JV-ODE. I've also updated the demos to use 'Flip 1' instead of 'Flip'. Please let me know if you experience any problems with the new update. :) |
| ||
@ VIP3R does JV-ODE will work in 3d gamestudio??? |
| ||
Hmm, I'm not familiar with 3D Game Studio, but providing it can access DLL's using the stdcall calling convention (like Blitz for example) it should work ok. You will need to create some kind of function declaration file like the Blitz3D decls or maybe something like the BlitzMax approach which uses the User32 API to load the library. |
| ||
JV-ODE V1.20 Update Released Please check your inbox :) JV-ODE is now compiled using ODE V0.7 which was released recently. To view the changes made to ODE, please visit the following ODE Wiki link: http://opende.sourceforge.net/wiki/index.php/Changelog Added new functions: dCreateHeightfield() dGeomHeightfieldDataCreate() dGeomHeightfieldDataDestroy() dGeomHeightfieldDataBuildSingle() dGeomHeightfieldDataSetBounds() dGeomHeightfieldSetHeightfieldData() dGeomHeightfieldGetHeightfieldData() dJointCreatePlane2D() dJointSetPlane2DXParam() dJointSetPlane2DYParam() dJointSetPlane2DAngleParam() Added new demos: CarDemo-See-Saw Demo-2DSpheres Demo-CollisionForces Demo-Ray It should be easier to build 2D simulations now that an official 2D joint has been added. 'TriMesh to TriMesh' collisions are now working in ODE, but they're slow so use with care. The flat-ended cylinder geom now collides with TriMeshes in V0.7 of ODE, but they've broken the 'Cylinder to Cylinder' and 'Cylinder to Plane' collisions so I've used the previous stable version (the same as in previous JV-ODE versions) until they fix it. Please let me know if you experience any problems with the new update. :) |
| ||
Here's four new demos to show how Geom Offsets are used. Geom Offsets are the replacement for the now obsolete Geom Transforms in ODE. [removed] These demos are included with the full version of JV-ODE |
| ||
Can you post some examples using the 2D joint? Thanks, John |
| ||
Hi John, [removed] The demo version of JV-ODE now includes the 2D Spheres demo / 2D Joint Support The usage of the 2D joint is very simple, you create an object then apply a 2D joint to it with the following code... Local Joint2D:Int=dJointCreatePlane2D(World,0) dJointAttach(Joint2D,ode.body,0)...now it will be locked on the Z axis, and free to move on the X and Y axis. Then you can apply the X/Y coordinates and rotation to a 2D object. |
| ||
VIP3R, the spheres don't appear to be acting correctly. It looks like they're not rolling on an axis but rolling oblong and slightly spinning. |
| ||
Hi Chroma, Hmm, I've just checked both the 3D and 2D spheres demos with BMax V1.24 without syncmods and also Bmax V1.24 with the latest syncmods. Everything seems to be working correctly here, I can't see any rotation issues. Is this with the included demos or your own code? |
| ||
It's with the demo. Can you make a ball with lines on it? That will for sure tell if the rotation while rolling is messing up. Perhaps my eyes are playing tricks on me with how the light bounces off the balls. |
| ||
In the demos, change the following shade mode... GL_SMOOTH to... GL_FLAT It's a lot easier to see the rotation with flat shading ;) |
| ||
I've just noticed, I don't seem to be receiving JV-ODE updates anymore. I'll drop you an email when I get home! :) |
| ||
Hi Cygnus, I flag any email addresses that return server errors etc when sending updates and make a note of them. Yours hasn't bounced or given an error so I can only assume it was sent successfully, maybe a spam filter caught it by mistake? As soon as I've heard from you I'll double check the address and re-send them for you ;) |
| ||
Whoops, forgot to check. I'll take a look later!!! *sets notification message* |
| ||
After some advice if possible. I was wondering how I was to setup a trimesh for use in 2D, all the demos only show terrains loaded in using the b3d loader. Basically imagine the 2d balls demo with a sloped terrain along the bottom of the screen - peaks and dips........ (just noticed that theres code in the blitz3D version - I shall investigate that code) |
| ||
You would create a profile of the TriMesh using the 2D drawing commands or an image to represent the TriMesh in 2D. The process for loading and using the actual B3D mesh remains the same as when used in 3D, make sure it's centered on the X and Z axis. The tricky bit is scaling the TriMesh and 2D representation to correctly match each other. @Cygnus: I've replied to your email, did you receive it ok? |
| ||
I was thinking more on the lines that the trimesh could be created in real time. It looks like a bit of maths to get a poly line chopped into triangles is needed ? |
| ||
Hmm, are you modifying the mesh continuously? I'm not sure why you would need to create it in real time. Doing so would be extremely slow and prone to penetration issues. If you explain the overall idea a little, I might be able to come up with a few suggestions. |
| ||
Not modifying them but more creating them in an editor rather than as a 3d model. i.e. as a series of points. Take for example a 2D platform game with slopes etc.... It would be nice to trace the contour of the platforms/slopes (done using the editor by the use of polylines) see middle pic If the map was a scrolling one, these poly collisions could be turned off and on depending if they were visible on screen or not (so not overloading the ODE). Im almost certain the polyline would have to be triangulated (see bottom picture). - (the maths of which frightens me :S) I suppose the points could be joined together with cylinders ? - but that seems alot of cylinders rather than 1 trimesh ? ![]() |
| ||
What about creating several prefabricated mesh blocks? For example a flat section, steep slope, shallow slope etc. You can add and remove them individually in a scrolling scenario. It would also work well in an editor. You should use a separate sub-space for the TriMesh blocks and disable internal collide mode to prevent them colliding with each other. See the CarDemo-TriMeshX4 demo for an example of using multiple TriMeshes with internal collide mode disabled. There's also some more info in the JV-ODE Function Reference. I might have misunderstood though as I'm still not 100% clear on what you're trying to do, let me know if so ;) |
| ||
Imagine a 2d platofrm game that can utalise the physics engine, things fall off platforms, fall down slopes etc... I was thinking more of speed and perfomance in using 1 trimesh rather than many pre-fabricated blocks. A typical screen 640x480, tiles = 16x16 would mean about 1200 pre-fabricated blocks, would the engine cope with so many ? I think Im going to bite the bullet and get a poly->single surface to work, seems more optimised. |
| ||
You won't need that many blocks, only the top edge of the platform would need to be created. Visualise it as if you're looking down from above to the platform below (along the Y axis), not from the front (Z axis). In your example image you would need 7 blocks to represent the slopes and flat areas. These can be as simple as 7 quads, from the side all you would see is 7 lines or the profile of the quads (like your poly lines), but looking down from above you would see 7 quads. In the bottom image you wouldn't need the mesh where the soil layer is because nothing would be colliding there, everything would fall onto the grass layer from above. [edit] Here you go, this should explain it better... ![]() Even though the design is 2D, you still need to think of it in 3 dimensions. Look at the 2D Spheres demo, the ground plane would just be a single line in 2D, but in reality it's actually a huge 3D quad. JV-ODE can handle a very large amount of any geom type including TriMeshes without much of a speed hit, so you should be fine performance wise. |
| ||
Yea were on the same lines just I was looking at it from the side - I knew that the shape would have to be extruded. (nice picture BTW) I'll try it with pre-fabracated blocks, with a fall back to a multi sided poly if the performance hit is too large. I will also use internal collide mode disabled. Thanks for the advice. |
| ||
You're welcome, good luck :) |
| ||
So far so good![]() Generated slope from prefabricated blocks. I load in the 3d block into blitz3D where I then outputs the list of tris and verts to a file. In MAX I load these blocks in once, and save them to a suitable structure for easy access. Wrote a small 2d draw routine that plots the verts so I could correct the scale of the imported blocks. |
| ||
JV-ODE V1.21 Update Released Please check your inbox :) The new update includes the following additions... Fixed dBodyGetMass() issue Added new functions: dMassRotateQuaternion(mass,qw#,qx#,qy#,qz#) - alternative rotation system for dMassRotate() dMassRotateAxisAngle(mass,angle#,rx#,ry#,rz#) - alternative rotation system for dMassRotate() Added new demos: CarDemo-GeomOffset-Car CarDemo-GeomOffset-Cube CarDemo-GeomOffset-Mixed CarDemo-GeomOffset-Sphere Please let me know if you experience any problems with the new update. :) |
| ||
Here's a couple of new demos to play with... [removed] These demos are included with the full version of JV-ODE |
| ||
whats the big deal why do you still shy from linux, what the big deal (there isnt one) |
| ||
You're right there's no big deal, it's nothing other than common sense ;) |
| ||
Its just I dont own a copy of windows any more (and aint missing it either!) so cant use your product. I don't see what's "common sense" about not supporting a platform that *much* easier to develop in/for .... |
| ||
I continuously re-assess the possibility and if anything changes you'll be the first to know. |
| ||
JV-ODE V1.22 Update Released Please check your inbox :) Changed dGeomTransformSetCleanup(geom,mode) - to prevent potential memory leaks, mode 1 is no longer supported To remain backwards compatible the above function can still be used, but it will silently return to 'mode 0' if an attempt to use 'mode 1' is made. Added new demos: Demo-Iceberg Demo-Water Please let me know if you experience any problems with the new update. :) |
| ||
JV-ODE V1.24 Update Released Please check your inbox :) JV-ODE is now compiled using ODE V0.8 source. To view the changes made to ODE, please visit the ODE Wiki link located here. A new 'Prismatic and Rotoide' joint has been added, you can learn more about this type of joint here... http://opende.sourceforge.net/wiki/index.php/Manual_(Joint_Types_and_Functions)#Prismatic_and_Rotoide Added new functions: dJointGetUniversalAngles() dJointCreatePR() dJointSetPRAnchor() dJointSetPRAxis1() dJointSetPRAxis2() dJointSetPRParam() dJointAddPRTorque() dJointGetPRAnchor() dJointGetPRPosition() dJointGetPRPositionRate() dJointGetPRAxis1() dJointGetPRAxis2() dJointGetPRParam() The dMassTranslate() function is no longer supported in JV-ODE, as its main purpose was to be used in conjunction with Geom Transforms (which are now depreciated). To achieve the same results, you can use Geom Offsets to offset the geom from the body, which effectively moves the mass center of gravity. A more accurate option is to build objects using multiple bodies giving each an individual mass value, then join them with fixed joints. To remain backwards compatible, the dMassTranslate() function can still be used, but its effect will be the same as using dMassTranslate(mass,0,0,0). There is also an updated JV-ODE 'C' include file available on request for registered users who wish to use JV-ODE in C++ using the Blitz3DSDK. Please let me know if you experience any problems with the new update. :) |
| ||
JV-ODE V1.26 Update Released Please check your inbox :) JV-ODE is now compiled using ODE V0.9 which includes a vast amount of fixes and tweaks. You can view the ODE changelog for specific details here. Added new functions: dJointSetBallParam(joint,param,value#) dJointGetBallParam#(joint,param) dJointSetFixedParam(joint,param,value#) dJointGetFixedParam#(joint,param) dMassSetTriMeshTotal(mass,totalmass#,geom) Please let me know if you experience any problems with the new update. :) |
| ||
Thanks Viper I'm off to experiment with BMax, ODE, and LW2. This looks interesting: dMassSetTriMeshTotal(mass,totalmass#,geom) |
| ||
You're welcome :) TriMesh mass is a nightmare to set up properly, in its current form you have to set the center of gravity at the origin of the mesh for it to work. It's still much easier to apply box mass as an approximation instead tbh. |
| ||
do you still have to pay for the blitzmax version if you own the blitz3d version? |
| ||
Not the full amount, you get a 50% discount with a voucher code. |
| ||
JV-ODE V1.27 Update Released Please check your inbox :) Added new functions: dInitODE() dBodySetAutoDisableAverageSamplesCount(body,averagesamplescount) dBodyGetAutoDisableAverageSamplesCount%(body) dBodyGetWorld%(body) dCreateConvex%(space,planes,planecount,points,pointcount,polygons) dGeomSetConvex(geom,planes,planecount,points,pointcount,polygons) dMassSetTriMesh(mass,density#,geom) Notice the dInitODE() function? At one time it was obsolete so was never added to JV-ODE, however it will become mandatory in future versions of ODE. It's still optional in this release but it would be wise to start adding it to your code. If you're using the Blitz3D version of JV-ODE, it has already been added for you at the top of the JV-ODE include file. If you're using the BlitzMax version of JV-ODE, you will need to add it to your code yourself. Another function which had become obsolete has sprung to life again, the dMassTranslate() function is now supported again in JV-ODE. We also now have Convex geom support, don't forget it's new so I'm not sure how stable it is yet ;) Please let me know if you experience any problems with the new update. :) |
| ||
Hi VIP3R, I'm playing around with the BlitzMax demo of JV-ODE. I'm converting my old Blitz3D code over to BlitzMax and my program crashes on the line: Local Joints:Int = dBodyGetNumJoints (Body)and I get the error message: Identifier "dBodyGetNumJoints" not found.Is the command name different in BlitzMax? |
| ||
Hi JA2, All function names are identical in both versions of Blitz. The dBodyGetNumJoints() function is only available in the full version of JV-ODE though. |
| ||
Thanks for the reply, VIP3R. Looks like I shall be buying your BlitzMax version soon then. I shall email you for a discount coupon in a few days time if that's okay :) |
| ||
Sure, no problem :) |
| ||
JV-ODE V1.28 Update Released Please check your inbox :) All JV-ODE demos have been updated, tweaked and improved. Added new demos: CarDemo-AABB CarDemo-Duo CarDemo-Velocity Demo-RayPick (Blitz3D Version) Demo-Slider Demo-TriMeshes (BlitzMax Version) The following demos now use Geom Offsets instead of Geom Transforms... CarDemo-TruckTrailer CarDemo-SphereWrapCylinder Demo-RagDolls-Zombie (Blitz3D Version) The old Geom Transform demos are obsolete and have been removed, however Geom Transforms are still supported in JV-ODE. The JV-ODE OpenGL 3D Engine module in the BlitzMax version has been completely redesigned to mimic the command set and appearance of Blitz3D. All JV-ODE BlitzMax demos have been modified to use the new 3D engine. It is now much easier to convert the demos to run in MiniB3D, for example to convert the Demo-Spheres code, change the Framework to SiDesign.MiniB3D and comment out the Blitz Plane code - that's it. An updated Leadwerks Engine Demo Pack is also available from the Leadwerks Forums. Please let me know if you experience any problems with the new update. :) |
| ||
hi I cant seem to pay you with paypal with shareit. It keeps saying the payment didnt go through. Could I pay you directly with paypal? |
| ||
No problem, I've emailed you with further instructions. |
| ||
JV-ODE V1.32 Update Released Please check your inbox :) JV-ODE is now compiled using ODE V0.10.1 which includes several additions, fixes and tweaks. You can view the ODE changelog for specific details here and here. Important Notes: JV-ODE V1.32 immediately follows V1.28, there were no versions released in between them. The version number has increased by 4 because there were 4 major changes made to JV-ODE for this update, two new ODE core updates (V0.10 and V0.10.1) and a wrapper update for each core. The ODE core V0.10 was broken, therefore the core was replaced with the new V0.10.1 bugfix release. The ODE core has been compiled using the new TriMesh>TriMesh collider to give improved results. As previously warned, you must initialize this version of ODE by calling dInitODE() before dWorldCreate(). It is now mandatory and failure to do so will result in an error. The dGeomTriMeshDataBuildSimple() function is not as stable as it was in previous releases, causing faulty collision contacts to be generated. To avoid the problem, the JV-ODE TriMesh creation functions have been modified to use dGeomTriMeshDataBuildSingle() instead, which also has the added benefit of a smaller memory footprint. If you have built your own 'CreateTriMesh()' functions, it is highly recommended you change over to use dGeomTriMeshDataBuildSingle() too, you can use the built-in functions as a guide. The new update includes built-in damping, 'sweep and prune' collision spaces, prismatic-universal & piston joints and multiple thread support (untested). Added new functions: dInitODE2(initflags) dAllocateODEDataForThread%(allocateflags) dCleanupODEAllDataForThread() dWorldGetLinearDamping#(world) dWorldGetAngularDamping#(world) dWorldSetLinearDamping(world,scale#) dWorldSetAngularDamping(world,scale#) dWorldSetDamping(world,linear_scale#,angular_scale#) dWorldGetLinearDampingThreshold#(world) dWorldGetAngularDampingThreshold#(world) dWorldSetLinearDampingThreshold(world,threshold#) dWorldSetAngularDampingThreshold(world,threshold#) dWorldGetMaxAngularSpeed#(world) dWorldSetMaxAngularSpeed(world,max_speed#) dSpaceSetSublevel(space,sublevel) dSpaceGetSublevel%(space) dSpaceGetClass%(space) dSweepAndPruneSpaceCreate%(space,axisorder) dBodyGetLinearDamping#(body) dBodyGetAngularDamping#(body) dBodySetLinearDamping(body,scale#) dBodySetAngularDamping(body,scale#) dBodySetDamping(body,linear_scale#,angular_scale#) dBodyGetLinearDampingThreshold#(body) dBodyGetAngularDampingThreshold#(body) dBodySetLinearDampingThreshold(body,threshold#) dBodySetAngularDampingThreshold(body,threshold#) dBodySetDampingDefaults(body) dBodyGetMaxAngularSpeed#(body) dBodySetMaxAngularSpeed(body,max_speed#) dBodyGetFirstGeom%(body) dBodyGetNextGeom%(geom) dJointSetHingeAxisOffset(joint,x#,y#,z#,angle#) dJointGetNumBodies%(joint) dJointCreatePU%(world,group) dJointSetPUAnchor(joint,x#,y#,z#) dJointSetPUAnchorDelta(joint,x#,y#,z#,dx#,dy#,dz#) dJointSetPUAxis1(joint,x#,y#,z#) dJointSetPUAxis2(joint,x#,y#,z#) dJointSetPUAxis3(joint,x#,y#,z#) dJointSetPUAxisP(joint,x#,y#,z#) dJointSetPUParam(joint,parameter,value#) dJointGetPUPosition#(joint) dJointGetPUPositionRate#(joint) dJointGetPUAnchor(joint) dJointGetPUAxis1(joint) dJointGetPUAxis2(joint) dJointGetPUAxis3(joint) dJointGetPUAxisP(joint) dJointGetPUAngles(joint) dJointGetPUAngle1#(joint) dJointGetPUAngle2#(joint) dJointGetPUAngle1Rate#(joint) dJointGetPUAngle2Rate#(joint) dJointGetPUParam#(joint,parameter) dJointCreatePiston%(world,group) dJointSetPistonAnchor(joint,x#,y#,z#) dJointSetPistonAnchorOffset(joint,x#,y#,z#,dx#,dy#,dz#) dJointSetPistonAxis(joint,x#,y#,z#) dJointSetPistonParam(joint,parameter,value#) dJointGetPistonAnchor(joint) dJointGetPistonAnchor2(joint) dJointGetPistonAxis(joint) dJointGetPistonPosition#(joint) dJointGetPistonPositionRate#(joint) dJointGetPistonAngle#(joint) dJointGetPistonAngleRate#(joint) dJointAddPistonForce(joint,force#) dJointGetPistonParam#(joint,parameter) Please let me know if you experience any problems with the new update. :) |
| ||
Viper, can i get an ODE update? I'm a customer. Please let me know. Thanks. |
| ||
Sure, can you email me your registered name and email address? |
| ||
Is this Still being developed? I'm looking at purchasing. Also is there a manual? Thanks, Eric |
| ||
Yes, it's constantly updated and supported. JV-ODE comes with a complete function reference which should be used in conjunction with the following official ODE docs... http://opende.sourceforge.net/wiki/index.php/Manual http://www.ode.org/ode-latest-userguide.html (not the latest, despite the title) |
| ||
I just purchased JV-ODE and am going through the Demos.. I rebuilt my docs but the JV-ODE Keywords are still not highlighted... Can you help me? Thanks, Eric |
| ||
Hi Eric, The keywords don't highlight in the IDE as there are currently no built-in docs in JV-ODE. |
| ||
Are you planning on doing that? Keyword Highlighting is really important to me. Thanks for your time, Eric |
| ||
Duplicating existing documentation on over 500 functions to make the keywords highlight in the default IDE is not very high on the 2do list to be honest. It would be nice if BlitzMax behaved in the same way as Blitz3D in this respect. Have you tried the BLIde IDE? I think there's an option to highlight all module functions regardless of module docs, so it should work with JV-ODE too. There's more info here... http://www.blitzmax.com/Community/posts.php?topic=77546#868652 |
| ||
I understand. Eric |
| ||
Does JV-ODE work with the Blitz3d SDK In Bmax? I hope so.. :) Do you have any demos with this setup? |
| ||
Yes JV-ODE will work with any 3D engine including the Blitz3D SDK. There are no Blitz3D SDK specific demos, however as the built-in JV-ODE OpenGL 3D Engine uses an almost identical command set to Blitz3D, it's a trivial task to edit the demo code to get it working with the SDK (or MiniB3D). In most cases you just need to add the 'bb' prefix to the function names. To see the functions used in the JV-ODE OpenGL 3D Engine, look at the 'JV-ODE-OpenGL-3DEngine.txt' file in the 'JV-ODE Physics BlitzMax/docs' folder. |
| ||
What about the create Trimesh Function.. I couldn't seem to get it to work. Does it work with in Blitz3D SDK? Can you maybe help? Thanks, Eric Will I get automatic updates to the E-mail Address I used on Share-it? |
| ||
You can use the extra CreateMiniB3DTriMesh() function as a guide, you will find it in the misc folder of JV-ODE. To convert it for use with the SDK, replace the MiniB3D functions with the SDK equivalent, for example... mesh.CountSurfaces() change to... bbCountSurfaces(mesh) If you get stuck let me know and I'll help you. You will receive an email with a new download link whenever an update is released, this is sent to the email address you registered during your purchase at Share-it. |
| ||
What are the limitations of surfaces and vertexs? It seems that when I have more than two TriMeshes it crashes. |
| ||
Can you post or send me your CreateTriMesh() function? it sounds like something isn't set up correctly. Might be worth posting the section of code that calls the CreateTriMesh() function too. |
| ||
' ################################################################################################### ' # JV-ODE - CreateMiniB3DTriMesh Function # ' # Code by Jim Williams (VIP3R) # ' # Devious Codeworks - Copyright © 2008 # ' ################################################################################################### ' updated to use blitz3d SDK - Eric Global TriBank:TBank Global VertBank:TBank ' ################################################################################################### Function CreateB3DMesh:Int(trispace:Int,mesh:Int) Local Tri:Int=0 Local Vert:Int=0 Local Count:Int=0 Local Corner:Int=0 Local TriCount:Int=0 Local VertCount:Int=0 Local Surface:Int For Count=1 To bbCountSurfaces(mesh) Surface=bbGetSurface(mesh,Count) TriCount=TriCount+bbCountTriangles(Surface) VertCount=VertCount+bbCountVertices(Surface) Next TriBank=CreateBank(TriCount*3*4) VertBank=CreateBank(VertCount*3*4) Local Offset:Int=0 Local TriOffset:Int=0 Local VertOffset:Int=0 For Count=1 To bbCountSurfaces(mesh) Surface=bbGetSurface(mesh,Count) For Vert=0 To bbCountVertices(Surface)-1 PokeFloat(VertBank,Offset,bbVertexX(Surface,Vert)) Offset:+4 PokeFloat(VertBank,Offset,bbVertexY(Surface,Vert)) Offset:+4 PokeFloat(VertBank,Offset,bbVertexZ(Surface,Vert)) Offset:+4 Next For Tri=0 To bbCountTriangles(Surface)-1 For Corner=0 To 2 PokeInt(TriBank,TriOffset,bbTriangleVertex(Surface,Tri,Corner)+VertOffset) TriOffset:+4 Next Next VertOffset=VertOffset+bbCountVertices(Surface) Next Local TriMeshData:Int=dGeomTriMeshDataCreate() dGeomTriMeshDataBuildSingle(TriMeshData,BankBuf(VertBank),4,VertCount,BankBuf(TriBank),TriCount*3,4) Return dCreateTriMesh(trispace,TriMeshData) End Function ' ################################################################################################### ode:ODEGeom=New ODEGeom ode.body=dBodyCreate(World) dBodySetPosition(ode.body,xp,30,zp) dBodySetRotation(ode.body,0,0,0) dBodySetAutoDisableFlag(ode.body,1) ode.mesh=bbLoadMesh("media\head.x") bbScaleMesh ode.mesh,2.5,2.5,2.5 bbEntityShininess ode.mesh,0.7 ode.geom=CreateB3DMesh(Space,ode.mesh) dGeomSetBody(ode.geom,ode.body) maybe it's the .x format. If I create a simple cube everything is fine but if it's a little more complicated it crashes. I have no way to create a .b3d mesh. Thanks for your help. Eric |
| ||
Hmm, the code looks ok to me visually (can't run it as I don't have the SDK). You could try making the TriBank and VertBank local instead of global, but I doubt it will help. There are two .B3D meshes in the media folder of JV-ODE you can try, if those work then it's most likely the .X mesh as you suggested. Some meshes can crash ODE if the tris and verts are not formatted correctly (even .B3D meshes). You can also try using .3DS meshes if you have the option to export them. |
| ||
I am still playing with the Meshes. I have another Problem. I create one ODE Object. Then I try to apply a force.. If bbMouseHit(1) dBodyAddForce(Cube.Body,0.0,5.0,0.0) EndIf I get this error ODE internal Error 2 (..\..\ode\scr\ode.cpp:520) My simulation run perfectly until I click my mouse. |
| ||
Ok, if you get an ODE Internal Error assert on dBodyAddForce() it means that your Cube.Body isn't an ODE body. Check that Cube.Body still exists and hasn't been deleted/nulled, and check it's not beyond the scope of your MouseHit section of code (local somewhere else). |
| ||
Is there a way to move a body at the same speed, regardless of if its hitting another object. i.e. Move the body with an adjustable force to move all other bodies out of the way ? |
| ||
The easiest way I can think of is giving the body much more mass than the objects it's hitting, so that they provide very little resistance. |
| ||
Hmmmm Im trying to recreate a "penny falls" aracde game. trimesh witha coin shape is really slow so im trying to prove the concept with flat cubes for now. The problem I have is that the draw looses force depending on how much its having to "push". The mass of the draw is high (that does the pushing) and the coins are really low. You'll see when you run the code the draw slows and sometimes even stops. Im at a loss on how to proceed ? Anyhoo heres the code so far. Press Space to drop a cube SuperStrict Framework DevCode.JVODEOpenGL Import DevCode.JVODE Import BRL.Random Graphics3D 800,600,0,2 Local dir:Int = -1 Type ODEGeom Field body:Int Field geom:Int Field mesh:TMesh End Type Global ODEGeomList:TList=CreateList() ' ################################################################################################### ' ### Setup ODE dInitODE() Global World:Int=dWorldCreate() Global Space:Int=dHashSpaceCreate(0) Global ContactGroup:Int=dJointGroupCreate(0) dWorldSetERP(World,0.1) dWorldSetAutoDisableFlag(World,1) dWorldSetGravity(World, 0, -5, 0) dContactSetMode(dContactSlip1) dContactSetBounce(0) ' ### Create Light Global Light:TLight = CreateLight() PositionEntity Light,-40,70,-40 LightColor Light,255,255,255 AmbientLight 130,130,130 ' ### Create Camera Global Camera:TCamera = CreateCamera() CameraClsColor Camera,0,0,0 CameraRange Camera,1,1000 PositionEntity Camera,0,20,-50 RotateEntity Camera,30,0,0 ' ################################################################################################### Local PTime:Int Local PhysicsTime:Float createfloor() Local drawer:ODEGeom = createdrawer() createback() While Not AppTerminate() And Not KeyDown(KEY_ESCAPE) If KeyHit(KEY_SPACE) AddObject() EndIf ' move the drawer If dir = 1 Then dBodyAddForce drawer.body, 0, 0, (250 * dir) If dGeomGetPositionZ(drawer.geom) > 43 Then dir = -1 EndIf Else dBodyAddForce drawer.body, 0, 0, (250 * dir) If dGeomGetPositionZ(drawer.geom) < 43 Then dir = 1 EndIf EndIf UpdateGeoms() PTime = MilliSecs() dSpaceCollide(Space,World,ContactGroup) dWorldQuickStep(World,0.1) dJointGroupEmpty(ContactGroup) PhysicsTime=MilliSecs()-PTime RenderWorld Text 0, 15, "Physics Time:" + FixFloat(PhysicsTime) Flip True Wend dJointGroupDestroy(ContactGroup) dSpaceDestroy(Space) dWorldDestroy(World) dCloseODE() End ' ################################################################################################### ' add a coin Function AddObject() Local xp:Float Local zp:Float Local ode:ODEGeom xp=Rand(-20,20) ode:ODEGeom=New ODEGeom ode.body=dBodyCreate(World) dBodySetPosition(ode.body,xp,40,0) dBodySetRotation(ode.body, 90, 0, 0) ' rotate it dBodySetAutoDisableFlag(ode.body,1) ode.geom = dCreateBox(Space, 4, 0.7, 4) dGeomSetBody(ode.geom,ode.body) dGeomContactSetMu(ode.geom, 0.01) ' only a little bit of friction Local mass:Int = dMassCreate() dMassSetBoxTotal(mass, 0.001, 10, 5, 10) ' tiny little bit of mass dBodySetMass(ode.body,mass) dGeomContactSetBounce(ode.geom, -10) ode.MESH = CreateCube() ScaleMesh ode.MESH, 2, 0.4, 2 EntityColor ode.mesh,Rand(0,255),Rand(0,255),Rand(0,255) ListAddLast(ODEGeomList,ode:ODEGeom) End Function ' ################################################################################################### Function UpdateGeoms() Local ode:ODEGeom For ode:ODEGeom=EachIn ODEGeomList PositionEntity ode.mesh,dGeomGetPositionX(ode.geom),dGeomGetPositionY(ode.geom),dGeomGetPositionZ(ode.geom) RotateEntity ode.mesh,dGeomGetPitch(ode.geom),dGeomGetYaw(ode.geom),dGeomGetRoll(ode.geom) Next End Function ' ################################################################################################### ' Create the drawer that slides in and out Function CreateDrawer:ODEGeom() Local ode:ODEGeom ode:ODEGeom=New ODEGeom ode.body=dBodyCreate(World) dBodySetPosition(ode.body, 0, 2.5, 45) dBodySetRotation(ode.body,0,0,0) dBodySetAutoDisableFlag(ode.body,0) ode.geom = dCreateBox(Space, 50, 5, 100) dGeomSetBody(ode.geom,ode.body) ode.MESH = CreateCube() ScaleMesh ode.mesh,25,2.5,50 EntityColor ode.mesh,0,0,200 Local mass:Int=dMassCreate() dMassSetBoxTotal(mass, 900, 50, 5, 50) dBodySetMass(ode.body,mass) dGeomContactSetMu(ode.geom, 0) ' no friction dGeomContactSetBounce(ode.geom, 0) ' no bounce ListAddLast(ODEGeomList,ode:ODEGeom) Return ode End Function ' create a static barrier Function CreateBack:ODEGeom() ' create the Drawer Local ode:ODEGeom ode:ODEGeom=New ODEGeom ode.geom=dCreateBox(Space,50,5,5) dGeomSetRotation(ode.geom,0,0,0) dGeomSetPosition(ode.geom,0,7.5,4) ode.mesh=CreateCube() dGeomContactSetMu(ode.geom, 0.5) ScaleMesh ode.MESH, 25, 25, 2.5 EntityColor ode.mesh,192,0,0 ListAddLast(ODEGeomList,ode:ODEGeom) ' 'create small bar that will make the discs topple over ' ode:ODEGeom=New ODEGeom ode.geom = dCreateBox(Space, 50, 0.1, 0.1) dGeomSetRotation(ode.geom,0,0,0) dGeomSetPosition(ode.geom, 0, 8.8, -1) ode.MESH = CreateCube() dGeomContactSetMu(ode.geom, 0.1) ScaleMesh ode.MESH, 25, 0.05, 0.05 EntityColor ode.MESH, 0, 0, 255 ListAddLast(ODEGeomList,ode:ODEGeom) Return ode End Function ' create Floor Function CreateFloor:ODEGeom() Local ode:ODEGeom ode:ODEGeom=New ODEGeom ode.geom=dCreateBox(Space,50,5,100) dGeomSetRotation(ode.geom,0,0,0) dGeomSetPosition(ode.geom, 0, -2.50, 0) dGeomContactSetMu(ode.geom, 0) ode.mesh=CreateCube() ScaleMesh ode.mesh,25,2.5,50 EntityColor ode.mesh,192,0,0 ListAddLast(ODEGeomList,ode:ODEGeom) Return ode End Function |
| ||
Cool, those are fun! It looks to me like the drawer forces are getting out of control, if you look closely you will notice the drawer slides further with each stroke, eventually disappearing behind the barrier. Part of the problem is caused by the direction mechanism (<43 or >43), it's still trying to apply force in one direction during the switch, then applies force at the same time in the opposite direction. These forces will accumulate in ODE. To fix it, I've changed the direction switching code, including zeroing the forces on each direction change. I've also lowered the force to slow it down a bit (it was too fast after removing the conflicting forces). Here's the code... |
| ||
Hi, some questions if you don't mind :) How do I draw an overlay? I'd like to do something similar to the 2dSheres demo, but with the spheres in 3d in the background. This is to see what I'm doing as the game I'm making is actually purely 2D based, but will be using JV ODE for collisions with hills, rooftops, etc. How do I disable hidden surface removal? Whenever I import models, and I'm not sure if I'm making them wrong, the faces that show in the editor (both Maplet and DeleD) get's turned around 180 degrees half the time. Disbling this should fix my problem. |
| ||
Sure :) If you want to view the spheres in 3D but limit them to 2D motion, it would be easier to use the 3D spheres demo as a guide and copy the 2D joint code from the 2D spheres demo to restrict the motion to two planes (X and Y). If you get stuck, let me know. You didn't specify which 3D engine you're using, if you're using the built-in 3D engine that comes with JV-ODE, it's only suitable for experimenting with the JV-ODE demos (as BlitzMax has no native 3D engine). Mesh support is very limited in the JV-ODE 3D engine, MiniB3D would be more suitable (see the MiniB3D forum for downloads and more info). |
| ||
Thank you for the fast reply I have included links hidden throughout the post to guide you to what I'm trying to do. If you want to view the spheres in 3D but limit them to 2D motion, it would be easier to use the 3D spheres demo as a guide As mentioned the game I'm making is going to be 2D so mesh support isn't much of a problem concerning that - but I have MiniB3D installed as a module, and if I can use that in combination with JV-ODE then that would be great! I didn't exactly think of combining those. So I guess I just do something like including both modules, calling the appropriate functions from both, and then use BeginMax2D() to draw my overlay, right? =) That's amazing, it will even fix my mesh "issue" at the same time. Just ignore the included pictures, heh |
| ||
Yes JV-ODE works with MiniB3D, for example to convert the Demo-Spheres code, change the Framework from 'DevCode.JVODEOpenGL' to 'SiDesign.MiniB3D' and comment out the Blitz Plane code. It will then render the JV-ODE 3D Spheres demo with MiniB3D. The UpdateGeoms() function is where the position and rotation of the objects get updated, you can change it depending on whether you're rendering in 2D or 3D. The rest of the physics code remains the same in both 2D and 3D. |
| ||
Works like a charm. Right, now I need to disable rotation on all three axes of the bodies, and have been trying to do so for the past couple of hours... I reached the conclusion that setting the values each step didn't work very well, so I tried reading up on joints, and typed this: Local JointMotor:Int=dJointCreateLMotor(World,0) dJointSetLMotorNumAxes(JointMotor,3) dJointSetLMotorAxis(JointMotor, 0, 0, MapWidth,MapHeight,MapDepth) dJointSetLMotorAxis(JointMotor, 1, 0, MapWidth,MapHeight,MapDepth) dJointSetLMotorAxis(JointMotor, 2, 0, MapWidth,MapHeight,MapDepth) dJointAttach(JointMotor,ode.body,0) But this doesn't do what I hoped it would, so now I'm stuck again :( EDIT: reading what I just wrote I found that I forgot the 2 other axes :o Sorry about that EDIT again. Nope, things are still not axis aligned and snapped rotation wise |
| ||
It's not recommended, but you can reset the rotation every frame using the following code... dBodySetAngularVel(ode.body,0,0,0) dBodySetRotation(ode.body,0,0,0) I might be able to offer a better solution if you could give an overall picture of what you're attempting to achieve. |
| ||
Ok, that would be great. Here's a description: My project is making a topdown RPG with the ability to climb on top of crates and up ladders etc. So, it has an x,y and z axis. You walk along the x and y axes and jump along the z axis. If you walk into a ramp you also get pushed upwards along the z axis. So you can call it 3D but no 3D graphics are used, only bitmaps. I need JV-ODE for collisions between the player/NPCs (cylinder shaped) and the environment like walls/pushable boxes (trimesh/box) and for realistic collision responce. But right now everything rotates in all directions. That is an unusual behavior for an adventure game character. Oh, also, the map is made up a traditional grid (tile based game) but in 3 dimensions with each cell containing a 3D polygon. So, a wall has a box, an isometric wall or a ramp has a triangle, a column has a cylinder etc. This is to limit the amount of neccesary collision checks. You can say that I'm making a 3D game in an orthographic perspective. So, to sum it up: I need a cylinder moving on the flat edge that doesn't fall over when it hits something. For the main character in a game. |
| ||
Thanks for the explanation. It's quite tricky to create a player controlled character with a cylinder in a physics engine like ODE, because it goes against the purpose of what the engine is designed to do. For example, a cylinder would not normally remain in an upright position if it collides with another object, nor would it move along a surface without falling over. You might find it easier to use a sphere that can roll along the surfaces instead. However, a sphere rotates in any direction which is something you don't want in this case. To prevent this from happening, you can omit the rotation alignment in the UpdateGeoms() function so that only the position of the player bitmap is updated. The sphere will still be rolling around in the physics environment, but the visible character bitmap will only change position so you won't need to worry about rotation and axis alignment. |
| ||
Ok, I see. I'll consider using a sphere instead of a cylinder, though I probably have to try something else for this project :s Thanks very much never the less your help has been most kind. |
| ||
VIP3R, I moved to another computer and want to know how to get JV-ode back. I purchased it before, I hope I don't need to do that again. Can you help? Thanks, Eric |
| ||
Sure :) Can you email me (address in Blitz user profile) with your original purchase details. |
| ||
Hi Viper. Can you resend me a download link to my email. THanks. |
| ||
Download link sent to the email address in your Blitz profile. |
| ||
I have amended one of the demos to use minib3d. If you watch the demo for a few seconds you will see the cubes start doing some weird spinning/extra rotation thing. I have also seen this using straight opengl programming and ode. VIP3R do you do something special in your opengl program rotate function that eliminates this behaviour? |
| ||
Hmm, well the first thing I noticed when I run the code is that the camera is looking up instead of down towards where the cubes hit the ground. If I change the camera rotation to 30 instead of -30 it corrects the view and the cubes are rotating normally, no weird rotations. If the camera is pointing down on your system with -30 then that would explain the weird rotation on your system. Are you using the latest version of MiniB3D? Have you modified anything in MiniB3D? I've tested it with the latest version of BlitzMax (V1.41) and MiniB3D (V0.531). |
| ||
Yes I am using a non standard version of minib3d which uses quaternions for rotation by Warner I think. The camera was pointing in the correct direction using this version even though set to -30 Using the standard version does indeed work fine. Most curious. Anyway that answers that. Thank you. |
| ||
You're welcome :) |