Im loading in a couple of .x models with a single texture each and it looks as expected with lighting flag off. I then add a point light to the scene and turn lighting on. this gives me a number of strange reactions. depending on which ones of the models I flag on, and in what order, either all models lose their texture and show as lighted whites, or some seemingly random models gets their nicely shaded textures. (not all though or I wouldnt be posting)
it feels like Im missing out on something fairly basic here, so any help is greatly appreciated. I isolated the problem in the code below, it should be runnable.
Code: Select all
#include <windows.h>
#include <irrlicht.h>
using namespace irr;
using namespace core;
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShw )
{
IrrlichtDevice *device = createDevice( video::EDT_OPENGL,dimension2d<s32>(800, 600), 16, false, false, false, 0);
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* guienv = device->getGUIEnvironment();
scene::IAnimatedMesh* model1 = smgr-> getMesh("model1.x");
scene::ISceneNode* model1Node = smgr->addAnimatedMeshSceneNode(model1);
scene::IAnimatedMesh* model2 = smgr-> getMesh("model2.x");
scene::ISceneNode* model2Node = smgr->addAnimatedMeshSceneNode(model2);
scene::IAnimatedMesh* model3 = smgr-> getMesh("model3.x");
scene::ISceneNode* model3Node = smgr->addAnimatedMeshSceneNode(model3);
model1Node->setMaterialFlag(video::EMF_LIGHTING, true);
model2Node->setMaterialFlag(video::EMF_LIGHTING, true);
model3Node->setMaterialFlag(video::EMF_LIGHTING, true);
scene::ILightSceneNode* light1 = smgr->addLightSceneNode(0, vector3df(0.0f,100.0f,0.0f), video::SColorf(1.0f,1.0f,1.0f),150.0f,-1);
smgr->addCameraSceneNodeFPS(0, 100.0f,500.0f,-1,0,0,false);
while( device->run() )
{
driver->beginScene(true, true, video::SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
device->drop();
return 0;
}