gpuray_glsl

annotate src/xform_node.h @ 5:000017955721

fixed the cone normal
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 11 Nov 2014 20:25:59 +0200
parents
children
rev   line source
nuclear@0 1 /*
nuclear@0 2 TODO: add multiple animations per node in libanim (i.e. multiple sets of tracks)
nuclear@0 3 */
nuclear@0 4 #ifndef XFORM_NODE_H_
nuclear@0 5 #define XFORM_NODE_H_
nuclear@0 6
nuclear@0 7 #include <vector>
nuclear@0 8 #include "vmath/vector.h"
nuclear@0 9 #include "vmath/quat.h"
nuclear@0 10 #include "vmath/matrix.h"
nuclear@0 11
nuclear@0 12 enum Interp { INTERP_STEP, INTERP_LINEAR, INTERP_CUBIC };
nuclear@0 13 enum Extrap { EXTRAP_EXTEND, EXTRAP_CLAMP, EXTRAP_REPEAT, EXTRAP_PINGPONG };
nuclear@0 14
nuclear@0 15 struct anm_node;
nuclear@0 16 struct anm_track;
nuclear@0 17
nuclear@0 18 // XXX all time arguments are milliseconds
nuclear@0 19
nuclear@0 20 class XFormNode {
nuclear@0 21 private:
nuclear@0 22 struct anm_node *anm;
nuclear@0 23 std::vector<XFormNode*> children;
nuclear@0 24
nuclear@0 25 Interp interp;
nuclear@0 26 Extrap extrap;
nuclear@0 27
nuclear@0 28 Matrix4x4 local_matrix;
nuclear@0 29 Matrix4x4 bone_matrix;
nuclear@0 30
nuclear@0 31 XFormNode(const XFormNode &node) {}
nuclear@0 32 XFormNode &operator =(const XFormNode &node) { return *this; }
nuclear@0 33
nuclear@0 34 public:
nuclear@0 35 XFormNode();
nuclear@0 36 virtual ~XFormNode();
nuclear@0 37
nuclear@0 38 void set_name(const char *name);
nuclear@0 39 const char *get_name() const;
nuclear@0 40
nuclear@0 41 void set_interpolator(Interp in);
nuclear@0 42 Interp get_interpolator() const;
nuclear@0 43 void set_extrapolator(Extrap ex);
nuclear@0 44 Extrap get_extrapolator() const;
nuclear@0 45
nuclear@0 46 // children management
nuclear@0 47 void add_child(XFormNode *child);
nuclear@0 48 void remove_child(XFormNode *child);
nuclear@0 49
nuclear@0 50 int get_children_count() const;
nuclear@0 51 XFormNode *get_child(int idx);
nuclear@0 52 const XFormNode *get_child(int idx) const;
nuclear@0 53
nuclear@0 54
nuclear@0 55 void set_position(const Vector3 &pos, long tmsec = 0);
nuclear@0 56 Vector3 get_node_position(long tmsec = 0) const;
nuclear@0 57
nuclear@0 58 void set_rotation(const Quaternion &quat, long tmsec = 0);
nuclear@0 59 Quaternion get_node_rotation(long tmsec = 0) const;
nuclear@0 60
nuclear@0 61 void set_scaling(const Vector3 &pos, long tmsec = 0);
nuclear@0 62 Vector3 get_node_scaling(long tmsec = 0) const;
nuclear@0 63
nuclear@0 64 // these take hierarchy into account
nuclear@0 65 Vector3 get_position(long tmsec = 0) const;
nuclear@0 66 Quaternion get_rotation(long tmsec = 0) const;
nuclear@0 67 Vector3 get_scaling(long tmsec = 0) const;
nuclear@0 68
nuclear@0 69 void set_pivot(const Vector3 &pivot);
nuclear@0 70 Vector3 get_pivot() const;
nuclear@0 71
nuclear@0 72 // the local matrix is concatenated with the regular node/anim matrix
nuclear@0 73 void set_local_matrix(const Matrix4x4 &mat);
nuclear@0 74 const Matrix4x4 &get_local_matrix() const;
nuclear@0 75
nuclear@0 76 // for bone nodes, the transformation of the bone in bind position
nuclear@0 77 void set_bone_matrix(const Matrix4x4 &bmat);
nuclear@0 78 const Matrix4x4 &get_bone_matrix() const;
nuclear@0 79
nuclear@0 80 // node transformation alone
nuclear@0 81 void get_node_xform(long tmsec, Matrix4x4 *mat, Matrix4x4 *inv_mat = 0) const;
nuclear@0 82
nuclear@0 83 // node transformation taking hierarchy into account
nuclear@0 84 void get_xform(long tmsec, Matrix4x4 *mat, Matrix4x4 *inv_mat = 0) const;
nuclear@0 85 };
nuclear@0 86
nuclear@0 87
nuclear@0 88 class Track {
nuclear@0 89 private:
nuclear@0 90 struct anm_track *trk;
nuclear@0 91 Interp interp;
nuclear@0 92 Extrap extrap;
nuclear@0 93
nuclear@0 94 public:
nuclear@0 95 Track();
nuclear@0 96 ~Track();
nuclear@0 97
nuclear@0 98 Track(const Track &trk);
nuclear@0 99 Track &operator =(const Track &trk);
nuclear@0 100
nuclear@0 101 void set_interpolator(Interp in);
nuclear@0 102 Interp get_interpolator() const;
nuclear@0 103 void set_extrapolator(Extrap ex);
nuclear@0 104 Extrap get_extrapolator() const;
nuclear@0 105
nuclear@0 106 void set_default(double def);
nuclear@0 107
nuclear@0 108 void set_value(float val, long tmsec = 0);
nuclear@0 109 float get_value(long tmsec = 0) const;
nuclear@0 110
nuclear@0 111 // the same as get_value
nuclear@0 112 float operator ()(long tmsec = 0) const;
nuclear@0 113 };
nuclear@0 114
nuclear@0 115 class Track3 {
nuclear@0 116 private:
nuclear@0 117 Track track[3];
nuclear@0 118
nuclear@0 119 public:
nuclear@0 120 void set_interpolator(Interp in);
nuclear@0 121 Interp get_interpolator() const;
nuclear@0 122 void set_extrapolator(Extrap ex);
nuclear@0 123 Extrap get_extrapolator() const;
nuclear@0 124
nuclear@0 125 void set_default(const Vector3 &def);
nuclear@0 126
nuclear@0 127 void set_value(const Vector3 &val, long tmsec = 0);
nuclear@0 128 Vector3 get_value(long tmsec = 0) const;
nuclear@0 129
nuclear@0 130 // the same as get_value
nuclear@0 131 Vector3 operator ()(long tmsec = 0) const;
nuclear@0 132 };
nuclear@0 133
nuclear@0 134 #endif /* XFORM_NODE_H_ */