vrshoot
view src/curve.h @ 2:334d17aed7de
visual studio project files
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 02 Feb 2014 18:36:38 +0200 |
parents | |
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 class Curve {
10 private:
11 std::string name;
13 std::vector<Vector3> cv;
14 float thickness;
16 int segm_subdiv, ring_subdiv;
18 /// normalized arc-lengths of each control vertex from the beginning
19 mutable std::vector<float> length;
20 mutable bool lengths_valid;
22 mutable Vector3 bbmin, bbmax;
23 mutable bool bbox_valid;
25 mutable Mesh mesh;
26 mutable bool mesh_valid;
28 float reparametrize(float t) const;
30 void calc_cvlengths() const;
31 void update_mesh() const;
33 public:
34 Curve();
35 Curve(const Vector3 *points, int num_points);
36 Curve(const Vector2 *points, int num_points);
38 void set_name(const char *name);
39 const char *get_name() const;
41 bool empty() const;
43 void set_thickness(float thickness);
44 void set_subdiv(int seg, int ring);
46 void clear();
47 void add_point(const Vector3 &pt);
48 Vector3 &get_point(int idx);
49 const Vector3 &get_point(int idx) const;
50 int get_count() const;
52 Vector3 &operator[] (int idx);
53 const Vector3 &operator[] (int idx) const;
55 void get_bbox(Vector3 *bbmin, Vector3 *bbmax) const;
56 void normalize();
58 Vector3 get_pos(float t) const;
59 Vector3 operator() (float t) const;
61 void draw() const;
62 };
64 #endif // CURVE_H_