What are the 3d cube normals used in OpenGL ES?

I have a cube that is defined as:

float vertices[] = { //Vertices according to faces -1.0f, -1.0f, 1.0f, //Vertex 0 1.0f, -1.0f, 1.0f, //v1 -1.0f, 1.0f, 1.0f, //v2 1.0f, 1.0f, 1.0f, //v3 1.0f, -1.0f, 1.0f, //... 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, }; 

What are the normals for this cube? I need actual values ​​for normals.

Do we need 6 or 12 normals? Since OpenGL ES uses only triangles, which means we need 12 normals, but I could be wrong.

+6
opengl-es
source share
2 answers

The normals are indicated for each vertex, and since the normals for the three faces that separate each vertex are orthogonal, you will get some really attractive results by specifying a cube of only 8 vertices and averaging the three face normals to get a normal vertex. It will be shaded like a sphere, but similar to a cube.

Instead, you will need to specify 24 vertices so that each face of the cube is drawn without sharing vertices with any other.

As for the meanings, this is easy. If we assume that x increases to the right, y increases as you move up, and z increases as you move forward, the normal for the right side is (1, 0, 0), on the left there is (-1, 0, 0), the top side (0,1,0) etc. Etc.

To summarize: don't draw a cube, draw 6 quads that have matching vertices

+13
source share

A surface normal is simply a direction vector. Since the normal will be the same for two surfaces that are coplanar, you only need 6 surface normals. However, it often happens that the normals must be determined by the vertex, in which case you will need 36 (one for each vertex of each triangle on each face of the cube).

To calculate normals, simply use the following calculation: http://www.opengl.org/wiki/Calculating_a_Surface_Normal

+4
source share

All Articles