Saturday 30 June 2012

Locked Ragdolls



This simplistic video shows how with SR1 there is a ragdoll movement option called "Locked", which locks the figure in the starting pose, but it still reacts to the physics in the scene.  It's like "Keyframed", however with Keyframed the whole figure will not move as part of the physics simulation (it moves via keyframes instead). 

Wednesday 27 June 2012

Tower Builder Script

In case anyone is interested, the script to create the building used in this video follows:




import poser

print

blockHeight = 0.8
yDelta = 0.1 * blockHeight

def newBlock(x, z, y):
    poser.Scene().LoadLibraryProp("/Runtime/Libraries/Props/Primitives/box.ppz")
    poser.Scene().CurrentActor().ParameterByCode (poser.kParmCodeXTRAN).SetValue(x)
    poser.Scene().CurrentActor().ParameterByCode (poser.kParmCodeZTRAN).SetValue(z)
    poser.Scene().CurrentActor().ParameterByCode (poser.kParmCodeYTRAN).SetValue(y)
    poser.Scene().CurrentActor().ParameterByCode (poser.kParmCodeYSCALE).SetValue(blockHeight)
    poser.Scene().CurrentActor().SetName("building_" + poser.Scene().CurrentActor().Name())

def row2x2(y):
    global yDelta
    a = 0.09
   
    newBlock (a, a, y)
    newBlock (-a, a, y)
    newBlock (-a, -a, y)
    newBlock (a, -a, y)
       
    y = y + yDelta
    b = 0.11
    newBlock (0.0, b, y)
    newBlock (-b, 0, y)
    newBlock (0.0, -b, y)
    newBlock (b, 0.0, y)

    newBlock (0.0, 0.0, y)
   
def row3x3(y): # 2 & 3
    global yDelta
    a = 0.15
    b = 1.1
   
    newBlock (a * 0.5, a * b, y)
    newBlock (-a * 0.5, a * b, y)
   
    newBlock (a * 0.5, -a * b, y)
    newBlock (-a * 0.5, -a * b, y)

    newBlock (a * b, a * 0.5, y)
    newBlock (a * b, -a * 0.5, y)

    newBlock (-a * b, a * 0.5, y)
    newBlock (-a * b, -a * 0.5, y)

    y = y + yDelta
   
    newBlock (0, a, y)
    newBlock (a, a, y)
    newBlock (-a, a, y)

    newBlock (a, 0, y)
    newBlock (-a, 0, y)

    newBlock (0, -a, y)
    newBlock (a, -a, y)
    newBlock (-a, -a, y)   
   
def row4x4(y): # 3 & 4
    global yDelta
    a = 0.14
    b = 0.9

    newBlock (0, a * 2 * b, y)
    newBlock (a * 1, a * 2 * b, y)
    newBlock (-a * 1, a * 2 * b, y)

    newBlock (a * 2 * b, 0, y)
    newBlock (a * 2 * b, a * 1, y)
    newBlock (a * 2 * b, -a * 1, y)
   
    newBlock (0, -a * 2 * b, y)
    newBlock (a * 1, -a * 2 * b, y)
    newBlock (-a * 1, -a * 2 * b, y)

    newBlock (-a * 2 * b, 0, y)
    newBlock (-a * 2 * b, a * 1, y)
    newBlock (-a * 2 * b, -a * 1, y)
           
    y = y + yDelta
   
    newBlock (a * 1.5, a * 1.5, y)
    newBlock (a * 0.5, a * 1.5, y)
    newBlock (-a * 1.5, a * 1.5, y)
    newBlock (-a * 0.5, a * 1.5, y)

    newBlock (a * 1.5, a * 0.5, y)
    newBlock (a * 1.5, a * -0.5, y)
    newBlock (-a * 1.5, a * 0.5, y)
    newBlock (-a * 1.5, a * -0.5, y)

    newBlock (a * 1.5, -a * 1.5, y)
    newBlock (a * 0.5, -a * 1.5, y)
    newBlock (-a * 1.5, -a * 1.5, y)
    newBlock (-a * 0.5, -a * 1.5, y)
   
       
