I got some problem when I wanted to do some work in collision detection. I want to get all the triangle vertexs,but I can not get the right indexbuffer indices. The right array should be: 0 2 1 2 3 1 ...,but what I get is : 131072 131073 65539 ...
Here is the code that relates to my question
meshMaterials = new Material();
meshMaterials.Ambient = System.Drawing.Color.White;
meshMaterials.Diffuse = System.Drawing.Color.White;
ExtendedMaterial[] materials = null;
mesh = Mesh.FromFile(@"C:\Users\Administrator\Documents\Visual Studio 2010\Projects\iR1000\iR1000\fang.x", MeshFlags.SystemMemory, device, out materials);
if (meshTextures == null)
{
meshTextures = new Texture[materials.Length];
meshMaterialsl = new Microsoft.DirectX.Direct3D.Material[materials.Length]; }
for (int i = 0; i < materials.Length; i++)
{
meshMaterialsl[i] = materials[i].Material3D;
meshMaterialsl[i].Ambient = meshMaterialsl[i].Diffuse;
meshTextures[i] = TextureLoader.FromFile(device, @"C:\Users\Administrator\Documents\Visual Studio 2010\Projects\iR1000\iR1000\1533.jpg"+ materials[i].TextureFilename);
}
Mesh mesh1 = mesh.Clone(mesh.Options.Value, VertexFormats.Position | VertexFormats.Normal | VertexFormats.Texture0 | VertexFormats.Texture1, mesh.Device);
using (IndexBuffer ib = mesh1.IndexBuffer)
{
int[] indices2 = (int[])ib.Lock(0, typeof(int), LockFlags.None , mesh1.NumberFaces * 3);
for (int i = 0; i < indices2.Length; i++)
{
button1.Text += Convert.ToString(indices2[i]) + " ";
}
ib.Unlock();
}
Can someone please tell me What am I doing wrong ?
and more importantly for me, how can I make the above work?
Any help would be much appreciated.