tavli

view src/snode.h @ 7:f1ecc2439802

hinges
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 26 Jun 2015 05:23:46 +0300
parents
children
line source
1 #ifndef SNODE_H_
2 #define SNODE_H_
4 #include <vector>
5 #include "object.h"
6 #include "vmath/vmath.h"
7 #include "geom.h"
9 class SceneNode {
10 private:
11 Vector3 pos;
12 Quaternion rot;
13 Vector3 scale;
15 std::vector<Object*> obj;
17 SceneNode *parent;
18 std::vector<SceneNode*> children;
20 Matrix4x4 xform;
21 Matrix4x4 inv_xform;
23 public:
24 SceneNode();
25 explicit SceneNode(Object *obj);
27 void add_child(SceneNode *node);
28 bool remove_child(SceneNode *node);
30 int get_num_children() const;
31 SceneNode *get_child(int idx) const;
33 SceneNode *get_parent() const;
35 void add_object(Object *obj);
36 int get_num_objects() const;
37 Object *get_object(int idx) const;
39 void set_position(const Vector3 &pos);
40 void set_rotation(const Quaternion &rot);
41 void set_scaling(const Vector3 &scale);
43 const Vector3 &get_node_position() const;
44 const Quaternion &get_node_rotation() const;
45 const Vector3 &get_node_scaling() const;
47 Vector3 get_position() const;
48 Quaternion get_rotation() const;
49 Vector3 get_scaling() const;
51 const Matrix4x4 &get_matrix() const;
52 const Matrix4x4 &get_inv_matrix() const;
54 void update_node(long msec = 0);
55 void update(long msec = 0);
57 bool intersect(const Ray &ray, HitPoint *hit) const;
58 };
60 #endif // SNODE_H_