Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Clark Lin
hw3d
Commits
1da10a89
Commit
1da10a89
authored
Jun 26, 2019
by
chili
Browse files
add exception to mesh loading / old assimp dll broken
parent
caf57593
Changes
6
Hide whitespace changes
Inline
Side-by-side
hw3d/App.h
View file @
1da10a89
...
...
@@ -24,5 +24,5 @@ private:
float
speed_factor
=
1.0
f
;
Camera
cam
;
PointLight
light
;
Model
nano
{
wnd
.
Gfx
(),
"Models
\\
nanosuit.obj
"
};
Model
nano
{
wnd
.
Gfx
(),
"Models
\\
boxy.gltf
"
};
};
\ No newline at end of file
hw3d/Bindable.cpp
View file @
1da10a89
...
...
@@ -12,7 +12,7 @@ namespace Bind
return
gfx
.
pDevice
.
Get
();
}
DxgiInfoManager
&
Bindable
::
GetInfoManager
(
Graphics
&
gfx
)
noxnd
DxgiInfoManager
&
Bindable
::
GetInfoManager
(
Graphics
&
gfx
)
{
#ifndef NDEBUG
return
gfx
.
infoManager
;
...
...
hw3d/Bindable.h
View file @
1da10a89
...
...
@@ -12,6 +12,6 @@ namespace Bind
protected:
static
ID3D11DeviceContext
*
GetContext
(
Graphics
&
gfx
)
noexcept
;
static
ID3D11Device
*
GetDevice
(
Graphics
&
gfx
)
noexcept
;
static
DxgiInfoManager
&
GetInfoManager
(
Graphics
&
gfx
)
noxnd
;
static
DxgiInfoManager
&
GetInfoManager
(
Graphics
&
gfx
);
};
}
\ No newline at end of file
hw3d/Mesh.cpp
View file @
1da10a89
#include "Mesh.h"
#include "imgui/imgui.h"
#include <unordered_map>
#include <sstream>
namespace
dx
=
DirectX
;
ModelException
::
ModelException
(
int
line
,
const
char
*
file
,
std
::
string
note
)
noexcept
:
ChiliException
(
line
,
file
),
note
(
std
::
move
(
note
)
)
{}
const
char
*
ModelException
::
what
()
const
noexcept
{
std
::
ostringstream
oss
;
oss
<<
ChiliException
::
what
()
<<
std
::
endl
<<
"[Note] "
<<
GetNote
();
whatBuffer
=
oss
.
str
();
return
whatBuffer
.
c_str
();
}
const
char
*
ModelException
::
GetType
()
const
noexcept
{
return
"Chili Model Exception"
;
}
const
std
::
string
&
ModelException
::
GetNote
()
const
noexcept
{
return
note
;
}
// Mesh
Mesh
::
Mesh
(
Graphics
&
gfx
,
std
::
vector
<
std
::
unique_ptr
<
Bind
::
Bindable
>>
bindPtrs
)
{
...
...
@@ -167,9 +194,16 @@ Model::Model( Graphics& gfx,const std::string fileName )
Assimp
::
Importer
imp
;
const
auto
pScene
=
imp
.
ReadFile
(
fileName
.
c_str
(),
aiProcess_Triangulate
|
aiProcess_JoinIdenticalVertices
aiProcess_JoinIdenticalVertices
|
aiProcess_ConvertToLeftHanded
|
aiProcess_GenNormals
);
if
(
pScene
==
nullptr
)
{
throw
ModelException
(
__LINE__
,
__FILE__
,
imp
.
GetErrorString
()
);
}
for
(
size_t
i
=
0
;
i
<
pScene
->
mNumMeshes
;
i
++
)
{
meshPtrs
.
push_back
(
ParseMesh
(
gfx
,
*
pScene
->
mMeshes
[
i
]
)
);
...
...
hw3d/Mesh.h
View file @
1da10a89
...
...
@@ -8,6 +8,18 @@
#include <assimp/postprocess.h>
#include "ConditionalNoexcept.h"
class
ModelException
:
public
ChiliException
{
public:
ModelException
(
int
line
,
const
char
*
file
,
std
::
string
note
)
noexcept
;
const
char
*
what
()
const
noexcept
override
;
const
char
*
GetType
()
const
noexcept
override
;
const
std
::
string
&
GetNote
()
const
noexcept
;
private:
std
::
string
note
;
};
class
Mesh
:
public
DrawableBase
<
Mesh
>
{
public:
...
...
hw3d/Models/boxy.gltf
0 → 100644
View file @
1da10a89
{
"asset" : {
"generator" : "Khronos glTF Blender I/O v0.9.33",
"version" : "2.0"
},
"scene" : 0,
"scenes" : [
{
"name" : "Scene",
"nodes" : [
0,
1,
2,
4
]
}
],
"nodes" : [
{
"mesh" : 0,
"name" : "Cube"
},
{
"name" : "Light",
"rotation" : [
0.16907575726509094,
0.7558803558349609,
-0.27217137813568115,
0.570947527885437
],
"translation" : [
4.076245307922363,
5.903861999511719,
-1.0054539442062378
]
},
{
"name" : "Camera",
"rotation" : [
0.483536034822464,
0.33687159419059753,
-0.20870360732078552,
0.7804827094078064
],
"translation" : [
7.358891487121582,
4.958309173583984,
6.925790786743164
]
},
{
"mesh" : 1,
"name" : "CubeChild",
"rotation" : [
-0.010719512589275837,
-0.4761998951435089,
0.585468053817749,
0.6560075879096985
],
"translation" : [
-3.221169948577881,
-1.2334983348846436,
-2.5518932342529297
]
},
{
"children" : [
3
],
"mesh" : 2,
"name" : "CubeBase",
"rotation" : [
0.3631047010421753,
0.3055294156074524,
-0.3922312557697296,
0.7880110740661621
],
"translation" : [
0.40776360034942627,
0.32469144463539124,
0.06666954606771469
]
}
],
"materials" : [
{
"doubleSided" : true,
"name" : "Material",
"pbrMetallicRoughness" : {
"baseColorFactor" : [
0.800000011920929,
0.800000011920929,
0.800000011920929,
1
],
"metallicFactor" : 0,
"roughnessFactor" : 0.4000000059604645
}
},
{
"doubleSided" : true,
"name" : "Material.002",
"pbrMetallicRoughness" : {
"baseColorFactor" : [
0.800000011920929,
0.800000011920929,
0.800000011920929,
1
],
"metallicFactor" : 0,
"roughnessFactor" : 0.4000000059604645
}
},
{
"doubleSided" : true,
"name" : "Material.001",
"pbrMetallicRoughness" : {
"baseColorFactor" : [
0.800000011920929,
0.800000011920929,
0.800000011920929,
1
],
"metallicFactor" : 0,
"roughnessFactor" : 0.4000000059604645
}
}
],
"meshes" : [
{
"name" : "Cube",
"primitives" : [
{
"attributes" : {
"POSITION" : 0,
"NORMAL" : 1,
"TEXCOORD_0" : 2
},
"indices" : 3,
"material" : 0
}
]
},
{
"name" : "Cube.001",
"primitives" : [
{
"attributes" : {
"POSITION" : 4,
"NORMAL" : 5,
"TEXCOORD_0" : 6
},
"indices" : 3,
"material" : 1
}
]
},
{
"name" : "Cube.000",
"primitives" : [
{
"attributes" : {
"POSITION" : 7,
"NORMAL" : 8,
"TEXCOORD_0" : 9
},
"indices" : 3,
"material" : 2
}
]
}
],
"accessors" : [
{
"bufferView" : 0,
"componentType" : 5126,
"count" : 24,
"max" : [
1,
1,
1
],
"min" : [
-1,
-1,
-1
],
"type" : "VEC3"
},
{
"bufferView" : 1,
"componentType" : 5126,
"count" : 24,
"type" : "VEC3"
},
{
"bufferView" : 2,
"componentType" : 5126,
"count" : 24,
"type" : "VEC2"
},
{
"bufferView" : 3,
"componentType" : 5123,
"count" : 36,
"type" : "SCALAR"
},
{
"bufferView" : 4,
"componentType" : 5126,
"count" : 24,
"max" : [
1,
1,
1
],
"min" : [
-1,
-1,
-1
],
"type" : "VEC3"
},
{
"bufferView" : 5,
"componentType" : 5126,
"count" : 24,
"type" : "VEC3"
},
{
"bufferView" : 6,
"componentType" : 5126,
"count" : 24,
"type" : "VEC2"
},
{
"bufferView" : 7,
"componentType" : 5126,
"count" : 24,
"max" : [
1,
1,
1
],
"min" : [
-1,
-1,
-1
],
"type" : "VEC3"
},
{
"bufferView" : 8,
"componentType" : 5126,
"count" : 24,
"type" : "VEC3"
},
{
"bufferView" : 9,
"componentType" : 5126,
"count" : 24,
"type" : "VEC2"
}
],
"bufferViews" : [
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 0
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 288
},
{
"buffer" : 0,
"byteLength" : 192,
"byteOffset" : 576
},
{
"buffer" : 0,
"byteLength" : 72,
"byteOffset" : 768
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 840
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 1128
},
{
"buffer" : 0,
"byteLength" : 192,
"byteOffset" : 1416
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 1608
},
{
"buffer" : 0,
"byteLength" : 288,
"byteOffset" : 1896
},
{
"buffer" : 0,
"byteLength" : 192,
"byteOffset" : 2184
}
],
"buffers" : [
{
"byteLength" : 2376,
"u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8AAIC/AACAPwAAgL8AAIC/AACAvwAAgL8AAIC/AACAPwAAgD8AAIC/AACAPwAAgD8AAIC/AACAvwAAgD8AAIA/AACAPwAAgD8AAIA/AACAvwAAgD8AAIC/AACAvwAAgD8AAIC/AACAvwAAgL8AAIA/AACAvwAAgD8AAIA/AACAvwAAgL8AAIC/AACAPwAAgD8AAIA/AACAvwAAgL8AAIA/AACAPwAAgL8AAIA/AACAvwAAgD8AAIA/AACAPwAAgL8AAIC/AACAPwAAgD8AAIA/AACAPwAAgL8AAIA/AACAPwAAgD8AAIC/AACAvwAAgL8AAIC/AACAPwAAgL8AAIA/AACAvwAAgL8AAIA/AACAPwAAgL8AAIC/AAAAAAAAAIAAAIC/AAAAAAAAAIAAAIC/AAAAAAAAAIAAAIC/AAAAAAAAAIAAAIC/AAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAACAAACAvwAAAAAAAACAAACAvwAAAAAAAACAAACAvwAAAAAAAACAAACAvwAAAAAAAACAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAgL8AAACAAAAAAAAAgL8AAACAAAAAAAAAgL8AAACAAAAAAAAAgL8AAACAAAAgPwAAQD8AAMA+AACAPwAAID8AAIA/AADAPgAAQD8AACA/AABAPwAAwD4AAAA/AADAPgAAQD8AACA/AAAAPwAAID8AAAA/AADAPgAAgD4AAMA+AAAAPwAAID8AAIA+AAAgPwAAAAAAAMA+AACAPgAAID8AAIA+AADAPgAAAAAAAMA+AAAAPwAAAD4AAIA+AAAAPgAAAD8AAMA+AACAPgAAYD8AAAA/AAAgPwAAgD4AACA/AAAAPwAAYD8AAIA+"
}
]
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment