Collision Detection with .fbx models
Posted: Tue Jul 13, 2010 7:38 pm
Hi
in the BEPU getting started documentation it shows the following handlecollision method
deleterBox.eventManager.addEventHook(new BEPUphysics.Events.EventHandlerInitialCollisionDetected(handleCollision));
public void handleCollision(Entity sender, Entity other, CollisionPair pair)
{
space.remove(other);
Components.Remove((EntityModel)other.tag); //Remove the graphics too.
}
My question is how would I do this for a .fbx model in stead of an Entity
This is how I load the model:
Model terrain = game.Content.Load<Model>("GYTerrain");
StaticTriangleGroup.getVerticesAndIndicesFromModel(terrain, out staticTriangleVertices, out staticTriangleIndices);
TriangleMesh terrainMesh = new TriangleMesh(staticTriangleVertices, staticTriangleIndices, 0);
StaticTriangleGroup terrainGroup = new StaticTriangleGroup(terrainMesh);
terrainGroup.worldMatrix = Matrix.CreateFromYawPitchRoll((float)Math.PI, 0, 0) * Matrix.CreateTranslation(0, -40, 0);
space.add(terrainGroup);
thanks in advance
in the BEPU getting started documentation it shows the following handlecollision method
deleterBox.eventManager.addEventHook(new BEPUphysics.Events.EventHandlerInitialCollisionDetected(handleCollision));
public void handleCollision(Entity sender, Entity other, CollisionPair pair)
{
space.remove(other);
Components.Remove((EntityModel)other.tag); //Remove the graphics too.
}
My question is how would I do this for a .fbx model in stead of an Entity
This is how I load the model:
Model terrain = game.Content.Load<Model>("GYTerrain");
StaticTriangleGroup.getVerticesAndIndicesFromModel(terrain, out staticTriangleVertices, out staticTriangleIndices);
TriangleMesh terrainMesh = new TriangleMesh(staticTriangleVertices, staticTriangleIndices, 0);
StaticTriangleGroup terrainGroup = new StaticTriangleGroup(terrainMesh);
terrainGroup.worldMatrix = Matrix.CreateFromYawPitchRoll((float)Math.PI, 0, 0) * Matrix.CreateTranslation(0, -40, 0);
space.add(terrainGroup);
thanks in advance