X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Fmesh.hh;h=3f0dc24a6dc78c319be23ed521787a625a16e2da;hp=1400cdd2f920680cb2b2b06a9046807a581dc37a;hb=44b3014bce798789e795242d1556cb7449e6386a;hpb=1fb5f7e36af1a4de040bc2989133703b0e0d4a9f diff --git a/src/moof/mesh.hh b/src/moof/mesh.hh index 1400cdd..3f0dc24 100644 --- a/src/moof/mesh.hh +++ b/src/moof/mesh.hh @@ -1,37 +1,41 @@ -/*] Copyright (c) 2009-2010, Charles McGarvey [************************** +/*] Copyright (c) 2009-2011, Charles McGarvey [***************************** **] All rights reserved. * -* vi:ts=4 sw=4 tw=75 -* * Distributable under the terms and conditions of the 2-clause BSD license; * see the file COPYING for a complete text of the license. * -**************************************************************************/ +*****************************************************************************/ #ifndef _MOOF_MESH_HH_ #define _MOOF_MESH_HH_ -/** - * \file mesh.hh - * Defines classes for loading and manipulating meshes. - */ - #include +#include +#include #include #include +#include -#include +#include #include #include #include +/** + * \file mesh.hh + * Defines classes for loading and manipulating meshes. + */ + namespace moof { -class mesh : public boost::noncopyable, public drawable +// forward declarations +class script; + +class mesh : public boost::noncopyable, public entity { public: @@ -39,108 +43,74 @@ public: void draw(scalar alpha = SCALAR(0.0)) const; - struct material { material(const std::string& id) : name(id) {} - + scalar shininess; std::string name; - + vector4 ambient; vector4 diffuse; - vector3 ambient; - vector3 emissive; - vector3 specular; - scalar shininess; + vector4 emissive; + vector4 specular; }; - - //typedef vector3 triangle[3]; - //typedef vector2 triangle_uv[3]; - //typedef vector3 quad[4]; - //typedef vector2 quad_uv[4]; - - //struct triangle - //{ - //vector3 verts[3]; - //vector3& operator [] (int i) { return verts[i]; } - //const vector3& operator [] (int i) const { return verts[i]; } - //}; - - //struct triangle_uv - //{ - //vector2 verts[3]; - //vector2& operator [] (int i) { return verts[i]; } - //const vector2& operator [] (int i) const { return verts[i]; } - //}; - - - //struct quad - //{ - //vector3 verts[4]; - //vector3& operator [] (int i) { return verts[i]; } - //const vector3& operator [] (int i) const { return verts[i]; } - //}; - - - //struct quad_uv - //{ - //vector2 verts[4]; - //vector2& operator [] (int i) { return verts[i]; } - //const vector2& operator [] (int i) const { return verts[i]; } - //}; - - void set_material(int index) const; void set_material(const material& material) const; - struct material_group : public drawable + struct material_group { - material_group() {} - std::vector triangles; std::vector triangles_uv; - - std::vector quads; - std::vector quads_uv; - - - void draw(scalar alpha = SCALAR(0.0)) const; }; - 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; + std::string url; - std::string name; - std::string data; - std::string url; + image_handle texture; + vector2 texrep; - image_handle texture; - vector2 texrep; + std::vector verts; + std::vector faces; - std::vector verts; - std::vector faces; - - std::vector kids; - object_ptr parent; + std::vector kids; + 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: