About Store Forum Documentation Contact



Post Reply 
ragdool simulate hit: increase falling time
Author Message
andrake Offline
Member

Post: #1
ragdool simulate hit: increase falling time
Hi
i try to simulate hit my personage.
when i do as in example it's near one second when chr in falling mode(blend mode)

there is a way to increase time for this mode?
there is a way to set parameter of blending?

Actually i want to make it manually:
1) chr.ragdollEnable (); //acto start falling
2) stop falling and start slowly moving ragdool actors to chrs bones
i try to use for this kinematic move to , but unsuccessfully.
need a tutorial

or so
Ragdoll.Bone *bone=ragdoll.findBone(8"Bone_010" ); bone.actor.orn(cskel.findBone(8"Bone_010").orn);

aa ok.... cskel is follow to ragdol in .ragdollEnable mode...i need to save cskel positions before go in ragdollEnableMode

looks like that in ragdool enable mode is bad idea moving ragdools actors
Code:
if(Chrs.elms())
   {
      Game.Chr &chr=Chrs[0];

      if(Kb.bp(KB_1)) {m = chr.cskel.findBone(8"Head").matrix(); chr.ragdollEnable ();} // switch to ragdoll
      if(Kb.bp(KB_2))chr.ragdollDisable(); // switch to skeleton animation

      if(Kb.bp(KB_Q))if(chr.ragdollBlend())if(Ragdoll.Bone *bone=chr.ragdoll.findBone(8"Head" ))bone.actor.addVel(Vec(0, 0, 30));
      if(Kb.bp(KB_W))if(chr.ragdollBlend())if(Ragdoll.Bone *bone=chr.ragdoll.findBone(8"Body" ))bone.actor.addVel(Vec(0, 0, 30));
      if(Kb.bp(KB_E))if(chr.ragdollBlend())if(Ragdoll.Bone *bone=chr.ragdoll.findBone(8"FootR"))bone.actor.addVel(Vec(0, 0, 40));
      if(Kb.bp(KB_R))if(chr.ragdollBlend())if(Ragdoll.Bone *bone=chr.ragdoll.findBone(8"HandR"))bone.actor.addVel(Vec(0, 0, 40));
      if(Kb.bp(KB_I)) if(Ragdoll.Bone *bone=chr.ragdoll.findBone(8"Head" )) bone.actor.matrix(m);
      if(Kb.bp(KB_J)) if(Ragdoll.Bone *bone=chr.ragdoll.findBone(8"Head" )) bone.actor.kinematicMoveTo(m);
      

      //Cam.setSpherical(Cam.at, Cam.yaw-Ms.d().x, Cam.pitch+Ms.d().y, 0, Max(0.1, Cam.dist*ScaleFactor(Ms.wheel()*-0.2))).updateVelocities().set();
   }

if i use ragdoll via editor ...not for every bone i cant use Ragdoll& toSkelBlend(CSkeleton &cskel, Flt blend );?
(This post was last modified: 07-24-2014 06:16 PM by andrake.)
07-24-2014 05:37 PM
Find all posts by this user Quote this message in a reply
andrake Offline
Member

