Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Johannes Braun
glare
Commits
d9b0a3bd
Commit
d9b0a3bd
authored
Aug 23, 2017
by
Johannes Braun
Browse files
Added initial support for non-triangulated mesh conversion
parent
add36593
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/executables/pathtracing/main.cpp
View file @
d9b0a3bd
...
...
@@ -204,7 +204,7 @@ void drawSceneWindow()
}
}
selected_node
->
destroy
();
ImGui
::
ClearSelectableTreeData
();
ImGui
::
ClearSelectableTreeData
(
"tree_scene_graph"
);
}
if
(
ImGui
::
BeginPopup
(
"del_curr_node"
))
...
...
@@ -216,7 +216,7 @@ void drawSceneWindow()
if
(
selected_node
)
selected_node
->
destroy
();
selected_node
=
nullptr
;
ImGui
::
ClearSelectableTreeData
();
ImGui
::
ClearSelectableTreeData
(
"tree_scene_graph"
);
ImGui
::
CloseCurrentPopup
();
}
ImGui
::
SameLine
();
...
...
src/libraries/core/res/collada.cpp
View file @
d9b0a3bd
...
...
@@ -457,6 +457,7 @@ namespace glare::core
const
auto
&
normals
=
sources
[
normals_id
];
const
auto
&
texcoords
=
sources
[
tcoord_id
];
//empty vector if no texcoords are specified.
std
::
vector
<
unsigned
>
vcount
=
string_parse
::
as_vector
<
unsigned
>
(
node
.
child
(
"vcount"
).
child_value
());
std
::
vector
<
unsigned
>
polys
=
string_parse
::
as_vector
<
unsigned
>
(
node
.
child
(
"p"
).
child_value
());
std
::
vector
<
math
::
Vertex
>
vertices
;
std
::
vector
<
unsigned
>
indices
;
...
...
@@ -465,34 +466,53 @@ namespace glare::core
if
(
std
::
string
(
node
.
name
())
==
"polylist"
)
{
for
(
unsigned
i
=
0
;
i
<
polys
.
size
()
/
stride
;
i
+=
1
)
unsigned
i
=
0
;
for
(
auto
vc
=
0
;
vc
<
vcount
.
size
();
++
vc
)
{
auto
count
=
vcount
[
vc
];
math
::
Vertex
vertex
;
const
unsigned
index_pos_x
=
(
polys
[
i
*
stride
])
*
3
;
const
unsigned
index_pos_y
=
(
polys
[
i
*
stride
])
*
3
+
1
;
const
unsigned
index_pos_z
=
(
polys
[
i
*
stride
])
*
3
+
2
;
//Z-Up
vertex
.
position
=
glm
::
vec4
{
positions
[
index_pos_x
],
positions
[
index_pos_y
],
positions
[
index_pos_z
],
1
};
const
unsigned
index_norm_x
=
(
polys
[
i
*
(
stride
)
+
1
])
*
3
;
const
unsigned
index_norm_y
=
(
polys
[
i
*
(
stride
)
+
1
])
*
3
+
1
;
const
unsigned
index_norm_z
=
(
polys
[
i
*
(
stride
)
+
1
])
*
3
+
2
;
vertex
.
normal
=
glm
::
vec4
{
normals
[
index_norm_x
],
normals
[
index_norm_y
],
normals
[
index_norm_z
],
0
};
if
(
stride
==
3
)
int
offset
=
0
;
for
(
auto
p
=
0
;
p
<
count
;
++
p
)
{
vertex
.
texcoord
=
glm
::
vec2
{
texcoords
[
polys
[
i
*
(
stride
)
+
2
]
*
2
],
texcoords
[(
polys
[
i
*
(
stride
)
+
2
]
*
2
)
+
1
]
};
}
else
{
vertex
.
texcoord
=
glm
::
vec2
(
0
);
if
((
p
-
offset
)
>
2
)
{
// 0..1..2..3 will then be
// 0..1..2
// 1..2..3
++
offset
;
p
=
p
-
2
;
}
unsigned
index
=
i
+
((
p
-
offset
==
0
)
?
0
:
(
p
));
math
::
Vertex
vertex
;
const
unsigned
index_pos_x
=
(
polys
[
index
*
stride
])
*
3
;
const
unsigned
index_pos_y
=
(
polys
[
index
*
stride
])
*
3
+
1
;
const
unsigned
index_pos_z
=
(
polys
[
index
*
stride
])
*
3
+
2
;
//Z-Up
vertex
.
position
=
glm
::
vec4
{
positions
[
index_pos_x
],
positions
[
index_pos_y
],
positions
[
index_pos_z
],
1
};
const
unsigned
index_norm_x
=
(
polys
[
index
*
(
stride
)
+
1
])
*
3
;
const
unsigned
index_norm_y
=
(
polys
[
index
*
(
stride
)
+
1
])
*
3
+
1
;
const
unsigned
index_norm_z
=
(
polys
[
index
*
(
stride
)
+
1
])
*
3
+
2
;
vertex
.
normal
=
glm
::
vec4
{
normals
[
index_norm_x
],
normals
[
index_norm_y
],
normals
[
index_norm_z
],
0
};
if
(
stride
==
3
)
{
vertex
.
texcoord
=
glm
::
vec2
{
texcoords
[
polys
[
index
*
(
stride
)
+
2
]
*
2
],
texcoords
[(
polys
[
index
*
(
stride
)
+
2
]
*
2
)
+
1
]
};
}
else
{
vertex
.
texcoord
=
glm
::
vec2
(
0
);
}
indices
.
push_back
(
static_cast
<
int
>
(
vertices
.
size
()));
vertices
.
push_back
(
vertex
);
}
indices
.
push_back
(
static_cast
<
int
>
(
vertices
.
size
()));
vertices
.
push_back
(
vertex
);
i
+=
count
;
}
mesh
=
std
::
make_shared
<
core
::
Mesh
>
(
vertices
,
indices
);
...
...
Write
Preview
Supports
Markdown
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