No texture when loading a mesh

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
MisterRose
Posts: 18
Joined: Thu Jun 16, 2011 2:46 pm

No texture when loading a mesh

Post by MisterRose »

Disclaimer - I am new to 3D programming, but I have been doing embedded software for about 15 years. Please forgive me if this is a trivial problem.

I am trying to use objects from various files (mainly Maya obj and 3DS) .

I do not see any errors logged to the console when I load the mesh. So far I have only been able to get 1 model to work. All the others have problems with the textures. Some will have no textures applied, some will have a few of the textures partially covering the model.

Granted, these are the free downloads that I get from places like TurboSquid, so the quality of these models may be questionable.

I am using the following code...

Code: Select all

        mesh = smgr->getMesh(filename);
        if( mesh )
        {
                node = smgr->addAnimatedMeshSceneNode( mesh );
                if (node)
                {
                        // Basic initialization is good enough to render on the screen.
                        node->setMaterialFlag(EMF_LIGHTING, false );
                        node->setCurrentFrame(0);
                        init = true;
                } else {
                        init = false;
                }
        }
Is there a problem with my code, or is there a problem with the model?

The one model that I could get to work was a 3DS file that had all the textures in the same directory as the 3DS file. Many of the other models have their textures in a subdirectory structure. I also see that some of the tutorial examples specifically load the texture onto the object, but others do not. How do I know when I need extra code to load the textures?

Thanks in advance
You are unique - just like everyone else.
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: No texture when loading a mesh

Post by Radikalizm »

I'm not sure, but I believe obj material files store their texture paths as relative paths which might cause some issues with loading them
If that's not the case then I wouldn't have a clue what the problem is
CarlS
Posts: 86
Joined: Wed May 09, 2007 1:21 am
Contact:

Re: No texture when loading a mesh

Post by CarlS »

The texture path for a .obj file should be specified in the .mtl file which usually sits in the same folder as the .obj file.
If that doesn't work, check the path to the .mtl specified inside the .obj file. You can open the .obj file in a text editor, but you may need to temporarily rename the extension first so the text editor doesn't think the .obj file is binary.

--Carl
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: No texture when loading a mesh

Post by CuteAlien »

You have some more possibilities. The easiest is to add the path in which your textures are as search-path like example 09 does it:

Code: Select all

 
Device->getFileSystem()->addFileArchive("../../media/");
 
Just try that first (you can also just set path's for .obj textures, but I'd have to look that up first).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: No texture when loading a mesh

Post by christianclavet »

Also check that your model does not contain any procedural texture. Everything in your model must be UV mapped with image based textures to work correctly.
Jake007
Posts: 16
Joined: Wed Jun 29, 2011 8:39 pm
Location: Slovenia

Re: No texture when loading a mesh

Post by Jake007 »

In my experience ( based on Blender where there is a little more trouble), you still have to put image over your model ( like in tutorial 1).

Code: Select all

node->setMaterialTexture( 0, driver->getTexture("image.something") );
Also make sure, that your models are properly unwrapped as christianclavet already said, and that you have correctly configured materials and textures in your 3D editing program.

Regards,
Jake
Post Reply