goat3dgfx

diff src/xform_node.h @ 22:92bfb0206969

- made all XFormNode functions virtual - added XFormNode::get_parent()
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 28 Dec 2013 06:48:23 +0200
parents 7c593721547f
children 07c08d970cb4
line diff
     1.1 --- a/src/xform_node.h	Fri Dec 27 11:59:32 2013 +0200
     1.2 +++ b/src/xform_node.h	Sat Dec 28 06:48:23 2013 +0200
     1.3 @@ -21,6 +21,7 @@
     1.4  private:
     1.5  	struct anm_node *anm;
     1.6  	std::vector<XFormNode*> children;
     1.7 +	XFormNode *parent;
     1.8  
     1.9  	Interp interp;
    1.10  	Extrap extrap;
    1.11 @@ -35,71 +36,74 @@
    1.12  	XFormNode();
    1.13  	virtual ~XFormNode();
    1.14  
    1.15 -	void set_name(const char *name);
    1.16 -	const char *get_name() const;
    1.17 +	virtual void set_name(const char *name);
    1.18 +	virtual const char *get_name() const;
    1.19  
    1.20 -	void set_interpolator(Interp in);
    1.21 -	Interp get_interpolator() const;
    1.22 -	void set_extrapolator(Extrap ex);
    1.23 -	Extrap get_extrapolator() const;
    1.24 +	virtual void set_interpolator(Interp in);
    1.25 +	virtual Interp get_interpolator() const;
    1.26 +	virtual void set_extrapolator(Extrap ex);
    1.27 +	virtual Extrap get_extrapolator() const;
    1.28 +
    1.29 +	virtual XFormNode *get_parent();
    1.30 +	virtual const XFormNode *get_parent() const;
    1.31  
    1.32  	// children management
    1.33 -	void add_child(XFormNode *child);
    1.34 -	void remove_child(XFormNode *child);
    1.35 +	virtual void add_child(XFormNode *child);
    1.36 +	virtual void remove_child(XFormNode *child);
    1.37  
    1.38 -	int get_children_count() const;
    1.39 -	XFormNode *get_child(int idx);
    1.40 -	const XFormNode *get_child(int idx) const;
    1.41 +	virtual int get_children_count() const;
    1.42 +	virtual XFormNode *get_child(int idx);
    1.43 +	virtual const XFormNode *get_child(int idx) const;
    1.44  
    1.45  
    1.46 -	void use_animation(int idx);
    1.47 -	void use_animation(const char *name);
    1.48 -	void use_animation(int aidx, int bidx, float t);
    1.49 -	void use_animation(const char *aname, const char *bname, float t);
    1.50 +	virtual void use_animation(int idx);
    1.51 +	virtual void use_animation(const char *name);
    1.52 +	virtual void use_animation(int aidx, int bidx, float t);
    1.53 +	virtual void use_animation(const char *aname, const char *bname, float t);
    1.54  
    1.55 -	int get_active_animation_index(int which = 0) const;
    1.56 -	float get_active_animation_mix() const;
    1.57 +	virtual int get_active_animation_index(int which = 0) const;
    1.58 +	virtual float get_active_animation_mix() const;
    1.59  
    1.60 -	int get_animation_count() const;
    1.61 +	virtual int get_animation_count() const;
    1.62  
    1.63  	// add a new empty animation slot (recursive)
    1.64 -	void add_animation(const char *name = 0);
    1.65 +	virtual void add_animation(const char *name = 0);
    1.66  
    1.67  	// set/get the current animation name (set is recursive)
    1.68 -	void set_animation_name(const char *name);
    1.69 -	const char *get_animation_name() const;
    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 -	void set_position(const Vector3 &pos, long tmsec = 0);
    1.75 -	Vector3 get_node_position(long tmsec = 0) const;
    1.76 +	virtual void set_position(const Vector3 &pos, long tmsec = 0);
    1.77 +	virtual Vector3 get_node_position(long tmsec = 0) const;
    1.78  
    1.79 -	void set_rotation(const Quaternion &quat, long tmsec = 0);
    1.80 -	Quaternion get_node_rotation(long tmsec = 0) const;
    1.81 +	virtual void set_rotation(const Quaternion &quat, long tmsec = 0);
    1.82 +	virtual Quaternion get_node_rotation(long tmsec = 0) const;
    1.83  
    1.84 -	void set_scaling(const Vector3 &pos, long tmsec = 0);
    1.85 -	Vector3 get_node_scaling(long tmsec = 0) const;
    1.86 +	virtual void set_scaling(const Vector3 &pos, long tmsec = 0);
    1.87 +	virtual Vector3 get_node_scaling(long tmsec = 0) const;
    1.88  
    1.89  	// these take hierarchy into account
    1.90 -	Vector3 get_position(long tmsec = 0) const;
    1.91 -	Quaternion get_rotation(long tmsec = 0) const;
    1.92 -	Vector3 get_scaling(long tmsec = 0) const;
    1.93 +	virtual Vector3 get_position(long tmsec = 0) const;
    1.94 +	virtual Quaternion get_rotation(long tmsec = 0) const;
    1.95 +	virtual Vector3 get_scaling(long tmsec = 0) const;
    1.96  
    1.97 -	void set_pivot(const Vector3 &pivot);
    1.98 -	Vector3 get_pivot() const;
    1.99 +	virtual void set_pivot(const Vector3 &pivot);
   1.100 +	virtual Vector3 get_pivot() const;
   1.101  
   1.102  	// the local matrix is concatenated with the regular node/anim matrix
   1.103 -	void set_local_matrix(const Matrix4x4 &mat);
   1.104 -	const Matrix4x4 &get_local_matrix() const;
   1.105 +	virtual void set_local_matrix(const Matrix4x4 &mat);
   1.106 +	virtual const Matrix4x4 &get_local_matrix() const;
   1.107  
   1.108  	// for bone nodes, the transformation of the bone in bind position
   1.109 -	void set_bone_matrix(const Matrix4x4 &bmat);
   1.110 -	const Matrix4x4 &get_bone_matrix() const;
   1.111 +	virtual void set_bone_matrix(const Matrix4x4 &bmat);
   1.112 +	virtual const Matrix4x4 &get_bone_matrix() const;
   1.113  
   1.114  	// node transformation alone
   1.115 -	void get_node_xform(long tmsec, Matrix4x4 *mat, Matrix4x4 *inv_mat = 0) const;
   1.116 +	virtual void get_node_xform(long tmsec, Matrix4x4 *mat, Matrix4x4 *inv_mat = 0) const;
   1.117  
   1.118  	// node transformation taking hierarchy into account
   1.119 -	void get_xform(long tmsec, Matrix4x4 *mat, Matrix4x4 *inv_mat = 0) const;
   1.120 +	virtual void get_xform(long tmsec, Matrix4x4 *mat, Matrix4x4 *inv_mat = 0) const;
   1.121  };
   1.122  
   1.123