def row5x5(y):
    global yDelta
    a = 0.14
    b = 1.1

    newBlock (a * 0.5, a * 2 * b, y)
    newBlock (a * 1.5, a * 2 * b, y)
    newBlock (-a * 0.5, a * 2 * b, y)
    newBlock (-a * 1.5, a * 2 * b, y)

    newBlock (a * 2 * b, a * 0.5, y)
    newBlock (a * 2 * b, a * 1.5, y)
    newBlock (a * 2 * b, -a * 0.5, y)
    newBlock (a * 2 * b, -a * 1.5, y)
   
    newBlock (a * 0.5, -a * 2 * b, y)
    newBlock (a * 1.5, -a * 2 * b, y)
    newBlock (-a * 0.5, -a * 2 * b, y)
    newBlock (-a * 1.5, -a * 2 * b, y)

    newBlock (-a * 2 * b, a * 0.5, y)
    newBlock (-a * 2 * b, a * 1.5, y)
    newBlock (-a * 2 * b, -a * 0.5, y)
    newBlock (-a * 2 * b, -a * 1.5, y)
           
    y = y + yDelta
   
    newBlock (a, a * 2, y)
    newBlock (a * 2, a * 2, y)
    newBlock (0, a * 2, y)
    newBlock (-a, a * 2, y)
    newBlock (-a * 2, a * 2, y)

    newBlock (a * 2, a, y)
    newBlock (a * 2, 0, y)
    newBlock (a * 2, -a, y)

    newBlock (-a * 2, a, y)
    newBlock (-a * 2, 0, y)
    newBlock (-a * 2, -a, y)
       
    newBlock (a, -a * 2, y)
    newBlock (a * 2, -a * 2, y)
    newBlock (0, -a * 2, y)
    newBlock (-a, -a * 2, y)
    newBlock (-a * 2, -a * 2, y)

   
# Unrem to delete any figures from the scene
#for f in poser.Scene().Figures():
#    poser.Scene().SelectFigure(f)
#    poser.Scene().DeleteCurrentFigure()

for p in poser.Scene().Actors():
   if (p.IsProp()):
        if string.find(p.Name(), "building_") != -1:
            print "Deleting " + p.Name()
            poser.Scene().SelectActor(p)
            poser.Scene().DeleteCurrentProp()
       
print "Creating Cubes"

y = 0
row4x4(y)

y = y + (2 * yDelta)
row4x4(y)

y = y + (2 * yDelta)
row4x4(y)

y = y + (2 * yDelta)
row3x3(y)

y = y + (2 * yDelta)
row3x3(y)

y = y + (2 * yDelta)
row3x3(y)

y = y + (2 * yDelta)
row2x2(y)

y = y + (2 * yDelta)
row2x2(y)

y = y + (2 * yDelta)
row2x2(y)

print "Finished - pls wait while screen refreshes - this could take some time"

Tuesday 26 June 2012

PoserPhysics SR1 Notes

This is a running list of SR1 changes, which I will keep up to date as things change.  SR1 have not been released yet - this is simply to give you forewarning of changes.



New Features
  1. Universal Joints have been added.  The UniversalX is like a ball joint, but with no SPIN/TWIST in the X Axis direction (as the props are positioned in frame 1).  UniversalY has no spin in the Y direction, and UniversalZ has no spin in the Z direction.  Universal joints are great for simulating things like chain links.  I will post a demo video shortly.
  2. The system will now ignore Invisible props (since this adversely effect the simulation).
  3. You can now join a prop to the GROUND for fixed joints, and other joints where the anchor point is "Child Origin".
  4. Added joint rotations around the Child origin and endpoint.  The original "Origin" and "Endpoint" selections have changed to "Join To Origin" and "Join To Endpoint".  Use the "Prop Origin" or "Prop Endpoint" for prop ball joins to the GROUND so it rotates on it's own Origin or Endpoint point.
  5. Added Cylinders.  Use the PoserCylinder to add cylinder elements to your scene.  IMPORTANT: The ODE does not support Cylinder to Capsule or Cylinder to Cylinder collisions.  So the PhysicsCylinder will only bounce (collide) off boxes, spheres and static trimesh shapes.  The cyclinder has been included for use as car wheels, where cylinder to cylinder and cylinder to capsule collisions are generally not required.
  6. Added Damping to the simulation, so that objects do not spin or roll forever.  In the unlikely event you need to change the default settings, change the PoserPhysics-LinearDamping and PoserPhysics->AngularDamping parameters on the UNIVERSE actor.
  7. For joining props, you NO LONGER USE THE POSER PARENTING system.  Instead, simply select the prop to join the current prop to in the "Join To" combobox in the Prop/Figure Settings tab of the PoserPhysics window.  Any parented prop in your scene will be unparented when the simulation is run.
  8. Added the setGravity(gravity) function to the API.  Removed the PoserPhysicsEngine(gravity = ?) option - simply call as PoserPhysicsEngine() now.
  9. Motors have been added.  These are a special type of Hinge joint, which has twist force applied.  Select the MotorX, Y or Z joint type.  The velocity of the rotation is set in the PoserPhysics->Velocity dial for that actor, and the acceleration is set by the  PoserPhysics->MaxForce dial.  For a simple sample, load a box, lift it a little, join it to the GROUND, set to MotorX, anchor point Child Endpoint.
  10. A new ragdoll keyframe movement type has been added called "Locked". This mode creates the ragdoll, but locks the joints in a fixed position.  There is an additional dial added to the ragdoll called PoserPhysics-LockedSoftness, which is you set this to anything other than the -1 default, applies this value to the CFM of the joints.  In effect, you can make the joints rigid (with a value of -1 or 0), or flexible (with a value of say 0.001). This is experimental at this stage, so use at your own risk!
