Sign in to follow this  
danne89

MeshView gets a textured object, but I don't

Recommended Posts

danne89    133
Hi all (again), I'm trying to render a mesh, which is loaded from a .x-file. The problem is that I got none texture information at all, but the DirectX SDK's MeshView got it! How come? I'm really confused about this, guys and need help. PS. I'm using managed DirectX if that matter and I'm using the methods in Tom Miller's "Managed DirectX"-book. // Daniel

Share this post


Link to post
Share on other sites
danne89    133
Ok. If that the case, let's be a little more technical then. I do something like this:

Mesh tempMesh = Mesh.FromFile(file, MeshFlags.Managed, device, out mtrl);

All entries in mtrl's members's TextureFilename is null. =(

Share this post


Link to post
Share on other sites
danne89    133
Hmm. Here you have some more code if it's requiered.

public Ship(Device device)
{
this.device = device;

ExtendedMaterial[] em;

mesh = Mesh.FromFile(path, MeshFlags.Managed, device, out em);

if (em != null && em.Length > 0)
{
materials = new Material[em.Length];
textures = new Texture[em.Length];
for (int i = 0; i < em.Length; i++)
{
this.materials[i] = em[i].Material3D;
if (em[i].TextureFilename != null && em[i].TextureFilename != string.Empty)
this.textures[i] = TextureLoader.FromFile(device,
@"..\..\" + em[i].TextureFilename);
}
}
}

public void Draw(float yaw, float pitch, float roll, Vector3 pos)
{
this.device.Transform.World = Matrix.RotationYawPitchRoll(yaw, pitch, roll);
this.device.Transform.World *= Matrix.Translation(pos);
for (int i = 0; i < materials.Length; i++)
{
this.device.Material = this.materials[i];
this.device.SetTexture(0, this.textures[i]);
mesh.DrawSubset(i);
}
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this