help with path functions :/

Posted By: Espér

help with path functions :/ - 06/06/12 05:53

hi there laugh

For my titelmenü, i worked with WED during the last weeks - the first time i use WED since i own an Acknex Engine ^_^"

Now i got a problem...
i created a few paths with different counts of nodes. All paths are just a line, not a closed circle. When i want to move my camera smoothly with speed reduction to the last node of a path, i looked into path_spline. This works so far - but with just a small Problem: The camera turns around at the Paths last node/start node, and flys back to the beginning ._.

Someone told me that i need to do the path movement by my own when using paths that are no closed circles. But i've not really a clue how to move the camera along a path with the same speed and smooth effect as path_spline did ._.

can someone help me out here?
Posted By: Puppeteer

Re: help with path functions :/ - 06/06/12 10:53

Maybe this helps:
http://www.opserver.de/ubb7/ubbthreads.p...true#Post290611
Posted By: Espér

Re: help with path functions :/ - 06/06/12 11:21

not really, cause my paths have more than 8 waypoints ^_^"
Posted By: exile

Re: help with path functions :/ - 06/06/12 11:36

o-----o-----o

See what I typed up top? Thats the basis for the idea I am having. Essentially, you would calculate the distance between 3 positions, Previous node, Current node, and Next node. what you would do is move the camera via lerp between the distance of the current node and the next node (Or the previous node if the camera is going backwards). After you get past the halfway point between the current node and the next node, the next node then becomes the current node and the next node becomes the literal next node. You could get the distance between nodes using vec_dist and smoothly move the camera between points using vec_lerp.

Hope this helps as it was the only thing I could think of.
Posted By: Espér

Re: help with path functions :/ - 06/06/12 11:40

smirk
how is vec_lerp working? It behaves strange, especially with rotations.. ._.
Posted By: sivan

Re: help with path functions :/ - 06/06/12 12:19

there is the algorithm given at vec_lerp() page, which is the vector equivalent of smooth(). maybe you need to use different smooth() functions for coordinates and speed...
some weeks ago I created a smoothing function for my tile based unit movements, I mean the best to customize the parameters by smooth(), or a similar own function to your actual needs.
Posted By: Puppeteer

Re: help with path functions :/ - 06/07/12 11:02

Originally Posted By: Espér
not really, cause my paths have more than 8 waypoints ^_^"

Dude Oo
You should really be capable of changing this code to work with any amount of nodes for it is as hard to do as lifting a feather =P

If you do not like this code you should look into splines. They are easy to implement and work really well. -> Wikipedia.

You can calc it pretty much like that:
Code:
fs[0]=2.0*time_*time_*time_-3.0*time_*time_+1.0;
	fs[1]=time_*time_*time_-2.0*time_*time_+time_;
	fs[2]=-2.0*time_*time_*time_+3.0*time_*time_;
	fs[3]=time_*time_*time_-time_*time_;
	temp_v.x=(fs[0]*spline.start.x+fs[1]*spline.start_tangent.x+fs[2]*spline.end.x+fs[3]*spline.end_tangent.x);
	temp_v.y=(fs[0]*spline.start.y+fs[1]*spline.start_tangent.y+fs[2]*spline.end.y+fs[3]*spline.end_tangent.y);


© 2024 lite-C Forums