9 #ifndef DUNE_ASSIMP_MESH
10 #define DUNE_ASSIMP_MESH
15 #include <assimp/scene.h>
16 #include <assimp/Importer.hpp>
17 #include <assimp/postprocess.h>
41 DirectX::XMFLOAT3 position;
42 DirectX::XMFLOAT3 normal;
43 DirectX::XMFLOAT3 tangent;
44 DirectX::XMFLOAT4 color;
45 DirectX::XMFLOAT2 texcoord[AI_MAX_NUMBER_OF_TEXTURECOORDS];
58 void update(
const DirectX::XMFLOAT3& v,
bool first)
68 Assimp::Importer importer_;
69 std::vector<mesh_info> mesh_infos_;
70 std::vector<unsigned int> indices_;
81 virtual void load_internal(
const aiScene* scene, aiNode* node, aiMatrix4x4 transform);
83 void load(
const tstring& file);
89 const aiScene*
const assimp_scene()
const;
99 {
"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
100 {
"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
101 {
"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 },
102 {
"TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0 },
128 DirectX::XMFLOAT3 position;
129 DirectX::XMFLOAT3 normal;
130 DirectX::XMFLOAT2 texcoord;
131 DirectX::XMFLOAT3 tangent;
137 DirectX::XMFLOAT4X4 world;
143 DirectX::XMFLOAT4 diffuse_color;
144 DirectX::XMFLOAT4 specular_color;
145 DirectX::XMFLOAT4 emissive_color;
146 BOOL has_diffuse_tex;
148 BOOL has_specular_tex;
152 FLOAT refractive_index;
161 DirectX::XMFLOAT4 diffuse_color;
162 DirectX::XMFLOAT4 specular_color;
163 DirectX::XMFLOAT4 emissive_color;
164 ID3D11ShaderResourceView* diffuse_tex;
165 ID3D11ShaderResourceView* emissive_tex;
166 ID3D11ShaderResourceView* specular_tex;
167 ID3D11ShaderResourceView* normal_tex;
168 ID3D11ShaderResourceView* alpha_tex;
171 FLOAT refractive_index;
182 std::vector<gilga_vertex> vertices_;
183 std::vector<mesh_data> meshes_;
194 virtual void create(ID3D11Device* device,
const tstring& file);
195 virtual void render(ID3D11DeviceContext* context, DirectX::XMFLOAT4X4* to_clip =
nullptr);
202 void render_direct(ID3D11DeviceContext* context, DirectX::XMFLOAT4X4* to_clip);
214 alpha_tex_slot_ = alpha_tex;
void set_alpha_slot(INT alpha_tex=-1)
Set the texture register for alpha textures.
Definition: assimp_mesh.h:212
Mesh data for CPU side useage.
Definition: assimp_mesh.h:157
A d3d_mesh created with the help of Assimp.
Definition: assimp_mesh.h:35
virtual void create(ID3D11Device *device, const tstring &file)
Create a mesh from a given filename.
Definition: assimp_mesh.cpp:343
const D3D11_INPUT_ELEMENT_DESC gilgamesh_vertex_desc[5]
The default layout for a gigla_mesh.
Definition: assimp_mesh.h:97
A vertex with all its attributes as loaded by Assimp.
Definition: assimp_mesh.h:39
void update_bb(const DirectX::XMFLOAT3 &p)
Update the bounding-box with a new point.
Definition: mesh.h:56
Mesh constant buffer data uploaded to the pixel shader.
Definition: assimp_mesh.h:141
virtual void render(ID3D11DeviceContext *context, DirectX::XMFLOAT4X4 *to_clip=nullptr)
Renders the mesh using the shaders previously set.
Definition: assimp_mesh.cpp:243
size_t num_faces()
Returns the number of faces of a mesh.
Definition: assimp_mesh.cpp:83
An axis-aligned bounding-box.
Definition: mesh.h:28
Default implementation of assimp_mesh (pun intended).
Definition: assimp_mesh.h:113
virtual void destroy()
Destroy a mesh and free all its resources.
Definition: assimp_mesh.cpp:498
void init_bb(const DirectX::XMFLOAT3 &p)
Initialize the bounding-box with a first point.
Definition: mesh.h:43
Mesh constant buffer data uploaded to the vertex shader.
Definition: assimp_mesh.h:135
A wrapper class for a sampler state.
Definition: shader_resource.h:49
void prepare_context(ID3D11DeviceContext *context)
Prepares the context for rendering a gilga_mesh with the correct shader.
Definition: assimp_mesh.cpp:232
void render_direct(ID3D11DeviceContext *context, DirectX::XMFLOAT4X4 *to_clip)
Render the gilga_mesh without touching the current state, which is useful if the shader has been set ...
Definition: assimp_mesh.cpp:249
A wrapper for constant buffers.
Definition: cbuffer.h:27
void push_back(vertex v)
Push back a new vertex: this member needs to be overloaded in derived assimp_mesh objects...
Definition: assimp_mesh.cpp:220
virtual void destroy()
Destroy a mesh and free all its resources.
Definition: assimp_mesh.cpp:64
A gilga_vertex comes with position, normal, one texture coordinate and a tanget.
Definition: assimp_mesh.h:126
A helper struct to supply information about submeshes loaded by Assimp.
Definition: assimp_mesh.h:50
virtual void push_back(vertex v)=0
Push back a new vertex: this member needs to be overloaded in derived assimp_mesh objects...
Main D3D mesh interface class.
Definition: mesh.h:129
size_t num_vertices()
Returns the number of vertices of a mesh.
Definition: assimp_mesh.cpp:73