Vertex3D: position; normal; tcoord

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Cyberdrill
Posts: 18
Joined: Wed Feb 27, 2008 2:32 pm
Location: Russia, Moscow

Vertex3D: position; normal; tcoord

Post by Cyberdrill »

I try to fill Mesh buffer with vertices, so when i try to create vertice it ask me for parameters:

position - it's clear...
normal - what is this? What is the geometric sense of this vector
(
for example I try to create pyramid mesh like this: http://en.wikipedia.org/wiki/Polygon_mesh
and what normal vector will be for Vertex1 from article? ... )

tcoord - the same question :)

:shock:
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

A normal vector is perpendicular to the polygon. So for example for floor polygons it will be upwards and for the ceiling it will be downwards. It's always useful to check the wikipedia (or google) if you are unsure about such stuff. See for example: http://en.wikipedia.org/wiki/Surface_normal

edit: Irrlicht supports you somewhat in calculating normals. As normals are perpendicular to a plane you have to calculate first a plane. You can use irr::core::plane3d by giving 3 vertices to setPlane. This will already calculate the normal for you (Normal is a public member of plane3d).

Texture coordinates are for mapping a texture on a polygon. So for each vertex of the polygon you need 2 coordinates which set the x/y position on the texture. The coordiantes are floats between 0 and 1, so left/top is (0,0 ) and right/bottom is (1,1).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Cyberdrill
Posts: 18
Joined: Wed Feb 27, 2008 2:32 pm
Location: Russia, Moscow

Post by Cyberdrill »

Thanks... But some more questions:

It's clear for me what normal to surface is. But normal for vertice? :) ...

For example I try define pyramid ABCDE (ABCD - base).
What normal should be for Vertice E? ... Maybe there is some algoritm for definig vertices? Maybe somebody could give ready custom Mesh creation with comments?...
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

I'm not sure if vertex-normals have a real fixed definition, don't nail me on that, but I think I've read that there are different algorithms to calculate those. In principle it's some average of the edges leading to the vertex.

I think Irrlicht can do those calculations for you. Try using recalculateNormals in the meshmanipulator.

Example 03 shows how to create a custom scenenode. Or you can also check the sources for the CCubeSceneNode.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Geometry is rendered by vertices (well by pixels but those are computed from vertices). Normal of vertex affects hove much light will be reflected by that vertex in to which direction so normals influence hove your model will be lit by light.

Your vertex E should (but don't have to) point up: vector(0,1,0). Its up to you to decide normal vector.
A normal vector is perpendicular to the polygon.
Not necessarily, if you want sharp edges of polygoons than yes, vertex normal should be perpendicular to the polygoon it belongs. If you however want your mesh to look smooth, normal should be the same for all vetrices which meet in one spot (like your E) even if they belongs to different polygoons. Normal of those vertices should be kind of average of what their normals would be if they were perpendicular to their polygoons.
Also often vertices are shared by several polygoons, In which case you have no other possibility then made it average.
Post Reply