ISceneNodeAnimator
Ahh, it's getDistanceFromSQ(), that's why I didn't find it...
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
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:
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
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.
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
}
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.
-
- Posts: 81
- Joined: Sun Sep 09, 2007 7:01 pm
- Location: BW, Germany
-
- Posts: 81
- Joined: Sun Sep 09, 2007 7:01 pm
- Location: BW, Germany
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!
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!
-
- Posts: 81
- Joined: Sun Sep 09, 2007 7:01 pm
- Location: BW, Germany
-
- Posts: 81
- Joined: Sun Sep 09, 2007 7:01 pm
- Location: BW, Germany
-
- Posts: 81
- Joined: Sun Sep 09, 2007 7:01 pm
- Location: BW, Germany
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?
Please help me, I want to continue working on my project.
Thanks for every answer!
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?
Please help me, I want to continue working on my project.
Thanks for every answer!
-
- Posts: 81
- Joined: Sun Sep 09, 2007 7:01 pm
- Location: BW, Germany
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
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.
-
- Posts: 81
- Joined: Sun Sep 09, 2007 7:01 pm
- Location: BW, Germany
End of this lesson: I GOT IT!! 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 ) 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
Well, now I'm happy. Time for some new features
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 ) 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
Well, now I'm happy. Time for some new features