ODEItem v0.10
by Pascal · 01/04/2004 (1:38 pm) · 130 comments
Edit: 1/9/04 -- updated to 2nd Release w/ multiplayer and a couple more config features (see docs)
You can download the file from HERE (it was too large with the included .lib files for GG)
see the README.html file for complete installation usage instructions.
A number of short engine changes are required to get it working (three have changed since release 1, see docs)
Included are compiled versions of the .lib files for ODE as well as the slightly modified source.
Take a look at the following Movie Zipfile for a demo (I think its compressed with DivX..)
For those of you familiar with ODE I decided to use the torque engine for collision mechanism instead of the one built into ODE. While this is probably a performance hit (or maybe not, I don't really know enough to say) it does make life much easier as any DTS file with collision meshes should work correctly with the rest of the world including the terrain.
The code will need some modifications to make it useful so check out the ODE Homepage for some more info on the engine. I need to do a revamp of the code an clean up my initial confusion a little so I will probably release a new version in a couple of weeks.
Included are a crate and an trash can to get you started.
Have fun throwing crates around (I did)..
My next step is to try to get some rag dolls working but that may be a little while.
-Pascal
You can download the file from HERE (it was too large with the included .lib files for GG)
see the README.html file for complete installation usage instructions.
A number of short engine changes are required to get it working (three have changed since release 1, see docs)
Included are compiled versions of the .lib files for ODE as well as the slightly modified source.
Take a look at the following Movie Zipfile for a demo (I think its compressed with DivX..)
For those of you familiar with ODE I decided to use the torque engine for collision mechanism instead of the one built into ODE. While this is probably a performance hit (or maybe not, I don't really know enough to say) it does make life much easier as any DTS file with collision meshes should work correctly with the rest of the world including the terrain.
The code will need some modifications to make it useful so check out the ODE Homepage for some more info on the engine. I need to do a revamp of the code an clean up my initial confusion a little so I will probably release a new version in a couple of weeks.
Included are a crate and an trash can to get you started.
Have fun throwing crates around (I did)..
My next step is to try to get some rag dolls working but that may be a little while.
-Pascal
About the author
#42
in Player::findContact, the contact angle is not right, or the polygon list is somehow screwed,
I've tried a dirty hack by setting run to true when its colliding with an ODEObject, but it didnt give me the desired result.
I hope someone else better with collision can help on that one, In the mean time I'm gonna try a bit of Joints :D
EDIT: Didn't get to joints yet, however I did implement something else: applyImpulse
Put this code at the end of ODEItem.cc:
Hope that helps :D
01/08/2004 (12:24 pm)
Hmmm, the thing i had in mind didnt work, however i can tell you the right directionin Player::findContact, the contact angle is not right, or the polygon list is somehow screwed,
I've tried a dirty hack by setting run to true when its colliding with an ODEObject, but it didnt give me the desired result.
I hope someone else better with collision can help on that one, In the mean time I'm gonna try a bit of Joints :D
EDIT: Didn't get to joints yet, however I did implement something else: applyImpulse
Put this code at the end of ODEItem.cc:
void ODEItem::applyImpulse(const Point3F& pos,const VectorF& vec)
{
mIsEnabled=true;
dBodyEnable(mBodyID);
dBodyAddForceAtRelPos(mBodyID,vec.x,vec.y,vec.z,pos.x,pos.y,pos.z);
}and add this in ODEItem.h after void setTransform(const MatrixF &mat);void applyImpulse(const Point3F&,const VectorF& vec);
Hope that helps :D
#43
All i expect in return is that you too publish the code you wrote for this :D
Ok there we go fire up ODEItem.h
find dBodyID mBodyID; and add:
find void setTransform(const MatrixF &mat); and add
Now at the end of ODEItem.cc add:
Now I'm gonna have a little break, and later i will try to extend the joints a little (Trying to make a bridge0r :D)
Have phun, DJMystic
01/09/2004 (7:40 am)
Simple joints done, Slider joints work ok, hinge and ball sockets work partially, and the rest is not yet implemented.All i expect in return is that you too publish the code you wrote for this :D
Ok there we go fire up ODEItem.h
find dBodyID mBodyID; and add:
//Joints added dJointGroupID mJointsID;
find void setTransform(const MatrixF &mat); and add
//Joints added long AddJoint(ODEItem *otherbox, int type);
Now at the end of ODEItem.cc add:
long ODEItem::AddJoint(ODEItem *otherbox, int type)
{
dBodyID otherbody=0;
if (otherbox) otherbody=otherbox->getBody();
const dReal empty[]={0,0,0,0};
const dReal *pos=dBodyGetPosition(mBodyID),*opos=empty;
if (otherbox) opos=dBodyGetPosition(otherbody);
dJointID joint;
switch (type) {
case dJointTypeBall: //1
joint=dJointCreateBall(gWorld,mJointsID);
dJointAttach(joint,mBodyID,otherbody);
dJointSetBallAnchor(joint,(pos[0]+opos[0])/2.0,(pos[1]+opos[1])/2.0,(pos[2]+opos[2])/2.0);
/*
Parameters for ball sockets are not valid
dJointSetBallParam(dParamLoStop,-M_PI/2);
dJointSetBallParam(dParamHiStop,M_PI/2);
dJointSetBallParam(dParamBounce,0.8);*/
break;
case dJointTypeHinge: //2
joint=dJointCreateHinge(gWorld,mJointsID);
dJointAttach(joint,mBodyID,otherbody);
dJointSetHingeAnchor(joint,(pos[0]+opos[0])/2.0,(pos[1]+opos[1])/2.0,(pos[2]+opos[2])/2.0);
dJointSetHingeParam(joint,dParamLoStop,-M_PI/2);
dJointSetHingeParam(joint,dParamHiStop,M_PI/2);
dJointSetHingeParam(joint,dParamBounce,0.8);
break;
case dJointTypeSlider: //3
joint=dJointCreateSlider(gWorld,mJointsID);
dJointAttach(joint,mBodyID,otherbody);
dJointSetSliderAxis(joint,pos[0]-opos[0],pos[1]-opos[1],pos[2]-opos[2]);
dJointSetSliderParam(joint,dParamLoStop,-1);
dJointSetSliderParam(joint,dParamHiStop,1);
dJointSetSliderParam(joint,dParamBounce,0.8);
break;
case dJointTypeContact:
break;
case dJointTypeUniversal:
break;
case dJointTypeHinge2:
joint=dJointCreateHinge2(gWorld,mJointsID);
break;
case dJointTypeFixed:
break;
case dJointTypeNull:
break;
case dJointTypeAMotor:
break;
default:
return 0;
}
return (long)joint;
}
ConsoleMethod( ODEItem, AddJoint, S32, 4, 4, "(ODEItem obj, int type)")
{
ShapeBase* otherbox;
if (Sim::findObject(argv[2],otherbox) && otherbox->getTypeMask() & ODEObjectType) {
ODEItem *obox=dynamic_cast<ODEItem* >(otherbox);
return object->AddJoint(obox,atoi(argv[3]));
}
return -1;
}Now I'm gonna have a little break, and later i will try to extend the joints a little (Trying to make a bridge0r :D)
Have phun, DJMystic
#44
I just uploaded a new version with a bunch of config features to let you play around with friction and bounciness as well as Dylan's multiplayer changes (see the end of the doc for the new stuff). Nothing too dramatic but it might help to start to nail down params that work. (No joints yet but you could try the stuff above from DYMystic). Also cleaned up ODEItem in general and removed some foul language (oops..).
You need to make 3 changes from the original version (see the doc): 2 in main.cc and 1 in player.cc
Lemme know if there are any problems.
-Pascal
EDIT: drat typos
01/09/2004 (1:36 pm)
Hey, I just uploaded a new version with a bunch of config features to let you play around with friction and bounciness as well as Dylan's multiplayer changes (see the end of the doc for the new stuff). Nothing too dramatic but it might help to start to nail down params that work. (No joints yet but you could try the stuff above from DYMystic). Also cleaned up ODEItem in general and removed some foul language (oops..).
You need to make 3 changes from the original version (see the doc): 2 in main.cc and 1 in player.cc
Lemme know if there are any problems.
-Pascal
EDIT: drat typos
#45
01/09/2004 (7:10 pm)
LOL, I found the language to be quite funny :D Thanks for all the work youve done Pascal, Im sure everyone really appreciates it :D
#46
Did you add my applyImpulse code too? It's quite handy to test, since you cant move the block very hard with the player :D
BTW Have you fixed the player-walking on ODEItem thing?
I'm trying to make a bridge :P
Hehe, anyway, Thanks a lot for this stuff! :D
01/10/2004 (1:37 am)
Yep :)Did you add my applyImpulse code too? It's quite handy to test, since you cant move the block very hard with the player :D
BTW Have you fixed the player-walking on ODEItem thing?
I'm trying to make a bridge :P
Hehe, anyway, Thanks a lot for this stuff! :D
#47
I added the include to my project.
I added the files to the lib directory and so on - so their is a folder lib/ode/include/ode which has ode.h in it and so on.
Then I changed the code correctly and then I compiled it but I still get the error where it cannot find?
Any ideas?
01/10/2004 (2:05 am)
I am still having problems compiling it, the new ODEItem v.10 was lots of help tho.I added the include to my project.
I added the files to the lib directory and so on - so their is a folder lib/ode/include/ode which has ode.h in it and so on.
Then I changed the code correctly and then I compiled it but I still get the error where it cannot find
Any ideas?
#48
The ODE include directory is kind of 'fucked' (no offence!)
the .h files should be in include/ode
but instead it is just in /include
try making a directory ode/ in the include directory and moving all files to that one :)
01/10/2004 (2:33 am)
I had that same problemThe ODE include directory is kind of 'fucked' (no offence!)
the .h files should be in include/ode
but instead it is just in /include
try making a directory ode/ in the include directory and moving all files to that one :)
#49
I don't think I have included the .lib file correctly, I went by doing
Project -> Settings... -> Link ->
Then I added ../lib/ode/ode-DBG.lib to the object/libary modules
If I have not added that correctly would it mean that I would get the error where it cannot find the ode/ode.h file?
By the way I did as you said above but still no change, even though I included the include directory as Westy[X-Tatic] said.
01/10/2004 (7:04 am)
If you have included the lib and include directory correctly then is there anything it should output in the build console (that is before you get any errors if you have done it wrong)?I don't think I have included the .lib file correctly, I went by doing
Project -> Settings... -> Link ->
Then I added ../lib/ode/ode-DBG.lib to the object/libary modules
If I have not added that correctly would it mean that I would get the error where it cannot find the ode/ode.h file?
By the way I did as you said above but still no change, even though I included the include directory as Westy[X-Tatic] said.
#50
01/10/2004 (7:24 am)
No, it wont output anything special, but as i said did you move the include files?
#51
01/10/2004 (10:45 am)
Yeah, I created the folder "ode" in the directory "lib/ode/include" and put the .h files in it, but still the same output.
#52
e.g ../lib/ode/include/
mkae sure its seperated from previous include with a comma.
01/10/2004 (3:14 pm)
Joshua, in project settings C++ tab, dro down to preprocessor and add it as include directory.e.g ../lib/ode/include/
mkae sure its seperated from previous include with a comma.
#53
01/11/2004 (3:33 am)
Hey, fixed it, I was putting ..lib/ode/include instead of ../lib/ode/include such simple things make such a difference!
#54
Took me a while to get this right, but seems to be compiling at least.
However when compiling the ODE lib, i get some oddities (which prevent further compilation) :
In order to fit ODE in, i did the following :
Add to mk/conf.common.mk :
Make an ode/lib directory, and copy all the files from the ODE src directory into it.
Copy the includes folder into this ode folder, but rename it ODE.
You need targets.ode.mk - here is a sample fragment of mine :
I also added code to the lib Makefile for ode. Just copy the zlib stuff there and rename to ode.
Then i added the source files for odeitem and odeworld to targets.torque.mk (except for the tools build), and i of course copied some of the code that links + includes the zlib headers and plonked in ODE equivalents. e.g adding "-I../lib/ode" to INCLUDES_BASE.
Since ODE is LGPL perhaps i should make it link dynamically...
Not sure why its not quite compiling though, since ODE is *nix friendly...
01/13/2004 (8:07 am)
Compiling on linux :Took me a while to get this right, but seems to be compiling at least.
However when compiling the ODE lib, i get some oddities (which prevent further compilation) :
--> Compiling ode/collision_kernel.cpp In file included from ode/collision_kernel.cpp:34: ode/collision_kernel.h: In member function `void dxGeom::bodyAdd(dxBody*)': ode/collision_kernel.h:146: invalid conversion from `dGeomID' to `dxGeom*' ode/collision_kernel.h:147: invalid conversion from `dxGeom* const' to ` unsigned int' ode/collision_kernel.cpp: In function `void space_geom_collider(void*, dxGeom*, dxGeom*)': ode/collision_kernel.cpp:56: invalid conversion from `dxGeom*' to `unsigned int ' ode/collision_kernel.cpp:56: invalid conversion from `dxGeom*' to `unsigned int '(Continues)
In order to fit ODE in, i did the following :
Add to mk/conf.common.mk :
$(DIR.OBJ)/%$O : %.cpp $(DO.COMPILE.CC)
Make an ode/lib directory, and copy all the files from the ODE src directory into it.
Copy the includes folder into this ode folder, but rename it ODE.
You need targets.ode.mk - here is a sample fragment of mine :
ODE.SOURCE=\ ode/array.cpp \ ode/obstack.cpp \ ode/collision_kernel.cpp \ ode/fastldlt.c \ ode/ode.cpp \ ode/collision_quadtreespace.cpp \ ode/fastlsolve.c \ ode/odemath.cpp \ ode/collision_space.cpp \ ode/fastltsolve.c \ ode/rotation.cpp \ ode/collision_std.cpp \ ode/geom.cpp \ ode/scrapbook.cpp \ ode/collision_transform.cpp \ ode/joint.cpp \ ode/space.cpp \ ode/collision_trimesh.cpp \ ode/lcp.cpp \ ode/stack.cpp \ ode/collision_trimesh_box.cpp \ ode/mass.cpp \ ode/step.cpp \ ode/collision_trimesh_ray.cpp \ ode/mat.cpp \ ode/stepfast.cpp \ ode/collision_trimesh_sphere.cpp \ ode/matrix.cpp \ ode/testing.cpp \ ode/collision_util.cpp \ ode/memory.cpp \ ode/timer.cpp \ ode/error.cpp \ ode/misc.cpp ODE.SOURCE.OBJ=$(addprefix $(DIR.OBJ)/, $(addsuffix $O, $(basename $(ODE.SOURCE))) ) SOURCE.ALL += $(ODE.SOURCE) targetsclean += TORQUEclean DIR.LIST = $(addprefix $(DIR.OBJ)/, $(sort $(dir $(SOURCE.ALL)))) $(DIR.LIST): targets.ode.mkBasically i copied targets.zlib.mk, sorted out ODE.SOURCE.OBJ (seemed to be hardcoded for .c files i think), and added the ODE stuff.
I also added code to the lib Makefile for ode. Just copy the zlib stuff there and rename to ode.
Then i added the source files for odeitem and odeworld to targets.torque.mk (except for the tools build), and i of course copied some of the code that links + includes the zlib headers and plonked in ODE equivalents. e.g adding "-I../lib/ode" to INCLUDES_BASE.
Since ODE is LGPL perhaps i should make it link dynamically...
Not sure why its not quite compiling though, since ODE is *nix friendly...
#55
@James:
At the end of the readme doc is the list of the ODE files that need to be included to make a working lib for torque. It's basically ODE minus any collision stuff. The conflicts you are getting are the changes I made to strip out all the ode collision stuff (any dxGeom defs) and make it work with Torque collisions. Try it with just the files listed and see if it helps.
-Pascal
01/14/2004 (9:00 am)
Shoot, I posted yesterday but it didn't take. GG sometimes seems to have trouble with Firebird. Let me try again with ie:@James:
At the end of the readme doc is the list of the ODE files that need to be included to make a working lib for torque. It's basically ODE minus any collision stuff. The conflicts you are getting are the changes I made to strip out all the ode collision stuff (any dxGeom defs) and make it work with Torque collisions. Try it with just the files listed and see if it helps.
-Pascal
#56
Seems to be working now.
Though i had to change the _isnan function call in ODEItem.cc
( just #include and use isnan() )
Though i seem to be getting some odd problems with the ode items in some cases :
And of course, it kindof likes to add the ODE items in the middle of the world, Not at my camera position :p
Another thing i noticed was that it sometimes crashes when i go into the world editor with my ode items... =/
01/14/2004 (1:46 pm)
Pascal,Seems to be working now.
Though i had to change the _isnan function call in ODEItem.cc
( just #include
Though i seem to be getting some odd problems with the ode items in some cases :
Quote:
ODE Message 3: LCP internal error, s <= 0 (s=-1.2725e-05)
And of course, it kindof likes to add the ODE items in the middle of the world, Not at my camera position :p
Another thing i noticed was that it sometimes crashes when i go into the world editor with my ode items... =/
#57
The LCP internal error stuff happens occasionally on Windows as well and is part of fine tuning ODE's params and stability. ODEItem is probably at a disadvantage from some other ODE usages because all the contact information is fed in from the outside and is single precision. First thing to do would be to try to fine tune the stepsize, gravity, erp and cfm and see what give you the best results. In the 2nd release createContacts is cleaned up a little so you could try playing around with that.
Here's a quote from the ODE mailing list:
01/14/2004 (2:06 pm)
James, The LCP internal error stuff happens occasionally on Windows as well and is part of fine tuning ODE's params and stability. ODEItem is probably at a disadvantage from some other ODE usages because all the contact information is fed in from the outside and is single precision. First thing to do would be to try to fine tune the stepsize, gravity, erp and cfm and see what give you the best results. In the 2nd release createContacts is cleaned up a little so you could try playing around with that.
Here's a quote from the ODE mailing list:
Quote:
--Olivier Michel wrote:
--Hi,
--I often get the following ODE message after my simulation has run for a while:
--ODE Message 3: LCP internal error, s <= 0 (s=0.0000e+00)
--ODE Message 3: LCP internal error, s <= 0 (s=-0.0000e+00)
--ODE Message 3: LCP internal error, s <= 0 (s=nan)
--ODE Message 3: LCP internal error, s <= 0 (s=0.0000e+00)
--which blows out my model...
--I could I avoid this ? Use double precision instead of single precision floating point --numbers in ODE ?
--Reset somehow my simulation after a given amount of time ?
--Any hint would be highly appreciated.
Double precision would probably help a bit, but numerical stability
is a general plague in simulation. See sections 12.12 and 11.4 in
the ODE manual for stability hints -- the unhappy answer is that
getting (almost!) rid of these situations basically often
comes down to lots of hand-tuning of constants and parameters.
Regards,
--Adam
ODE mailing list
ODE@q12.org
http://q12.org/mailman/listinfo/ode
#58
02/22/2004 (9:20 am)
any news on this?
#59
It appears that my NCP errors(and the obvious movement problems in torque) were mainly being caused by the fact that i did not apply the ode code properly to torque; In the update loop, the loop that updates the regular torque objects was being called X amount of times per loop, but the ode code was only being called once (since i forgot the brackets).
Anyway, now that it seems to work ok now, it seems pretty cool :)
02/26/2004 (1:54 pm)
Pascal,It appears that my NCP errors(and the obvious movement problems in torque) were mainly being caused by the fact that i did not apply the ode code properly to torque; In the update loop, the loop that updates the regular torque objects was being called X amount of times per loop, but the ode code was only being called once (since i forgot the brackets).
Anyway, now that it seems to work ok now, it seems pretty cool :)
#60
I've stepped away from this for a little while to focus on other things but I'm still playing around with it and am planning to do a new release in a liile while.
02/27/2004 (9:22 am)
@ChrisI've stepped away from this for a little while to focus on other things but I'm still playing around with it and am planning to do a new release in a liile while.

Torque Owner F.W. Hardijzer
I'm currently trying to find out for you why the player wont move on an ODEItem,
I think i've already spotted the problem, but i'm still waiting to compile :(
PC's get old too fast these days :'(
Anyway, Just to inform you I'm working on it :D
Also, I wrote my own rope-like physics a while ago in a nehe-basecode opengl thingie, and i thought about implementing a bridge into torque, however i've never done collision in torque before so i didnt do it.
A moment later i saw this thing and read about ODE, and it's perfect for bridges :)
Might be able to do some research on that too :D