예제 #1
0
 BepuEntity fireBall()
 {
     BepuEntity ball = new BepuEntity();
     ball.modelName = "sphere";
     float size = 1;
     ball.localTransform = Matrix.CreateScale(new Vector3(size, size, size));
     ball.body = new Sphere(Camera.Position + (Camera.Look * 8), size, size * 10);
     ball.diffuse = new Vector3((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble());
     space.Add(ball.body);
     ball.LoadContent();
     ball.configureEvents();
     ball.body.ApplyImpulse(Camera.Position, Camera.Look * 500);
     children.Add(ball);
     return ball;
 }
예제 #2
0
 BepuEntity createFromMesh(Vector3 position, string mesh, float scale)
 {
     BepuEntity entity = new BepuEntity();
     entity.modelName = mesh;
     entity.LoadContent();
     Vector3[] vertices;
     int[] indices;
     TriangleMesh.GetVerticesAndIndicesFromModel(entity.model, out vertices, out indices);
     AffineTransform localTransform = new AffineTransform(new Vector3(scale, scale, scale), Quaternion.Identity, new Vector3(0, 0, 0));
     MobileMesh mobileMesh = new MobileMesh(vertices, indices, localTransform, BEPUphysics.CollisionShapes.MobileMeshSolidity.Counterclockwise, 1);
     entity.localTransform = Matrix.CreateScale(scale, scale, scale);
     entity.body = mobileMesh;
     entity.HasColor = true;
     entity.diffuse = new Vector3((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble());
     entity.body.Position = position;
     space.Add(entity.body);
     children.Add(entity);
     return entity;
 }
예제 #3
0
 BepuEntity createWheel(Vector3 position, float wheelWidth, float wheelRadius)
 {
     BepuEntity wheelEntity = new BepuEntity();
     wheelEntity.modelName = "cyl";
     wheelEntity.LoadContent();
     wheelEntity.body = new Cylinder(position, wheelWidth, wheelRadius, wheelRadius);
     wheelEntity.localTransform = Matrix.CreateScale(wheelRadius, wheelWidth, wheelRadius);
     wheelEntity.body.Orientation = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.PiOver2);
     wheelEntity.diffuse = new Vector3((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble());
     space.Add(wheelEntity.body);
     children.Add(wheelEntity);
     return wheelEntity;
 }
예제 #4
0
 public BepuEntity createBox(Vector3 position, float width, float height, float length)
 {
     BepuEntity theBox = new BepuEntity();
     theBox.modelName = "cube";
     theBox.LoadContent();
     theBox.localTransform = Matrix.CreateScale(new Vector3(width, height, length));
     theBox.body = new Box(position, width, height, length, 1);
     theBox.diffuse = new Vector3((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble());
     theBox.configureEvents();
     space.Add(theBox.body);
     children.Add(theBox);
     return theBox;
 }