Skip to content

Instantly share code, notes, and snippets.

@finlaybob
Created March 19, 2015 20:18
Show Gist options
  • Save finlaybob/865f579d6651fe1f33df to your computer and use it in GitHub Desktop.
Save finlaybob/865f579d6651fe1f33df to your computer and use it in GitHub Desktop.
Function to utilise the teapot mesh.
void Tess3D::MakeTeapot(void)
{
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 16; j++)
{
meshData.vindex.push_back(TeapotPatches[i].indices[j]);
}
}
for (int i = 0; i < 127; i++)
{
dxVerts d = TeapotControlPoints[i];
glm::vec3 v = glm::vec3(d.x,d.y,d.z);
meshData.vvertex.push_back(v);
}
int vxCount = meshData.vvertex.size();
for (int i = 0; i < 10; i++)
{
if(TeapotPatches[i].mirrorZ == true){
for (int j = 0; j < 16; j++)
{
glm::vec3 v = meshData.vvertex[TeapotPatches[i].indices[j]];
VecTools::mirrorX(v);
meshData.vvertex.push_back(v);
meshData.vindex.push_back(vxCount++);
}
}
}
vxCount = meshData.vvertex.size();
for (int i = 0; i < 10; i++)
{
if(TeapotPatches[i].mirrorZ == true){
for (int j = 0; j < 16; j++)
{
glm::vec3 v = meshData.vvertex[TeapotPatches[i].indices[j]];
VecTools::mirrorZ(v);
VecTools::mirrorX(v);
meshData.vvertex.push_back(v);
meshData.vindex.push_back(vxCount++);
}
}
}
vxCount = meshData.vvertex.size();
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 16; j++)
{
glm::vec3 v = meshData.vvertex[TeapotPatches[i].indices[j]];
VecTools::mirrorZ(v);
meshData.vvertex.push_back(v);
meshData.vindex.push_back(vxCount++);
}
}
this->drawMode = GL_PATCHES;
glPatchParameteri(GL_PATCH_VERTICES,16);
meshData.numIndices = meshData.vindex.size();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment