Dynamic lights issue (a small one) [SOLVED]
Dynamic lights issue (a small one) [SOLVED]
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...!
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...!
Last edited by Lovehina on Fri Jun 02, 2006 12:15 pm, edited 1 time in total.
Either one of two things is happening...
Travis
- 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.
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;
}
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...
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...
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
But when using the exported animation from 3DSMAX, the lightning doesn't get updated.
Anyways, here is the file: Cube
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... 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...
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... 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...
-
- Posts: 322
- Joined: Tue Aug 30, 2005 10:34 am
- Location: slovakia
double posted
Last edited by needforhint on Sat May 27, 2006 8:54 pm, edited 1 time in total.
what is this thing...
-
- Posts: 322
- Joined: Tue Aug 30, 2005 10:34 am
- Location: slovakia
-
- Posts: 322
- Joined: Tue Aug 30, 2005 10:34 am
- Location: slovakia
that's what he says in an another topic, also disabling max tics is good choiceSince nobody answered me, I assume nobody has had this problem, anyway, I solved it applying a reset Xform modifier in 3Ds Max as Mobeen suggested in this thread http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=12323
what is this thing...