MobileMesh Model anomaly
Posted: Sun Nov 03, 2013 10:14 pm
Hi I have a problem with a model I have been using as it seems to be missing some of the mesh when I draw it to the game window. The model on the right is drawn as you would normally, while the model on the left that is missing part of the mesh is drawn using Bepu's MobileMesh.
Has anyone seen this before? or can anyone suggest a way to resolve it.

Code to draw Ship missing mesh parts
Draw Method
Method to draw mesh plus graphic
Has anyone seen this before? or can anyone suggest a way to resolve it.


Code to draw Ship missing mesh parts
Code: Select all
//==============================Player Ship=============================================
Vector3[] ShipVertices;
int[] ShipIndices;
//Create a big hollow sphere (squished into an ellipsoid).
TriangleMesh.GetVerticesAndIndicesFromModel(Content.Load<Model>("Models/Ship"), out ShipVertices, out ShipIndices);
var transform = new AffineTransform(new Vector3(.0005f, .0005f, .0005f), Quaternion.Identity, new Vector3(0, 0, 0));
//Note that meshes can also be made solid (MobileMeshSolidity.Solid). This gives meshes a solid collidable volume, instead of just
//being thin shells. However, enabling solidity is more expensive.
shipMesh = new MobileMesh(ShipVertices, ShipIndices, transform, MobileMeshSolidity.Counterclockwise);
shipMesh.Position = new Vector3(1, 0, 0);
space.Add(shipMesh);
//ModelDrawer.Add(shipMesh);
//========================================================================================
Code: Select all
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
//RasterizerState rasterizerState = new RasterizerState();
//rasterizerState.FillMode = FillMode.WireFrame;
//GraphicsDevice.RasterizerState = rasterizerState;
// TODO: Add your drawing code here
DrawModels(shipModel, Matrix.CreateScale(0.0005f));
DrawMobileModels(shipModel, shipMesh);
//ModelDrawer.Draw(Camera.ViewMatrix, Camera.ProjectionMatrix);
base.Draw(gameTime);
}
Code: Select all
void DrawMobileModels(Model M, MobileMesh MM)
{
Matrix a = M.Bones[0].Transform;//note that model contents a single mesh
a *= Matrix.CreateFromQuaternion(MM.Orientation) * Matrix.CreateScale(0.0005f);
a.Translation = MM.Position;
BasicEffect B = M.Meshes[0].Effects[0] as BasicEffect;
B.Projection = Camera.ProjectionMatrix;
B.View = Camera.ViewMatrix;
B.World = a;
M.Meshes[0].Draw();
}