Пример #1
0
void generateSphere(GLuint program, ShapeData* sphereData)
{
    tetrahedron(N);

    sphereData->numVertices = numSphereVertices;

    // Normals
    for (int i = 0; i < numSphereVertices; i++)
    {
        sphereNormals[i] = point3(spherePoints[i].x, spherePoints[i].y, spherePoints[i].z);
    }
    
    // TexCoords
    double u, v;
    for (int i = 0; i < numSphereVertices; i++)
    {
        v = 0.5 - asin(spherePoints[i].y)/M_PI ; //0~1
        u = 0.5*(atan2(spherePoints[i].z,spherePoints[i].x)/M_PI + 1); //0~1
        sphereUVs[i] = point2(u,v);
    }

    // Create a vertex array object
    glGenVertexArrays( 1, &sphereData->vao );
    glBindVertexArray( sphereData->vao );

    // Set vertex attributes
    setVertexAttrib(program,
        (float*)spherePoints,  sizeof(spherePoints),
        (float*)sphereNormals, sizeof(sphereNormals),
        (float*)sphereUVs, sizeof(sphereUVs));
}
Пример #2
0
void generateTriPrism(GLuint program, ShapeData* triPrismData)
{
	int Index = 0;
	point3 p1(1.0f, -0.5f, 0.0f);
	point3 p2(0.0f, -0.5f, 0.0f);
	point3 p3(0.0f, -0.5f, 1.0f);
	point3 p4(1.0f,  0.5f, 0.0f);
	point3 p5(0.0f,  0.5f, 0.0f);
	point3 p6(0.0f,  0.5f, 1.0f);

	// Bottom of the triangular prism
	triPrismPoints[Index] = p1; triPrismNormals[Index] = point3(0.0f, -1.0f, 0.0f); Index++;
	triPrismPoints[Index] = p3; triPrismNormals[Index] = point3(0.0f, -1.0f, 0.0f); Index++;
	triPrismPoints[Index] = p2; triPrismNormals[Index] = point3(0.0f, -1.0f, 0.0f); Index++;

	// Top of the triangular prism
	triPrismPoints[Index] = p4; triPrismNormals[Index] = point3(0.0f, 1.0f, 0.0f); Index++;
	triPrismPoints[Index] = p5; triPrismNormals[Index] = point3(0.0f, 1.0f, 0.0f); Index++;
	triPrismPoints[Index] = p6; triPrismNormals[Index] = point3(0.0f, 1.0f, 0.0f); Index++;

	// Back of the triangular prism
	triPrismPoints[Index] = p1; triPrismNormals[Index] = point3(0.0f, 0.0f, -1.0f); Index++;
	triPrismPoints[Index] = p2; triPrismNormals[Index] = point3(0.0f, 0.0f, -1.0f); Index++;
	triPrismPoints[Index] = p4; triPrismNormals[Index] = point3(0.0f, 0.0f, -1.0f); Index++;

	triPrismPoints[Index] = p2; triPrismNormals[Index] = point3(0.0f, 0.0f, -1.0f); Index++;
	triPrismPoints[Index] = p5; triPrismNormals[Index] = point3(0.0f, 0.0f, -1.0f); Index++;
	triPrismPoints[Index] = p4; triPrismNormals[Index] = point3(0.0f, 0.0f, -1.0f); Index++;

	// Left of the triangular prism
	triPrismPoints[Index] = p2; triPrismNormals[Index] = point3(-1.0f, 0.0f, 0.0f); Index++;
	triPrismPoints[Index] = p3; triPrismNormals[Index] = point3(-1.0f, 0.0f, 0.0f); Index++;
	triPrismPoints[Index] = p6; triPrismNormals[Index] = point3(-1.0f, 0.0f, 0.0f); Index++;

	triPrismPoints[Index] = p2; triPrismNormals[Index] = point3(-1.0f, 0.0f, 0.0f); Index++;
	triPrismPoints[Index] = p6; triPrismNormals[Index] = point3(-1.0f, 0.0f, 0.0f); Index++;
	triPrismPoints[Index] = p5; triPrismNormals[Index] = point3(-1.0f, 0.0f, 0.0f); Index++;

	// Front of the triangular prism
	triPrismPoints[Index] = p1; triPrismNormals[Index] = point3(1.0f, 0.0f, 1.0f); Index++;
	triPrismPoints[Index] = p6; triPrismNormals[Index] = point3(1.0f, 0.0f, 1.0f); Index++;
	triPrismPoints[Index] = p3; triPrismNormals[Index] = point3(1.0f, 0.0f, 1.0f); Index++;

	triPrismPoints[Index] = p1; triPrismNormals[Index] = point3(1.0f, 0.0f, 1.0f); Index++;
	triPrismPoints[Index] = p4; triPrismNormals[Index] = point3(1.0f, 0.0f, 1.0f); Index++;
	triPrismPoints[Index] = p6; triPrismNormals[Index] = point3(1.0f, 0.0f, 1.0f); Index++;

    triPrismData->numVertices = numTriPrismVertices;

    glGenVertexArrays( 1, &triPrismData->vao );
    glBindVertexArray( triPrismData->vao );

    setVertexAttrib(program,
    				(float*)triPrismPoints, sizeof(triPrismPoints),
    				(float*)triPrismNormals, sizeof(triPrismNormals),
    				0, 0);
}
Пример #3
0
        void apply(osg::Geometry& geom)
        {
            geom.setUseDisplayList(false);

            if (!_manualVertexAliasing) return;

            osg::notify(osg::NOTICE)<<"Found geometry "<<&geom<<std::endl;
            if (geom.getVertexArray())
            {
                setVertexAttrib(geom, _vertexAlias, geom.getVertexArray(), false, osg::Array::BIND_PER_VERTEX);
                geom.setVertexArray(0);
            }

            if (geom.getNormalArray())
            {
                setVertexAttrib(geom, _normalAlias, geom.getNormalArray(), true);
                geom.setNormalArray(0);
            }

            if (geom.getColorArray())
            {
                setVertexAttrib(geom, _colorAlias, geom.getColorArray(), false);
                geom.setColorArray(0);
            }

            if (geom.getSecondaryColorArray())
            {
                setVertexAttrib(geom, _secondaryColorAlias, geom.getSecondaryColorArray(), false);
                geom.setSecondaryColorArray(0);
            }

            if (geom.getFogCoordArray())
            {
                // should we normalize the FogCoord array? Don't think so...
                setVertexAttrib(geom, _fogCoordAlias, geom.getFogCoordArray(), false);
                geom.setFogCoordArray(0);
            }

            unsigned int maxNumTexCoords = geom.getNumTexCoordArrays();
            if (maxNumTexCoords>8)
            {
                osg::notify(osg::NOTICE)<<"Warning: Ignoring "<<maxNumTexCoords-8<<" texture coordinate arrays, only 8 are currently supported in vertex attribute conversion code."<<std::endl;
                maxNumTexCoords = 8;
            }
            for(unsigned int i=0; i<maxNumTexCoords; ++i)
            {
                if (geom.getTexCoordArray(i))
                {
                    setVertexAttrib(geom, _texCoordAlias[i], geom.getTexCoordArray(i), false, osg::Array::BIND_PER_VERTEX);
                    geom.setTexCoordArray(i,0);
                }
                else
                {
                    osg::notify(osg::NOTICE)<<"Found empty TexCoordArray("<<i<<")"<<std::endl;
                }
            }
        }
