Question to VertexBuffer.Position in Box class

I’ve been trying to create customized meshes, i.e. a cube. So a cube has 6 faces and 8 vertices/points. I assume that makes 8 Vertex Positions, 12 Indice groups (=> 12 Triangles) and 24 texture coordinates (4 tex coords for each face) to define.

However when i looked into the jme shape class “Box” i was surprised to find out it has 24 position components in its position buffer.

This seems like the vertices are double defined (other vertex buffers seem to be the same way). For me this seems a little like unnecessary data, so now my question is: to what behavior does this lead and what is the advantage of handling the buffers this way? Is this required for rendering the box also from the inside?

A vertex is all of its attributes. Different attributes = different vertexes. This is basically an OpenGL thing.

Put another way, how else would the GPU line up all of that data? You’d have to include something to relate the position to the other attributes…each one separately. And that would take memory and time.

I am aware that you need different vertex buffers to effectively render an object on screen. I don’t think you understood my question, so let me rephrase this:

This is a mesh i created with 8 Vertex Positions and 12 Triangles. Visually it is seemingly) identical to the box created using the jme Box shape.

Please note that not all faces are displaying here because the normals are not set up properly - apart from that I could confirm this mesh’s buffer should be correctly initialized to display the cube.

So my question is: Why use 24 single vertice positions for a cube when it can be done with 8? and again: Is this because the standard box is rendered from two “sides” instead of just one? (the double defining of positions seems to be imply this)

It’s important for me to know because I need to avoid possible error sources here. Thanks for any tips in advance.

Repeating with more detail:
Because a vertex is not just position. A vertex is position PLUS all of the attributes for the vertex. ie: normal, texture coords, colors, etc. etc.

So a JME box has 24 vertexes because each face needs four vertexes with different normals and texture coordinates than the other faces.

@b5cully said: Please note that not all faces are displaying here because the normals are not set up properly
The point exactly. There is a slight chance that you don't want a smooth cube, and that you want sharp edges. this means 3 normals per cube corners. Meaning 24 normals values...meaning 24 vertices.
1 Like
@nehon said: The point exactly. There is a slight chance that you don't want a smooth cube, and that you want sharp edges. this means 3 normals per cube corners. Meaning 24 normals values...meaning 24 vertices.
Ah that make sense. I was wondering why that cube I had displayed without clear corners...

One more question though: What do normals do? From using 3D software I know normals define from which angle the face is visible (defining “inside” and “outside”), but I’m not sure if this is applicable in this context as well.

That’s it. It helps to know how the object should be lighted, how light will “reflect” on it.

1 Like

Probably more background than you want but if you want to start from the fundamentals, normal + lighting =

2 Likes

aaahhh now that puzzle is coming together slowly. Thanks a lot for the help!