How To Texture An IAnimatedSceneNode .obj file

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
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

How To Texture An IAnimatedSceneNode .obj file

Post by kklouzal »

Hello, I am trying to load an .obj file as an IAnimatedSceneNode; I'm able to get the .obj model loaded into the level but it has no texture, there is a .mtl file provided with the model which I am assuming is the texture but when I apply it to the model it's still textureless.

Can someone please enlighten me as to what's going on here?

Code: Select all

IAnimatedMesh* gunmesh = smgr->getMesh("./Media/M41-A Pulse Rifle.obj");
    IAnimatedMeshSceneNode* gunnode = smgr->addAnimatedMeshSceneNode(gunmesh);
    gunnode->setPosition(vector3df(50,50,-60));
    gunnode->setMaterialFlag(EMF_LIGHTING, false);
I may not even be loading it properly.

Here is the model i'm using if that helps anyone.
http://thefree3dmodels.com/stuff/weapon ... 18-1-0-523

Thank you all for your continued help.
Dream Big Or Go Home.
Help Me Help You.
ACE247
Posts: 704
Joined: Tue Mar 16, 2010 12:31 am

Re: How To Texture An IAnimatedSceneNode .obj file

Post by ACE247 »

You cannot apply an mtl as a texture. The .mtl is just a text-based material descriptor file that automatically links to the obj. Look inside of it and see if you can find the texture path it specifies. If you did you would realise It doesn't specify any texture path nor does the model have any uv's assigned. The models geometry itself is quite messy and will need cleaning up first. Try opening it up in Blender or some other Mesh Editor.
Also .obj files generally hold no Animation data, so unless you're going to manually animate the mesh in code, there is no need to use an IAnimtedMeshSceneNode.
This instead would be better in that case:

Code: Select all

 
IMesh* gunmesh = smgr->getMesh("./Media/M41-A Pulse Rifle.obj");
 
IMeshSceneNode* gunnode = smgr->addMeshSceneNode(gunmesh);
 
Last edited by ACE247 on Fri Nov 16, 2012 8:26 am, edited 1 time in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: How To Texture An IAnimatedSceneNode .obj file

Post by hybrid »

You load it correctly, and I assume that you also see the model, just not textures. The mtl file does not contain any texture information, only basic shading settings. There is no texture anyway, besides the ammunition counter on the side. The rest of the model is meant to be colored by the light materials. Which means that you have to enable lighting to get the proper colors, as the .obj loader does not copy the vertex color IIRC. This model is not usable for any gameplay, anyway, as it seems to be not just high, but max poly. The file has about 5MB of data, and it's just a gun.
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Re: How To Texture An IAnimatedSceneNode .obj file

Post by kklouzal »

Thank you all for your replies!

Yes, I went with another model that had an included texture file and left the post to make sure my code was correct, on a side note, does anyone know of a good site for free model resources?
Dream Big Or Go Home.
Help Me Help You.
ACE247
Posts: 704
Joined: Tue Mar 16, 2010 12:31 am

Re: How To Texture An IAnimatedSceneNode .obj file

Post by ACE247 »

Google 3D Warehouse, Blendswap, and many others :)
MynithiX
Posts: 26
Joined: Thu Oct 11, 2012 4:06 pm
Location: Germany

Re: How To Texture An IAnimatedSceneNode .obj file

Post by MynithiX »

I don't know which program you use to make the model, but you must make an UV Map. I think there are alot of tutorials around the www :D
After exporting it to .obj, look into the mtl file with a normal texteditor, and write in the path to the texture with the UV Map.
Then just load it, and it must work :)
Hope this helps ( when you didn't find the solution already)
MynithiX
Two things are infinite: the stupidity of the humans and universe. I'm just not sure if the universe is really infinite!
YOLO
Post Reply