Dynamic lights issue (a small one) [SOLVED]

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.
Lovehina
Posts: 21
Joined: Fri May 19, 2006 12:24 pm

Dynamic lights issue (a small one) [SOLVED]

Post 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...!
Last edited by Lovehina on Fri Jun 02, 2006 12:15 pm, edited 1 time in total.
Lovehina
Posts: 21
Joined: Fri May 19, 2006 12:24 pm

Post by Lovehina »

Anyone...? Come on people.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Either one of two things is happening...
  1. the light scene nodes are children to the cube, so they rotate/translate with it
  2. 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
Lovehina
Posts: 21
Joined: Fri May 19, 2006 12:24 pm

Post 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... :oops:

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... :cry:
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post 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
Lovehina
Posts: 21
Joined: Fri May 19, 2006 12:24 pm

Post 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
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post 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
Lovehina
Posts: 21
Joined: Fri May 19, 2006 12:24 pm

Post 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... :cry:
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... :cry: 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... :?
needforhint
Posts: 322
Joined: Tue Aug 30, 2005 10:34 am
Location: slovakia

Post by needforhint »

double posted
Last edited by needforhint on Sat May 27, 2006 8:54 pm, edited 1 time in total.
what is this thing...
needforhint
Posts: 322
Joined: Tue Aug 30, 2005 10:34 am
Location: slovakia

Post by needforhint »

what is this thing...
Lovehina
Posts: 21
Joined: Fri May 19, 2006 12:24 pm

Post 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.
Lovehina
Posts: 21
Joined: Fri May 19, 2006 12:24 pm

Post by Lovehina »

A small update: Iv also tried this with an .MS3D animated model and the lighting issue is still there... :cry:
needforhint
Posts: 322
Joined: Tue Aug 30, 2005 10:34 am
Location: slovakia

Post by needforhint »

Since 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
that's what he says in an another topic, also disabling max tics is good choice
what is this thing...
Lovehina
Posts: 21
Joined: Fri May 19, 2006 12:24 pm

Post 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... :cry:
Lovehina
Posts: 21
Joined: Fri May 19, 2006 12:24 pm

Post by Lovehina »

Anyone...? :(
Post Reply