Page 1 of 2
Dynamic lights issue (a small one) [SOLVED]
Posted: Thu May 25, 2006 8:21 am
by Lovehina
I have a small issue with dynamic lighting in IRRLicht. I have a simple scene with three dynamic lights of different colors. I also have there a simple animated mesh of a cube spinning.
Now the cube is properly lighted by those dynamic lights, but as it spins, the lightning doesn't get "updated", instead the cube is still lighted as though it was standing still.
To explain it further, the side of the cube that was facing the red light is still red, no mater which way it spins.
The model was exported from 3DSMAX to .X file format.
Thanks for answering in advance...!
Posted: Fri May 26, 2006 3:30 pm
by Lovehina
Anyone...? Come on people.
Posted: Fri May 26, 2006 4:36 pm
by vitek
Either one of two things is happening...
- the light scene nodes are children to the cube, so they rotate/translate with it
- the cube and lights are not moving, and the camera is moving around them.
This works just fine for me.
Code: Select all
#include <irrlicht.h>
#pragma comment(lib, "Irrlicht.lib")
using namespace irr;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == EET_LOG_TEXT_EVENT)
{
fprintf(stderr, "%u: %s\n", event.LogEvent.Level, event.LogEvent.Text);
return true;
}
return false;
}
};
int main()
{
// select driver
video::E_DRIVER_TYPE driverType = video::EDT_DIRECT3D8;
// create device and exit if creation failed
MyEventReceiver receiver;
IrrlichtDevice* device = createDevice(driverType, core::dimension2d<s32>(800, 600),
16, false, false, false, &receiver);
if (device == 0)
return 1; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
gui::IGUIEnvironment* env = device->getGUIEnvironment();
scene::ISceneManager* smgr = device->getSceneManager();
// add a camera scene node
smgr->addCameraSceneNodeMaya();
// add cube
scene::ISceneNode* cube = smgr->addTestSceneNode(10);
cube->setMaterialFlag(video::EMF_LIGHTING, true);
// make the cube spin
scene::ISceneNodeAnimator* spin = smgr->createRotationAnimator(core::vector3df(1.f, 1.f, 1.f));
cube->addAnimator(spin);
spin->drop();
// add lights with billboards so we can visualize them
scene::ISceneNode* light, *bill;
light = smgr->addLightSceneNode(0, core::vector3df(20.f, 0.f, 0.f), video::SColorf(1.f, 0.f, 0.f));
bill = smgr->addBillboardSceneNode(light);
bill->setMaterialTexture(0, driver->getTexture("../../media/particlered.bmp"));
bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
light = smgr->addLightSceneNode(0, core::vector3df(0.f, 20.f, 0.f), video::SColorf(1.f, 1.f, 1.f));
bill = smgr->addBillboardSceneNode(light);
bill->setMaterialTexture(0, driver->getTexture("../../media/particlewhite.bmp"));
bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
light = smgr->addLightSceneNode(0, core::vector3df(0.f, 0.f, 20.f), video::SColorf(3.f, 0.f, 3.f));
bill = smgr->addBillboardSceneNode(light);
bill->setMaterialTexture(0, driver->getTexture("../../media/portal4.bmp"));
bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
// add the irrlicht engine logo
env->addImage(driver->getTexture("../../media/irrlichtlogoaligned.jpg"), core::position2d<s32>(10, 10));
// draw everything
while(device->run() && driver)
{
if (driver->beginScene(true, true, video::SColor(150,50,50,50)))
{
// render the 3d scene
smgr->drawAll();
// render the 2d ui
env->drawAll();
// rendering finished
driver->endScene();
}
}
// free all irrlicht stuff
device->drop();
return 0;
}
Travis
Posted: Fri May 26, 2006 9:16 pm
by Lovehina
OMG! I'm so sorry for this, I forgot the key thing here...! I forgot to write that the animation was exported from 3DSMAX, its not a programmed or built in animation. I cant believe I forgot to mention the most important thing...
If I manually rotate the cube with the keyboard, the lightning is correctly updated.
This issue happens only if the animation is exported from 3DSMAX, and it happens both with bones and regular animation (like position, rotation and scale). It also happens both in OpenGL and Direct3D8/9.
I apologize again for this missunderstaning...
![Crying or Very sad :cry:](./images/smilies/icon_cry.gif)
Posted: Fri May 26, 2006 10:19 pm
by vitek
You actually mentioned that in your original post. I'm convinced that it is not an issue. Once the vertex data is loaded from the file, it is all treated the same. If you can link to a sample mesh that shows the problem, I'd be glad to help.
Travis
Posted: Sat May 27, 2006 1:50 am
by Lovehina
I know what you mean, and the thing is that if I manually rotate the exact same mesh: cube->setRotation(core::vector3df(0,10,0)); or rotate it with the keyboard, the lightning is correctly updated.
But when using the exported animation from 3DSMAX, the lightning doesn't get updated.
Anyways, here is the file:
Cube
Posted: Sat May 27, 2006 3:44 am
by vitek
Weird. You are absolutely right. The lighting doesn't update as it should. The other weird thing is that I don't see that problem with other x meshes [dwarf.x for example]. It appears to be some kind of problem with the mesh or maybe the animated mesh not treating the data properly.
Travis
Posted: Sat May 27, 2006 7:44 am
by Lovehina
Thank you so much, I was beginning to think that this was only happening to me...
What could be causing this...? As I said, if I manually rotate the model within IRRLicht, the lightning gets updated, but not when I use the imported animation...
Could this have something to do with how the model was exported, or perhaps how it was setup within 3DSMAX. I'm using the latest version of the Panda exporter, and I'm just using simple rotate animation in 3DSMAX.
I've had a lot of troubles with .X file format anyway, it was just this week that I got the bone animation working nicely, and now this happens...
![Crying or Very sad :cry:](./images/smilies/icon_cry.gif)
Trouble is that besides the .X format, there really isn't much to pick from if one wants to have bone animation.
PS: The greatest irony with IRRLicht is although having an easy to use and learn API, the "really complicated" part lies in the issues concerning the different file formats...
![Confused :?](./images/smilies/icon_confused.gif)
Posted: Sat May 27, 2006 8:53 pm
by needforhint
double posted
Posted: Sat May 27, 2006 8:53 pm
by needforhint
Posted: Sat May 27, 2006 11:14 pm
by Lovehina
Thanks for nothing needforhint...
As you can clearly read at the end of that post, his lightning problems still remained. Besides he had a lot of trouble with animation which I don't. And by the way there is nothing there that suggests him having exact same lightning problems a I do.
Posted: Sun May 28, 2006 4:45 am
by Lovehina
A small update: Iv also tried this with an .MS3D animated model and the lighting issue is still there...
![Crying or Very sad :cry:](./images/smilies/icon_cry.gif)
Posted: Sun May 28, 2006 9:22 am
by needforhint
that's what he says in an another topic, also disabling max tics is good choice
Posted: Mon May 29, 2006 9:29 pm
by Lovehina
None of those things solved the issue for me. And by the way this thing also happens with Dwarf.X mesh that comes with IRRLicht.
I even tried completely modeling a cube in MS3D and animating it, just in case 3DSMAX was messing things up, but I still got the same problem...
![Crying or Very sad :cry:](./images/smilies/icon_cry.gif)
Posted: Wed May 31, 2006 12:03 am
by Lovehina
Anyone...?
![Sad :(](./images/smilies/icon_sad.gif)