(solved) Animatorless animations

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
kormoran
Posts: 47
Joined: Mon Dec 28, 2015 4:50 pm
Location: Tolentino

(solved) Animatorless animations

Post by kormoran »

I'm trying to move scene nodes without animators, since there are no predefined tracks to follow.
Problem is, ISceneNode::setRotation() and ISceneNode::setPosition() functions does not work :?

Here is a trying I'm doing with setRotation(), I tried setPosition() too

Code: Select all

while((MyApp.IsRunning())&&(IrrDevice->run()))
{
    FrameNow  = IrrDevice->getTimer()->getTime();
    TimeFrame = FrameNow - FramePast;
    FramePast = FrameNow;
    DoPhysics(TimeFrame);    // Time unit: milliseconds
 
// rest of game loop etc. etc...
 
void DoPhysics(u32 ms) 
{
    GrabRot.rotateXYBy(ms*0.002f, GrabRot);
    GrabRot.rotateXZBy(ms*0.001f, GrabRot);
    cube->setRotation(GrabRot);
};
The cube does not move nor rotate, just stays still :( what's wrong with this code?
Last edited by kormoran on Sun Feb 21, 2016 12:28 pm, edited 1 time in total.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Animatorless animations

Post by CuteAlien »

Nothing wrong so far. I guess the bug is in another place.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Animatorless animations

Post by mongoose7 »

What is the initial value of GrabRot? And why are you casting a vector to Euler angles? If GrabRot is initially (0, 0, 0) it will stay (0, 0, 0). And I'm guessing it is.

Unless I miss my guess, I'm thinking you need to start from scratch and think this thing through.
kormoran
Posts: 47
Joined: Mon Dec 28, 2015 4:50 pm
Location: Tolentino

Re: Animatorless animations

Post by kormoran »

mongoose7 wrote:What is the initial value of GrabRot? And why are you casting a vector to Euler angles? If GrabRot is initially (0, 0, 0) it will stay (0, 0, 0).
You guessed right. However, changing it to a (initial) random value did no good.
I'm just trying to animate a cube, this is a rotation but it could be any other transformation. I'm casting a vector because setRotation() requires a vector to work. If you can suggest a better method you are welcome :wink:
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Animatorless animations

Post by CuteAlien »

Argh, sorry that I missed that (my excuse is having a bad flu right now, can't really think...). mongoose7 is on the right track. You are mixing up direction vector and euler angles. rotateXYBy does rotate a direction vector. While setRotation expects euler angles (telling how many degrees to rotate around each axis). Rotating a rotation value won't work (you are trying to rotate an angle... there is no meaning for that). To increase an angle just add/subtract to the value instead. Start by rotating just around one axis (for example y). So it's just GrabRot.Y =+ something.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
kormoran
Posts: 47
Joined: Mon Dec 28, 2015 4:50 pm
Location: Tolentino

Re: Animatorless animations

Post by kormoran »

It works now. I already had some clues that setRotation() argument wasn't really a vector... I suppose I'm also to blame for not having investigated deeper. Oh well.

Until next trouble folks :P
Post Reply