rayzor

view src/snode.h @ 14:a9a948809c6f

starting the renderer screen, plus misc stuff
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 13 Apr 2014 08:06:21 +0300
parents 964f8ea5f095
children 79609d482762
line source
1 #ifndef SCENE_NODE_H_
2 #define SCENE_NODE_H_
4 #include "vector.h"
5 #include "vmath.h"
6 #include "quat.h"
7 #include "vmathmat.h"
8 #include "vmathray.h"
10 enum NodeType {
11 NODE_NULL,
12 NODE_OBJECT,
13 NODE_LIGHT,
14 NODE_CAMERA
15 };
17 class SceneNode {
18 protected:
19 char *name;
20 NodeType type;
22 Vector3 pos;
23 Quat rot;
24 Vector3 scale;
25 Vector3 pivot;
27 mutable Matrix4x4 xform, inv_xform;
28 mutable bool xform_valid, inv_xform_valid;
30 vector<SceneNode*> children;
31 SceneNode *parent;
33 SceneNode(const SceneNode &node) {}
34 SceneNode &operator =(const SceneNode &node) { return *this; }
36 void invalidate() const;
37 virtual void calc_matrix() const;
38 virtual void calc_inv_matrix() const;
40 virtual void pre_draw() const;
41 virtual void post_draw() const;
43 public:
44 SceneNode();
45 virtual ~SceneNode();
47 virtual void set_name(const char *name);
48 virtual const char *get_name() const;
50 virtual NodeType get_type() const;
52 virtual SceneNode *get_parent();
53 virtual const SceneNode *get_parent() const;
55 // children management
56 virtual void add_child(SceneNode *child);
57 virtual void remove_child(SceneNode *child);
59 virtual int get_children_count() const;
60 virtual SceneNode *get_child(int idx);
61 virtual const SceneNode *get_child(int idx) const;
63 virtual void set_position(const Vector3 &pos);
64 virtual Vector3 get_node_position() const;
66 virtual void set_rotation(const Quat &quat);
67 virtual Quat get_node_rotation() const;
69 virtual void set_scaling(const Vector3 &scale);
70 virtual Vector3 get_node_scaling() const;
72 // these take hierarchy into account
73 virtual Vector3 get_position() const;
74 virtual Quat get_rotation() const;
75 virtual Vector3 get_scaling() const;
77 virtual void set_pivot(const Vector3 &pivot);
78 virtual Vector3 get_pivot() const;
80 virtual const Matrix4x4 &get_matrix() const;
81 virtual const Matrix4x4 &get_inv_matrix() const;
83 virtual void draw(bool emph = false) const;
85 virtual bool intersect(const Ray &ray, float *dist = 0) const;
86 };
88 #endif /* SCENE_NODE_H_ */