Ive been using The demo's BEPUphysicsDrawer to draw the majority of my items in my current project most importantly my 3d model terrain
ive also been trying to figure out how the physicsDrawer works, but since it uses so many custom classes and jumps back and forth between InstancedModelDraw to ModelDisplayObjectBase and selfDrawingModel...so on and so forth
my question is What are the key needed components to draw a terrain using the Static Triangle Group Method?
Drawing Static Triangle Groups / Mesh
Re: Drawing Static Triangle Groups / Mesh
The simplest way to do it is to load in a Model and draw it directly. You can see an example in the DisplayModel class.
It basically goes through each mesh in the model, sets up the mesh's BasicEffect, and then tells it to draw.
If you create a StaticTriangleGroup from a Model, the graphics and physics should be aligned as long as the worldTransform you use for each is consistent.
The above is not the fastest or cleanest way to draw things, but it's fairly simple. There's a variety of samples on the XNA site too.
Code: Select all
myModel.CopyAbsoluteBoneTransformsTo(transforms);
for (int i = 0; i < model.Meshes.Count; i++)
{
for (int j = 0; j < model.Meshes[i].Effects.Count; j++)
{
BasicEffect effect = model.Meshes[i].Effects[j] as BasicEffect;
if (effect != null)
{
effect.World = transforms[model.Meshes[i].ParentBone.Index] * worldTransform;
effect.View = viewMatrix;
effect.Projection = projectionMatrix;
}
}
model.Meshes[i].Draw();
}
If you create a StaticTriangleGroup from a Model, the graphics and physics should be aligned as long as the worldTransform you use for each is consistent.
The above is not the fastest or cleanest way to draw things, but it's fairly simple. There's a variety of samples on the XNA site too.