IrrODE - an Irrlicht - ODE wrapper (now with SVN)

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Brainsaw
Posts: 1177
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

I think I should add a list of dependencies to the homepage (and the initial post). You can find it either in the code snippets forum or on my homepage (http://bulletbyte.de/products.php?sub=irr&show=aps). I'll do a little update to the initial post right away.
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
Grz-
Posts: 62
Joined: Wed Dec 26, 2007 1:06 pm

Post by Grz- »

Hi, great lib but i have some problems getting the collision/physics working with a trimesh and a heightfield terrain, i did it almost like the example:

Terrain physics setup:

Code: Select all

                pNode = smgr->addSceneNode(CIrrOdeSceneNode::nodeNameToC8(IRR_ODE_GEOM_HEIGHTFIELD_NAME), pTerrain);
                CIrrOdeGeomHeightfield *hf = reinterpret_cast<CIrrOdeGeomHeightfield *>(pNode);
                hf->setID(1);
                hf->getSurfaceParameters(0)->setModeBounce(false);
                hf->getSurfaceParameters(0)->setMaxLinearVelocity(0.0001f, 0.0f);
                hf->getSurfaceParameters(0)->setMaxAngularVelocity(0.0001f, 0.0f);
                hf->getSurfaceParameters(0)->setDampsObjects(false);
                hf->getSurfaceParameters(0)->setSoftErp(0.00005f);
                hf->getSurfaceParameters(0)->setSoftCfm(0.00005f);
                hf->getSurfaceParameters(0)->setSlip1(0.0f);
                hf->getSurfaceParameters(0)->setSlip2(0.0f);
                hf->getSurfaceParameters(0)->setMode(dContactSoftERP);
                hf->getSurfaceParameters(0)->setMu2(0);
                hf->setCollide(true);
                hf->drop();
Trimesh setup:

Code: Select all

                 CIrrOdeGeom *pGeom=NULL;
                scene::ISceneNode *pDummy=smgr->addSceneNode(CIrrOdeSceneNode::nodeNameToC8(IRR_ODE_BODY_NAME),worldNode);
  CIrrOdeBody *pNewBody=reinterpret_cast<CIrrOdeBody *>(pDummy);

  pNewBody->setID(2);

                scene::IAnimatedMesh* mesh = smgr->getMesh("data/models/MALP/malp.3ds");
                malp = smgr->addAnimatedMeshSceneNode( mesh , pNewBody);
                malp->setPosition(core::vector3df(5000,2000,20000));
                malp->setScale(core::vector3df(10.0f,10.0f,10.0f));
                malp->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
                malp->setMaterialFlag(video::EMF_FOG_ENABLE, false);
                malp->setMaterialFlag(video::EMF_LIGHTING, true);
                pDummy=smgr->addSceneNode(CIrrOdeSceneNode::nodeNameToC8(IRR_ODE_GEOM_TRIMESH_NAME),malp);
 
  pGeom=reinterpret_cast<CIrrOdeGeom *>(pDummy);
  pGeom->setMassTotal(malp->getScale().getLength()/64);
  pGeom->getSurfaceParameters(0)->setModeBounce(false);
                pGeom->getSurfaceParameters(0)->setModeBounce(false);
                pGeom->getSurfaceParameters(0)->setMaxLinearVelocity(0.0001f, 0.0f);
                pGeom->getSurfaceParameters(0)->setMaxAngularVelocity(0.0001f, 0.0f);
                pGeom->getSurfaceParameters(0)->setDampsObjects(false);
                pGeom->getSurfaceParameters(0)->setSoftErp(0.00005f);
                pGeom->getSurfaceParameters(0)->setSoftCfm(0.00005f);
                pGeom->getSurfaceParameters(0)->setSlip1(0.0f);
                pGeom->getSurfaceParameters(0)->setSlip2(0.0f);
                pGeom->getSurfaceParameters(0)->setMode(dContactSoftERP);
                //pGeom->getSurfaceParameters(0)->setMu(dInfinity);
                pGeom->getSurfaceParameters(0)->setMu2(0);
                pGeom->setCollide(true);
  pGeom->drop();
The problem is if i remove the "setMode(dContactSoftERP);" from both, the mesh 'bounce' rapidly when it hit the terrain, if i keep the setMode, the mesh slide a bit after it hit the terrain and i get a 'ODE INTERNAL ERROR' with 'assertion bNormlizationResult' error message.

Tried several settings and it dont change much the result, i would like that when my mesh hit the terrain, it stop or react in a realistic way (not slide etc).

Also, what is the difference with heightfield terrain and trimesh one?
Brainsaw
Posts: 1177
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

Hello,

hmm ... i can't see any error in your code. Maybe you could put the whole project online someplace so I can take a look.

To your other question: the ODE heightfield is a bit buggy. Try the IrrOdeCar demo and drive a car over the terrain and you'll see that the car penetrates the terrain in some places. From the answer I got on the ODE forum this is a known bug, but as a workaround I got the suggestion to use a trimesh instead. With the trimesh it works, but it is slower (especially the initialization ... doesn't seem to be so problematic later on).
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Post by polylux »

