erebus

view liberebus/src/snode.h @ 46:c4d48a21bc4a

in the middle of the vmath->gph-math port
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 24 Feb 2016 00:26:50 +0200
parents bab25c0ce337
children
line source
1 #ifndef SNODE_H_
2 #define SNODE_H_
4 #include <vector>
5 #include "object.h"
6 #include "gmath/gmath.h"
8 class SceneNode {
9 private:
10 Vec3 pos;
11 Quat rot;
12 Vec3 scale;
14 std::vector<Object*> obj;
16 SceneNode *parent;
17 std::vector<SceneNode*> children;
19 Mat4x4 xform;
20 Mat4x4 inv_xform;
22 public:
23 SceneNode();
24 explicit SceneNode(Object *obj);
26 void add_child(SceneNode *node);
27 bool remove_child(SceneNode *node);
29 int get_num_children() const;
30 SceneNode *get_child(int idx) const;
32 SceneNode *get_parent() const;
34 void add_object(Object *obj);
35 int get_num_objects() const;
36 Object *get_object(int idx) const;
38 void set_position(const Vec3 &pos);
39 void set_rotation(const Quat &rot);
40 void set_scaling(const Vec3 &scale);
42 const Vec3 &get_node_position() const;
43 const Quat &get_node_rotation() const;
44 const Vec3 &get_node_scaling() const;
46 Vec3 get_position() const;
47 Quat get_rotation() const;
48 Vec3 get_scaling() const;
50 const Mat4x4 &get_matrix() const;
51 const Mat4x4 &get_inv_matrix() const;
53 void update_node(long msec = 0);
54 void update(long msec = 0);
56 bool intersect(const Ray &ray, RayHit *hit) const;
57 };
59 #endif // SNODE_H_