[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 5150: file_get_contents(https://freedomsponsors.org/api/project/294): failed to open stream: HTTP request failed! HTTP/1.1 502 Bad Gateway
Physx3 ragdoll progress continues, slowly... - Page 2 - Forums | Torque 3D

Physx3 ragdoll progress continues, slowly...

30 posts Page 2 of 3
chriscalef
Posts: 326
Joined: Mon Feb 09, 2015 7:48 pm
by chriscalef » Sat Mar 21, 2015 8:13 am
Ah, right, solver iterations, I haven't messed with them yet. Thanks!
MangoFusion
Posts: 50
Joined: Wed Feb 04, 2015 12:00 am
by MangoFusion » Sat Mar 21, 2015 3:42 pm
Would be interesting to see how you hooked up the joints to the animation system. I did some work a few months back on importing MikuMikuDance models into torque and had to add a whole bunch of override code to correctly handle their constraint system so animations would work correctly.
chriscalef
Posts: 326
Joined: Mon Feb 09, 2015 7:48 pm
by chriscalef » Sat Mar 21, 2015 5:27 pm
Okay, no further progress to report except code cleaned up and committed, so grab updates if you're interested.

@Mango, not sure what you mean, were you bringing in models with animations or was physics involved? I shouldn't have to worry about constraints (until we get to the next phase, that is) since all I'm looking at is driving kinematic rigid bodies with the animation data.

The really fun part (I've done this already in Ecstasy Motion, just not here in stock Torque physx) is when you start driving joint forces with animation data. It looks pretty weird and is definitely a very different product from the original animation, but if you're planning for that it can be really cool.
chriscalef
Posts: 326
Joined: Mon Feb 09, 2015 7:48 pm
by chriscalef » Sat Mar 21, 2015 6:33 pm
Ah, hehe, whoops! Spoke too soon. Currently they work fine unless you happen to want to start them rotated in any way other than identity. :-P

Working on it...
chriscalef
Posts: 326
Joined: Mon Feb 09, 2015 7:48 pm
by chriscalef » Mon Mar 23, 2015 4:09 am
And, WHEW. Was an all weekend project, but they are now working from any direction. Still the same joint limits, iterations, etc. issues, but the key transform problems appear to all be solved at this point.

https://vimeo.com/122938362

EDIT: Oh yeah, also I moved gravity out to a pref in scripts/client/prefs.cs, but I took that file out of the repo so you'll have to add this yourself if you want a non default gravity:


$pref::Physics::gravity = "0 0 -1.0";

The above is very light gravity, handy for fine tuning joints, but normal is more like -9.8.
chriscalef
Posts: 326
Joined: Mon Feb 09, 2015 7:48 pm
by chriscalef » Wed Apr 01, 2015 3:57 am
Minor improvements: got setDynamic(bool) and setHasGravity(bool) functioning, as well as setPartDynamic and setPartHasGravity.

https://vimeo.com/123790399

Still WIP status, remaining most immediate issues are:

1) we still have an offset problem, when actors start out kinematic and later change to dynamic, they are rendering the shape mesh out at double the main body transform

2) knee/elbow joints reveal an apparent bug in physx3 (?), or else some fundamental misunderstanding on my part, because: I have succeeded in rotating the physx view of my joint limit cone to exactly where I want it, judging by the debug render view anyway, but in practice the limit cone is always right down the center, and the knees and elbows bend backward exactly as much as they bend forward. Will probably try limit planes next.

3) finally, I also haven't set up the kinematic side yet to drive the physx bodyparts with the nodeTransforms.
Steve_Yorkshire
Posts: 191
Joined: Tue Feb 03, 2015 10:30 pm
 
by Steve_Yorkshire » Wed Apr 01, 2015 7:06 pm
♫ It's raining men! ♪ ;)
Nice work Chris! :)
chriscalef
Posts: 326
Joined: Mon Feb 09, 2015 7:48 pm
by chriscalef » Thu Apr 02, 2015 1:36 am
Thanks!

Oh btw, meant to post it earlier, but that transform problem is gone now and changes pushed to github, was due to a minor oversight.
chriscalef
Posts: 326
Joined: Mon Feb 09, 2015 7:48 pm
by chriscalef » Thu Apr 02, 2015 9:54 pm
Ah, there we go...

https://vimeo.com/123978547

Now we can drive kinematic bodyparts around as expected.

Remaining goals:

1) start moving actors around the world in realtime, making sure above still works

2) build a game with a player in it and hook up the rifle to effectively shoot them

3) fix all the single-player-game assumptions

4) eventually figure out what's up with the knee/elbow joint orientations. Possibly move on up to latest greatest physx, currently still on version 3.3.1.
chriscalef
Posts: 326
Joined: Mon Feb 09, 2015 7:48 pm
by chriscalef » Sat Apr 04, 2015 12:25 am
So... if the video's still processing then come back in a few minutes, but... I successfully addressed the most entertaining point on the above list:

https://vimeo.com/124068087

Yes, you can shoot them now! Although I haven't committed the script side yet because it's part of a new project, which as you can see merges my terrain pager and physx3 projects into one game build... master plan coming together... all it took on the script side is the following addition to WeaponImage::onFire (put it right after the "create the projectile object" block)

