Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
eos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Richard Torenvliet
eos
Commits
681f89e9
Commit
681f89e9
authored
Aug 22, 2015
by
Patrik Huber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a function to draw the texture coordinate triangles
parent
a8177af5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
include/eos/render/utils.hpp
include/eos/render/utils.hpp
+26
-0
No files found.
include/eos/render/utils.hpp
View file @
681f89e9
...
...
@@ -79,6 +79,32 @@ inline cv::Vec2f screen_to_clip_space(const cv::Vec2f& screen_coordinates, int s
return
cv
::
Vec2f
(
x_cs
,
y_cs
);
};
/**
* Draws the texture coordinates (uv-coords) of the given mesh
* into an image by looping over the triangles and drawing each
* triangle's texcoords.
*
* @param[in] mesh A mesh with texture coordinates.
* @param[in] image An optional image to draw onto.
* @return An image with the texture coordinate triangles drawn in it, 512x512 if no image is given.
*/
cv
::
Mat
draw_texcoords
(
Mesh
mesh
,
cv
::
Mat
image
=
cv
::
Mat
())
{
using
cv
::
Point2f
;
using
cv
::
Scalar
;
if
(
image
.
empty
())
{
image
=
cv
::
Mat
(
512
,
512
,
CV_8UC4
,
Scalar
(
0.0
f
,
0.0
f
,
0.0
f
,
255.0
f
));
}
for
(
const
auto
&
triIdx
:
mesh
.
tvi
)
{
cv
::
line
(
image
,
Point2f
(
mesh
.
texcoords
[
triIdx
[
0
]][
0
]
*
image
.
cols
,
mesh
.
texcoords
[
triIdx
[
0
]][
1
]
*
image
.
rows
),
Point2f
(
mesh
.
texcoords
[
triIdx
[
1
]][
0
]
*
image
.
cols
,
mesh
.
texcoords
[
triIdx
[
1
]][
1
]
*
image
.
rows
),
Scalar
(
255.0
f
,
0.0
f
,
0.0
f
));
cv
::
line
(
image
,
Point2f
(
mesh
.
texcoords
[
triIdx
[
1
]][
0
]
*
image
.
cols
,
mesh
.
texcoords
[
triIdx
[
1
]][
1
]
*
image
.
rows
),
Point2f
(
mesh
.
texcoords
[
triIdx
[
2
]][
0
]
*
image
.
cols
,
mesh
.
texcoords
[
triIdx
[
2
]][
1
]
*
image
.
rows
),
Scalar
(
255.0
f
,
0.0
f
,
0.0
f
));
cv
::
line
(
image
,
Point2f
(
mesh
.
texcoords
[
triIdx
[
2
]][
0
]
*
image
.
cols
,
mesh
.
texcoords
[
triIdx
[
2
]][
1
]
*
image
.
rows
),
Point2f
(
mesh
.
texcoords
[
triIdx
[
0
]][
0
]
*
image
.
cols
,
mesh
.
texcoords
[
triIdx
[
0
]][
1
]
*
image
.
rows
),
Scalar
(
255.0
f
,
0.0
f
,
0.0
f
));
}
return
image
;
};
// TODO: Should go to detail:: namespace, or texturing/utils or whatever.
unsigned
int
get_max_possible_mipmaps_num
(
unsigned
int
width
,
unsigned
int
height
)
{
...
...
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