Rscorpiox
01-08-2009 15:04:36
Sorry to post in such a short time and for my poor English.
But I just can't find way to solve the problem.
Here's the thing :
My project got two Character (Main character and NPC).
I move the main character by adding force.
When the two character collision , the movement of two body just shiver around.
Or the NPC just fly away.
My goal is to make the collision smoothly just like the normal game's collision.
Like : when I walk to the npc and collision occor , the npc won't move , and the main character just slide to side by the npc.
Here's my code of setting the body:
Here's the main character's forcecallback function:
I trying to set the parameter of mass and inertia , but just can't make it work.
Maybe it's a newbie question.
But I just can't find way to solve it...
Please give me some advice.
And thanks for the reading.
But I just can't find way to solve the problem.
Here's the thing :
My project got two Character (Main character and NPC).
I move the main character by adding force.
When the two character collision , the movement of two body just shiver around.
Or the NPC just fly away.
My goal is to make the collision smoothly just like the normal game's collision.
Like : when I walk to the npc and collision occor , the npc won't move , and the main character just slide to side by the npc.
Here's my code of setting the body:
mEntity = mSceneMgr->createEntity("NPC","npc.mesh");
mNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("NPCnode",Vector3(0,0,0));
mNode->attachObject(mEntity);
mNode->scale(0.1,0.1,0.1);
OgreNewt::Body *npcBody;
OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::ConvexHull(m_World,mNode);
npcBody = new OgreNewt::Body( m_World, col );
Ogre::Vector3 inertia = Ogre::Vector3::ZERO;
npcBody->setMassMatrix( 90000 , inertia );
npcBody->attachToNode( mNode );
npcBody->setPositionOrientation(Vector3(-1035,10,98),mNode->getOrientation());
npcBody->setStandardForceCallback();
OgreNewt::BasicJoints::UpVector(m_World,npcBody,Vector3(Vector3::UNIT_Y));
delete col;
Here's the main character's forcecallback function:
Vector3 inertia,move(0,0,0),pos;
Ogre::Quaternion orient;
Real mass;
me->getMassMatrix(mass,inertia);
me->getPositionOrientation(pos,orient);
Ogre::Vector3 V1 = orient * mDirection , V0 = me->getVelocity();
Ogre::Vector3 accel = (( V1 - V0 ) / me->getWorld()->getTimeStep());
move = accel*mass;
move.y = -9.8*mass;
me->addForce(move);
OgreNewt::BasicJoints::UpVector(m_World,me,Vector3(Vector3::UNIT_Y));
I trying to set the parameter of mass and inertia , but just can't make it work.
Maybe it's a newbie question.
But I just can't find way to solve it...
Please give me some advice.
And thanks for the reading.