X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Fmesh.hh;h=0fbc3cc5b303a526f6aa99f0b19ec075fadeb6e8;hp=cf267fba65d8a437a014301869e24dcf78245d44;hb=6f1b787a10d8ab1a3117a4b8c004dd2d90599608;hpb=c143f7e806766a73cd69dc6e084e977641019ce6 diff --git a/src/moof/mesh.hh b/src/moof/mesh.hh index cf267fb..0fbc3cc 100644 --- a/src/moof/mesh.hh +++ b/src/moof/mesh.hh @@ -18,11 +18,14 @@ */ #include +#include +#include #include #include +#include -#include +#include #include #include #include @@ -31,7 +34,10 @@ namespace moof { -class mesh : public boost::noncopyable, public drawable +class script; + + +class mesh : public boost::noncopyable, public entity { public: @@ -49,9 +55,9 @@ public: std::string name; vector4 diffuse; - vector3 ambient; - vector3 emissive; - vector3 specular; + vector4 ambient; + vector4 emissive; + vector4 specular; scalar shininess; }; @@ -59,13 +65,8 @@ public: void set_material(int index) const; void set_material(const material& material) const; - struct material_group : public drawable + struct material_group { - material_group() {} - - void draw(scalar alpha = SCALAR(0.0)) const; - - std::vector triangles; std::vector triangles_uv; }; @@ -73,20 +74,23 @@ public: class object; typedef boost::shared_ptr object_ptr; + typedef boost::weak_ptr object_weakptr; struct object { - object() : + object(const mesh& m) : + mesh(m), texrep(SCALAR(1.0), SCALAR(1.0)) {} - static object_ptr alloc() + static object_ptr alloc(const mesh& m) { - return object_ptr(new object); + return object_ptr(new object(m)); } + void draw(scalar alpha = SCALAR(0.0), bool recurse = true) const; - void draw(const mesh& mesh, scalar alpha = SCALAR(0.0)) const; + const moof::mesh& mesh; std::string name; std::string data; @@ -99,10 +103,25 @@ public: std::vector faces; std::vector kids; - object_ptr parent; + std::map kids_byname; + object_weakptr parent; }; + object_ptr operator [] (unsigned index) const + { + return objects_[index]; + } + + + /** + * Import script bindings for the mesh class. + * \param The script. + * \param The name of the namespace to import to. + */ + static void import(script& script, const std::string& nspace = ""); + + private: void import(std::istream& stream);