; SetPhysicsShapeTag Example ; -------------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() Const PHYSICS_STATIC=0 Const PHYSICS_DYNAMIC=2 Const MAX_CRATES=20 SeedRnd MilliSecs() camera=CreateCamera() PositionEntity camera,0,5,-12 RotateEntity camera,15,0,0 light=CreateLight() RotateEntity light,45,-30,0 AmbientLight 60,60,60 ; An independent Box3D world with standard gravity world=CreatePhysicsWorld() ; Blue static floor ground=CreateCube() ScaleEntity ground,6,0.5,6 PositionEntity ground,0,-0.5,0 EntityColor ground,80,160,255 ground_body=CreatePhysicsBody(world,ground,PHYSICS_STATIC) ground_shape=PhysicsBodyBox(ground_body,12,1,12) ; A static hook, and a lamp that swings from it on a ball joint hook=CreateCube() ScaleEntity hook,0.2,0.2,0.2 PositionEntity hook,0,6,0 hook_body=CreatePhysicsBody(world,hook,PHYSICS_STATIC) hook_shape=PhysicsBodyBox(hook_body,0.4,0.4,0.4) lamp=CreateSphere(12) ScaleMesh lamp,0.4,0.4,0.4 PositionEntity lamp,1.5,4,0 EntityColor lamp,255,230,120 lamp_body=CreatePhysicsBody(world,lamp,PHYSICS_DYNAMIC) bulb_shape=PhysicsBodySphere(lamp_body,0.8) cord=CreatePhysicsBallJoint(hook_body,lamp_body,0,6,0) ; The shade is a second shape on the lamp's body shade=CreateCone(12,True,lamp) ScaleEntity shade,0.6,0.3,0.6 PositionEntity shade,0,0.5,0 shade_shape=PhysicsBodyBox(lamp_body,1.2,0.6,1.2,1,0,0.5,0) Dim crates(MAX_CRATES) Dim crate_bodies(MAX_CRATES) Dim crate_shapes(MAX_CRATES) ; Label the lamp's shapes: 1 for the bulb, 2 for the shade SetPhysicsShapeTag bulb_shape,1 SetPhysicsShapeTag shade_shape,2 While Not KeyDown(1) ; Space drops a crate If KeyHit(57) And count