rate up
1
rate down
12 vertices in quad?
Ok, so i\'m not following your tutorials(i\'m really sorry) and i found guy who implemented heightmaps thingie. Ok, so, he made the system who reads the bitmap file and do some shit with it, after that system needs to make all terrain with triangles. so as i know, quad is made out of 2 triangles, one triagle is made out of 3 vertices. so 3+3=6. So why does he do this 12 times? for(j=0; j<(m_terrainHeight-1); j++) { for(i=0; i<(m_terrainWidth-1); i++) { index1 = (m_terrainHeight * j) + i; // Bottom left. index2 = (m_terrainHeight * j) + (i+1); // Bottom right. index3 = (m_terrainHeight * (j+1)) + i; // Upper left. index4 = (m_terrainHeight * (j+1)) + (i+1); // Upper right. // Upper left. vertices[index].position = D3DXVECTOR3(m_heightMap[index3].x, m_heightMap[index3].y, m_heightMap[index3].z); vertices[index].color = D3DXVECTOR4(0.0f, 0.0f, 0.0f, 1.0f); indices[index] = index; index++; // Upper right. vertices[index].position = D3DXVECTOR3(m_heightMap[index4].x, m_heightMap[index4].y, m_heightMap[index4].z); vertices[index].color = D3DXVECTOR4(0.0f, 0.0f, 0.0f, 1.0f); indices[index] = index; index++; // Upper right. vertices[index].position = D3DXVECTOR3(m_heightMap[index4].x, m_heightMap[index4].y, m_heightMap[index4].z); vertices[index].color = D3DXVECTOR4(0.0f, 0.0f, 0.0f, 1.0f); indices[index] = index; index++; // Bottom left. vertices[index].position = D3DXVECTOR3(m_heightMap[index1].x, m_heightMap[index1].y, m_heightMap[index1].z); vertices[index].color = D3DXVECTOR4(0.0f, 0.0f, 0.0f, 1.0f); indices[index] = index; index++; // Bottom left. vertices[index].position = D3DXVECTOR3(m_heightMap[index1].x, m_heightMap[index1].y, m_heightMap[index1].z); vertices[index].color = D3DXVECTOR4(0.0f, 0.0f, 0.0f, 1.0f); indices[index] = index; index++; // Upper left. vertices[index].position = D3DXVECTOR3(m_heightMap[index3].x, m_heightMap[index3].y, m_heightMap[index3].z); vertices[index].color = D3DXVECTOR4(0.0f, 0.0f, 0.0f, 1.0f); indices[index] = index; index++; // Bottom left. vertices[index].position = D3DXVECTOR3(m_heightMap[index1].x, m_heightMap[index1].y, m_heightMap[index1].z); vertices[index].color = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f); indices[index] = index; index++; // Upper right. vertices[index].position = D3DXVECTOR3(m_heightMap[index4].x, m_heightMap[index4].y, m_heightMap[index4].z); vertices[index].color = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f); indices[index] = index; index++; // Upper right. vertices[index].position = D3DXVECTOR3(m_heightMap[index4].x, m_heightMap[index4].y, m_heightMap[index4].z); vertices[index].color = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f); indices[index] = index; index++; // Bottom right. vertices[index].position = D3DXVECTOR3(m_heightMap[index2].x, m_heightMap[index2].y, m_heightMap[index2].z); vertices[index].color = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f); indices[index] = index; index++; // Bottom right. vertices[index].position = D3DXVECTOR3(m_heightMap[index2].x, m_heightMap[index2].y, m_heightMap[index2].z); vertices[index].color = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f); indices[index] = index; index++; // Bottom left. vertices[index].position = D3DXVECTOR3(m_heightMap[index1].x, m_heightMap[index1].y, m_heightMap[index1].z); vertices[index].color = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f); indices[index] = index; index++; } } P.S. dont judge me, i don\'t know how to properly use code thingie.
Comments
to tell you the truth, i can\'t see why he would do that, it doesn\'t make sense to me from looking at this code. you should only have to add up to 6 vertices per square like you said. you could do it less depending on the topology, but i don\'t see why you would need to do it more
on Nov 21 `15
iedoc
Sign in to answer!