2022-09-04 15:16:35 +00:00
|
|
|
#ifndef BBGE_SPLINEGRID_H
|
|
|
|
#define BBGE_SPLINEGRID_H
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include "Vector.h"
|
|
|
|
#include "glm/glm.hpp"
|
|
|
|
#include "Quad.h"
|
2022-09-13 16:38:44 +00:00
|
|
|
#include "Interpolators.h"
|
2022-09-04 15:16:35 +00:00
|
|
|
|
2022-09-05 15:19:34 +00:00
|
|
|
enum SplineType
|
|
|
|
{
|
|
|
|
SPLINE_BSPLINE,
|
|
|
|
SPLINE_COSINE,
|
|
|
|
};
|
|
|
|
|
2022-09-04 15:16:35 +00:00
|
|
|
class SplineGridCtrlPoint : public Quad
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SplineGridCtrlPoint();
|
|
|
|
virtual void onUpdate(float dt) OVERRIDE;
|
|
|
|
Vector getSplinePosition() const;
|
|
|
|
|
|
|
|
static SplineGridCtrlPoint *movingPoint;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SplineGrid : public Quad
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef Vector value_type;
|
|
|
|
|
|
|
|
SplineGrid();
|
|
|
|
~SplineGrid();
|
|
|
|
|
|
|
|
// # of control points on each axis
|
2022-09-13 16:38:44 +00:00
|
|
|
void resize(size_t w, size_t h, size_t xres, size_t yres, unsigned deg);
|
2022-09-04 15:16:35 +00:00
|
|
|
void recalc();
|
2022-09-05 15:19:34 +00:00
|
|
|
|
2022-09-04 15:16:35 +00:00
|
|
|
void resetControlPoints();
|
|
|
|
|
|
|
|
virtual void onRender(const RenderState& rs) const OVERRIDE;
|
|
|
|
virtual void onUpdate(float dt) OVERRIDE;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
SplineGridCtrlPoint *createControlPoint(size_t x, size_t y);
|
|
|
|
|
|
|
|
std::vector<SplineGridCtrlPoint*> ctrlp;
|
2022-09-13 16:38:44 +00:00
|
|
|
unsigned deg;
|
|
|
|
BSpline2D bsp;
|
2022-09-04 15:16:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|