GlistEngine
Loading...
Searching...
No Matches
gSpline.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016 Nitra Games Ltd.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * gSpline.h
19 *
20 * Created on: Aug 20, 2026
21 * Authors: Bahar Kucukozer, Mehmet Sefa Ciftci
22 */
23
24#ifndef GRAPHICS_GSPLINE_H_
25#define GRAPHICS_GSPLINE_H_
26
27#include "gMesh.h"
28
29#include <glm/glm.hpp>
30#include <vector>
31
32class gSpline : public gMesh {
33public:
35 virtual ~gSpline();
36
37 void setPoint(const std::vector<glm::vec2>& points);
38 void setPoint(const std::vector<glm::vec3>& points);
39
40 void addPoint(glm::vec2 point);
41 void addPoint(glm::vec3 point);
42
43 void setPointAtIndex(int index, glm::vec2 point);
44 void setPointAtIndex(int index, glm::vec3 point);
45
46 glm::vec3 getPointAtIndex(int index) const;
47 glm::vec2 getPoint2DAtIndex(int index) const;
48
49 std::vector<glm::vec3> getPoints() const;
50 std::vector<glm::vec2> getPoints2D() const;
51
53
54 void setDegree(int degree);
55 int getDegree() const;
56
57 glm::vec3 getPoint(float t) const;
58 glm::vec2 getPoint2D(float t) const;
59 float getSlope(float t) const;
60
61 void setResolution(int resolution);
62 int getResolution() const;
63
64 void draw() const;
65
66private:
67 int getEffectiveDegree() const;
68 void updateKnotVector();
69 int findSpan(float t) const;
70
71 std::vector<glm::vec3> points;
72 std::vector<float> knots;
73
74 int degree;
75 int resolution;
76 bool is3D;
77};
78
79#endif /* GRAPHICS_GSPLINE_H_ */
void addPoint(glm::vec2 point)
glm::vec3 getPoint(float t) const
void setDegree(int degree)
void addPoint(glm::vec3 point)
void clearPoints()
void setResolution(int resolution)
float getSlope(float t) const
int getDegree() const
void setPoint(const std::vector< glm::vec3 > &points)
void setPoint(const std::vector< glm::vec2 > &points)
int getResolution() const
void setPointAtIndex(int index, glm::vec2 point)
glm::vec2 getPoint2DAtIndex(int index) const
glm::vec3 getPointAtIndex(int index) const
virtual ~gSpline()
glm::vec2 getPoint2D(float t) const
void draw() const
std::vector< glm::vec2 > getPoints2D() const
void setPointAtIndex(int index, glm::vec3 point)
std::vector< glm::vec3 > getPoints() const