Forum Discussion
BalajiRam
11 years agoHonored Guest
Vertex order
Hello,
I have the vertices and index data for a model. But some of the faces do not get rendered. After experimenting for a while, i have found that the vertex order is causing the issue. To demonstrate the behavior, here is a small code snippet that i am trying with "OculusRoomTiny" sample. In this code, the vertices correspond to a plane with +Y as its normal and vertices are as shown.
2 3
x--------------x
|--------------|
|--------------|
x--------------x
0 1
If the indices of the two triangles are provided as 2,1,0 2,3,1 - it works.
If the indices of the two triangles are provided as 0,1,2,2,1,3 - it does not work.
But considering that the face has a normal of 0,1,0, I am expecting it to work with 0,1,2,2,1,3 as the indices.
Any suggestion on how the vertex order is determined ?
Here is the code snippet that can be included in "OculusRoomTiny" sample for testing. I haven't done any other change to the sample other than stopping the model[0] from getting moved so that i can see the plane.
Thank you
Regards,
Ram
I have the vertices and index data for a model. But some of the faces do not get rendered. After experimenting for a while, i have found that the vertex order is causing the issue. To demonstrate the behavior, here is a small code snippet that i am trying with "OculusRoomTiny" sample. In this code, the vertices correspond to a plane with +Y as its normal and vertices are as shown.
2 3
x--------------x
|--------------|
|--------------|
x--------------x
0 1
If the indices of the two triangles are provided as 2,1,0 2,3,1 - it works.
If the indices of the two triangles are provided as 0,1,2,2,1,3 - it does not work.
But considering that the face has a normal of 0,1,0, I am expecting it to work with 0,1,2,2,1,3 as the indices.
Any suggestion on how the vertex order is determined ?
Here is the code snippet that can be included in "OculusRoomTiny" sample for testing. I haven't done any other change to the sample other than stopping the model[0] from getting moved so that i can see the plane.
void Model::AddCustomSolid( Color c)
{
Vector3f Vert[][2] =
{
// y = 1 Top face with normal 0,1,0
Vector3f(1.0, 1.0, 1.0), Vector3f(1.0, 1.0),
Vector3f(1.0, 1.0, 0.0), Vector3f(1.0, 0.0),
Vector3f(0.0, 1.0, 1.0), Vector3f(0.0, 1.0),
Vector3f(0.0, 1.0, 0.0), Vector3f(0.0, 0.0),
};
int numOfIndices = 6;
int numOfVertices = 4;
// Works
uint16_t CubeIndices[] =
{
2, 1, 0,
2, 3, 1,
};
//*/
//// Does not work
//uint16_t CubeIndices[] =
//{
// 0, 1, 2,
// 2, 1, 3,
//};
for(int i = 0; i < numOfIndices; i++)
AddIndex(CubeIndices[i] + (uint16_t) numVertices);
for(int v = 0; v < numOfVertices; v++)
{
Vertex vvv;
vvv.Pos = Vert[v][0];
vvv.U = Vert[v][1].x;
vvv.V = Vert[v][1].y;
vvv.C = c;
AddVertex(vvv);
}
}
Thank you
Regards,
Ram
4 Replies
- cyberealityGrand ChampionWhat is it you are trying to accomplish?
- g4cExplorerVertex stitching order is anticlockwise around the surface normal in most engines.
Some 3d tools have it clockwise when physically stitching with a mouse.
Your code disagrees with your post, code implies vertex arranged like:
// y = 1 Top face with normal 0,1,0
Vector3f(1.0, 1.0, 1.0), Vector3f(1.0, 1.0),
Vector3f(1.0, 1.0, 0.0), Vector3f(1.0, 0.0),
Vector3f(0.0, 1.0, 1.0), Vector3f(0.0, 1.0),
Vector3f(0.0, 1.0, 0.0), Vector3f(0.0, 0.0),
VERTEX VIEWED FROM ABOVE
[2].....[0]
: :
: :
: :
[3].....[1]
So just stitch two anticlockwise triangles. - g4cExplorer
"cybereality" wrote:
What is it you are trying to accomplish?
I'll bet a voxel engine... - BalajiRamHonored GuestThank you g4c and cybereality !
As you rightly mentioned, I was not considering the coordinate system while viewing the plane along its normal. Now i understand it.
I am working on viewing a CAD model (mostly machine parts) using Oculus Rift DK2 and using its Direct HMD access.
Regards,
Ram
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device