Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Normal question

$
0
0
If I had a quad which consists of 2 tris, when I work out their face normals, why one would face up, the other face down? DWORD numVerts = pMesh->GetNumVertices(); DWORD numTris = pMesh->GetNumFaces(); VertexPN* v = NULL; DWORD* id = NULL; std::vector<VertexPN> verts; pMesh->LockVertexBuffer(0, (void**)&v); for (int i = 0; i < numVerts; i++) { const VertexPN& _v = v[i]; verts.push_back(_v); } pMesh->UnlockVertexBuffer(); pMesh->LockIndexBuffer(0, (void**)&id); for (int i = 0; i < numTris; i++) { const VertexPN& v0 = verts[id[i*3+0]]; const VertexPN& v1 = verts[id[i*3+1]]; const VertexPN& v2 = verts[id[i*3+2]]; D3DXVECTOR3 faceNormal; D3DXVec3Cross(&faceNormal, &v0.pos, &v1.pos); if (faceNormal.y > 0) { TRACE("Face #" << i << " is up" << "\n"); ChangeAttrib(i, 246); } TRACE("Face #: " << i << " normal is y:" << faceNormal.y << "\n"); } pMesh->UnlockIndexBuffer();

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>