goat3d

diff src/xform_node.h @ 47:498ca7ac7047

- placed all the implementation stuff in the g3dimpl namespace - added animation stuff to the public API - started writing animation saving/loading
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 28 Dec 2013 06:47:39 +0200
parents 0fe02696fb1e
children 9ef9de80649c
line diff
     1.1 --- a/src/xform_node.h	Sun Dec 08 03:00:25 2013 +0200
     1.2 +++ b/src/xform_node.h	Sat Dec 28 06:47:39 2013 +0200
     1.3 @@ -1,6 +1,3 @@
     1.4 -/*
     1.5 -TODO: add multiple animations per node in libanim (i.e. multiple sets of tracks)
     1.6 -*/
     1.7  #ifndef XFORM_NODE_H_
     1.8  #define XFORM_NODE_H_
     1.9  
    1.10 @@ -9,13 +6,16 @@
    1.11  #include "vmath/quat.h"
    1.12  #include "vmath/matrix.h"
    1.13  
    1.14 -enum Interp { INTERP_STEP, INTERP_LINEAR, INTERP_CUBIC };
    1.15 -enum Extrap { EXTRAP_EXTEND, EXTRAP_CLAMP, EXTRAP_REPEAT };
    1.16  
    1.17  struct anm_node;
    1.18  struct anm_track;
    1.19  
    1.20 -// XXX all time arguments are milliseconds
    1.21 +namespace g3dimpl {
    1.22 +
    1.23 +enum Interp { INTERP_STEP, INTERP_LINEAR, INTERP_CUBIC };
    1.24 +enum Extrap { EXTRAP_EXTEND, EXTRAP_CLAMP, EXTRAP_REPEAT };
    1.25 +
    1.26 +// NOTE: all time arguments are milliseconds
    1.27  
    1.28  class XFormNode {
    1.29  private:
    1.30 @@ -36,6 +36,9 @@
    1.31  	XFormNode();
    1.32  	virtual ~XFormNode();
    1.33  
    1.34 +	// retrieve the pointer to the underlying libanim data structure
    1.35 +	virtual struct anm_node *get_libanim_node() const;
    1.36 +
    1.37  	virtual void set_name(const char *name);
    1.38  	virtual const char *get_name() const;
    1.39  
    1.40 @@ -44,6 +47,9 @@
    1.41  	virtual void set_extrapolator(Extrap ex);
    1.42  	virtual Extrap get_extrapolator() const;
    1.43  
    1.44 +	virtual XFormNode *get_parent();
    1.45 +	virtual const XFormNode *get_parent() const;
    1.46 +
    1.47  	// children management
    1.48  	virtual void add_child(XFormNode *child);
    1.49  	virtual void remove_child(XFormNode *child);
    1.50 @@ -52,7 +58,24 @@
    1.51  	virtual XFormNode *get_child(int idx);
    1.52  	virtual const XFormNode *get_child(int idx) const;
    1.53  
    1.54 -	virtual XFormNode *get_parent() const;
    1.55 +
    1.56 +	virtual void use_animation(int idx);
    1.57 +	virtual void use_animation(const char *name);
    1.58 +	virtual void use_animation(int aidx, int bidx, float t);
    1.59 +	virtual void use_animation(const char *aname, const char *bname, float t);
    1.60 +
    1.61 +	virtual int get_active_animation_index(int which = 0) const;
    1.62 +	virtual float get_active_animation_mix() const;
    1.63 +
    1.64 +	virtual int get_animation_count() const;
    1.65 +
    1.66 +	// add a new empty animation slot (recursive)
    1.67 +	virtual void add_animation(const char *name = 0);
    1.68 +
    1.69 +	// set/get the current animation name (set is recursive)
    1.70 +	virtual void set_animation_name(const char *name);
    1.71 +	virtual const char *get_animation_name() const;
    1.72 +
    1.73  
    1.74  	virtual void set_position(const Vector3 &pos, long tmsec = 0);
    1.75  	virtual Vector3 get_node_position(long tmsec = 0) const;
    1.76 @@ -133,4 +156,6 @@
    1.77  	Vector3 operator ()(long tmsec = 0) const;
    1.78  };
    1.79  
    1.80 +}	// namespace g3dimpl
    1.81 +
    1.82  #endif	/* XFORM_NODE_H_ */