1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-29 22:35:45 +00:00
Aquaria/BBGE/SplineGrid.h

67 lines
1.4 KiB
C
Raw Normal View History

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"
#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();
2023-08-25 18:13:56 +00:00
virtual ~SplineGridCtrlPoint();
2022-09-04 15:16:35 +00:00
virtual void onUpdate(float dt) OVERRIDE;
Vector getSplinePosition() const;
void setSplinePosition(Vector pos);
2022-09-04 15:16:35 +00:00
static SplineGridCtrlPoint *movingPoint;
};
class SplineGrid : public Quad
{
public:
typedef Vector value_type;
SplineGrid();
2023-08-25 18:13:56 +00:00
virtual ~SplineGrid();
2022-09-04 15:16:35 +00:00
// # of control points on each axis
DynamicRenderGrid *resize(size_t w, size_t h, size_t xres, size_t yres, unsigned degx, unsigned degy);
2022-09-04 15:16:35 +00:00
void recalc();
void exportControlPoints(Vector *controlpoints);
void importControlPoints(const Vector *controlpoints);
2022-09-04 15:16:35 +00:00
void resetControlPoints();
void setPointScale(const float scale);
float getPointScale() const { return pointscale; }
2022-09-04 15:16:35 +00:00
virtual void onRender(const RenderState& rs) const OVERRIDE;
virtual void onUpdate(float dt) OVERRIDE;
BSpline2D& getSpline() { return bsp; }
const BSpline2D& getSpline() const { return bsp; }
bool wasModified; // to be checked/reset by external code
2022-09-04 15:16:35 +00:00
private:
SplineGridCtrlPoint *createControlPoint(size_t x, size_t y);
std::vector<SplineGridCtrlPoint*> ctrlp;
unsigned deg;
BSpline2DWithPoints bsp;
float pointscale;
2022-09-04 15:16:35 +00:00
};
#endif