Original Post
🔒 Locked
texturing a cube
Advertisement
Well, here's what I have:
And I have 8 of these that represent a cube. Should this be changed?
/** * A class to represent a vertex and its texture coordinates. */class CVertex3d{public: util::CVector3d point; ///< The position of this vertex in 3d space util::CVector3d normal; ///< The normal vector of the vertex. float u, ///< Component of the texture coordinates v; ///< Component of the texture coordinates video::CColor color; ///< Color for the vertexpublic: // misc member functions};And I have 8 of these that represent a cube. Should this be changed?
A cube have 8 corners, but each corner actually have 3 different sets of texture coordinates and normals, so the cube, when using texture coordinates and/or normals, actually have 24 vertices, not 8.
For vertex arrays, a cube or other objects that consists of "hard" edged only, is actually the worst case concerning vertex sharing.
For vertex arrays, a cube or other objects that consists of "hard" edged only, is actually the worst case concerning vertex sharing.
So, even though I'm using vertex arrays, I need to have 24 vertices, one copy for each set of texture coords.
So, this pretty much means that whenever I have two polygons with one point in common, I'll need two versions of that vertex?
Remind me again, the advantages of vertex arrays?
So, this pretty much means that whenever I have two polygons with one point in common, I'll need two versions of that vertex?
Remind me again, the advantages of vertex arrays?
Well in vertex arrays are good in most cases where you can remove redundant vertices. Here the cube with a possibly different texture on each face is a worst case scenario. But supposing for a minute that you have a panel mesh. This is made up of a grid of quads. There will be lots of shared vertices. Supposing that you where applying a single texture right accross the entire face of the mesh then the vertices in middle are shared between multiple quads, but are identical. These can be removed. You would then update the indexes so that they point to the first occurance of the vertex in the vertex array.
I hope that makes it clear.
ace
I hope that makes it clear.
ace
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement