Camera collision problem

feng007lhf

08-08-2007 10:27:08

hi

how can I do a collision between camera and other entities.

my code as follows:

Entity* floor;
SceneNode* floornode;
floor = mSceneMgr->createEntity("Floor", "wall_27.mesh" );
floor->setNormaliseNormals(true);
floornode = mSceneMgr->getRootSceneNode()->createChildSceneNode( "FloorNode" );
floornode->attachObject( floor );
floor->setCastShadows( false );
floornode->setScale(0.01, 0.01, 0.01);

OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::ConvexHull(m_World, floornode);
OgreNewt::Body* bod = new OgreNewt::Body( m_World, col);
delete col;
bod->attachToNode(floornode)
bod->setPositionOrientation( Ogre::Vector3(0.0,-10.0,0.0), Ogre::Quaternion::IDENTITY );

msnCam = mSceneMgr->getRootSceneNode()->createChildSceneNode();
msnCam->attachObject( mCamera );
mCamera->setPosition(0.0, 0.0, 0.0);
msnCam->setPosition( 0.0, 5.0, 0.0);

OgreNewt::CollisionPrimitives::Ellipsoid* colCamra = new OgreNewt::CollisionPrimitives::Ellipsoid(m_World, Vector3(4, 4, 4));
OgreNewt::Body* mbody = new OgreNewt::Body(m_World, colCamra);
delete colCamra;
mbody->attachToNode(msnCam);

so are my codes. why camera can't collision with floor when i move camera.

ths

goldman82

08-08-2007 21:32:28

hi,

i think you must move the newton body instead of the camera.
there are many threads about that this forum.

goldman82

feng007lhf

09-08-2007 11:25:02

hi goldman82

thank you. I have found many theads, and now my camera can collision with other entities in scene.

I use tree collison , but i find it so slowly , any other way can improve the efficiency.

ths

Nox587

12-08-2007 03:07:46

The object used for your tree collision may be to large. My project is using several large objects for tree collisions, the project ran better when I seperated (split) some of the larger meshes that were being used for the tree collision.

Also if you are running your project in debug, you will want to try it in release to see how fast it will actually run. Debug mode will surely slow your project down.

Hope that helps.

feng007lhf

13-08-2007 09:23:44

hi Nox587

thanks. i find release mode faster than debug mode.