goat3d

annotate src/xform_node.h @ 3:31cf61bfd29d

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