]>
Dogcows Code - chaz/yoink/blob - src/moof/mesh.hh
2 /*] Copyright (c) 2009-2011, Charles McGarvey [*****************************
3 **] All rights reserved.
5 * Distributable under the terms and conditions of the 2-clause BSD license;
6 * see the file COPYING for a complete text of the license.
8 *****************************************************************************/
10 #ifndef _MOOF_MESH_HH_
11 #define _MOOF_MESH_HH_
17 #include <boost/noncopyable.hpp>
18 #include <boost/shared_ptr.hpp>
19 #include <boost/weak_ptr.hpp>
21 #include <moof/entity.hh>
22 #include <moof/image.hh>
23 #include <moof/math.hh>
24 #include <moof/resource.hh>
29 * Defines classes for loading and manipulating meshes.
35 // forward declarations
38 class mesh
: public boost::noncopyable
, public entity
42 explicit mesh(const std::string
& path
);
44 void draw(scalar alpha
= SCALAR(0.0)) const;
48 material(const std::string
& id
) :
59 void set_material(int index
) const;
60 void set_material(const material
& material
) const;
64 std::vector
<unsigned> triangles
;
65 std::vector
<vector2
> triangles_uv
;
69 typedef boost::shared_ptr
<object
> object_ptr
;
70 typedef boost::weak_ptr
<object
> object_weakptr
;
74 object(const mesh
& m
) :
76 texrep(SCALAR(1.0), SCALAR(1.0)) {}
78 static object_ptr
alloc(const mesh
& m
)
80 return object_ptr(new object(m
));
84 draw(scalar alpha
= SCALAR(0.0), bool recurse
= true) const;
86 const moof::mesh
& mesh
;
95 std::vector
<vector3
> verts
;
96 std::vector
<material_group
> faces
;
98 std::vector
<object_ptr
> kids
;
99 std::map
<std::string
,object_ptr
> kids_byname
;
100 object_weakptr parent
;
103 object_ptr
operator [] (unsigned index
) const
105 return objects_
[index
];
109 * Import script bindings for the mesh class.
111 * \param The name of the namespace to import to.
113 static void import(script
& script
, const std::string
& nspace
= "");
117 void load(std::istream
& stream
);
119 void load_material(std::istream
& stream
);
120 object_ptr
load_object(std::istream
& stream
, object_ptr parent
);
121 void load_surface(std::istream
& stream
, object_ptr obj
);
123 std::vector
<material
> materials_
;
124 std::vector
<object_ptr
> objects_
;
127 typedef resource_handle
<mesh
> mesh_handle
;
132 #endif // _MOOF_MESH_HH_
This page took 0.041017 seconds and 5 git commands to generate.