TrackGuy
23-08-2006 09:31:51
Hello,
I just want to find out what the most elegant solution for the following question is:
The code works with possettings for both (node and body) and with possetting only for the body. But I am not sure if it is good to set both because I could imagine that there are maybe some offset problems arising ...
I just want to find out what the most elegant solution for the following question is:
Entity* cylinder = mSceneMgr->createEntity ( "Cylinder", "cylinder.mesh" );
cylinder->setNormaliseNormals ( true );
cylinder->setMaterialName ( materialname );
SceneNode* cylindernode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
cylindernode->attachObject ( cylinder );
cylindernode->scale ( height, radius, radius );
// Does this setposition make sence?
cylindernode->setposition ( pos );
OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::Cylinder ( m_World, radius, height );
OgreNewt::Body* bod = new OgreNewt::Body ( m_World, col );
delete col;
Real mass = radius * 2 * 3.14 * height;
Vector3 inertia = OgreNewt::MomentOfInertia::CalcCylinderSolid ( mass, radius, height );
bod->attachToNode ( cylindernode );
bod->setMassMatrix ( mass, inertia );
bod->setStandardForceCallback();
// or is it better to do it (only?) here?
bod->setPositionOrientation ( pos, Quaternion::IDENTITY );
The code works with possettings for both (node and body) and with possetting only for the body. But I am not sure if it is good to set both because I could imagine that there are maybe some offset problems arising ...