assimp
[laserbrain_demo] / src / snode.h
1 #ifndef SNODE_H_
2 #define SNODE_H_
3
4 #include <vector>
5 #include "object.h"
6 #include "gmath/gmath.h"
7
8 class SceneNode {
9 private:
10         char *name;
11
12         Vec3 pos;
13         Quat rot;
14         Vec3 scale;
15
16         std::vector<Object*> obj;
17
18         SceneNode *parent;
19         std::vector<SceneNode*> children;
20
21         Mat4 xform;
22         Mat4 inv_xform;
23
24 public:
25         SceneNode();
26         explicit SceneNode(Object *obj);
27         ~SceneNode();
28
29         void set_name(const char *s);
30         const char *get_name() const;
31
32         void add_child(SceneNode *node);
33         bool remove_child(SceneNode *node);
34
35         int get_num_children() const;
36         SceneNode *get_child(int idx) const;
37
38         SceneNode *get_parent() const;
39
40         void add_object(Object *obj);
41         bool remove_object(Object *obj);
42
43         int get_num_objects() const;
44         Object *get_object(int idx) const;
45
46         void set_position(const Vec3 &pos);
47         void set_rotation(const Quat &rot);
48         void set_scaling(const Vec3 &scale);
49
50         const Vec3 &get_node_position() const;
51         const Quat &get_node_rotation() const;
52         const Vec3 &get_node_scaling() const;
53
54         Vec3 get_position() const;
55         Quat get_rotation() const;
56         Vec3 get_scaling() const;
57
58         const Mat4 &get_matrix() const;
59         const Mat4 &get_inv_matrix() const;
60
61         void update_node(float dt = 0.0f);
62         void update(float dt = 0.0f);
63
64         bool intersect(const Ray &ray, HitPoint *hit) const;
65 };
66
67 #endif  // SNODE_H_