unclepauly
08-09-2006 15:09:43
hello
i have been trying to improve on demo 5, the simple vehicle demo, by replacing the box with an actual car. i have got some 3ds max cars and exported everything to Ogre - it's an Audi TT, and it looks awesome.
but i am struggling to add the physics. in my test app, i have a cone, a cylinder, and my car. they all start the same height above the surface, and when the app starts, they all should drop to the floor. the cone and the cylinder do, but my car stays in the air. i think this is something to do with the collision object i am attaching, and/or the inertia or mass settings.
the car is actually made up of loads of meshes, eah one represnting a part of the car. so there is the body, the interior, the grill, the lights etc. however i can reproduce my problem with only one mesh, for example the body.
so here is my code:
in demo5, the 'car' has a collision object of type CollisionPrimitives::Box. I figured this would only work for boxes, so i changed it to a TreeCollision for my car. Is this correct?
also, i calculate the interia above by using CalcBoxSolid. I'm guessing this is wrong, but i am not sure what to replace it with.
Appreciate any help, and thanks.
i have been trying to improve on demo 5, the simple vehicle demo, by replacing the box with an actual car. i have got some 3ds max cars and exported everything to Ogre - it's an Audi TT, and it looks awesome.
but i am struggling to add the physics. in my test app, i have a cone, a cylinder, and my car. they all start the same height above the surface, and when the app starts, they all should drop to the floor. the cone and the cylinder do, but my car stays in the air. i think this is something to do with the collision object i am attaching, and/or the inertia or mass settings.
the car is actually made up of loads of meshes, eah one represnting a part of the car. so there is the body, the interior, the grill, the lights etc. however i can reproduce my problem with only one mesh, for example the body.
so here is my code:
body = mSceneMgr->createEntity( "carentity", "AudiTT_body.mesh" );
carnode->attachObject(body);
carnode->setScale( size );
// rigid body.
OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::TreeCollision(m_World, carnode, false);
bod = new OgreNewt::Body( m_World, col );
bod->attachToNode(carnode);
// initial position
bod->setPositionOrientation( Ogre::Vector3(10,10,13),Ogre::Quaternion::IDENTITY );
delete col;
mass = 100.0;
inertia = OgreNewt::MomentOfInertia::CalcBoxSolid( mass, size );
bod->setMassMatrix( mass, inertia );
bod->setStandardForceCallback();
in demo5, the 'car' has a collision object of type CollisionPrimitives::Box. I figured this would only work for boxes, so i changed it to a TreeCollision for my car. Is this correct?
also, i calculate the interia above by using CalcBoxSolid. I'm guessing this is wrong, but i am not sure what to replace it with.
Appreciate any help, and thanks.