public Particle createParticle(Vector3f emitterPosition, bool emitterUseDirection, Vector3f emitterDirection) { Color4f color = new Color4f((maximumColor.a - minimalColor.a) * random.NextDouble() + minimalColor.a, (maximumColor.r - minimalColor.r) * random.NextDouble() + minimalColor.r, (maximumColor.g - minimalColor.g) * random.NextDouble() + minimalColor.g, (maximumColor.b - minimalColor.b) * random.NextDouble() + minimalColor.b); Vector3f velocity = new Vector3f((maximumInitialVelocity.x - minimalInitialVelocity.x) * random.NextDouble(), (maximumInitialVelocity.y - minimalInitialVelocity.y) * random.NextDouble(), (maximumInitialVelocity.z - minimalInitialVelocity.z) * random.NextDouble()); velocity.add(minimalInitialVelocity); float particleLife = minimalParticleLife; float t = (maximumParticleLife - minimalParticleLife); particleLife += t * (float)random.NextDouble(); return new BillboardedParticle(emitterPosition.copy(), velocity, gravity, color, particleLife, size); }
public Vector3f computeTrajectory(Vector3f vector) { float len = vector.length(); Vector3f newTrajectory = vector.copy(); float projection = (vector * normal) / (normal * normal); Vector3f u = normal * projection; newTrajectory.subtract(u).subtract(u); newTrajectory.stretch(friction); //Console.Out.WriteLine("Got: " + vector.ToString() + " computed: " + newTrajectory.ToString()); return newTrajectory; }
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); }