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
238afe3c
Commit
238afe3c
authored
Aug 22, 2015
by
Patrik Huber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a function that calculates the per-vertex normal
parent
681f89e9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
include/eos/render/utils.hpp
include/eos/render/utils.hpp
+18
-0
No files found.
include/eos/render/utils.hpp
View file @
238afe3c
...
...
@@ -79,6 +79,24 @@ inline cv::Vec2f screen_to_clip_space(const cv::Vec2f& screen_coordinates, int s
return
cv
::
Vec2f
(
x_cs
,
y_cs
);
};
/**
* Calculates the normal of a face (or triangle), i.e. the
* per-face normal. Return normal will be normalised.
* Assumes the triangle is given in CCW order, i.e. vertices
* in counterclockwise order on the screen are front-facing.
*
* @param[in] v0 First vertex.
* @param[in] v1 Second vertex.
* @param[in] v2 Third vertex.
* @return The unit-length normal of the given triangle.
*/
cv
::
Vec3f
calculate_face_normal
(
const
cv
::
Vec3f
&
v0
,
const
cv
::
Vec3f
&
v1
,
const
cv
::
Vec3f
&
v2
)
{
cv
::
Vec3f
n
=
(
v1
-
v0
).
cross
(
v2
-
v0
);
// v0-to-v1 x v0-to-v2
n
/=
cv
::
norm
(
n
);
return
n
;
};
/**
* Draws the texture coordinates (uv-coords) of the given mesh
* into an image by looping over the triangles and drawing each
...
...
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