vrshoot
diff src/curve.h @ 0:b2f14e535253
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 01 Feb 2014 19:58:19 +0200 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/curve.h Sat Feb 01 19:58:19 2014 +0200 1.3 @@ -0,0 +1,64 @@ 1.4 +#ifndef CURVE_H_ 1.5 +#define CURVE_H_ 1.6 + 1.7 +#include <string> 1.8 +#include <vector> 1.9 +#include "vmath/vmath.h" 1.10 +#include "mesh.h" 1.11 + 1.12 +class Curve { 1.13 +private: 1.14 + std::string name; 1.15 + 1.16 + std::vector<Vector3> cv; 1.17 + float thickness; 1.18 + 1.19 + int segm_subdiv, ring_subdiv; 1.20 + 1.21 + /// normalized arc-lengths of each control vertex from the beginning 1.22 + mutable std::vector<float> length; 1.23 + mutable bool lengths_valid; 1.24 + 1.25 + mutable Vector3 bbmin, bbmax; 1.26 + mutable bool bbox_valid; 1.27 + 1.28 + mutable Mesh mesh; 1.29 + mutable bool mesh_valid; 1.30 + 1.31 + float reparametrize(float t) const; 1.32 + 1.33 + void calc_cvlengths() const; 1.34 + void update_mesh() const; 1.35 + 1.36 +public: 1.37 + Curve(); 1.38 + Curve(const Vector3 *points, int num_points); 1.39 + Curve(const Vector2 *points, int num_points); 1.40 + 1.41 + void set_name(const char *name); 1.42 + const char *get_name() const; 1.43 + 1.44 + bool empty() const; 1.45 + 1.46 + void set_thickness(float thickness); 1.47 + void set_subdiv(int seg, int ring); 1.48 + 1.49 + void clear(); 1.50 + void add_point(const Vector3 &pt); 1.51 + Vector3 &get_point(int idx); 1.52 + const Vector3 &get_point(int idx) const; 1.53 + int get_count() const; 1.54 + 1.55 + Vector3 &operator[] (int idx); 1.56 + const Vector3 &operator[] (int idx) const; 1.57 + 1.58 + void get_bbox(Vector3 *bbmin, Vector3 *bbmax) const; 1.59 + void normalize(); 1.60 + 1.61 + Vector3 get_pos(float t) const; 1.62 + Vector3 operator() (float t) const; 1.63 + 1.64 + void draw() const; 1.65 +}; 1.66 + 1.67 +#endif // CURVE_H_