Fixes
  1. There is now user input validation of the numeric input fields of the PoserPhysics dialog.
  2. You can now no longer have two PoserPhysics windows open at the same time
  3. Fixed the instance where checkbox inputs were not being saved in the Scene Settings tab
  4. The capsule has been renamed to PoserCapsule.  Delete the capusle.pp2 (not ppZ!) file from the primitives folder.  The standard Poser capsule and cylinders are not supported - use the PhysicsCapsule and PhysicsCylinder instead.
  5. Fixed an instance when the old version of PoserPhysics had been installed on Poser 9/Poser Pro 2012, stopped the new version from working.

Sunday 24 June 2012

Getting a Figure to Fall Into a Chair

M4 falling into a chair.  First go I just bent his thighs and shins a little, but he slumped forward and eventually fell off the chair.





For the second simulation, I bent his abdomen back 13 degrees, and he then fell nicely into the chair and came to rest.  Chair was set to Immoveable.

Friday 22 June 2012

New Joint System Tutorial




Additional Items:
  1. Do not have 2 props joined together touching (or intersecting) at the start of the simulation.
  2. In the shipped PoserPhysics 2012, you can anchor a prop to it's parent's "Origin" or "Endpoint".  This tutorial was done using PoserPhysics 2012 Service Release 1, which adds a third option "Child Origin" (with is the current props Origin point).
  3. The Poser Primitive box prop has it's Origin at the bottom of the box, and the EndPoint in the top of the box.
  4. The Poser Primitive sphere prop has it's Origin in the middle of the ball and the EndPoint at the outer perimeter.  So the EndPoint of the sphere is not generally a good place to anchor another prop to - parent to the Origin of the sphere.  You can link together many spheres (by parenting each sphere to other and setting the anchor point to the Origin) to get effect.
  5. The Poser Primitive capsule prop has it's Origin on the left end and EndPoint on the right end, so it is the ideal prop to use for linking components together as Ball or Hinge joints to create rope, etc.
  6. SR1 will also add a Universal Joint, which is simply a Ball Joint which does not allow twists.  The Universal Joint will be ideal for simulating chain links.

Troubleshooting

PoserPhysics 2012 has been release, and there have been almost no reported issues, which is great.  Some items that you should note though:
  1. Do not have more the one instance of the PoserPhysics2012 script running at a time.  I will add a check in SR1 to make sure a second copy is not started.
  2. Whilst the PoserPhysics window is displayed, it is using the Poser python callback system to detect when you select different Poser scene elements.  If you run another PoserPython script which sets the Poser callback (which is highly unlikely), PoserPhysics will no longer know when you change your figure or prop selection in the scene.  If you do need to run such a script, simply close the PoserPhysics window first.
  3. If you have previously installed the old PoserPhysics plugin into your Poser9 or PoserPro2012 Runtime (which would not have worked), make sure you delete it prior to installing PoserPhysics2012.  So delete the following folders/files:
      - Runtime\Python\Lib\site-packages\P6
      - Runtime\Python\Lib\site-packages\P7
      - Runtime\Python\Lib\physics*.*
      - Runtime\Python\poserscripts\PoserPhysics
  4. There is a capsule primitive (pp2) supplied with PoserPhysics which gets installed in the Primitives folder, and loads into your scene as "capsule" (lowercase "C"), and  you may already have the Smith Micro supplied capsule (pz2) in the same folder, which loads into your scene as "Capsule" (uppercase "C").  Either of these props work in PoserPhysics, however the former is simulated as a "Capsule", and the later defaults to a "trimesh box".  If using the Smith Micro supplied capsule, set the Shape to "Trimesh Capsule".  This is will set as the default in SR1.
  5. The valid "Bounciness" range is 0 - 1, however the PoserPhysics GUI will let you entered numbers greater than 1 (which will be address in SR1).  Keep Bounciness <= 1.

Tuesday 19 June 2012

Rolling Car Simulation


A very simple simulation to demonstrate how 4 spheres can be joined (using a hinge joint) to a car body, which then rolls down a bumpy slope - using PoserPhysics.  No python needed for this simulation.

Wednesday 6 June 2012

Collection of Joints


PoserPhysics2012 joints in action.  Ball joints hold the chain (capsules) together.  The top capsule of the chain has a fixed joint to the spinning box.  The spinning box has a HingeY joint to the supporting pole.  The whole thing is put in motion by a ball placed inside an immoveable box.

Tuesday 5 June 2012

Newton's Cradle


Done with PoserPhysics2012.  The balls have a HingeZ joint to the blocks above them, so they swing in the X axis plane.  The 2 struts from each ball are thin capsules, with a fixed joint to the ball.  Each ball's friction is 0 and bounce is 1.

Monday 4 June 2012

Joint Hardness


A very quick example showing how you can join spheres end-to-end and then adjust the Joint Hardness of the simulation to get different effects. I will do a more detailed tutorial once PoserPhysics2012 is released.