public BodyBox(World hostWorld, Space space, Vector3f position, Vector3f size, Vector3f force) { this.hostWorld = hostWorld; this.space = space; bodyID = Ode.dBodyCreate(hostWorld.getID()); // create a mass object, in this case a box of size 50 x 0.2 x 50 Ode.dMass mass = new Ode.dMass(); //Ode.dMassSetBox(ref mass, 200.0f, radius, radius, radius); Ode.dMassSetBoxTotal(ref mass, 200.0f, size.x, size.y, size.z); // set it's mass to 1000.0f. If this value is too low, // you'll get some wierd collisions //mass.mass = 1000.0f; // set the mass object on the body Ode.dBodySetMass(bodyID, ref mass); // Set the body's position Ode.dBodySetPosition(bodyID, position.x, position.y, position.z); // Set an initial force on the body. This will be // wiped to zero after the first frame. Ode.dBodyAddForce( bodyID, force.x, force.y, force.z ); // create a collion geometry to go with our rigid body. // without this, the rigid body will not collide with anything. geomID = Ode.dCreateBox(space.getSpaceID(), size.x, size.y, size.z); // assign a rigid body to the collision geometry. If we didn't do this, // the object would be a static object much like our ground plane. Ode.dGeomSetBody(geomID, bodyID); this.position = position.copy(); this.rotationOGL = new Color4f(0.0f, 0.0f, 0.0f, 0.0f); }
public Space(World world, IntPtr contactGroup) { this.hostWorld = world; this.contactGroup = contactGroup; spaceID = Ode.dSimpleSpaceCreate(spaceID); }