Пример #4
0
// initialization
void generateCube(GLuint program, ShapeData* cubeData)
{
    colorcube();
    cubeData->numVertices = numCubeVertices;

    // Create a vertex array object
    glGenVertexArrays( 1, &cubeData->vao );
    glBindVertexArray( cubeData->vao );

    // Set vertex attributes
    setVertexAttrib(program, 
        (float*)cubePoints,  sizeof(cubePoints), 
        (float*)cubeNormals, sizeof(cubeNormals),0,0);
//        (float*)cubeUV,      sizeof(cubeUV));
}
Пример #5
0
void duplicateSquare(GLuint program, ShapeData* squareData, vec3 loc)
{
	squareData->numVertices = numSquareVertices;
	squareData->location = loc;
	squareData->color = vec3(0.0);

	//Create a vertex array object
	glGenVertexArrays( 1, &squareData->vao );
	glBindVertexArray( squareData->vao );

    // Set vertex attributes
    setVertexAttrib(program, 
        (float*)squarePoints,  sizeof(squarePoints), 
        (float*)squareNormals, sizeof(squareNormals),
        (float*)squareUV,      sizeof(squareUV));
}
Пример #6
0
void generateCone(GLuint program, ShapeData* coneData)
{
    makeCircle(circlePoints, numConeDivisions);
    int Index = 0;
    makeConeWall(conePoints, coneNormals, numConeDivisions, 1.0f, 1.0f, Index, 1);
    makeConeWall(conePoints, coneNormals, numConeDivisions, 1.0f, -1.0f, Index, -1);
    
    coneData->numVertices = numConeVertices;

    // Create a vertex array object
    glGenVertexArrays( 1, &coneData->vao );
    glBindVertexArray( coneData->vao );
    
    // Set vertex attributes
    setVertexAttrib(program,
                    (float*)conePoints,  sizeof(conePoints),
                    (float*)coneNormals, sizeof(coneNormals),
                    0, 0);
}
Пример #7
0
void generateCylinder(GLuint program, ShapeData* cylData)
{
    makeCircle(circlePoints, numCylDivisions);
    int Index = 0;
    makeConeWall(cylPoints, cylNormals, numCylDivisions, 1.0f, 1.0f, Index, 1);
    makeConeWall(cylPoints, cylNormals, numCylDivisions, -1.0f, -1.0f, Index, -1);
    
    for (int i = 0; i < numCylDivisions; i++)
    {
        int i2 = (i+1)%numCylDivisions;
        point3 p1(circlePoints[i2].x, circlePoints[i2].y, -1.0f);
        point3 p2(circlePoints[i2].x, circlePoints[i2].y, 1.0f);
        point3 p3(circlePoints[i].x,  circlePoints[i].y,  1.0f);
        //point3 n = cross(p3-p2, p1-p2);
        cylPoints[Index] = p1; cylNormals[Index] = point3(p1.x, p1.y, 0.0f); Index++;
        cylPoints[Index] = p2; cylNormals[Index] = point3(p2.x, p2.y, 0.0f); Index++;
        cylPoints[Index] = p3; cylNormals[Index] = point3(p3.x, p3.y, 0.0f); Index++;
        p1 = point3(circlePoints[i2].x, circlePoints[i2].y, -1.0f);
        p2 = point3(circlePoints[i].x,  circlePoints[i].y,  1.0f);
        p3 = point3(circlePoints[i].x,  circlePoints[i].y,  -1.0f);
        //n = cross(p3-p2, p1-p2);
        cylPoints[Index] = p1; cylNormals[Index] = point3(p1.x, p1.y, 0.0f); Index++;
        cylPoints[Index] = p2; cylNormals[Index] = point3(p2.x, p2.y, 0.0f); Index++;
        cylPoints[Index] = p3; cylNormals[Index] = point3(p3.x, p3.y, 0.0f); Index++;
    }
    
    cylData->numVertices = numCylVertices;
    
    // Create a vertex array object
    glGenVertexArrays( 1, &cylData->vao );
    glBindVertexArray( cylData->vao );
    
    // Set vertex attributes
    setVertexAttrib(program,
                    (float*)cylPoints,  sizeof(cylPoints),
                    (float*)cylNormals, sizeof(cylNormals),
                    0, 0);
}
Пример #8
0
void generateRoundCorner(GLuint program, ShapeData* roundCornerData)
{
	point2 outerPoints[numRoundCornerDivisions+1];
	int i, Index = 0;
	float a;

	for(i = 0; i <= numRoundCornerDivisions; i++)
	{
		// First, generate outer points
		a = M_PI / 2.0f + i * M_PI / numRoundCornerDivisions / 2.0f;
		outerPoints[i] = point2(2.0f * cosf(a), -2.0f * sinf(a));
	}

	point3 p1, p2, p3, p4, p5, p6, p7, p8, crs;
	for(i = 0; i < numRoundCornerDivisions; i++)
	{
		p1 = point3(outerPoints[i].x,    0.5f, 0.0f);
		p2 = point3(outerPoints[i].x,   -0.5f, 0.0f);
		p3 = point3(outerPoints[i+1].x,  0.5f, 0.0f);
		p4 = point3(outerPoints[i+1].x, -0.5f, 0.0f);

		p5 = point3(outerPoints[i].x,    0.5f, outerPoints[i].y);
		p6 = point3(outerPoints[i].x,   -0.5f, outerPoints[i].y);
		p7 = point3(outerPoints[i+1].x,  0.5f, outerPoints[i+1].y);
		p8 = point3(outerPoints[i+1].x, -0.5f, outerPoints[i+1].y);

		// Generate Outer Curve phase.
		addTriangle(roundCornerPoints, roundCornerNormals, p5, p6, p7, Index);
		addTriangle(roundCornerPoints, roundCornerNormals, p6, p8, p7, Index);

		// Generate Top flat phase
		addTriangle(roundCornerPoints, roundCornerNormals, p1, p5, p7, Index);
		addTriangle(roundCornerPoints, roundCornerNormals, p1, p7, p3, Index);

		// Generate Bottom flat phase
		addTriangle(roundCornerPoints, roundCornerNormals, p2, p4, p6, Index);
		addTriangle(roundCornerPoints, roundCornerNormals, p4, p8, p6, Index);
	}

	p1 = point3(0.0f,  0.5f, 0.0f);
	p2 = point3(0.0f, -0.5f, 0.0f);
	p3 = point3(outerPoints[0].x,  0.5f, outerPoints[0].y);
	p4 = point3(outerPoints[0].x, -0.5f, outerPoints[0].y);

	// Draw the right flat rectangle
	addTriangle(roundCornerPoints, roundCornerNormals, p1, p2, p4, Index);
	addTriangle(roundCornerPoints, roundCornerNormals, p1, p4, p3, Index);

	p3 = point3(outerPoints[numRoundCornerDivisions].x,  0.5f, outerPoints[numRoundCornerDivisions].y);
	p4 = point3(outerPoints[numRoundCornerDivisions].x, -0.5f, outerPoints[numRoundCornerDivisions].y);

	// Draw the right flat rectangle
	addTriangle(roundCornerPoints, roundCornerNormals, p1, p3, p2, Index);
	addTriangle(roundCornerPoints, roundCornerNormals, p3, p4, p2, Index);

    roundCornerData->numVertices = numRoundCornerVertices;

    glGenVertexArrays( 1, &roundCornerData->vao );
    glBindVertexArray( roundCornerData->vao );

    setVertexAttrib(program,
    				(float*)roundCornerPoints, sizeof(roundCornerPoints),
    				(float*)roundCornerNormals, sizeof(roundCornerNormals),
    				0, 0);
}
Пример #9
0
void generateQuarterHole(GLuint program, ShapeData* quarterHoleData)
{
	point2 cirPoints[numQuarterHoleDivisions+1];
	int i, Index = 0;
	for(i = 0; i <= numQuarterHoleDivisions; i++)
	{
		float a =  M_PI / 2.0f + i * M_PI / numQuarterHoleDivisions / 2.0f;
		cirPoints[i] = point2(1.0f + cosf(a), 1.0f - sinf(a));
	}

	point3 p1, p2, p3, p4, p5, p6, p7, p8;
	for(i = 0; i < numQuarterHoleDivisions; i++)
	{
		p1 = point3(cirPoints[i].x,    0.5f, cirPoints[i].y);
		p2 = point3(cirPoints[i].x,   -0.5f, cirPoints[i].y);
		p3 = point3(cirPoints[i+1].x,  0.5f, cirPoints[i+1].y);
		p4 = point3(cirPoints[i+1].x, -0.5f, cirPoints[i+1].y);

		p5 = point3(p1.x, p1.y, 0.0f);
		p6 = point3(p2.x, p2.y, 0.0f);
		p7 = point3(p3.x, p3.y, 0.0f);
		p8 = point3(p4.x, p4.y, 0.0f);

		// Draw the curly phase of the Quarter Hole
		quarterHolePoints[Index] = p1; quarterHoleNormals[Index] = point3(p1.x, 0.0f, p1.z); Index++;
		quarterHolePoints[Index] = p3; quarterHoleNormals[Index] = point3(p3.x, 0.0f, p3.z); Index++;
		quarterHolePoints[Index] = p2; quarterHoleNormals[Index] = point3(p2.x, 0.0f, p2.z); Index++;

		quarterHolePoints[Index] = p2; quarterHoleNormals[Index] = point3(p2.x, 0.0f, p2.z); Index++;
		quarterHolePoints[Index] = p3; quarterHoleNormals[Index] = point3(p3.x, 0.0f, p3.z); Index++;
		quarterHolePoints[Index] = p4; quarterHoleNormals[Index] = point3(p4.x, 0.0f, p4.z); Index++;

		// Draw the Top of the Quarter Hole
		quarterHolePoints[Index] = p1; quarterHoleNormals[Index] = point3(0.0f, 1.0f, 0.0f); Index++;
		quarterHolePoints[Index] = p7; quarterHoleNormals[Index] = point3(0.0f, 1.0f, 0.0f); Index++;
		quarterHolePoints[Index] = p3; quarterHoleNormals[Index] = point3(0.0f, 1.0f, 0.0f); Index++;

		quarterHolePoints[Index] = p1; quarterHoleNormals[Index] = point3(0.0f, 1.0f, 0.0f); Index++;
		quarterHolePoints[Index] = p5; quarterHoleNormals[Index] = point3(0.0f, 1.0f, 0.0f); Index++;
		quarterHolePoints[Index] = p7; quarterHoleNormals[Index] = point3(0.0f, 1.0f, 0.0f); Index++;

		// Draw the Bottom of the Quarter Hole
		quarterHolePoints[Index] = p2; quarterHoleNormals[Index] = point3(0.0f, -1.0f, 0.0f); Index++;
		quarterHolePoints[Index] = p4; quarterHoleNormals[Index] = point3(0.0f, -1.0f, 0.0f); Index++;
		quarterHolePoints[Index] = p8; quarterHoleNormals[Index] = point3(0.0f, -1.0f, 0.0f); Index++;

		quarterHolePoints[Index] = p2; quarterHoleNormals[Index] = point3(0.0f, -1.0f, 0.0f); Index++;
		quarterHolePoints[Index] = p8; quarterHoleNormals[Index] = point3(0.0f, -1.0f, 0.0f); Index++;
		quarterHolePoints[Index] = p6; quarterHoleNormals[Index] = point3(0.0f, -1.0f, 0.0f); Index++;
	}

	p1 = point3(1.0f,  0.5f, 0.0f);
	p2 = point3(1.0f, -0.5f, 0.0f);
	p3 = point3(0.0f,  0.5f, 0.0f);
	p4 = point3(0.0f, -0.5f, 0.0f);
	p5 = point3(0.0f,  0.5f, 1.0f);
	p6 = point3(0.0f, -0.5f, 1.0f);

	// Draw the back of the Quarter Hole
	quarterHolePoints[Index] = p1; quarterHoleNormals[Index] = point3(0.0f, 0.0f, -1.0f); Index++;
	quarterHolePoints[Index] = p2; quarterHoleNormals[Index] = point3(0.0f, 0.0f, -1.0f); Index++;
	quarterHolePoints[Index] = p3; quarterHoleNormals[Index] = point3(0.0f, 0.0f, -1.0f); Index++;

	quarterHolePoints[Index] = p2; quarterHoleNormals[Index] = point3(0.0f, 0.0f, -1.0f); Index++;
	quarterHolePoints[Index] = p4; quarterHoleNormals[Index] = point3(0.0f, 0.0f, -1.0f); Index++;
	quarterHolePoints[Index] = p3; quarterHoleNormals[Index] = point3(0.0f, 0.0f, -1.0f); Index++;

	// Draw the left of the Quarter Hole
	quarterHolePoints[Index] = p3; quarterHoleNormals[Index] = point3(-1.0f, 0.0f, 0.0f); Index++;
	quarterHolePoints[Index] = p4; quarterHoleNormals[Index] = point3(-1.0f, 0.0f, 0.0f); Index++;
	quarterHolePoints[Index] = p5; quarterHoleNormals[Index] = point3(-1.0f, 0.0f, 0.0f); Index++;

	quarterHolePoints[Index] = p4; quarterHoleNormals[Index] = point3(-1.0f, 0.0f, 0.0f); Index++;
	quarterHolePoints[Index] = p6; quarterHoleNormals[Index] = point3(-1.0f, 0.0f, 0.0f); Index++;
	quarterHolePoints[Index] = p5; quarterHoleNormals[Index] = point3(-1.0f, 0.0f, 0.0f); Index++;

	quarterHoleData->numVertices = numQuarterHoleVertices;

    glGenVertexArrays( 1, &quarterHoleData->vao );
    glBindVertexArray( quarterHoleData->vao );

    setVertexAttrib(program,
    				(float*)quarterHolePoints, sizeof(quarterHolePoints),
    				(float*)quarterHoleNormals, sizeof(quarterHoleNormals),
    				0, 0);
}
Пример #10
0
void generateHole(GLuint program, ShapeData* holeData)
{
	makeHalfCircle(circlePoints, numHoleDivisions);
	int Index = 0;

	point3 p1, p2, p3, p4, p5, p6, p7, p8;

    for (int i = 0; i < numHoleDivisions; i++)
    {
    	// First, make the curvy wall of the hole
    	p1 = point3(circlePoints[i].x, circlePoints[i].y-1, 1.0f);
    	p2 = point3(circlePoints[i+1].x, circlePoints[i+1].y-1, -1.0f);
    	p3 = point3(circlePoints[i].x, circlePoints[i].y-1, -1.0f);

    	GLfloat norm_x1 = -p1.x, norm_y1 = -p1.y, norm_x2 = -p2.x, norm_y2 = -p2.y, norm_x3 = -p3.x, norm_y3 = -p3.y;
    	if( i >= numHoleDivisions/2) {
    		norm_x1 = p1.x;
    		norm_y1 = p1.y;
    		norm_x2 = p2.x;
    		norm_y2 = p2.y;
    		norm_x3 = p3.x;
    		norm_y3 = p3.y;
    	}
        holePoints[Index] = p1; holeNormals[Index] = point3(norm_x1, norm_y1, 0.0f); Index++;
        holePoints[Index] = p2; holeNormals[Index] = point3(norm_x2, norm_y2, 0.0f); Index++;
        holePoints[Index] = p3; holeNormals[Index] = point3(norm_x3, norm_y3, 0.0f); Index++;

        p3 = p2;
        p2 = point3(circlePoints[i+1].x,  circlePoints[i+1].y-1,  1.0f);
        holePoints[Index] = p1; holeNormals[Index] = point3(norm_x1, norm_y1, 0.0f); Index++;
        holePoints[Index] = p2; holeNormals[Index] = point3(norm_x2, norm_y2, 0.0f); Index++;
        holePoints[Index] = p3; holeNormals[Index] = point3(norm_x3, norm_y3, 0.0f); Index++;

        // Then, make the front all of the hole
        p3 = point3(circlePoints[i].x, holeHeight-1, 1.0f);
        holePoints[Index] = p1; holeNormals[Index] = point3(0.0f, 0.0f, 1.0f); Index++;
        holePoints[Index] = p3; holeNormals[Index] = point3(0.0f, 0.0f, 1.0f); Index++;
        holePoints[Index] = p2; holeNormals[Index] = point3(0.0f, 0.0f, 1.0f); Index++;

        p1 = point3(circlePoints[i+1].x, holeHeight-1, 1.0f);
        holePoints[Index] = p1; holeNormals[Index] = point3(0.0f, 0.0f, 1.0f); Index++;
        holePoints[Index] = p2; holeNormals[Index] = point3(0.0f, 0.0f, 1.0f); Index++;
        holePoints[Index] = p3; holeNormals[Index] = point3(0.0f, 0.0f, 1.0f); Index++;

        // Then, make the back wall of the hole
        p1.z = -1.0f * p1.z;
        p2.z = -1.0f * p2.z;
        p3.z = -1.0f * p3.z;
        holePoints[Index] = p1; holeNormals[Index] = point3(0.0f, 0.0f, -1.0f); Index++;
        holePoints[Index] = p3; holeNormals[Index] = point3(0.0f, 0.0f, -1.0f); Index++;
        holePoints[Index] = p2; holeNormals[Index] = point3(0.0f, 0.0f, -1.0f); Index++;

        p1 = point3(circlePoints[i].x, circlePoints[i].y-1, -1.0f);
        holePoints[Index] = p1; holeNormals[Index] = point3(0.0f, 0.0f, -1.0f); Index++;
        holePoints[Index] = p2; holeNormals[Index] = point3(0.0f, 0.0f, -1.0f); Index++;
        holePoints[Index] = p3; holeNormals[Index] = point3(0.0f, 0.0f, -1.0f); Index++;
    }

    // Generate the top, left, right rectangles
    p1 = point3(1.0f, 0.0f-1, 1.0f);
    p2 = point3(1.0f, 0.0f-1, -1.0f);
    p3 = point3(1.0f, holeHeight-1, -1.0f);
    p4 = point3(1.0f, holeHeight-1, 1.0f);
    p5 = point3(-1.0f, 0.0f-1, 1.0f);
    p6 = point3(-1.0f, 0.0f-1, -1.0f);
    p7 = point3(-1.0f, holeHeight-1, -1.0f);
    p8 = point3(-1.0f, holeHeight-1, 1.0f);

    // Draw right rectangles
    holePoints[Index] = p1; holeNormals[Index] = point3(1.0f, 0.0f, 0.0f); Index++;
    holePoints[Index] = p2; holeNormals[Index] = point3(1.0f, 0.0f, 0.0f); Index++;
    holePoints[Index] = p4; holeNormals[Index] = point3(1.0f, 0.0f, 0.0f); Index++;

    holePoints[Index] = p2; holeNormals[Index] = point3(1.0f, 0.0f, 0.0f); Index++;
    holePoints[Index] = p3; holeNormals[Index] = point3(1.0f, 0.0f, 0.0f); Index++;
    holePoints[Index] = p4; holeNormals[Index] = point3(1.0f, 0.0f, 0.0f); Index++;

    // Draw top rectangles
    holePoints[Index] = p4; holeNormals[Index] = point3(0.0f, 1.0f, 0.0f); Index++;
    holePoints[Index] = p3; holeNormals[Index] = point3(0.0f, 1.0f, 0.0f); Index++;
    holePoints[Index] = p7; holeNormals[Index] = point3(0.0f, 1.0f, 0.0f); Index++;

    holePoints[Index] = p4; holeNormals[Index] = point3(0.0f, 1.0f, 0.0f); Index++;
    holePoints[Index] = p7; holeNormals[Index] = point3(0.0f, 1.0f, 0.0f); Index++;
    holePoints[Index] = p8; holeNormals[Index] = point3(0.0f, 1.0f, 0.0f); Index++;

    // Draw left rectangles
    holePoints[Index] = p6; holeNormals[Index] = point3(-1.0f, 0.0f, 0.0f); Index++;
    holePoints[Index] = p8; holeNormals[Index] = point3(-1.0f, 0.0f, 0.0f); Index++;
    holePoints[Index] = p7; holeNormals[Index] = point3(-1.0f, 0.0f, 0.0f); Index++;

    holePoints[Index] = p5; holeNormals[Index] = point3(-1.0f, 0.0f, 0.0f); Index++;
    holePoints[Index] = p8; holeNormals[Index] = point3(-1.0f, 0.0f, 0.0f); Index++;
    holePoints[Index] = p6; holeNormals[Index] = point3(-1.0f, 0.0f, 0.0f); Index++;

    holeData->numVertices = numHoleVertices;

    glGenVertexArrays( 1, &holeData->vao );
    glBindVertexArray( holeData->vao );

    setVertexAttrib(program,
    				(float*)holePoints, sizeof(holePoints),
    				(float*)holeNormals, sizeof(holeNormals),
    				0, 0);
}