sdragou
27-03-2006 10:41:30
I am trying to make a character moving on a horizontal plane.
I've made an upvector joint and attached a cylindrical body to it.
In the frame listener I use setVelocity in order to move the body. But when they contact there is no movement.
here is some of the code:
After a while (due to gravity) the body reaches the ground and then it stops.
Here is the code for the ground
and the framelistener framestarted method (a part of it)
I also tryied to set friction to zero:
nothing.
Any Ideas?
I've made an upvector joint and attached a cylindrical body to it.
In the frame listener I use setVelocity in order to move the body. But when they contact there is no movement.
here is some of the code:
Ogre::Quaternion quat=Ogre::Quaternion(Ogre::Math::Sqrt(0.5),0,0,Ogre::Math::Sqrt(0.5));
OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::Cylinder(m_World,30,170,quat,Vector3(0,85,0));
body = new OgreNewt::Body( m_World, col, 1 );
delete col;
assil_node->setPosition(500,12,300);
body->setPositionOrientation(assil_node->getPosition(),assil_node->getOrientation());
body->attachToNode(assil_node);
Ogre::Vector3 inertia = OgreNewt::MomentOfInertia::CalcCylinderSolid(100,30,170);
body->setMassMatrix(100.0f,inertia);
body->setStandardForceCallback();
OgreNewt::Joint *joint = new OgreNewt::BasicJoints::UpVector(m_World,body,Vector3(0,1,0));
After a while (due to gravity) the body reaches the ground and then it stops.
Here is the code for the ground
SceneNode *patnode = mSceneMgr->getRootSceneNode()->createChildSceneNode("patwma");
Entity *patwma=mRoot->getSceneManager("generic")->createEntity( "patwma", "patwma.mesh" );
patnode->attachObject(patwma);
patnode->setPosition(4000,0,4000);
patwma->setQueryFlags(FLOOR_MASK);
OgreNewt::Collision* pcol = new OgreNewt::CollisionPrimitives::TreeCollision( m_World, patnode, true );
OgreNewt::Body* pbod = new OgreNewt::Body( m_World, pcol );
pbod->setContinuousCollisionMode(1);
pbod->attachToNode( patnode );
pbod->setPositionOrientation(patnode->getPosition(),patnode->getOrientation());
and the framelistener framestarted method (a part of it)
m_World->update( evt.timeSinceLastFrame );
OgreNewt::Debugger::getSingleton().showLines( assil->m_World );
body->setVelocity(assil_node->getOrientation()*(-mDirection));
I also tryied to set friction to zero:
const OgreNewt::MaterialID* mMatDefault = m_World->getDefaultMaterialID();
const OgreNewt::MaterialID* mMatAssil = new OgreNewt::MaterialID( m_World );
OgreNewt::MaterialPair *mMatPairDefaultAssil = new OgreNewt::MaterialPair( m_World, mMatDefault, mMatAssil );
mMatPairDefaultAssil->setDefaultFriction( 0, 0 );
mMatPairDefaultAssil->setDefaultElasticity(0);
mMatPairDefaultAssil->setContinuousCollisionMode(1);
body->setMaterialGroupID(mMatAssil);
nothing.
Any Ideas?