Jump to content
  • Advertisement
Sign in to follow this  
danne89

MeshView gets a textured object, but I don't

This topic is 5039 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
This means you're not loading or setting the textures correctly when you load/render it.

Share this post


Link to post
Share on other sites
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
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 = em.Material3D;
if (em.TextureFilename != null && em.TextureFilename != string.Empty)
this.textures = TextureLoader.FromFile(device,
@"..\..\" + em.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;
this.device.SetTexture(0, this.textures);
mesh.DrawSubset(i);
}
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!