[solved] problem about using ogrenewt on irregular geometry

abanknote

14-01-2007 01:02:33

Hi~
I have a few questions using ogrenew in my map editor program. First, I implemented mouse dragging so that the position and direction of the object can be adjusted after creation. Then the problem came. If I place the object without dragging, the tree collision works. If I rotated it or moved it, my car could drive right through it. I wonder whether I have to use "body" all the time in order to do some move and rotation? Currently I'm using only the object node. Another problem is that SSCube.mesh is a very weird geometry created at runtime, will it work with TreeCollision if I just pass its scene node to TreeCollision?

Appreciate any help...

Solution:
I see no point to setup physics during editing mode, so I keep track of all scene nodes and setup physics when switching to play mode all in once.

OgreNewt::CollisionPrimitives::TreeCollision* treeCol;

if( on[ManualMesh] ){
mMeshBuilder->createMesh("SSCube.mesh"); // create a mesh from custom points, and save it to resources manager
mMeshBuilder->clear();
mMeshBuilder->update();
mCurrentMesh = "SSCube.mesh";
on[ ManualMesh ] = false;
}

String entityName( "Sign" + StringConverter::toString(mEntityCount++) );
mCurrentObject = mTerrainMesh->createObject( entityName, mCurrentMesh );

treeCol = new OgreNewt::CollisionPrimitives::TreeCollision(mWorld, mCurrentObject, true );

body = new OgreNewt::Body(mWorld, treeCol);
delete treeCol;
body->attachToNode( mCurrentObject );
body->setPositionOrientation( intersect, Ogre::Quaternion::IDENTITY );
}

danharibo

14-01-2007 12:49:01

are you buukding the colisions in Editing mode?