Tag: 法线

计算三angular形网格中的法线

我绘制了一个有10000个顶点(100×100)的三angular形网格,这将是一个草地。 我使用gldrawelements()。 我看了整天,仍然不明白如何计算这个法线。 每个顶点都有自己的法线,还是每个三angular形都有自己的法线? 有人可以指导我如何编辑我的代码,以正确的方向? struct vertices { GLfloat x; GLfloat y; GLfloat z; }vertices[10000]; GLuint indices[60000]; /* 99..9999 98..9998 …….. 01..9901 00..9900 */ void CreateEnvironment() { int count=0; for (float x=0;x<10.0;x+=.1) { for (float z=0;z<10.0;z+=.1) { vertices[count].x=x; vertices[count].y=0; vertices[count].z=z; count++; } } count=0; for (GLuint a=0;a<99;a++){ for (GLuint b=0;b<99;b++){ GLuint v1=(a*100)+b;indices[count]=v1;count++; GLuint v2=(a*100)+b+1;indices[count]=v2;count++; GLuint […]