X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fscene.h;h=1cf8dccca4ceeda9ababb6523ed81d32546fea38;hb=227256d6c3c633982a7e7bc1dd224c4f43765b42;hp=7c30445f14885fd966ec7273e31365c8ba254cca;hpb=b7c92831285013b2a0783bccaf3d900545ebb5ba;p=laserbrain_demo diff --git a/src/scene.h b/src/scene.h index 7c30445..1cf8dcc 100644 --- a/src/scene.h +++ b/src/scene.h @@ -2,16 +2,39 @@ #define SCENE_H_ #include +#include #include "mesh.h" #include "snode.h" +#include "texture.h" +#include "dataset.h" +#include "datamap.h" + +enum { + SCNLOAD_FLIPYZ = 1, + SCNLOAD_FLIPTEX = 2, + + SCNLOAD_STAGE_IO = 0x4000, + SCNLOAD_STAGE_GL = 0x8000 +}; + +class MetaScene; class Scene { public: + MetaScene *metascn; + DataMap datamap; + + // meshes objects and nodes are owned by Scene std::vector meshes; std::vector objects; SceneNode *nodes; - Scene(); + Mesh *walk_mesh; + + TextureSet *texset; // only owned by Scene if own_texset is true + void *loader_data; + + explicit Scene(); ~Scene(); Scene(const Scene &rhs) = delete; @@ -19,10 +42,49 @@ public: void destroy(); - bool load(const char *fname); + 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; + + void add_mesh(Mesh *m); + bool remove_mesh(Mesh *m); + bool have_mesh(Mesh *m) const; + + void add_node(SceneNode *n); + bool remove_node(SceneNode *n); + bool have_node(SceneNode *n) 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 + * need to change the algorithm. + */ + Scene *extract_nodes(const char *qstr); + + /* bake all node transformations to their respective meshes and make the + * node transformations identity. + * XXX this assumes no mesh is shared by two nodes. + */ + void apply_xform(); void update(float dt); void draw() const; }; +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_