private Material[] meshMaterials;
private Texture[] meshTextures;
private Mesh mesh = null;
private void LoadMesh(string file)
{
//LOAD X FILE
ExtendedMaterial[] mtrl;
// Load our mesh
mesh = Mesh.FromFile(file, MeshFlags.Managed, device, out mtrl);
// If we have any materials, store them
if ((mtrl != null) && (mtrl.Length > 0))
{
meshMaterials = new Material[mtrl.Length];
meshTextures = new Texture[mtrl.Length];
// Store each material and texture
for (int i = 0; i < mtrl.Length; i++)
{
meshMaterials
if ((mtrl
string.Empty))
{
// We have a texture, try to load it
meshTextures
mtrl
}
}
}
}
The problem is in the Mesh.FromFile line, I get a System Error because of a Null Object Reference. I've debugged to check, and the only thing that's null at that point is mesh. (I ruled out mtrl, because I tried the following two lines also):
mesh = Mesh.FromFile(file, MeshFlags.Managed, device);
mesh = Mesh.Box(device, 2.0f, 2.0f, 2.0f);
Both of them give me the same error as well.
None of the sample code I've seen ever shows mesh being initialized to anything other than null... and the constructor for Mesh takes arguments like the number of vertices, etc.
Any ideas what could be the problem here

problem loading mesh from .X file.
Howard Wilton
Since mesh is on the left hand side you can't get a null object reference becuase of it. Given the other 2 lines also fail I have to suspect that its a problem with the device parameter. You say its not null though which is odd. What do you see if you bring up device in a watch window, can you expend its properties etc
ozhonetech
Rclip
and it has many properties under it, AvailableTextureMemory, ClipPlanes, ClipStatus, Indices, Lights, etc... just to name a few.
Though I just noticed that the Pixel and Vertex Shader properties of the device are null... how do I explicitly tell DirectX to not use these, or will they automatically not be used since they're null
JoshKraker
null in those means that there is no shader, that is correct.
My only guess is that something is not set up properly with the device since Mesh.Box() is failing. But I can't imagine what. Can you post the device creation code you use
You can convince yourself its not the mesh varialbe by just using removing the 'mesh =' from this line. It will not make any sense but the code will compile and run and probably still fail in this line showing that it must be an issue with the device.
mesh = Mesh.Box(device, 2.0f, 2.0f, 2.0f);
becomes
Mesh.Box(device, 2.0f, 2.0f, 2.0f);