The Dirtchamber
A mixed reality testing environment for real-time global illumination algorithms
composite_mesh.h
Go to the documentation of this file.
1 /*
2  * Dune D3D library - Tobias Alexander Franke 2011
3  * For copyright and license see LICENSE
4  * http://www.tobias-franke.eu
5  */
6 
9 #ifndef DUNE_COMPOSITE_MESH
10 #define DUNE_COMPOSITE_MESH
11 
12 #include "mesh.h"
13 
14 #include <memory>
15 #include <vector>
16 
17 namespace dune
18 {
28  class composite_mesh : public d3d_mesh
29  {
30  protected:
31  typedef std::shared_ptr<d3d_mesh> mesh_ptr;
32  std::vector<mesh_ptr> meshes_;
33 
34  public:
35  size_t num_vertices();
36  size_t num_faces();
37 
38  virtual void set_world(const DirectX::XMFLOAT4X4& world);
39 
40  void set_shader(ID3D11Device* device, ID3DBlob* input_binary, ID3D11VertexShader* vs, ID3D11PixelShader* ps);
41 
42  virtual void set_shader_slots(INT diffuse_tex = -1, INT specular_tex = -1, INT normal_tex = -1);
43 
44  void create(ID3D11Device* device, const tstring& file);
45 
56  void create_from_dir(ID3D11Device* device, const tstring& pattern);
57 
59  void push_back(mesh_ptr& m);
60  void render(ID3D11DeviceContext* context, DirectX::XMFLOAT4X4* to_clip = nullptr);
61 
63  mesh_ptr operator[](size_t i);
64 
66  inline size_t size() { return meshes_.size(); }
67 
68  virtual void destroy();
69  };
70 }
71 
72 #endif // COMPOSITE_MESH
void push_back(mesh_ptr &m)
Add a new mesh m to the composite_mesh.
Definition: composite_mesh.cpp:107
A mesh composed from other meshes.
Definition: composite_mesh.h:28
virtual void set_world(const DirectX::XMFLOAT4X4 &world)
Update the world matrix of this mesh.
Definition: composite_mesh.cpp:18
void render(ID3D11DeviceContext *context, DirectX::XMFLOAT4X4 *to_clip=nullptr)
Renders the mesh using the shaders previously set.
Definition: composite_mesh.cpp:80
void create_from_dir(ID3D11Device *device, const tstring &pattern)
Create a composite_mesh from a filename pattern.
Definition: composite_mesh.cpp:51
mesh_ptr operator[](size_t i)
Returns the mesh at index i.
Definition: composite_mesh.cpp:117
const DirectX::XMFLOAT4X4 & world()
Returns the current world matrix of this mesh.
Definition: mesh.h:79
virtual void destroy()
Destroy a mesh and free all its resources.
Definition: composite_mesh.cpp:85
size_t size()
Returns the number of submeshes.
Definition: composite_mesh.h:66
void create(ID3D11Device *device, const tstring &file)
Create a mesh from a given filename.
Definition: composite_mesh.cpp:32
virtual void set_shader_slots(INT diffuse_tex=-1, INT specular_tex=-1, INT normal_tex=-1)
Sets three register numbers to identify the slots the pixel shader is looking for surface textures...
Definition: composite_mesh.cpp:112
A basic pattern.
Definition: tracker.h:28
Main D3D mesh interface class.
Definition: mesh.h:129
size_t num_vertices()
Returns the number of vertices of a mesh.
Definition: composite_mesh.cpp:93
size_t num_faces()
Returns the number of faces of a mesh.
Definition: composite_mesh.cpp:100
void set_shader(ID3D11Device *device, ID3DBlob *input_binary, ID3D11VertexShader *vs, ID3D11PixelShader *ps)
Sets the input layout, vertex- and pixel shader of this mesh.
Definition: composite_mesh.cpp:24