Open Dynamics Engine and camera in Irrlicht

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
mpeniak
Posts: 1
Joined: Sun Jun 01, 2008 12:25 pm
Contact:

Open Dynamics Engine and camera in Irrlicht

Post by mpeniak »

Hi Guys,

I am totally new to Irrlicht. I am doing research in mobile robotics and currently developing simulator of a Martian rover based on Open Dynamics Engine.

Basically I have got a rover pretty much like Spirit or Opportunity. The rover has a pan/tilt camera. I need to be able to get a view from this camera so I can process data that the rover 'sees'. The rover's camera is an ODE object.

By now I was using SDL but I am not able to implement this functionality. I tried but the camera never worked 100%. People from ODE mailing list have recommended me to use a 3D engine that allows me to fix a camera to ODE body. Therefore my questions are. Does Irrlich allow me to do this? Has anyone of you guys dealt with similar issue?

Any help very much appreciated :D
Regards,
Martin Peniak
xDan
Competition winner
Posts: 673
Joined: Thu Mar 30, 2006 1:23 pm
Location: UK
Contact:

Post by xDan »

Here are some functions I use to convert from ODE to Irrlicht matrices and vice versa, if that helps: http://xzist.org/temp/ODEFramework/
(the two ODESetRotation methods)

Then I guess you need to update the Irrlicht camera each frame. something like this?

Code: Select all

core::vector3df target(0,0,-1);
matrix.transformVect(target);

camera->setTarget(target);
camera->setPosition(matrix.getTranslation());
_drake_
Posts: 6
Joined: Wed May 28, 2008 7:44 am

Post by _drake_ »

xDan thank you for sharing the code.

I took a look at it because of a different problem I'm having with ODE trimesh collisions.

Is your ODE's dll compiled as OPCODE or GIMPACT? Are the trimesh collisions working?
xDan
Competition winner
Posts: 673
Joined: Thu Mar 30, 2006 1:23 pm
Location: UK
Contact:

Post by xDan »

I'm using ODE 0.8 with OPCODE. And Sphere/box/capsule to trimesh collisions are indeed working. I haven't tried trimesh-trimesh though.
_drake_
Posts: 6
Joined: Wed May 28, 2008 7:44 am

Post by _drake_ »

I haven't tried trimesh-trimesh though.
I tried but I cannot make it running. I tried compile using GIMPACT instead of OPCODE but the same. Ok, its better I will create a new topic to discuss it.

I have another question for you about the function

ODEMeshData *ODEUtility::ODECreateMeshData(scene::IMesh *mesh, core::vector3df scale)

I tried passing a simple box mesh (36 vertices/36 indices) using the default scale

ODEMeshData* myMesh = odeUtils->ODECreateMeshData(cubeMesh->getMesh(0));

then I use the struct to create the TriMesh geometry
obj[iFreeSlot].geom[0]=dCreateTriMesh(space,myMesh->triMeshData,0,0,0);

finally I create the mass for the body and assign it to the geometry

dMass mass;
dMassSetTrimesh(&mass, DENSITY, obj[iFreeSlot].geom[0]);
//dMassSetBox(&mass, DENSITY, 10.0, 10.0, 10.0);
dMassAdjust(&mass, 0.75f);

obj[iFreeSlot].body = dBodyCreate(world);

// add the body to the geom
dGeomSetBody(obj[iFreeSlot].geom[0], obj[iFreeSlot].body);

// combine body and mass
dBodySetMass(obj[iFreeSlot].body, &mass);


Now, if I use the default scale it seems working well, the trimesh collide with the plane. Instead, if I set a scale of 40 I receive the error message The center of mass must be at origin when I try to combine body and mass.

Do you have any suggestion that can help me?
xDan
Competition winner
Posts: 673
Joined: Thu Mar 30, 2006 1:23 pm
Location: UK
Contact:

Post by xDan »

Hmm, well I haven't done much with trimeshes that have bodies either. So I don't really have much idea, sorry - anything I say is just a shot in the dark.

But have you tried commenting out dMassAdjust? That seems to be the only thing that might affect the mass at all...

Failing that, could the order of functions affect anything?

I found this I used once in a project, which I *believe* worked...

Code: Select all

            dReal density = 0.01;
            dBodyID dBody = dBodyCreate(dPhysics->dWorld);
            dMass mass;
            dMassSetTrimesh(&mass, density, dGeom);
            dBodySetMass(dBody, &mass);
            dGeomSetBody(dGeom, dBody);
_drake_
Posts: 6
Joined: Wed May 28, 2008 7:44 am

Post by _drake_ »

thanks for the reply xDan, I tried your suggestion but the result doesn't change, even switching the order of operations.:roll:

Anyway, its better I create a dedicated topic to it.

Thanks
Post Reply