--- /dev/null
+
+/*] Copyright (c) 2009-2010, 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 <iostream>
+
+#include <boost/noncopyable.hpp>
+#include <boost/shared_ptr.hpp>
+
+#include <moof/drawable.hh>
+#include <moof/image.hh>
+#include <moof/math.hh>
+#include <moof/resource.hh>
+
+
+namespace moof {
+
+
+class mesh : public boost::noncopyable, public drawable
+{
+public:
+
+ explicit mesh(const std::string& path);
+
+ void draw(scalar alpha = SCALAR(0.0)) const;
+
+
+ struct material
+ {
+ material(const std::string& id) :
+ name(id) {}
+
+
+ std::string name;
+
+ vector4 diffuse;
+ vector3 ambient;
+ vector3 emissive;
+ vector3 specular;
+ scalar shininess;
+ };
+
+
+ //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
+ {
+ material_group() {}
+
+ std::vector<unsigned> triangles;
+ std::vector<vector2> triangles_uv;
+
+ std::vector<unsigned> quads;
+ std::vector<vector2> quads_uv;
+
+
+ void draw(scalar alpha = SCALAR(0.0)) const;
+ };
+
+
+ class object;
+ typedef boost::shared_ptr<object> object_ptr;
+
+ struct object
+ {
+ object() :
+ texrep(SCALAR(1.0), SCALAR(1.0)) {}
+
+ static object_ptr alloc()
+ {
+ return object_ptr(new object);
+ }
+
+
+ void draw(const mesh& mesh, scalar alpha = SCALAR(0.0)) const;
+
+
+ std::string name;
+ std::string data;
+ std::string url;
+
+ image_handle texture;
+ vector2 texrep;
+
+ std::vector<vector3> verts;
+ std::vector<material_group> faces;
+
+ std::vector<object_ptr> kids;
+ object_ptr parent;
+ };
+
+
+private:
+
+ void import(std::istream& stream);
+
+ std::vector<material> materials_;
+ std::vector<object_ptr> objects_;
+};
+
+typedef resource_handle<mesh> mesh_handle;
+
+
+} // namespace moof
+
+#endif // _MOOF_MESH_HH_
+