v0.6: ODE physics!
April 9th, 2007Hi,
here is another update to the Irrlicht Xtra, v0.6, 807Kb in size, and now with the ODE physics engine on board.
Grab the new Xtra, toss it into the Xtras folder of your Director installation, and run the demo movie (make sure you got the media folder right next to it).
Enjoy!
Added methods:
- createPhysics() — initializes the physics engine
- shutdownPhysics() — shuts down the physics engine
- addBody(TYPE, position, rotation, size, density) — adds a model TYPE to the physics simulation - TYPE can be #sphere,#box, #cylinder, #capsule, #character_avatar (for fps cameras) - position. rotation and size are optional vectors, density an optional float describing the mass of the object
- setWorld(TriangleSelection)
- getWorld() — returns the triangleselection which makes up the physics world
- updateWorld() — updates only a segment of the physics world
- collidesRayWithWorld(from,to) — from, to = vectors, returns true or false if a physics world segment is hit
- getBody(idx) — idx is a number>0 and idx
- removeBody(idx) — removes the body from the physics engine
- setSimulationHz() — sets the speed of the simulation
- getSimulationHz() — gets the speed of the physics simulation, default is 60
- getType() — returns name of physics engine, now only #ODE
- createPhysicsAvatarAnimator() — ties a fps cam to a physics object so that you can interact with the 3d world
Here is code on how to initialize the physics engine:
wrld=sprite(1).member
cam=wrld.newCamera(”mycam”,#fps)
cam.setPosition(10,50,10)mdl=sprite(1).quakeMap — just fetching the model from the sprite, nothing 3d here…
mesh=sprite(1).quakeMesh — same here, but for the mesh
— just fetched the model and mesh of the map so that it can be submitted to the triangle selectortriangleSelector=wrld.createTriangleSelector(mesh, mdl)
— got the triangle selector, now doing the assignmentwrld.createPhysics() — create the physics engine
wrld.setWorld(triangleSelector) — submit the quake mesh triangle selector to the engine
wrld.createPhysicsAvatarAnimator(cam,4,2, vector(10,10,75)) — creates a fps cam tied to a physics object with eyeheight 4, density 2 and size vector(10,10,75)


