X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Fscene.h;h=c0a56127fd2212ed4d57eb21c4039183c73616a0;hp=acabd10172c5bab23d107eb4f4d9e86f856fe38d;hb=d29eba477666f0753170d9ad549a4715ce071d04;hpb=dbcb9345c23c5c027d808915962843e7db2d14aa diff --git a/src/scene.h b/src/scene.h index acabd10..c0a5612 100644 --- a/src/scene.h +++ b/src/scene.h @@ -6,17 +6,24 @@ #include "mesh.h" #include "snode.h" #include "texture.h" +#include "dataset.h" +#include "datamap.h" enum { SCNLOAD_FLIPYZ = 1, - SCNLOAD_FLIPTEX = 2 + SCNLOAD_FLIPTEX = 2, + + SCNLOAD_STAGE_IO = 0x4000, + SCNLOAD_STAGE_GL = 0x8000 }; -class Scene { -private: - bool own_texset; +class MetaScene; +class Scene { public: + MetaScene *metascn; + DataMap datamap; + // meshes objects and nodes are owned by Scene std::vector meshes; std::vector objects; @@ -24,18 +31,23 @@ public: Mesh *walk_mesh; - TextureSet *texset; // only owned by Scene if own_texset is true + TextureSet *texset; + void *loader_data; - explicit Scene(TextureSet *tset = 0); + explicit Scene(); ~Scene(); Scene(const Scene &rhs) = delete; Scene &operator =(const Scene &rhs) = delete; void destroy(); + void clear(); // clear all contents (meshes, objects, and nodes) bool load(const char *fname, unsigned int flags = 0); + // merge scn into this scene, leaving scn empty and safe to destroy + bool merge(Scene *scn); + void add_object(Object *obj); bool remove_object(Object *obj); bool have_object(Object *obj) const; @@ -48,6 +60,13 @@ public: bool remove_node(SceneNode *n); bool have_node(SceneNode *n) const; + // find node by name + SceneNode *find_node(const char *name) const; + // match nodes with regexp and return the first that matches + SceneNode *match_node(const char *qstr) const; + // match nodes with regexp and return a list of matches + std::list match_nodes(const char *qstr) const; + /* find and remove all nodes whose names match the regexp * XXX at the moment this has the effect of flattening the hierarchy in the * result scene. If we ever need verbatim extraction of whole subtrees we'll @@ -65,4 +84,16 @@ public: void draw() const; }; +//! Resource manager for Scenes +class SceneSet : public DataSet { +private: + static Scene *create_scene(); + static bool load_scene(Scene *scn, const char *fname); + static bool done_scene(Scene *scn); + static void free_scene(Scene *scn); + +public: + SceneSet(); +}; + #endif // SCENE_H_