Page 1 of 1

Applying Texture to a Custom Scene Node

Posted: Sat Jan 12, 2008 9:22 am
by z4rd0z
Hi all,

I have a problem applying a simple texture to a custom scene node with irrlicht 1.4. I do not have this problem with Irrlicht 1.3.1. I use the OpenGL renderer under Linux.

How to get the problem:

* Add the "setMaterialTexture" line to the 03.CustomSceneNode irrlicht 1.4 tutorial:

Code: Select all

	// createRotationAnimator() could return 0, so should be checked
	if(anim)
	{
		myNode->addAnimator(anim);
		// I'm done referring to anim, so must drop this reference now because it
		// was produced by a createFoo() function.
		anim->drop();
		anim = 0; // As I shouldn't refer to it again, ensure that I can't
	}

        // This is the line to add (set diffuse texture)
	myNode->setMaterialTexture(0, driver->getTexture("../../media/012shot.jpg")); 

	// I'm done with my CSampleSceneNode object, and so must drop my reference
	myNode->drop();
	myNode = 0; // As I shouldn't refer to it again, ensure that I can't
* Build the sample and run it: the texture is not applied.

* Adding a myNode->setMaterialType(video::EMT_SOLID); line does not help.

* If I build/link the same code against irrLicht 1.3.1 the tetraeder is totally textured


So I suspect that I have to do something different in irrLicht 1.4 to get the same effect.

Can someone help me ?

Thanks in advance.

Posted: Sat Jan 12, 2008 10:42 am
by hybrid
No, the example has a bug. Simply make the getMateriaCount method const.

Posted: Sat Jan 12, 2008 1:50 pm
by z4rd0z
Ah yes, thanks for your prompt answer.

I just read the changes.txt file and I saw that I have to change some method signatures in my code to make a right usage of const. It explains why my project did not work anymore after irrlicht update.

Thanks again !