Mixing Textured and Untextured SceneNodes

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
Bl00drav3n
Posts: 48
Joined: Sun Apr 22, 2012 11:55 pm
Location: Vienna
Contact:

Mixing Textured and Untextured SceneNodes

Post by Bl00drav3n »

I made myself familiar with the basics of the Irrlicht engine already but I ran into an issue with texturing. If I try the following code:

Code: Select all

scene::ISceneNode* node = scenemgr->addCubeSceneNode(10.0);
if(node) {
    node->setPosition(core::vector3df(0.f, 0.f, 0.f));
    node->setMaterialFlag(video::EMF_LIGHTING, false);
    node->setMaterialTexture(0, driver->getTexture("data/textures/terrain/test.png"));
}
it looks like this:
http://www.imagebanana.com/view/o4ykqpm8/1.jpg
so everything fine on this. But if I activate the rendering of the cube's bounding box, I end up with this:
http://www.imagebanana.com/view/55kkjt47/2.jpg

In addition to that, every other mesh with the same texture as "node" will be rendered black. I actually ran into this issue when I tried to implement an own Terrain-class. At that time I was rendering the terrain and 2 spheres above it. Everything went fine until i assigned a texture to the terrain - suddenly it was rendered all black. I couldn't find the real cause of this issue - it seems to happen if untextured primitives overlapp textured primitves, but it's also texturefile-dependent somehow. If I change the texture to a black and white .png with the same fileattributes, the error disappears.

Btw, I am using Irrlicht Version 1.7.3 on Windows 7 with mingw-gcc and the OpenGL renderer 3.3.11554 with an AMD Radeon HD 4870.

Anyone got an idea what's going wrong?
Last edited by Bl00drav3n on Mon Apr 23, 2012 1:05 pm, edited 1 time in total.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Mixing Textured and Untextured SceneNodes

Post by CuteAlien »

Bl00drav3n wrote: so everything fine on this. But if I activate the rendering of the cube's bounding box, I end up with this:
http://www.imagebanana.com/view/55kkjt47/2.jpg
Can you please paste the exact lines you use to do that?
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
Bl00drav3n
Posts: 48
Joined: Sun Apr 22, 2012 11:55 pm
Location: Vienna
Contact:

Re: Mixing Textured and Untextured SceneNodes

Post by Bl00drav3n »

CuteAlien wrote:Can you please paste the exact lines you use to do that?
Sure - I just recognized, I pasted the wrong code sample, stupid me. -.-

Code: Select all

scene::ISceneNode* node = scenemgr->addCubeSceneNode(10.0);
if(node) {
    node->setPosition(core::vector3df(0.f, 0.f, 0.f));
    node->setMaterialFlag(video::EMF_LIGHTING, false);
    node->setMaterialTexture(0, driver->getTexture("data/textures/terrain/test.png"));
    node->setDebugDataVisible(scene::EDS_BBOX);
}
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Mixing Textured and Untextured SceneNodes

Post by hybrid »

Make sure you try the texturing with power-of-two textures. Sometimes an undefined texture (due to wrong texture sizes) can show up all black.
Bl00drav3n
Posts: 48
Joined: Sun Apr 22, 2012 11:55 pm
Location: Vienna
Contact:

Re: Mixing Textured and Untextured SceneNodes

Post by Bl00drav3n »

All textures I tried out had dimensions 64x64. Maybe there is a problem with the .png file format?

I wrote some code to let the scenemanager draw the bounding box when I select the node with the mouse. At program start the cube gets rendered normally with the texture on it. But as soon as I select it and the bounding box gets drawn, the cube will be rendered black, regardless of the bounding box getting drawn or not.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Mixing Textured and Untextured SceneNodes

Post by CuteAlien »

Sorry for taking this long, never found time for this. Unfortunately I can't reproduce it - maybe check if the following code also fails on your system (just replace the code of one of the examples with it for testing, then you can just run it using of the example project files).

Code: Select all

 
#include <irrlicht.h>
#include "driverChoice.h"
 
using namespace irr;
 
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif
 
int main()
{
        video::E_DRIVER_TYPE driverType=driverChoiceConsole();
        if (driverType==video::EDT_COUNT)
                return 1;
 
        IrrlichtDevice *device = createDevice(driverType, core::dimension2d<u32>(640, 480));
        if (!device)
                return 1;
 
        video::IVideoDriver* driver = device->getVideoDriver();
        scene::ISceneManager* smgr = device->getSceneManager();
        scene::ISceneNode* node = smgr->addCubeSceneNode(10.0);
        if(node)
        {
                node->setPosition(core::vector3df(0.f, 0.f, 0.f));
                node->setMaterialFlag(video::EMF_LIGHTING, false);
                node->setMaterialTexture(0, driver->getTexture("../../media/irrlichtlogo2.png"));
                node->setDebugDataVisible(scene::EDS_BBOX);
        }
 
        scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();
        camera->setPosition(core::vector3df(50,100,50));
        camera->updateAbsolutePosition();
        camera->setTarget(core::vector3df(0,0,0));
 
        while(device->run())
        {
                if (device->isWindowActive())
                {
                        driver->beginScene(true, true, irr::video::SColor(255,0, 0, 127) );
                        smgr->drawAll();
                        driver->endScene();
                }
        }
 
        device->drop();
 
        return 0;
}
 
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
Bl00drav3n
Posts: 48
Joined: Sun Apr 22, 2012 11:55 pm
Location: Vienna
Contact:

Re: Mixing Textured and Untextured SceneNodes

Post by Bl00drav3n »

Hm, no problem with that I guess. Sadly I lost the code that produced that error, so I can't reproduce it neither. Maybe I had some strange material settings applied to the box or the graphics drivers had a bug (changed my graphics card from Radeon HD 4870 to Radeon HD 6950 today).
But thanks, I think we can close this thread.
Post Reply