Sun in game?

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.
Post Reply
danielmccarthy
Posts: 51
Joined: Fri May 30, 2014 12:55 am

Sun in game?

Post 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.
Rama112
Posts: 7
Joined: Mon Aug 18, 2014 7:08 am

Re: Sun in game?

Post 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.
dearingj
Posts: 7
Joined: Sun Dec 30, 2007 5:43 am
Contact:

Re: Sun in game?

Post 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.
danielmccarthy
Posts: 51
Joined: Fri May 30, 2014 12:55 am

Re: Sun in game?

Post by danielmccarthy »

Lol my math is not great can you explain it a little easier. What is delta angle and delta time?
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Re: Sun in game?

Post 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
Dream Big Or Go Home.
Help Me Help You.
Post Reply