[ODE] Moving trimesh trouble
Shamyl Zakariya
shamyl at zakariya.net
Tue Mar 6 06:37:13 MST 2007
I've been experimenting with moving trimeshes, using
test_moving_trimesh.cpp as a tutorial.
First, I want to say that fairly certain my trimesh data is good,
because when I don't have a body attached, ray/capsule/box/sphere ->
trimesh collisions are working just fine. Thus I can infer that my
trimesh data is good.
Reading test_moving_trimesh, I see that there's only two things that
are "special" about having a body attached to a trimesh. One:
COnfigure the mass with dMassSetTrimesh. Two: Call
dGeomTriMeshSetLastTransform() with the current trimesh transform
before calling dWorldStep and the like.
So here's some code snippets
World::step():
for ( EntityRefSet::iterator it( _bodiedEntities.begin() ), end
( _bodiedEntities.end() );
it != end; ++it )
{
(*it)->aboutToUpdateBody();
}
/*
step ODE
*/
if ( _world )
{
dSpaceCollide2( (dGeomID) _staticSpace, (dGeomID) _actorSpace,
this, &nearCallback );
dSpaceCollide2( (dGeomID) _groundSpace, (dGeomID) _actorSpace,
this, &nearCallback );
dSpaceCollide( _actorSpace, this, &nearCallback);
dWorldStep( _world, simtime::interval() );
dJointGroupEmpty( _contactGroup );
}
The function Entity::aboutToUpdateBody() calls the following when
bodies have trimesh geoms:
void TrimeshGeom::transformWillChange( void )
{
dGeomTriMeshSetLastTransform( _geom, _lastTransform );
_lastTransform.set_ode_transform( dGeomGetPosition( _geom ),
dGeomGetRotation( _geom ) );
}
I've put in printfs of my bodied trimeshs' position and rotation
before dWorldStep and after, and what I see is interesting.
On the very first step cycle, before dWorldStep, my trimesh prints
the position and identity rotation I've assigned to it. After the
world update, my trimesh is at (0,0,0) and has an identity rotation
matrix but with R(4,4) at zero, instead of 1.
Here's what's being printed before dWorldStep -- this is what I've
manually assigned:
Entity[Nubbles]::aboutToUpdateBody position: (0.00, 0.00, 50.00)
rotation: ((1.00, 0.00, 0.00, 0.00), (0.00, 1.00, 0.00, 0.00), (0.00,
0.00, 1.00, 0.00), (0.00, 0.00, 0.00, 1.00))
And here's what's printed after the first dWorldStep:
Entity[Nubbles]::synchronizeToBody position: (0.00, 0.00, 0.00)
rotation: ((1.00, 0.00, 0.00, 0.00), (0.00, 1.00, 0.00, 0.00), (0.00,
0.00, 1.00, 0.00), (0.00, 0.00, 0.00, 0.00))
Notice that rotation( 4,4 ) is zero, instead of one. All subsequent
output is like that.
I've read over test_moving_trimesh over and over and I have to assume
I'm missing some particular, but I can't figure out what it is.
For reference, I'm using ODE 0.8 with trimesh=OPCODE. I tried using
GIMPACT, but it kept crashing when I tried to upload my trimesh data.
shamyl at zakariya.net
"this is, after all, one of those movies where people spend a great
deal of time looking at things and pointing."
From a review of _Fantastic Voyage_
More information about the ODE
mailing list