Code: Select all

   ...
     
      //Add this for physics raycasting
      //TEMP! Hard coding it for basic pistol and rifle for first pass, but this 
      //  should be maybe a projectile property(?)
      if ((%this.getName() $= "RyderWeaponImage")||(%this.getName() $= "LurkerWeaponImage"))
      {
         %start = %obj.getEyePoint();
         %start = VectorAdd(%start,VectorScale(%muzzleVector,2)); 
         %vec = VectorScale(%muzzleVector,100);
         
         //TEMP! Define this in the (weapon or the projectile datablock)?
         if (%this.getName() $= "RyderWeaponImage")
            %weaponForce = 70.0;
         else
            %weaponForce = 95.0;
           
         //echo("casting ray from: " @ %start @ " in direction of " @ %vec);
         %id = physx3CastRay(%start,%vec,1);//0=static,1=dynamic,2=player,3=all
         if ((%id)&&(%id.getClassName() $= "PhysicsShape"))
         {
            %id.setDynamic(1);
            %id.aitp(%id.getContactBody(),VectorScale(%muzzleVector,%weaponForce));
         }
         //end physics raycasting


(Sorry if that is too confusing, here is the full function for reference)

Code: Select all


// ----------------------------------------------------------------------------
// A "generic" weaponimage onFire handler for most weapons.  Can be overridden
// with an appropriate namespace method for any weapon that requires a custom
// firing solution.

// projectileSpread is a dynamic property declared in the weaponImage datablock
// for those weapons in which bullet skew is desired.  Must be greater than 0,
// otherwise the projectile goes straight ahead as normal.  lower values give
// greater accuracy, higher values increase the spread pattern.
// ----------------------------------------------------------------------------

function WeaponImage::onFire(%this, %obj, %slot)
{
   //echo("\c4WeaponImage::onFire( "@%this.getName()@", "@%obj.client.nameBase@", "@%slot@" )");

   // Make sure we have valid data
   if (!isObject(%this.projectile))
   {
      error("WeaponImage::onFire() - Invalid projectile datablock");
      return;
   }
   
   // Decrement inventory ammo. The image's ammo state is updated
   // automatically by the ammo inventory hooks.
   if ( !%this.infiniteAmmo )
      %obj.decInventory(%this.ammo, 1);

   // Get the player's velocity, we'll then add it to that of the projectile
   %objectVelocity = %obj.getVelocity();
   
   %numProjectiles = %this.projectileNum;
   if (%numProjectiles == 0)
      %numProjectiles = 1;
     
   for (%i = 0; %i < %numProjectiles; %i++)
   {
      if (%this.projectileSpread)
      {
         // We'll need to "skew" this projectile a little bit.  We start by
         // getting the straight ahead aiming point of the gun
         %vec = %obj.getMuzzleVector(%slot);

         // Then we'll create a spread matrix by randomly generating x, y, and z
         // points in a circle
         %matrix = "";
         for(%j = 0; %j < 3; %j++)
            %matrix = %matrix @ (getRandom() - 0.5) * 2 * 3.1415926 * %this.projectileSpread @ " ";
         %mat = MatrixCreateFromEuler(%matrix);

         // Which we'll use to alter the projectile's initial vector with
         %muzzleVector = MatrixMulVector(%mat, %vec);
      }
      else
      {
         // Weapon projectile doesn't have a spread factor so we fire it using
         // the straight ahead aiming point of the gun
         %muzzleVector = %obj.getMuzzleVector(%slot);
      }

      // Add player's velocity
      %muzzleVelocity = VectorAdd(
         VectorScale(%muzzleVector, %this.projectile.muzzleVelocity),
         VectorScale(%objectVelocity, %this.projectile.velInheritFactor));

      // Create the projectile object
      %p = new (%this.projectileType)()
      {
         dataBlock = %this.projectile;
         initialVelocity = %muzzleVelocity;
         initialPosition = %obj.getMuzzlePoint(%slot);
         sourceObject = %obj;
         sourceSlot = %slot;
         client = %obj.client;
         sourceClass = %obj.getClassName();
      };
      MissionCleanup.add(%p);
     
      //Physics: do a castRay, IF this is a weapon which should do this.
      //TEMP! Hard coding it for basic pistol and rifle for first pass, but this 
      //  should be maybe a projectile property(?)
      if ((%this.getName() $= "RyderWeaponImage")||(%this.getName() $= "LurkerWeaponImage"))
      {
         %start = %obj.getEyePoint();
         %start = VectorAdd(%start,VectorScale(%muzzleVector,2)); 
         %vec = VectorScale(%muzzleVector,100);
         
         //TEMP! Define this in the (weapon or the projectile datablock)?
         if (%this.getName() $= "RyderWeaponImage")
            %weaponForce = 70.0;
         else
            %weaponForce = 95.0;
           
         //echo("casting ray from: " @ %start @ " in direction of " @ %vec);
         %id = physx3CastRay(%start,%vec,1);//0=static,1=dynamic,2=player,3=all
         if ((%id)&&(%id.getClassName() $= "PhysicsShape"))
         {
            %id.setDynamic(1);
            %id.aitp(%id.getContactBody(),VectorScale(%muzzleVector,%weaponForce));
         }
      }
   }
}


Obviously it's still in its raw and cluttered state of "just barely got it working this morning", but it seems to be on the right track anyway.
30 posts Page 2 of 3

Who is online

Users browsing this forum: No registered users and 1 guest