Skip to main content
GameDev.net gamedev.net
🔒 Locked

[MDX] LoadFromFile -Mesh- Problem!?

Started by XeeRox Apr 24, 2006 at 8:01 PM 1 replies 550+ views
Original Post
XeeRox
XeeRox
Hi everyone! I am seeking one problem right now && it is about Loading .X models from files. PS.I just borrow Tom Miller's book "MDX kick start: G & G programming", and i must say it is one of the best i had ever.It is true that it is a bit too old(some codes wont work), but then head to the Z-Buffer and download August2005 Source, and everything work perfectly The problem is, somewhat with textures...Here is a source: =============================================================================================== //Load Mesh <- located in InitializeGraphics LoadMesh(@"C:\Program Files\Microsoft DirectX SDK\Samples\Media\Tiny\tiny.x"); =============================================================================================== And the rest a.k.a Full LoadMesh Class =============================================================================================== private void LoadMesh(string 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 = mtrl.Material3D; if ((mtrl.TextureFilename != null) && (mtrl.TextureFilename != string.Empty)) { // We have a texture, try to load it meshTextures = TextureLoader.FromFile(device, @"..\..\" + mtrl.TextureFilename); } } } } =============================================================================================== I get an error at this line: meshTextures = TextureLoader.FromFile(device, @"..\..\" + mtrl.TextureFilename); Error message: Invalid DataException Any ideas guys?!
u235
u235
My bet is that the textures aren't in the right directory. Try putting the textures associated with the model in the same directory as the model. Hope that helps.

-AJ
V/R,-AJThere are 10 kinds of people in the world: Those who understand binary and those who don't...
XeeRox
XeeRox
Nevermind guys, i managed it to works!

Textures were not a problem at all :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.