Physic ragdoll folowing bone animation.

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Physic ragdoll folowing bone animation.

Postby PJani » Mon Dec 21, 2009 2:49 pm

Is there any possible way to make ragdoll bones follow bone positions. So in case of some outside force ragdoll bones tries to resistance that force until outside force is big enough to move it from there. When outside force lowers, ragdoll goes back to animation pose...
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: Physic ragdoll folowing bone animation.

Postby Julio Jerez » Mon Dec 21, 2009 3:26 pm

yes there is a way.
If you wait until I get to the Rag doll demo in Ogrenewt so that you use a proper Ogre style joint, that uses the cotusm joint in Newton.
I should have it in a usable by this friday at most.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Physic ragdoll folowing bone animation.

Postby PJani » Mon Dec 21, 2009 4:32 pm

No problem, I will wait till then.

anyway for what and how is KinematicController used?

i worte this code for OgreNewt...and put it in
OgreNewt_BasicJoints.h
Code: Select all
class _OgreNewtExport KinematicController : public Joint
{
public:
   KinematicController::KinematicController(OgreNewt::Body* bdy0, const Ogre::Vector3& pos);
   KinematicController::~KinematicController();

   void KinematicController::setPickMode(int mode);
   void KinematicController::setMaxLinearFriction(float accel);
   void KinematicController::setMaxAngularFriction(float alpha);
   void KinematicController::setTargetRotation(const Ogre::Quaternion& rot);
   void KinematicController::setTargetPosit(const Ogre::Vector3& pos);

};

OgreNewt_BasicJoints.cpp
Code: Select all
             KinematicController::KinematicController(OgreNewt::Body* bdy0, const Ogre::Vector3& pos)
      :Joint()
   {
      //OgreNewt::Body::
      CustomKinematicController* ckc = new CustomKinematicController(bdy0->getNewtonBody(),dVector(pos.x,pos.y,pos.z));
      
      SetSupportJoint(ckc);
   }
   
   KinematicController::~KinematicController(){}

   void KinematicController::setPickMode(int mode)
   {
      CustomKinematicController* ckc = (CustomKinematicController*)m_joint;
      ckc->SetPickMode(mode);
   }

   void KinematicController::setMaxLinearFriction(float accel)
   {
      CustomKinematicController* ckc = (CustomKinematicController*)m_joint;
      ckc->SetMaxLinearFriction(accel);
   }

   void KinematicController::setMaxAngularFriction(float alpha)
   {
      CustomKinematicController* ckc = (CustomKinematicController*)m_joint;
      ckc->SetMaxAngularFriction(alpha);
   }

   void KinematicController::setTargetRotation(const Ogre::Quaternion& rot)
   {
      CustomKinematicController* ckc = (CustomKinematicController*)m_joint;
      ckc->SetTargetRotation(dQuaternion(rot.x,rot.y,rot.z,rot.w));
   }

   void KinematicController::setTargetPosit(const Ogre::Vector3& pos)
   {
      CustomKinematicController* ckc = (CustomKinematicController*)m_joint;
      ckc->SetTargetRotation(dVector(pos.x,pos.y,pos.z));
   }


but it seems like there is no effect on the body...
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: Physic ragdoll folowing bone animation.

Postby Julio Jerez » Mon Dec 21, 2009 5:37 pm

The KinematicController is a special joint for controlling single object by setting a matrix.
it is good for stuff tha can be scripetd in a game, like doors that open and close when you push a bottom.
elevators that go op and own, picking objects, making and object follow a path etc.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Physic ragdoll folowing bone animation.

Postby PJani » Tue Dec 22, 2009 1:13 pm

what actually setTargetPosit does becouse i don't see any effect.
Code: Select all
   
//Dont look at this is just some internal creation calls of my game engine.
      SceneGeometryManager::getSingleton().CreateMesh("player_2",&tmplt,pos+Ogre::Vector3(0,0,5),Ogre::Quaternion::IDENTITY,Ogre::Vector3(1,1,1));

      PhysicObject* po2 = ObjectManager::getSingleton().createBody("player_2",false,Ogre::Vector3::ZERO,2400,false);
//////////////////////////////////
// Mass of object is 2400kg and gravitation accel is 9.8m/s^2

      kc = new OgreNewt::KinematicController(po2->getOgreNewtBody(),pos+Ogre::Vector3(0,1,5));
      kc->setMaxLinearFriction(200);
      kc->setMaxAngularFriction(800);

      kc->setTargetRotation(Ogre::Quaternion::IDENTITY);
      kc->setTargetPosit(Ogre::Vector3(0,10,0));
      //kc->setPickMode(1);
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: Physic ragdoll folowing bone animation.

Postby Julio Jerez » Tue Dec 22, 2009 2:17 pm

// Mass of object is 2400kg and gravitation accel is 9.8m/s^2

kc = new OgreNewt::KinematicController(po2->getOgreNewtBody(),pos+Ogre::Vector3(0,1,5));
kc->setMaxLinearFriction(200);
kc->setMaxAngularFriction(800);


if the body is 2400 kg then then it will not move if the friction is so low, make friction make teh frition a factor of the body weight

kc->setMaxLinearFriction(mass * gravity * 4.0);
kc->setMaxAngularFriction(5 * (mass * gravity * 4.0));
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron