X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Fsnode.h;fp=src%2Fsnode.h;h=21cf16db0bc92691895fed17192472c310bc4ab9;hp=0000000000000000000000000000000000000000;hb=b7c92831285013b2a0783bccaf3d900545ebb5ba;hpb=a58455a92c7ecab980cbe1b7e282aeb6bfe7e889 diff --git a/src/snode.h b/src/snode.h new file mode 100644 index 0000000..21cf16d --- /dev/null +++ b/src/snode.h @@ -0,0 +1,67 @@ +#ifndef SNODE_H_ +#define SNODE_H_ + +#include +#include "object.h" +#include "gmath/gmath.h" + +class SceneNode { +private: + char *name; + + Vec3 pos; + Quat rot; + Vec3 scale; + + std::vector obj; + + SceneNode *parent; + std::vector children; + + Mat4 xform; + Mat4 inv_xform; + +public: + SceneNode(); + explicit SceneNode(Object *obj); + ~SceneNode(); + + void set_name(const char *s); + const char *get_name() const; + + void add_child(SceneNode *node); + bool remove_child(SceneNode *node); + + int get_num_children() const; + SceneNode *get_child(int idx) const; + + SceneNode *get_parent() const; + + void add_object(Object *obj); + bool remove_object(Object *obj); + + int get_num_objects() const; + Object *get_object(int idx) const; + + void set_position(const Vec3 &pos); + void set_rotation(const Quat &rot); + void set_scaling(const Vec3 &scale); + + const Vec3 &get_node_position() const; + const Quat &get_node_rotation() const; + const Vec3 &get_node_scaling() const; + + Vec3 get_position() const; + Quat get_rotation() const; + Vec3 get_scaling() const; + + const Mat4 &get_matrix() const; + const Mat4 &get_inv_matrix() const; + + void update_node(float dt = 0.0f); + void update(float dt = 0.0f); + + bool intersect(const Ray &ray, HitPoint *hit) const; +}; + +#endif // SNODE_H_