tavli
diff src/snode.h @ 3:94aff2ff1934
too much?
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 22 Jun 2015 21:46:57 +0300 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/snode.h Mon Jun 22 21:46:57 2015 +0300 1.3 @@ -0,0 +1,60 @@ 1.4 +#ifndef SNODE_H_ 1.5 +#define SNODE_H_ 1.6 + 1.7 +#include <vector> 1.8 +#include "object.h" 1.9 +#include "vmath/vmath.h" 1.10 +#include "geom.h" 1.11 + 1.12 +class SceneNode { 1.13 +private: 1.14 + Vector3 pos; 1.15 + Quaternion rot; 1.16 + Vector3 scale; 1.17 + 1.18 + std::vector<Object*> obj; 1.19 + 1.20 + SceneNode *parent; 1.21 + std::vector<SceneNode*> children; 1.22 + 1.23 + Matrix4x4 xform; 1.24 + Matrix4x4 inv_xform; 1.25 + 1.26 +public: 1.27 + SceneNode(); 1.28 + explicit SceneNode(Object *obj); 1.29 + 1.30 + void add_child(SceneNode *node); 1.31 + bool remove_child(SceneNode *node); 1.32 + 1.33 + int get_num_children() const; 1.34 + SceneNode *get_child(int idx) const; 1.35 + 1.36 + SceneNode *get_parent() const; 1.37 + 1.38 + void add_object(Object *obj); 1.39 + int get_num_objects() const; 1.40 + Object *get_object(int idx) const; 1.41 + 1.42 + void set_position(const Vector3 &pos); 1.43 + void set_rotation(const Quaternion &rot); 1.44 + void set_scaling(const Vector3 &scale); 1.45 + 1.46 + const Vector3 &get_node_position() const; 1.47 + const Quaternion &get_node_rotation() const; 1.48 + const Vector3 &get_node_scaling() const; 1.49 + 1.50 + Vector3 get_position() const; 1.51 + Quaternion get_rotation() const; 1.52 + Vector3 get_scaling() const; 1.53 + 1.54 + const Matrix4x4 &get_matrix() const; 1.55 + const Matrix4x4 &get_inv_matrix() const; 1.56 + 1.57 + void update_node(long msec = 0); 1.58 + void update(long msec = 0); 1.59 + 1.60 + bool intersect(const Ray &ray, HitPoint *hit) const; 1.61 +}; 1.62 + 1.63 +#endif // SNODE_H_