Creating a physics scene is Director is simple. Let us follow the 5 step process:

  1. Create a 3d world ( name it ‘3d_scene’ ) using menu Insert-> Media Element -> Shockwave 3d
  2. Create a physics world ( name it ‘physX’ )using menu Insert -> Media Element -> Physics
  3. Create a behavior script ( click on menu Window-> Script , set the type to behavior ) with the following code say physics_init ( just a random name i gave )
  4. property pDirPhyz
    property pTimeStep,pSubSteps
    on endSprite me
    --if the physics world is initialized, then stop it on endsprite
    if (pDirPhyz.isInitialized = 1) then
    pDirPhyz.destroy()
    end if
    end
     
    --step physics on every exit frame
     
    on exitFrame me
    -- Step the physics
    pDirPhyz.simulate()
    end exitFrame
     
    on beginSprite me
    --get a handler for physX
    pDirPhyz = member("physX")
    pTimeStep = 0.025
    pSubSteps = 5
    --hook the physics world to the 3d world
    pDirPhyz.Init(member("3d_scene"), vector(1,1,1),#equal, pTimeStep, pSubSteps )
     
    pDirPhyz.gravity = vector(0,-9.8,0)
    pDirPhyz.contacttolerance = 0.02
    pDirPhyz.friction = 0.8
    pDirPhyz.lineardamping = 0.4
    pDirPhyz.angulardamping = 0.4
    pDirPhyz.restitution = 0.5
    -- put "Initialized Physics"
    end
  5. From the cast member window , drag and drop the behavior on to the 3d world placed on the stage ( place the 3d world on the stage if you have not already done so :) )
  6. To create a simple sphere in 3d and make it a rigidbody , use the following code, make a movie script:
  7. on startmovie
    g3d_scene = member("3d_scene")
    BallRes = g3d_scene.newModelResource("sphere", #sphere)
    BallRes.radius = 10
    BallRes.resolution = 6 --create a model out of the resource
    Ball = g3d_scene.newModel("Ball" ,BallRes)
    Ball.addmodifier(#meshdeform)
    --create rigidbodies out of the spheres created above
    physX = member("physX")
    --read the doc/help in Director :)
    rb_ball  = physX.createRigidBody(Ball.name,Ball.name,#sphere,#dynamic)
    rb_ball.mass = 100
    end

That should do it, run the movie and see the ball fall under gravity :). Let us know if this helped…