Textures for 3ds files

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
gustav05
Posts: 10
Joined: Tue Mar 21, 2006 3:19 pm
Location: Germany

Textures for 3ds files

Post by gustav05 »

Hello!

When I try to set a texture for a *.3ds File it doesn`t show me the correct texture, but rather a black/grey color. Here is a code snippet:

Code: Select all

IAnimatedMesh* mesh = smgr->getMesh(Player1.GetMeshPath());
IAnimatedMeshSceneNode* node_mesh = 
  smgr->addAnimatedMeshSceneNode(mesh);
if(node_mesh)
{
  node_mesh->setScale(core::vector3df(15,15,15));
  node_mesh->setMaterialTexture(0,  
    driver->getTexture("../models/steel.bmp"));
  node_mesh->setMaterialFlag(video::EMF_LIGHTING, false);

  }
BTW: Is this right, that you load a 3ds-File with getMesh()?

I hope you can help me.

Thanks.
Yeurl
Posts: 31
Joined: Thu Apr 13, 2006 9:34 am

Post by Yeurl »

Hi gustav05,

i never use irrlicht in c++, but only in c#... i will try to help you lol ^^
IAnimatedMesh* mesh = smgr->getMesh(Player1.GetMeshPath());
you have missing to tel in GetMeshPath the way to have your mesh model

...
exemple

IAnimatedMesh* mesh = smgr->getMesh(Player1.GetMeshPath("c:/MyMeshDirectory/MyMeshWhithExtention"));


try this with too

if (node_mesh)
{
node_mesh->setMaterialFlag(EMF_LIGHTING, false);
node_mesh->setMaterialTexture( 0, driver->getTexture("../models/steel.bmp"));
}


hope that i was usefull to you ;)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, gustav05, you did it correctly. There are several things which might not work here. Check the console output whether the texture was loaded, otherwise adjust the path.
If the model stays white you might have forgot to UV map your model. You need a proper 3d tool for this purpose. Adding a texture later on is also not a good idea because 3ds supports textures from within the format. So texture your model correctly and just load the model. Everything else will work.
If you also want vertex colors (no textures) you need the 3ds patch.
gustav05
Posts: 10
Joined: Tue Mar 21, 2006 3:19 pm
Location: Germany

Post by gustav05 »

I don`t know, but when you create a UV-Map to the model then it place the texture right on the model.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, but if you did so you do not need to add the texture manually. It is loaded automatically by the 3ds loader. You just need to put it into the right location (best would be to use the same directory as the 3ds model). But just check the console log, it will have some important messages for you.
gustav05
Posts: 10
Joined: Tue Mar 21, 2006 3:19 pm
Location: Germany

Post by gustav05 »

Ok, I added the texture manually, because I didn`t know how to call the 3ds loader. Is it not with getMesh()?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, just use getMesh("mesh.3ds") and everything happens automatically (ok, the other code of your example is required as well, except for the manually applied texture). If it does not work maybe upload your model or send it to me directly. But please: Check the console log and find whether the texture is loaded or not.
gustav05
Posts: 10
Joined: Tue Mar 21, 2006 3:19 pm
Location: Germany

Post by gustav05 »

Thank you for your help.

Now I got it. The name of the texture that belongs to the 3ds-Objekt was not correct. I renamed it and then Irrlicht could load the texture.
Post Reply