ISceneNodeAnimator

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

Post by vitek »

Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Ahh, it's getDistanceFromSQ(), that's why I didn't find it... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

grep would still help you in that case, but the 'From' between Distance and SQ would be more of a problem. Still, searching for SQ is pretty safe :wink:
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

He wants to compare two positions of the same node, not positions of two different nodes ;)

All you have to do is keep a variable which holds the previous position. Something like this:

Code: Select all

vector3df prev_pos;
bool followTarget = true;

while (device->run()) {
  if (followTarget) {
    if (dummyNode->getPosition == prev_pos) { //hasn't moved since last frame
      followTarget = false;
    }
    prev_pos = dummyNode->getPosition();
    camera->setTarget(dummyNode->getPosition());
  }
  // Render code
}
You can use 'if (dummyNode->getPosition == prev_pos)' in this case because when the node stops moving it will definetly stay in its previous position and they will be equal to each other. But as the others have said, if you're comparing the positions of two different nodes you'd want some kind of threshold to the comparison as they may never be exactly the same but 'very close' may be enough for you to say that they're 'exactly' the same... if that makes any sense :lol:

But if you're using a followspline and it's a ping pong animator which starts reversing the route once it's completed then it would be best to use the threshold idea as you may not catch it when it's position is exactly the same between frames if your framerate dips or something. So when it gets close to the end point you remove the animator from the dummy node and stop the camera from following it.
Image Image Image
Namek Kural
Posts: 81
Joined: Sun Sep 09, 2007 7:01 pm
Location: BW, Germany

Post by Namek Kural »

Thanks, I just thought about it and the node does definitly not stay in the same position for two frames. I'll use the other method.

Could you please tell me how to use the 'getDistanceFromSQ' method? I will also look it up in the API, of course! :)
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Look it up in the API before asking for help on it ;)

Presumably you've now looked it up and understood it so i, and others, shan't bother explaining it :lol:
Image Image Image
Namek Kural
Posts: 81
Joined: Sun Sep 09, 2007 7:01 pm
Location: BW, Germany

Post by Namek Kural »

It worked but there's another problem. :?
The animation seems to run in the background but I dropped the animator before. I use "getDistanceFrom" to remove the animator from the dummy node when the returned value is lower than 10.
Now when I select another node to which the animator should animate it doesn't animate from point a to point b but from anywhere on the a/b path to point a and then to point b, where it stops.
I hope you understand waht I mean by this.
Please help! :(
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

It happens to me too, if I use createFollowSplineAnimator() for example when I "remove" it and use it again it doesn't start from the first position I give it..
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
Namek Kural
Posts: 81
Joined: Sun Sep 09, 2007 7:01 pm
Location: BW, Germany

Post by Namek Kural »

That's exactly it! :? Anyone knows what to do?
Note: I even dropped it! Shouldn't it be some kind of deleted then?
Namek Kural
Posts: 81
Joined: Sun Sep 09, 2007 7:01 pm
Location: BW, Germany

Post by Namek Kural »

Doesn't anyone know a solution? :cry:
Namek Kural
Posts: 81
Joined: Sun Sep 09, 2007 7:01 pm
Location: BW, Germany

Post by Namek Kural »

I just wonder if nobody here is able to give me a possible solution although this is the official irrlicht forum.
I want to finish my project but whithout your help I can't do it.
Again: The problem is that I don't get the SceneNodeAnimator to start from the beginning after removing it. It looks like it's running in the background all the time and is made visible when I create it oO

Maybe it's easier to understand MasterGod's post who has the same problem.

Is this a bug? Or am I just doing anything wrong? :cry:

Please help me, I want to continue working on my project. :cry:
Thanks for every answer!
Namek Kural
Posts: 81
Joined: Sun Sep 09, 2007 7:01 pm
Location: BW, Germany

Post by Namek Kural »

Today I tried irrlicht 1.4 the first time. I hoped this would solve the problem but it didn't!

I prepared a .rar archive for anyone who wanna try to help me.
It contains the 0.17 beta of my program and the parts of the source code that are important for solving my problem.

I hope now we'll find a solution. If you're a star wars fan you'll surely find it very interesting. This version of my program is NOT supposed to be an official beta. I'll just give it to developers like you.
Therefore you need a password for downloading it. The password is: debug

Link Deleted, problem solved

Please do NOT send this to anyone who doesn't want to help solving the problem.

The problem is the animation of the camera when clicking on one of the planet spheres. The white sphere illustrates the position of the "dummy" scene node.

In the "config.txt" file you can change the settings of the program. It starts in fullscreen mode but you can change this of course.

If you're personally interested in my project, visit this (german) project website: http://www.starwars-galaxy.isgreat.org

Thanks! Namek Kural
Last edited by Namek Kural on Sat Dec 01, 2007 9:12 pm, edited 1 time in total.
Namek Kural
Posts: 81
Joined: Sun Sep 09, 2007 7:01 pm
Location: BW, Germany

Post by Namek Kural »

End of this lesson: I GOT IT!! :D WHOHOO!

Well, I don't know if you wanted me to find the problem on my own because it was such a tiny detail in my createFollowSpline line of code.

The problem was (as yu all might know :P) the starting time, which I set to zero :? I didn't understand that '0' means 'the beginning of the application runtime'. It just works fine with 'device->getTimer()->getTime()

What I really would like to know is: Did you know the solution to my problem?

I wasted so much time trying to get it work fine. I hope you just didn't recognize my problem and did not ignore me :wink:

Well, now I'm happy. :) Time for some new features :P
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

Great! I've been having problems with it too and after many searches I found your thread which seemed to lead somewhere (void), untill now!!
I just left it alone cause I didn't find the solution back at the time I needed it..

Thank you very much!
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
Frodenius
Posts: 64
Joined: Sun Aug 29, 2004 11:24 am
Location: Germany/Frankfurt
Contact:

Post by Frodenius »

of course it is!
getDistanceFromSQ()
worst programming style ever seen...
Post Reply