Brainsaw wrote:I think I should add a list of dependencies to the homepage (and the initial post). You can find it either in the code snippets forum or on my homepage (http://bulletbyte.de/products.php?sub=irr&show=aps). I'll do a little update to the initial post right away.
Gold, thanks Brainsaw!
beer->setMotivationCallback(this);
Kordman916
Posts: 23
Joined: Sat Apr 03, 2010 3:44 am

Post by Kordman916 »

Linux?
Brainsaw
Posts: 1177
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

There are Linux targets inside some of the projects, but as I am a Windozed user I can't maintain those (tecan provided those). I think the Linux version needs some updates like adding some source files to (and I hope I didn't get any case-sensitive include errors again), but apart from that it *should* compile. If you get any error messages you can post them here and I'll try to help (or some Linux user ... hopefully).
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
ulao
Posts: 274
Joined: Fri Mar 28, 2008 2:13 am

Post by ulao »

Brainsaw, I just got back to my project and started updating. I'm on irrlicht 1.7.2 and have your latest code. For some reason anything that includes the file "irrode.h" gets errors left and right.

syntax error : missing ';' before '*'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

If I try to go to the definitional of CIrrOdeBody I get
Image
this lines says CIrrOdeBody *playerNode; ( first error above )

So is ode now part of namespace? If I do irr::ode::CIrrOdeBody its ok. So I guess I dont need the includes now?

-------update------
not sure this is the best method but I just added the name space irr:ode and left the include there.

Now I see there is now setTimer method any more, its init enough?

If I comment out the timer I get complied with these external issue, some of which is not related I'm sure.

Code: Select all

MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: _printf already defined in LIBCMTD.lib(printf.obj)
MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: _sprintf already defined in LIBCMTD.lib(sprintf.obj)
MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
irrKlangSceneNode.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) class irr::video::SMaterial irr::video::IdentityMaterial" (__imp_?IdentityMaterial@video@irr@@3VSMaterial@12@A)
Camera.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) class irr::video::SMaterial irr::video::IdentityMaterial" (__imp_?IdentityMaterial@video@irr@@3VSMaterial@12@A)
irrode.lib(CIrrOdeSceneNode.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) class irr::video::SMaterial irr::video::IdentityMaterial" (__imp_?IdentityMaterial@video@irr@@3VSMaterial@12@A) referenced in function "public: virtual class irr::core::CMatrix4<float> __thiscall irr::scene::ISceneNode::getRelativeTransformation(void)const " (?getRelativeTransformation@ISceneNode@scene@irr@@UBE?AV?$CMatrix4@M@core@3@XZ)
irrode.lib(CIrrOdeDevice.obj) : error LNK2019: unresolved external symbol _dJointGetPRAngle referenced in function "public: virtual float __thiscall irr::ode::CIrrOdeDevice::jointGetPrAngle(unsigned int)" (?jointGetPrAngle@CIrrOdeDevice@ode@irr@@UAEMI@Z)
irrode.lib(CIrrOdeDevice.obj) : error LNK2019: unresolved external symbol _dJointGetPRAngleRate referenced in function "public: virtual float __thiscall irr::ode::CIrrOdeDevice::jointGetPrAngleRate(unsigned int)" (?jointGetPrAngleRate@CIrrOdeDevice@ode@irr@@UAEMI@Z)
ignoring libcmtd.lib seems to fix the top half.
Brainsaw
Posts: 1177
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

Early morning - hard stuff ;)

I replaced the setTimer method some time ago by the "install" method in the CIrrOdeManager class. This method needs the IrrlichtDevice as parameter and gets the timer from there. The IrrOdeManager does now also need the scene manager in order to process some of it's own events, like removing or cloning a node. You have to call both the "install" and the "init" method, but "install" is just required once (unless you recreate you IrrlichtDevice) whereas "init" initializes the ODE (I call it everytime before a level is started in the Stunt Marble Racers project).

I have also added namespaces some time ago, just to get the whole thing a little "C++ clean"

The "IdentityMaterial" issue is a classic one. I can solve it by moving the libIrrOde.a lib to the top of the linked libs (i.e. the first one to be linked). Sounds strange, I know.

I hope I could help you with those problems.
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
ulao
Posts: 274
Joined: Fri Mar 28, 2008 2:13 am

Post by ulao »

Yeah, that fixed up the timer issues and yes that is strange about linking the lib first in the list. Never saw that before...

So down to the 2 dJointGetPRAngle errors left When you said "I hope I could help you with those problems." Did you mean you had more to offer, or extinguished all you had?

No thoughts on the _dJointGetPRAngle stuff?

