SimpleJavaEngine/src/main/java/speiger/src/coreengine/math/smooth/SmoothVec3f.java

45 lines
1.1 KiB
Java

package speiger.src.coreengine.math.smooth;
import speiger.src.coreengine.math.vector.floats.Vec3f;
public class SmoothVec3f
{
Vec3f value = Vec3f.mutable();
Vec3f target = Vec3f.mutable();
Vec3f helper = Vec3f.mutable();
float agility = 0F;
public SmoothVec3f(float agility)
{
this.agility = agility;
}
public SmoothVec3f(Vec3f vec, float agility)
{
value.set(vec);
target.set(vec);
this.agility = agility;
}
public boolean isDone()
{
return target.distanceToSquared(value) <= 0.005F;
}
public void update(float delta)
{
value.add(target.difference(value, helper).multiply(agility * delta));
}
public void setTarget(Vec3f value){setTarget(value.getX(), value.getY(), value.getZ());}
public void setTarget(float x, float y, float z) {target.set(x, y, z);}
public void addTarget(Vec3f value){addTarget(value.getX(), value.getY(), value.getZ());}
public void addTarget(float x, float y, float z) {target.add(x, y, z);}
public Vec3f getTarget(){return target.copy();}
public Vec3f getValue(){return value.copy();}
public void forceFinish(){value.set(target);}
}