Page 1 of 1

Sun in game?

Posted: Thu Aug 21, 2014 1:20 am
by danielmccarthy
I have created a sun using this code

Code: Select all

 
    ILightSceneNode* sun = smgr->addLightSceneNode(0, core::vector3df(0, 10, 0), video::SColorf(255.0f, 255.0f, 255.0f), 1000.0f);
       scene::ISceneNodeAnimator* anim =
                                smgr->createFlyCircleAnimator(core::vector3df(1000, 10, 1000), 1000.0f, 0.0001f);
    if (anim)
    {
        sun->addAnimator(anim);
        anim->drop();
    }
 
According to the Irrlicht reference the speed is radians per milisecond. My question is how can I have it complete its rotation like once a minute or hour. How can I calculate that.

Re: Sun in game?

Posted: Thu Aug 21, 2014 4:06 am
by Rama112
Hi!

One rotation = 360deg = 2*PI Radians,
There are 60.000ms in one minute so the rotational speed will be DeltaAngle/DeltaTime = 2*PI/60000 = 0.0001047 rad/ms
There are 3.600.000ms in one hours so the rotational speed will be 2*PI/3600000 = 0.000001745 rad/ms

Hope that was the answer you were looking for.

Re: Sun in game?

Posted: Thu Aug 21, 2014 4:15 am
by dearingj
I see Rama112 beat me to answering your question :) so I'll just add that Irrlicht has a couple of built-in constants that represent pi, in case you ever want to use them: core::PI is a 32-bit float (which should be more than accurate enough for this), and core::PI64 is a 64-bit float.

Re: Sun in game?

Posted: Thu Aug 21, 2014 10:17 pm
by danielmccarthy
Lol my math is not great can you explain it a little easier. What is delta angle and delta time?

Re: Sun in game?

Posted: Thu Aug 21, 2014 11:17 pm
by kklouzal
Delta usually means change over time. since frame rate is variable the time it takes to move from one frame to another is not constant that being said neither will the angle at which the fly circle animator moves each frame so you must take the DeltaTime and DeltaAngle which is usually something like PreviousTime-CurrentTime/1000