class EE::Math::Interpolation2d

Overview

A waypoint manager, used for movement interpolations. More…

#include <interpolation2d.hpp>

class Interpolation2d {
public:
    // typedefs

    typedef std::function<void(Interpolation2d&)> OnPathEndCallback;
    typedef std::function<void(Interpolation2d&)> OnStepCallback;

    // construction

    Interpolation2d();
    Interpolation2d(std::vector<Point2d> points);
    ~Interpolation2d();

    // methods

    Interpolation2d& add(const Vector2f& pos, const Time& time = Time::Zero);
    Interpolation2d& edit(const unsigned int& PointNum, const Vector2f& pos, const Time& time);
    Interpolation2d& erase(const unsigned int& PointNum);
    Interpolation2d& wait(const Vector2f& pos, const Time& time);
    Interpolation2d& waitAndAdd(const Vector2f& pos, const Time& waitTime, const Time& addTime);
    Interpolation2d& start();
    Interpolation2d& start(OnPathEndCallback PathEndCallback, OnStepCallback StepCallback = OnStepCallback());
    Interpolation2d& stop();
    Interpolation2d& setPathEndCallback(OnPathEndCallback PathEndCallback);
    Interpolation2d& setStepCallback(OnStepCallback StepCallback);
    void update(const Time& Elapsed);
    Interpolation2d& reset();
    const Vector2f& getPosition();
    bool getLoop() const;
    Interpolation2d& setLoop(const bool& loop);
    Interpolation2d& clear();
    bool ended() const;
    Interpolation2d& setDuration(const Time& TotTime);
    const Time& getDuration() const;
    Point2d* getCurrentActual() const;
    Point2d* getCurrentNext() const;
    const Uint32& getCurrentPositionIndex() const;
    const std::vector<Point2d>& getPoints() const;
    std::vector<Point2d> getReversePoints();
    Interpolation2d& setSpeed(const Float& speed);
    const Float& getSpeed() const;
    const bool& isEnabled() const;
    Interpolation2d& setEnabled(const bool& enabled);
    Interpolation2d& setType(Ease::Interpolation InterpolationType);
    const int& getType() const;
    UintPtr getData() const;
    void setData(const UintPtr& data);
    Float getCurrentProgress();
    Float getPartialCurrentProgress();
};

Detailed Documentation

A waypoint manager, used for movement interpolations.

Methods

Interpolation2d& add(const Vector2f& pos, const Time& time = Time::Zero)

Add a new waypoint

Interpolation2d& edit(const unsigned int& PointNum, const Vector2f& pos, const Time& time)

Edit a waypoint

Interpolation2d& erase(const unsigned int& PointNum)

Erase a waypoint

Interpolation2d& wait(const Vector2f& pos, const Time& time)

Same as add( pos, time ).add( pos );

Interpolation2d& waitAndAdd(const Vector2f& pos, const Time& waitTime, const Time& addTime)

Same as add( pos, waitTime ).add( pos, addTime );

Interpolation2d& start()

Start the animation ( will reset the current state, and start from the beginning )

Interpolation2d& start(OnPathEndCallback PathEndCallback, OnStepCallback StepCallback = OnStepCallback())

Start the animation ( will reset the current state, and start from the beginning )

Parameters:

PathEndCallback

An optional callback fired when the animation ends.

StepCallback

An optional callback that is fired every time that a step is completed.

Interpolation2d& stop()

Stop the animation ( Enable = false )

Interpolation2d& setPathEndCallback(OnPathEndCallback PathEndCallback)

Sets a path end callback

Interpolation2d& setStepCallback(OnStepCallback StepCallback)

Sets a step callback

void update(const Time& Elapsed)

Update the movement interpolation

Interpolation2d& reset()

Reset the class

const Vector2f& getPosition()

Returns:

The Current Position

bool getLoop() const

Returns:

If movement interpolation is a loop

Interpolation2d& setLoop(const bool& loop)

Set if loop the movement interpolation

Interpolation2d& clear()

Clear all the waypoints

bool ended() const

Returns:

If the animation ended

Interpolation2d& setDuration(const Time& TotTime)

Instead if setting the time between every waypoing, this set a total time for all the movement interpolation.

const Time& getDuration() const

Returns:

The total duration of the interpolation.

Point2d* getCurrentActual() const

Returns:

The Current Node

Point2d* getCurrentNext() const

Returns:

The Next Node

const Uint32& getCurrentPositionIndex() const

Returns:

The Current Position in the vector

const std::vector<Point2d>& getPoints() const

Returns:

the vector of waypoints

std::vector<Point2d> getReversePoints()

Returns:

the vector of waypoints reversed

Interpolation2d& setSpeed(const Float& speed)

Set the current interpolation speed ( This will destroy the time of the interpolation and create one depending on the speed ) ( pixels per second )

const Float& getSpeed() const

Get the current interpolation speed

const bool& isEnabled() const

Returns:

If enabled

Interpolation2d& setEnabled(const bool& enabled)

Set it enabled or not

Interpolation2d& setType(Ease::Interpolation InterpolationType)

Set the type of interpolation to be used

const int& getType() const

Returns:

The type of the interpolation

Float getCurrentProgress()

Returns:

The current progress percentage (between 0 and 1) of the complete interpolation.

Float getPartialCurrentProgress()

Returns:

The current progress percentage (between 0 and 1) of the current interpolation. This is the partial progress, not the global of the whole interpolation.