ported the University CGI demo from WINDOWS + GLUT + GLEW + GLU + OpenGL 4 to LINUX WAYLAND + EGL + GLES 2 with minimal cuts
This commit is contained in:
24
GL_STUFF/HEADERS/CURVES/Bezier.hpp
Executable file
24
GL_STUFF/HEADERS/CURVES/Bezier.hpp
Executable file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include "./Curve.hpp"
|
||||
|
||||
class Bezier : public Curve {
|
||||
private:
|
||||
unsigned int order;
|
||||
protected:
|
||||
float evaluateBasisFunction(float at, int number, int order, float intervalLeft, float intervalRight);
|
||||
public:
|
||||
Bezier(unsigned int order, vector<glm::vec3> *points, vector<float> *intervals);
|
||||
glm::vec3 evaluate(float at);
|
||||
glm::vec3 derivate(float at);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class Bezier3Segments : public Bezier {
|
||||
public:
|
||||
Bezier3Segments( vector<glm::vec3>* points, vector<float>* intervals);
|
||||
glm::vec3 evaluate(float at);
|
||||
glm::vec3 derivate(float at);
|
||||
float getLeftBound();
|
||||
float getRightBound();
|
||||
};
|
||||
22
GL_STUFF/HEADERS/CURVES/Curve.hpp
Executable file
22
GL_STUFF/HEADERS/CURVES/Curve.hpp
Executable file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <glm/glm.hpp>
|
||||
using namespace std;
|
||||
|
||||
class Curve {
|
||||
protected:
|
||||
vector<glm::vec3> *controlPoints;
|
||||
vector<float> *intervalBoundaries;
|
||||
|
||||
public:
|
||||
Curve(vector<glm::vec3> *points, vector<float> *boundaries);
|
||||
vector<glm::vec3>* getControlPoints();
|
||||
void setControlPoints(vector<glm::vec3>* points);
|
||||
vector<float>* getIntervalBoundaries();
|
||||
void setIntervalBoundaries(vector<float>* boundaries);
|
||||
virtual float getLeftBound();
|
||||
virtual float getRightBound();
|
||||
virtual glm::vec3 evaluate(float at) = 0;
|
||||
virtual glm::vec3 derivate(float at) = 0;
|
||||
|
||||
};
|
||||
35
GL_STUFF/HEADERS/CURVES/CurveIterator.hpp
Executable file
35
GL_STUFF/HEADERS/CURVES/CurveIterator.hpp
Executable file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include "./Curve.hpp"
|
||||
|
||||
enum class CurveIterationMode
|
||||
{
|
||||
BASIC,
|
||||
LENGTH
|
||||
};
|
||||
|
||||
class CurveIterator {
|
||||
private:
|
||||
Curve *curve;
|
||||
unsigned int steps;
|
||||
CurveIterationMode iterationMode;
|
||||
float estimatedLength;
|
||||
int basicStepCounter;
|
||||
float lengthStepCounter;
|
||||
float leftBound;
|
||||
float rightBound;
|
||||
float lastIncrement;
|
||||
|
||||
void resetIterator();
|
||||
void computeLength();
|
||||
|
||||
public:
|
||||
CurveIterator(Curve *curve, unsigned int steps, CurveIterationMode basicOrLength);
|
||||
void nextStep();
|
||||
float getStep();
|
||||
void setProgress(float at);
|
||||
glm::vec3 evaluation();
|
||||
glm::vec3 derivation();
|
||||
|
||||
Curve* getCurve();
|
||||
|
||||
};
|
||||
35
GL_STUFF/HEADERS/CURVES/CurvesLoader.hpp
Executable file
35
GL_STUFF/HEADERS/CURVES/CurvesLoader.hpp
Executable file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <regex>
|
||||
#include <iostream>
|
||||
#include "./Curve.hpp"
|
||||
#include "Bezier.hpp"
|
||||
#include "NURBS.hpp"
|
||||
|
||||
class CurvesLoader {
|
||||
static string currentCurveType;
|
||||
static vector<glm::vec3>* pointsBuffer;
|
||||
|
||||
static vector<NURBS*> NURBSes;
|
||||
static vector<Bezier3Segments*> beziers;
|
||||
|
||||
static unsigned int NURBSOrder;
|
||||
static NURBSType NURBS_TYPE;
|
||||
static vector<float>* NURBSWeights;
|
||||
|
||||
static char lineHeader[128];
|
||||
static char* res;
|
||||
static FILE* file;
|
||||
|
||||
static std::smatch pieces;
|
||||
static void beginCurve(string str, std::smatch pieces, std::regex regex);
|
||||
static NURBS* BasicNURBS();
|
||||
static NURBS* ClampedNURBS();
|
||||
static NURBS* CyclicNURBS();
|
||||
static void closeNURBS();
|
||||
static void closeBezier();
|
||||
static void closePendingCurve();
|
||||
static void parseVertexData(string str);
|
||||
public:
|
||||
static bool loadCurves(std::string path, vector<Curve*>& curves);
|
||||
};
|
||||
21
GL_STUFF/HEADERS/CURVES/Hermite.hpp
Executable file
21
GL_STUFF/HEADERS/CURVES/Hermite.hpp
Executable file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "./Curve.hpp"
|
||||
|
||||
enum class HermiteModes {
|
||||
Basic,
|
||||
Direct,
|
||||
Cardinal,
|
||||
TBC
|
||||
};
|
||||
|
||||
class Hermite : public Curve {
|
||||
private:
|
||||
vector<glm::vec3> derivatives;
|
||||
glm::vec3 evaluateCubic(float t, float t1, float t2, glm::vec3 y1, glm::vec3 y2, glm::vec3 dy1, glm::vec3 dy2);
|
||||
|
||||
public:
|
||||
void computeDerivatives(HermiteModes mode, vector<glm::vec3> auxData);
|
||||
Hermite(vector<glm::vec3> *points, vector<float> *intervals);
|
||||
glm::vec3 evaluate(float at);
|
||||
glm::vec3 derivate(float at);
|
||||
};
|
||||
28
GL_STUFF/HEADERS/CURVES/NURBS.hpp
Executable file
28
GL_STUFF/HEADERS/CURVES/NURBS.hpp
Executable file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#include "./Curve.hpp"
|
||||
|
||||
enum class NURBSType {
|
||||
BASIC,
|
||||
CLAMPED,
|
||||
CYCLIC
|
||||
};
|
||||
|
||||
class NURBS : public Curve {
|
||||
private:
|
||||
unsigned int order;
|
||||
vector<float>* weights;
|
||||
vector<unsigned int>* multiplicities;
|
||||
vector<float>* derivativeBoundaries;
|
||||
vector<glm::vec3>* derivativePoints;
|
||||
vector<float>* derivativeWeghts;
|
||||
glm::vec3 deBoor( float at, int index);
|
||||
void preliminaryChecks();
|
||||
public:
|
||||
NURBS( unsigned int order, vector<glm::vec3>* points, vector<float>* weights, vector<float>* boundaries, vector<unsigned int>* multiplicities);
|
||||
unsigned int getOrder();
|
||||
vector<float>* getWeights();
|
||||
glm::vec3 evaluate(float at);
|
||||
glm::vec3 derivate(float at);
|
||||
float getLeftBound();
|
||||
float getRightBound();
|
||||
};
|
||||
Reference in New Issue
Block a user