Post: #2
RE: ragdool simulate hit: increase falling time
this extended ragdooll tutorial helps me to understood how it works
Code:
/******************************************************************************/
Game.ObjMap<Game.Chr> Chrs;
Matrix m;
int a=0;
flt tm=0.0;
/******************************************************************************/
void InitPre()
{
   EE_INIT();
   App.flag=APP_MS_EXCLUSIVE;
   D.viewRange(30).shadowSoft(1);

   Cam.at.set(16, 0, 16);
   Cam.yaw   =-PI_4;
   Cam.pitch =-0.5;
   Cam.dist  =4;
}
/******************************************************************************/
bool Init()
{
   Physics.create(EE_PHYSX_DLL_PATH);

   Game.World.activeRange(D.viewRange())
             .setObjType (Chrs, OBJ_CHR)
             .New        (UID(4053788456, 1284500709, 3533893555, 3086486877));
   if(Game.World.settings().environment)Game.World.settings().environment->set();

   return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
bool Update()
{
  
   if(Kb.bp(KB_ESC))return false;
   Game.World.update(Cam.at);

   if(Chrs.elms())
   {
      Game.Chr &chr=Chrs[0];
      
      chr.ragdoll.gravity(true);
      if(Kb.bp(KB_1)) {m = chr.cskel.findBone(8"Head").matrix(); chr.ragdollEnable (); } // switch to ragdoll
      if(Kb.bp(KB_2)) {chr.ragdollDisable(); chr.cskel.findBone(8"Head").pos=Vec(0, 10, 0);  } // switch to skeleton animation
      if(Kb.b(KB_3)) {a=1;chr.ragdollBlend();}
      if(a==1)
      {
         tm=0.1;
      chr.ragdoll_time=tm;      
      }
      
      if(Kb.b(KB_4)) {a=2;}
      if(a==2)
      {
         if(tm<0.35) tm+=0.02;
      chr.ragdoll_time=tm;      
      }
      
      if(Kb.b(KB_5)) chr.ragdoll.toSkel(chr.cskel);

      if(Kb.bp(KB_Q)) if(Ragdoll.Bone *bone=chr.ragdoll.findBone(8"Head" ))bone.actor.addForce(Vec(0, -9, 0));
      if(Kb.bp(KB_W))if(chr.ragdollBlend())if(Ragdoll.Bone *bone=chr.ragdoll.findBone(8"Body" ))bone.actor.addVel(Vec(0, 0, 10));
      if(Kb.bp(KB_E))if(chr.ragdollBlend())if(Ragdoll.Bone *bone=chr.ragdoll.findBone(8"FootR"))bone.actor.addVel(Vec(0, 0, 10));
      if(Kb.bp(KB_R))if(chr.ragdollBlend())if(Ragdoll.Bone *bone=chr.ragdoll.findBone(8"HandR"))bone.actor.addVel(Vec(0, 0, 10));
      if(Kb.bp(KB_I)) if(Ragdoll.Bone *bone=chr.ragdoll.findBone(8"Head" )) bone.actor.matrix(m);
      
      if(Kb.bp(KB_J)) if(Ragdoll.Bone *bone=chr.ragdoll.findBone(8"Head" )) bone.actor.kinematicMoveTo(Vec(0, 15, 0));
      

      Cam.setSpherical(Cam.at, Cam.yaw-Ms.d().x, Cam.pitch+Ms.d().y, 0, Max(0.1, Cam.dist*ScaleFactor(Ms.wheel()*-0.2))).updateVelocities().set();
   }

   return true;
}
/******************************************************************************/
void Render()
{
   Game.World.draw();
}
void Draw()
{
   Renderer(Render);

   if(Ms.b(0))
   {
      if(Renderer.rebuildDepthNeededForDebugDrawing())Renderer.rebuildDepth();
      //Physics.draw();
      Game.Chr &chr=Chrs[0];
      chr.cskel.draw(RED);
      chr.ragdoll.draw();
      
   }
Game.Chr &chr=Chrs[0];
   D.text(0, 0.9, "Press 1, 2 to switch between skeleton<->ragdoll animation");
   D.text(0, 0.8, "Press q, w, e, r to simulate shot hits"  );
   D.text(0, 0.7, S + chr.ragdoll_time);
}
/******************************************************************************/
07-25-2014 06:18 PM
Find all posts by this user Quote this message in a reply
andrake Offline
Member

Post: #3
RE: ragdool simulate hit: increase falling time
can't understood why ragdoll_time can have values 0....0.35 ?
is it a function value from time?
when it's 0.0001 there is alreday too big value for blending

ehh..looks like that hit simulation can be better than in example (
(This post was last modified: 07-26-2014 07:49 AM by andrake.)
07-26-2014 07:13 AM
Find all posts by this user Quote this message in a reply
Post Reply