conworlds
diff src/object.h @ 13:283cdfa7dda2
added a crapload of code from goat3dgfx
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 24 Aug 2014 09:41:24 +0300 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/object.h Sun Aug 24 09:41:24 2014 +0300 1.3 @@ -0,0 +1,51 @@ 1.4 +#ifndef OBJECT_H_ 1.5 +#define OBJECT_H_ 1.6 + 1.7 +#include <list> 1.8 +#include "xform_node.h" 1.9 +#include "mesh.h" 1.10 +#include "material.h" 1.11 + 1.12 +enum DrawMode { 1.13 + DRAW_DEFAULT, 1.14 + DRAW_WIREFRAME, 1.15 + DRAW_VERTICES 1.16 +}; 1.17 + 1.18 + 1.19 +class Object : public XFormNode { 1.20 +private: 1.21 + Mesh *mesh; ///< no ownership, just keeping the pointer around 1.22 + static DrawMode draw_mode; 1.23 + 1.24 + bool setup_bones(long msec) const; 1.25 + 1.26 +public: 1.27 + Material material; 1.28 + 1.29 + Object(); 1.30 + 1.31 + /// destroy this object and all the hierarchy of objects hanging below it 1.32 + void destroy_all(); 1.33 + 1.34 + void set_mesh(Mesh *m); 1.35 + Mesh *get_mesh(); 1.36 + const Mesh *get_mesh() const; 1.37 + 1.38 + /// get all the meshes of the subtree rooted in this object @{ 1.39 + std::list<Mesh*> get_all_meshes(); 1.40 + std::list<const Mesh*> get_all_meshes() const; 1.41 + /// @} 1.42 + 1.43 + AABox get_aabbox() const; 1.44 + Sphere get_bsphere() const; 1.45 + 1.46 + void draw(long msec = 0) const; 1.47 + 1.48 + bool intersect(const Ray &ray, HitPoint *hit = 0) const; 1.49 + 1.50 + /// this is mostly for tools, to allow drawing only the wireframe or vertices 1.51 + static DrawMode set_draw_mode(DrawMode mode); 1.52 +}; 1.53 + 1.54 +#endif // OBJECT_H_