Becouse i need in my project ;D
if someone can share with my his obejct that define
static path and
iterator on it to get the varoius poin to follow
Thanks!!! :
Becouse i need in my project ;D
if someone can share with my his obejct that define
static path and
iterator on it to get the varoius poin to follow
Thanks!!! :
An ArrayList<Point2D.Float> and a for-loop?
I’m assuming you have a set of points in 2D space and you simply want to move from one point to the other? Doing this is fairly straightforward, however there is one problem, finding weather or not the object has reached its current point so that it can move towards a new point. This is only a problem for floating point numbers.
You will need this support function.
// destination as a Point in X-Y plane (the destination)
// current as a Point in X-Y plane (the current position)
// direction as a Normalized Vector of the current direction (can be computed from destination - current vectors if needed
// function will return a boolean true/false if the current point has reached its destination.
// 2D version
public static boolean isInFront2(final Vector destination,
final Vector current,
final Vector direction)
{
float product = (current.getX() - destination.getX()) * direction.getX() +
(current.getY() - destination.getY()) * direction.getY();
return (product > 0.0f);
}
// 3D version
public static boolean isInFront3(final Vector destination,
final Vector current,
final Vector direction)
{
float product = (current.getX() - destination.getX()) * direction.getX() +
(current.getY() - destination.getY()) * direction.getY() +
(current.getZ() - destination.getZ()) * direction.getZ();
return (product > 0.0f);
}
hope that helps
when you don’t need something like bezier cuves just use a collection of points which define a path
I for example just use this code:
thanks Danny!
this is something close to what i’m looking for!
a class Path that implement an Iterator interface
the implementation can be good as basic, but i have to add some functionality becouse
i need also to calculate the rotation of the sprite so i will need to avaluate the derivate to the point where i’m arrived
and use it to rotate the sprite
anyway i can start from this chunk of code
thanks again!
i will post the code when will be complete
thanks for you help guys
i create my iplementation that is shared always in this section of the forum
this is the link