goat3dgfx

view src/curve.h @ 34:3eb6c8f89fe1

merge
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 02 Mar 2014 17:41:10 +0200
parents 1873dfd13f2d
children
line source
1 #ifndef CURVE_H_
2 #define CURVE_H_
4 #include <string>
5 #include <vector>
6 #include "vmath/vmath.h"
7 #include "mesh.h"
9 namespace goatgfx {
11 class Curve {
12 private:
13 std::string name;
15 std::vector<Vector3> cv;
16 float thickness;
18 int segm_subdiv, ring_subdiv;
20 /// normalized arc-lengths of each control vertex from the beginning
21 mutable std::vector<float> length;
22 mutable bool lengths_valid;
24 mutable Vector3 bbmin, bbmax;
25 mutable bool bbox_valid;
27 mutable Mesh mesh;
28 mutable bool mesh_valid;
30 float reparametrize(float t) const;
32 void calc_cvlengths() const;
33 void update_mesh() const;
35 public:
36 Curve();
37 Curve(const Vector3 *points, int num_points);
38 Curve(const Vector2 *points, int num_points);
40 void set_name(const char *name);
41 const char *get_name() const;
43 bool empty() const;
45 void set_thickness(float thickness);
46 void set_subdiv(int seg, int ring);
48 void clear();
49 void add_point(const Vector3 &pt);
50 Vector3 &get_point(int idx);
51 const Vector3 &get_point(int idx) const;
52 int get_count() const;
54 Vector3 &operator[] (int idx);
55 const Vector3 &operator[] (int idx) const;
57 void get_bbox(Vector3 *bbmin, Vector3 *bbmax) const;
58 void normalize();
60 Vector3 get_pos(float t) const;
61 Vector3 operator() (float t) const;
63 void draw() const;
64 };
66 } // namespace goatgfx
68 #endif // CURVE_H_