Ok, im trying to disply the bounding box around my character in directX 9 and c#.
After I load the mesh I use this method to to get the bounding box:
public void CalculateBoundingBox()
{
flag = mesh.Options.Use32Bit ? MeshFlags.Use32Bit : 0;
vBuffer = mesh.VertexBuffer;
Vector3 max = new Vector3();
Vector3 min = new Vector3();
//lock vBuffer
GraphicsStream vertexData = vBuffer.Lock(0,0,LockFlags.NoSystemLock);
Geometry.ComputeBoundingBox(vertexData,mesh.NumberVertices,mesh.VertexFormat,out min,out max);
vBuffer.Unlock();
vBuffer.Dispose();
float maxX = max.X;
float maxY = max.Y;
float maxZ = max.Z;
float minX = min.X;
float minY = min.Y;
float minZ = min.Z;
objectBounds[0] = new Vector3(min.X,min.Y,min.Z);
objectBounds[1] = new Vector3(max.X,min.Y,min.Z);
objectBounds[2] = new Vector3(min.X,max.Y,min.Z);
objectBounds[3] = new Vector3(max.X,max.Y,min.Z);
objectBounds[4] = new Vector3(min.X,min.Y,max.Z);
objectBounds[5] = new Vector3(max.X,min.Y,max.Z);
objectBounds[6] = new Vector3(min.X,max.Y,max.Z);
objectBounds[7] = new Vector3(max.X,max.Y,min.Z);
for(int i = 0; i <=7; i++)
{
worldBounds = Vector3.TransformCoordinate(objectBounds,device.Transform.World);
}
for(int i = 0;i<8;i++)
{
verts.X = worldBounds.X;
verts.Y = worldBounds.Y;
verts.Z = worldBounds.Z;
verts.Color = Color.Black.ToArgb();
}
}
in the onPaint method, I use these lines to draw the bounding box around my character,
device.SetStreamSource(0,vb,0);
device.VertexFormat = CustomVertex.TransformedColored.Format;
device.DrawPrimitives(PrimitiveType.TriangleList,0,12);
but the problem Is that although the character is drawn to screen, the bounding box isn’t. any ideas why?
I currently only use c# and directX9, in case its relivant and i didnt mention it in the post