BTW: I renamed your libirrode.lib to irrode.lib ( I was lazy ;) )
Brainsaw
Posts: 1177
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

Nice to hear you got rid of most of the problems. I honestly don't have any idea about the dJointGetPRAngle issue. I just read the ODE manual on their Wiki and that method isn't mentioned there. If you don't need that method (I never did, and neither does IrrOde in it's internals) you could simply outcomment the function call in the manager and return "0". The lib always compiles on my systems with CodeBlocks and MinGW, and I also get the VC2008 version compiled. If you're using the VC2005 lib you'll have to recompile it and (maybe) also add some missing files. As I don't have VC2005 I can't keep that one up to date.
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
ulao
Posts: 274
Joined: Fri Mar 28, 2008 2:13 am

Post by ulao »

do I need a new ode_single lib?

You mean to un-comment any calls to JointGetPRAngl, because I dont even use that?

Commenting in the CIrrOdeDevice.h of course has no effect.
Brainsaw
Posts: 1177
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

By commenting out the call I meant modifying the CIrrOdeDevice.cpp file to:

Code: Select all

f32 CIrrOdeDevice::jointGetPrAngle(u32 iJoint) {
  return 0;//dJointGetPRAngle(GETJOINT(iJoint));
}
This would keep it all compiling and working, and as long as you don't need to get that angle (I don't need that, haven't (yet) used the PrismaticRotoide joint anywhere) everything would still work.

You don't need a new ode_single lib, but you'd have to recompile the IrrOde lib of course.

Btw: are you using the latest ODE version (0.11.1)? Maybe that function got in with this release. I'm just asking because I never got that error, and I recompile IrrOde from time to time.
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
ulao
Posts: 274
Joined: Fri Mar 28, 2008 2:13 am

Post by ulao »

Btw: are you using the latest ODE version (0.11.1)? Maybe that function got in with this release. I'm just asking because I never got that error, and I recompile IrrOde from time to time.
- I guess thats what I meant by the single lib. looks like I'm on version ode-0.11.1.


but yes removing those return in your source did it. ;)

Few more questions.

>Is there a way to say OBJ1 can not touch OBJ 2,3,4,5,6. In other words, so that I can walk trough stuff whiling allowing those (2,3,4,5,6) objects to also interact whit the terrain.

>When I added a height filed do I need a body? Is this why I have friction problems? Because ODE will not let me put a Height field on a body.

> I never get the timer back from the ODE, I just send it. My game is based on the irr engine timer, is that wrong?

BTW:when using capsule I get bad arguments in capsule.cpp:51. You talked about this error here
http://irrlicht.sourceforge.net/phpBB2/ ... c6cd8fb787
Brainsaw
Posts: 1177
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

Added ODE's "approx" flags to IrrOde's surface parameters. Thanks to ulao for pointing out these were missing.

@ulao:
Is there a way to say OBJ1 can not touch OBJ 2,3,4,5,6. In other words, so that I can walk trough stuff whiling allowing those (2,3,4,5,6) objects to also interact whit the terrain.
I think you can use the collisionGroup attribute for that (http://bulletbyte.de/irrOde/doxygen/index.html)

When I added a height filed do I need a ... on a body.

No, you don't need a body for a heightfield. ODE bodies are dynamic objects, geoms without bodies are static, so a heightfield can't even be attached to a body, because it's always static. Got no idea about friction problems there, works fine in my IrrOdeCar demo.
I never get the timer back from the ODE, I just send it. My game is based on the irr engine timer, is that wrong?
You don't need to get the timer back. You just pass a reference to ODE so that it can also retrieve the current time information, but you can still use Irrlicht's timer function. I do this in my Stunt Marble Racers game as well.
BTW:when using capsule I get bad arguments in capsule.cpp:51. You talked about this error here
Hmm ... what parameters are you using? Maybe I got something wrong there, I don't (yet) use a capsule anywhere but in the IrrOdePlayground demo.
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
ulao
Posts: 274
Joined: Fri Mar 28, 2008 2:13 am

Post by ulao »

none, I just drop the capsule on in irredit and load the irr file. I then get the error.

Looks like the approx is now exposed in irrEdit thx! Assuming this is all the changes require from you the desired effect is still not working. Was there a change in the irrode dll?

The car example you have uses contact point yes? I dont have those options in irredit with a basic body. From what I know MU is a property of the contact joint, not geoms. I guess then your wrapper determines the actual MU value of the contact from those specified for the geoms?

UPDATE:: Ok I think I see whats wrong with my friction. I gathered via the examples somewhere that friction was 0-1. but talking to the ode guys its 0-dInfinity Forgive me if I missed this in the docs but how do I get dInfinity ? I tried to set it to 65535 and the object fell on its side once force was added. I'm told this is because I need to use a capsule for standing objects. So I'm going to play with a few numbers.
Last edited by ulao on Mon Jan 24, 2011 5:46 pm, edited 7 times in total.
Post Reply