As an addendum to the above sample, here's a couple of things:
Code: Select all
//Create Box Entity
entity = new Box(BEPUphysics.DataStructures.MotionState.DefaultState,3,3,3);
//Set Box properties, here we make the box static. I dunno if theres a better way of doing this though. default entity location will be Vector3.Zero
entity.IsAffectedByGravity = false;
entity.IsActive = false;
If you do not pass a mass into the entity constructor, it is kinematic to begin with. You don't need to worry about setting IsAffectedByGravity or IsActive. IsAffectedByGravity only does something on entities with less than infinite mass (so not kinematic entities). Since the kinematic entity won't move unless specifically told to do so, you also don't n eed to set it to inactive (it will go inactive immediately if appropriate). Setting a
dynamic entity to inactive would also just be temporary- once something new collided with it, it would wake up.
Code: Select all
//Create Sphere Entity and set its properties
sphere = new Sphere(BEPUphysics.DataStructures.MotionState.DefaultState,1,1);
sphere.Mass = 5;
sphere.Bounciness = 0.5f;
sphere.Density = 1.0f;
//Set the Initial Position of the Sphere
sphere.WorldTransform = Matrix.CreateTranslation(new Vector3(0, 10, 0));
Rather than setting the world transform/mass outside of the constructor, you can do that in the constructor. Right now, it sets the sphere's mass to 1, and then immediately afterward sets it to 5. Note that there is a overload of the constructor that takes a position instead of a motionstate as well.
Density is an auxiliary field used to tune things like buoyancy, and setting it will not directly change the mass or volume of an entity. It also has a default value computed by the initial mass and volume of the entity, so you don't have to set it if you don't want to.
If you want another super-duper bare minimum example, this creates a dynamic box above a flat kinematic box and adds them to the space:
Space.Add(new Box(new Vector3(0, 5, 0), 1, 1, 1, 1));
Space.Add(new Box(new Vector3(0, 0, 0), 10, 1, 10));
Please show me simple use only 1 fbx 1 entity movement.
If by fbx you mean having a loaded fbx graphic follow the entity, then you can use the entity's WorldTransform. Whatever way you choose to draw it (e.g. BasicEffect) should have some method to set the world transform of the graphic, which can be the entity.WorldTransform. This is basically a rendering issue; you can check the BasicSetupDemo for a simple approach, but there's a huge number of ways to handle it.
If you mean loading in a static collision mesh that other stuff collides with, then you should use a StaticTriangleGroup. Here's the loading process copied from the PlaygroundDemo in the BEPUphysicsDemos:
Code: Select all
//Load in mesh data and create the group.
StaticTriangleGroup.StaticTriangleGroupVertex[] staticTriangleVertices;
int[] staticTriangleIndices;
var playgroundModel = game.Content.Load<Model>("playground");
//This load method wraps the TriangleMesh.getVerticesAndIndicesFromModel method
//to output vertices of type StaticTriangleGroupVertex instead of TriangleMeshVertex or simply Vector3.
StaticTriangleGroup.GetVerticesAndIndicesFromModel(playgroundModel, out staticTriangleVertices, out staticTriangleIndices);
var mesh = new TriangleMesh(staticTriangleVertices, staticTriangleIndices, 0);
var group = new StaticTriangleGroup(mesh);
Space.Add(group);
Basically, the StaticTriangleGroup is created with a TriangleMesh object. TriangleMesh needs a vertex list and index list- it doesn't care where they come from. In the above, they are created by using the GetVerticesAndIndicesFromModel method. Another option would be setting the vertex and index list up in a content processor.