Beispiel #1
0
void DrawGimbal(glutil::MatrixStack &currMatrix, GimbalAxis eAxis, glm::vec4 baseColor)
{
	if(!g_bDrawGimbals)
		return;

	glutil::PushStack pusher(currMatrix);

	switch(eAxis)
	{
	case GIMBAL_X_AXIS:
		break;
	case GIMBAL_Y_AXIS:
		currMatrix.RotateZ(90.0f);
		currMatrix.RotateX(90.0f);
		break;
	case GIMBAL_Z_AXIS:
		currMatrix.RotateY(90.0f);
		currMatrix.RotateX(90.0f);
		break;
	}

	glUseProgram(theProgram);
	//Set the base color for this object.
	glUniform4fv(baseColorUnif, 1, glm::value_ptr(baseColor));
	glUniformMatrix4fv(modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(currMatrix.Top()));

	g_Gimbals[eAxis]->Render();

	glUseProgram(0);
}
Beispiel #2
0
void DrawCar(glutil::MatrixStack &modelMatrix)
{
	glutil::PushStack push(modelMatrix);

	modelMatrix.Translate(car->x(), 0, car->z());
	modelMatrix.Scale(car->scale());
	modelMatrix.RotateY(glm::degrees(car->degree()));

	glUseProgram(UniformColor.theProgram);
	glUniformMatrix4fv(UniformColor.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
	glUniform4f(UniformColor.baseColorUnif, 0.2f, 0.2f, 0.7f, 1.0f);
	car->Render();

	glUseProgram(0);
}
Beispiel #3
0
void DrawCarLight(glutil::MatrixStack &modelMatrix, float moveRight, float yScale, glm::vec4 color)
{
	glutil::PushStack push(modelMatrix);

	modelMatrix.Translate(car->x(), 5.0f, car->z());
	modelMatrix.RotateY(glm::degrees(car->degree()));
	modelMatrix.Translate(moveRight, 0, 0);
	modelMatrix.RotateZ(90);
	modelMatrix.Scale(1.0f, yScale, 1.0f);

	glUseProgram(ColorProvided.theProgram);
	glUniformMatrix4fv(ColorProvided.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
	glUniform4f(ColorProvided.baseColorUnif, color.r, color.g, color.b, color.a);	
	g_pCylinderMesh->Render();

	glUseProgram(0);
}
Beispiel #4
0
void DrawTetrahedron(glutil::MatrixStack &modelMatrix)
{
	glutil::PushStack push(modelMatrix);
	g_TetrahedronTimer.Update();

	glm::mat4 worldToCamera = modelMatrix.Top();

	modelMatrix.SetIdentity();
	modelMatrix.Translate(40.0f, 2.0f, 75.0f);
	modelMatrix.RotateY(360.0f * g_TetrahedronTimer.GetAlpha());
	modelMatrix.Translate(1.0f, 1.0f + sqrtf(2.0f) * 10, 1.0f);
	modelMatrix.Scale(10);
	modelMatrix.Rotate(glm::vec3(-0.707f, 0.0f, -0.707f), 54.735f);
	
	glUseProgram(ReflectorsAndLightProgram.reflectorsProgramData.theProgram);

	glUniform1f(ReflectorsAndLightProgram.reflectorsProgramData.shininess, 2.3f);
	glUniform3f(ReflectorsAndLightProgram.reflectorsProgramData.ks, 0.5f, 0.5f, 0.5f);
	glUniform3f(ReflectorsAndLightProgram.reflectorsProgramData.ka, 0.2f, 0.2f, 0.2f);
	glUniform3f(ReflectorsAndLightProgram.reflectorsProgramData.kd, 0.3f, 0.3f, 0.3f);

	glUniform1f(ReflectorsAndLightProgram.reflectorsProgramData.spotLight.cutoffUnif, 73.0f);
	glUniform1f(ReflectorsAndLightProgram.reflectorsProgramData.spotLight.exponentUnif, 3.0f);

	glUniform3fv(ReflectorsAndLightProgram.reflectorsProgramData.spotLight.directionUnif, 1, glm::value_ptr(car->reflectorDirection()));
	glUniform3fv(ReflectorsAndLightProgram.reflectorsProgramData.spotLight.intensityUnif, 1, glm::value_ptr(glm::vec3(0.8f, 0.8f, 0.8f)));

	SendReflectorPosition(ReflectorsAndLightProgram.reflectorsProgramData.spotLight.positionLeftReflectorUnif, -0.2f, 0.2f, -0.5f);
	SendReflectorPosition(ReflectorsAndLightProgram.reflectorsProgramData.spotLight.positionRightReflectorUnif, 0.2f, 0.2f, -0.5f);

	glUniformMatrix4fv(ReflectorsAndLightProgram.reflectorsProgramData.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
	glUniformMatrix4fv(ReflectorsAndLightProgram.reflectorsProgramData.worldToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(worldToCamera));

	glUniform4fv(ReflectorsAndLightProgram.lightIntensityUnif, 1, glm::value_ptr(glm::vec4(0.7f, 0.7f, 0.7f, 1.0f)));

	glm::vec3 worldLightPos(CalcLightPosition());
	
	glUniform3fv(ReflectorsAndLightProgram.worldSpaceLightPosUnif, 1, glm::value_ptr(worldLightPos));
	
	g_pTetrahedronMesh->Render();

	glUseProgram(0);
}
Beispiel #5
0
void Scene::Draw( glutil::MatrixStack &modelMatrix, int materialBlockIndex, float alphaTetra )
{
	//Render the ground plane.
	{
		glutil::PushStack push(modelMatrix);
		modelMatrix.RotateX(-90);

		DrawObject(m_pTerrainMesh.get(), GetProgram(LP_VERT_COLOR_DIFFUSE), materialBlockIndex, 0,
			modelMatrix);
	}

	//Render the tetrahedron object.
	{
		glutil::PushStack push(modelMatrix);
		modelMatrix.Translate(75.0f, 5.0f, 75.0f);
		modelMatrix.RotateY(360.0f * alphaTetra);
		modelMatrix.Scale(10.0f, 10.0f, 10.0f);
		modelMatrix.Translate(0.0f, sqrtf(2.0f), 0.0f);
		modelMatrix.Rotate(glm::vec3(-0.707f, 0.0f, -0.707f), 54.735f);

		DrawObject(m_pTetraMesh.get(), "lit-color", GetProgram(LP_VERT_COLOR_DIFFUSE_SPECULAR),
			materialBlockIndex, 1, modelMatrix);
	}

	//Render the monolith object.
	{
		glutil::PushStack push(modelMatrix);
		modelMatrix.Translate(88.0f, 5.0f, -80.0f);
		modelMatrix.Scale(4.0f, 4.0f, 4.0f);
		modelMatrix.Scale(4.0f, 9.0f, 1.0f);
		modelMatrix.Translate(0.0f, 0.5f, 0.0f);

		DrawObject(m_pCubeMesh.get(), "lit", GetProgram(LP_MTL_COLOR_DIFFUSE_SPECULAR),
			materialBlockIndex, 2, modelMatrix);
	}

	//Render the cube object.
	{
		glutil::PushStack push(modelMatrix);
		modelMatrix.Translate(-52.5f, 14.0f, 65.0f);
		modelMatrix.RotateZ(50.0f);
		modelMatrix.RotateY(-10.0f);
		modelMatrix.Scale(20.0f, 20.0f, 20.0f);

		DrawObject(m_pCubeMesh.get(), "lit-color", GetProgram(LP_VERT_COLOR_DIFFUSE_SPECULAR),
			materialBlockIndex, 3, modelMatrix);
	}

	//Render the cylinder.
	{
		glutil::PushStack push(modelMatrix);
		modelMatrix.Translate(-7.0f, 30.0f, -14.0f);
		modelMatrix.Scale(15.0f, 55.0f, 15.0f);
		modelMatrix.Translate(0.0f, 0.5f, 0.0f);

		DrawObject(m_pCylMesh.get(), "lit-color", GetProgram(LP_VERT_COLOR_DIFFUSE_SPECULAR),
			materialBlockIndex, 4, modelMatrix);
	}

	//Render the sphere.
	{
		glutil::PushStack push(modelMatrix);
		modelMatrix.Translate(-83.0f, 14.0f, -77.0f);
		modelMatrix.Scale(20.0f, 20.0f, 20.0f);

		DrawObject(m_pSphereMesh.get(), "lit", GetProgram(LP_MTL_COLOR_DIFFUSE_SPECULAR),
			materialBlockIndex, 5, modelMatrix);
	}
}
void DrawParthenon(glutil::MatrixStack &modelMatrix)
{
    //Draw base.
    {
        glutil::PushStack push(modelMatrix);

        modelMatrix.Scale(glm::vec3(parthenonWidth, parthenonBaseHeight, parthenonLength));
        modelMatrix.Translate(glm::vec3(0.0f, 0.5f, 0.0f));

        glUseProgram(UniformColorTint.theProgram);
        glUniformMatrix4fv(UniformColorTint.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
        glUniform4f(UniformColorTint.baseColorUnif, 0.9f, 0.9f, 0.9f, 0.9f);
        cubeTintMesh->Render();
        glUseProgram(0);
    }

    //Draw top.
    {
        glutil::PushStack push(modelMatrix);

        modelMatrix.Translate(glm::vec3(0.0f, parthenonColumnHeight + parthenonBaseHeight, 0.0f));
        modelMatrix.Scale(glm::vec3(parthenonWidth, parthenonTopHeight, parthenonLength));
        modelMatrix.Translate(glm::vec3(0.0f, 0.5f, 0.0f));

        glUseProgram(UniformColorTint.theProgram);
        glUniformMatrix4fv(UniformColorTint.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
        glUniform4f(UniformColorTint.baseColorUnif, 0.9f, 0.9f, 0.9f, 0.9f);
        cubeTintMesh->Render();
        glUseProgram(0);
    }

    //Draw columns.
    const float frontZVal = (parthenonLength / 2.0f) - 1.0f;
    const float rightXVal = (parthenonWidth / 2.0f) - 1.0f;

    for(int columnNum = 0; columnNum < int(parthenonWidth / 2.0f); columnNum++)
    {
        {
            glutil::PushStack push(modelMatrix);
            modelMatrix.Translate(glm::vec3((2.0f * columnNum) - (parthenonWidth / 2.0f) + 1.0f,
                                            parthenonBaseHeight,
                                            frontZVal));

            DrawColumn(modelMatrix, parthenonColumnHeight);
        }
        {
            glutil::PushStack push(modelMatrix);
            modelMatrix.Translate(glm::vec3((2.0f * columnNum) - (parthenonWidth / 2.0f) + 1.0f,
                                            parthenonBaseHeight,
                                            -frontZVal));

            DrawColumn(modelMatrix, parthenonColumnHeight);
        }
    }

    //Don't draw the first or last columns, since they've been drawn already.
    for(int columnNum = 1; columnNum < int((parthenonLength - 2.0f) / 2.0f); columnNum++)
    {
        {
            glutil::PushStack push(modelMatrix);
            modelMatrix.Translate(glm::vec3(rightXVal,
                                            parthenonBaseHeight,
                                            (2.0f * columnNum) - (parthenonLength / 2.0f) + 1.0f));

            DrawColumn(modelMatrix, parthenonColumnHeight);
        }
        {
            glutil::PushStack push(modelMatrix);
            modelMatrix.Translate(glm::vec3(-rightXVal,
                                            parthenonBaseHeight,
                                            (2.0f * columnNum) - (parthenonLength / 2.0f) + 1.0f));

            DrawColumn(modelMatrix, parthenonColumnHeight);
        }
    }

    //Draw interior.
    {
        glutil::PushStack push(modelMatrix);

        modelMatrix.Translate(glm::vec3(0.0f, 1.0f, 0.0f));
        modelMatrix.Scale(glm::vec3(parthenonWidth - 6.0f, parthenonColumnHeight, parthenonLength - 6.0f));
        modelMatrix.Translate(glm::vec3(0.0f, 0.5f, 0.0f));

        glUseProgram(ObjectColor.theProgram);
        glUniformMatrix4fv(ObjectColor.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
        cubeColorMesh->Render();
        glUseProgram(0);
    }

    //Draw headpiece.
    {
        glutil::PushStack push(modelMatrix);

        modelMatrix.Translate(glm::vec3(0.0f,
                                        parthenonColumnHeight + parthenonBaseHeight + (parthenonTopHeight / 2.0f),
                                        parthenonLength / 2.0f));
        modelMatrix.RotateX(-135.0f);
        modelMatrix.RotateY(45.0f);

        glUseProgram(ObjectColor.theProgram);
        glUniformMatrix4fv(ObjectColor.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
        cubeColorMesh->Render();
        glUseProgram(0);
    }
}