//Trees are 3x3 in X/Z, and fTrunkHeight+fConeHeight in the Y.
void DrawTree(glutil::MatrixStack &modelMatrix, float trunkHeight = 2.0f, float coneHeight = 3.0f)
{
    //Draw trunk.
    {
        glutil::PushStack push(modelMatrix);

        modelMatrix.Scale(glm::vec3(1.0f, trunkHeight, 1.0f));
        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.694f, 0.4f, 0.106f, 1.0f);
        cylinderMesh->Render();
        glUseProgram(0);
    }

    //Draw the treetop
    {
        glutil::PushStack push(modelMatrix);

        modelMatrix.Translate(glm::vec3(0.0f, trunkHeight, 0.0f));
        modelMatrix.Scale(glm::vec3(3.0f, coneHeight, 3.0f));

        glUseProgram(UniformColorTint.theProgram);
        glUniformMatrix4fv(UniformColorTint.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
        glUniform4f(UniformColorTint.baseColorUnif, 0.0f, 1.0f, 0.0f, 1.0f);
        coneMesh->Render();
        glUseProgram(0);
    }
}
//Columns are 1x1 in the X/Z, and fHieght units in the Y.
void DrawColumn(glutil::MatrixStack &modelMatrix, float height = 5.0f)
{
    //Draw the bottom of the column.
    {
        glutil::PushStack push(modelMatrix);

        modelMatrix.Scale(glm::vec3(1.0f, columnBaseHeight, 1.0f));
        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, 1.0f, 1.0f, 1.0f, 1.0f);
        cubeTintMesh->Render();
        glUseProgram(0);
    }

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

        modelMatrix.Translate(glm::vec3(0.0f, height - columnBaseHeight, 0.0f));
        modelMatrix.Scale(glm::vec3(1.0f, columnBaseHeight, 1.0f));
        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 the main column.
    {
        glutil::PushStack push(modelMatrix);

        modelMatrix.Translate(glm::vec3(0.0f, columnBaseHeight, 0.0f));
        modelMatrix.Scale(glm::vec3(0.8f, height - (columnBaseHeight * 2.0f), 0.8f));
        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);
        cylinderMesh->Render();
        glUseProgram(0);
    }
}
Beispiel #3
0
// Rysuje jedno œwiat³o samochodu
void drawLight(glutil::MatrixStack &modelMatrix, glm::vec4 lightPos) {
	glutil::PushStack push(modelMatrix);

	modelMatrix.Translate(glm::vec3(lightPos));
	modelMatrix.Scale(0.1f, 0.1f, 0.1f);

	glUseProgram(flatShader.theProgram);
	glUniformMatrix4fv(flatShader.modelToCameraMatrixUnif, 1, GL_FALSE,
		glm::value_ptr(modelMatrix.Top()));
	glUniform4f(flatShader.objectColorUnif, 0.9078f, 0.9706f, 0.1922f, 1.0f);
	g_pCubeMesh->Render("flat");
}
Beispiel #4
0
void DrawTrunk(glutil::MatrixStack &modelMatrix, float fTrunkHeight)
{
	glutil::PushStack push(modelMatrix);

	modelMatrix.Scale(glm::vec3(1.0f, fTrunkHeight, 1.0f));
	modelMatrix.Translate(glm::vec3(0.0f, 0.5f, 0.0f));

	glUseProgram(ColorProvided.theProgram);
	glUniformMatrix4fv(ColorProvided.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
	glUniform4f(ColorProvided.baseColorUnif, 0.55f, 0.35f, 0.056f, 1.0f);
	g_pCylinderMesh->Render();
	glUseProgram(0);
}
void DrawWall2(glutil::MatrixStack &modelMatrix)
{
	//Draw wall 2
	glutil::PushStack push(modelMatrix);

	modelMatrix.Scale(glm::vec3(g_fWall2Width, g_fWall2Height, g_fWall2Length));
	modelMatrix.Translate(glm::vec3(0.0f, 0.5f, -9.5f));

	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);
	g_pCubeTintMesh->Render();
	glUseProgram(0);
}
void DrawArmchair2(glutil::MatrixStack &modelMatrix)
{
	//Draw armchair 2
	glutil::PushStack push(modelMatrix);

	modelMatrix.Scale(glm::vec3(g_fArmchair2Width, g_fArmchair2Height, g_fArmchair2Length));
	modelMatrix.Translate(glm::vec3(-8.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);
	g_pCylinderMesh->Render();
	glUseProgram(0);
}
void DrawPlant1(glutil::MatrixStack &modelMatrix)
{
	//Draw plant 1
	glutil::PushStack push(modelMatrix);

	modelMatrix.Scale(glm::vec3(g_fPlant1Width, g_fPlant1Height, g_fPlant1Length));
	modelMatrix.Translate(glm::vec3(-2.8f, 1.0f, 2.5f));

	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);
	g_pCubeTintMesh->Render();

	glUseProgram(0);
}
Beispiel #8
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 #9
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);
}
void DrawCarpet(glutil::MatrixStack &modelMatrix)
{
	//Draw carpet
	glutil::PushStack push(modelMatrix);



	float fElapsedTime = glutGet(GLUT_ELAPSED_TIME) / 1000.0f;
	modelMatrix.Scale(glm::vec3(g_fCarpetWidth, g_fCarpetHeight, g_fCarpetLength));
	modelMatrix.Translate(BottomCircleOffset(fElapsedTime));

	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);
	g_pCylinderMesh->Render();

	glUseProgram(0);
}
Beispiel #11
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);
}
void DrawTableLegsInLoop(glutil::MatrixStack &modelMatrix)
{
	for (int i = 0; i < ARRAY_COUNT(g_tableLegs); i++)
	{
		const TableLegsData &currLeg = g_tableLegs[i];

		glutil::PushStack push(modelMatrix);

		modelMatrix.Scale(glm::vec3(g_fTableLegWidth, g_fTableLegHeight, g_fTableLegLength));
		modelMatrix.Translate(glm::vec3(currLeg.fXPos, currLeg.fYPos, currLeg.fZPos));

		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);
		g_pCubeTintMesh->Render();

		glUseProgram(0);
	}
}
Beispiel #13
0
void DrawRoad(glutil::MatrixStack &modelMatrix)
{
	glutil::PushStack push(modelMatrix);
	
	glDisable(GL_DEPTH_TEST);
	glm::mat4 worldToCamera = modelMatrix.Top();

	modelMatrix.SetIdentity();
	
	modelMatrix.Scale(glm::vec3(30.0f, 1.0f, 100.0f));
	modelMatrix.Translate(0.0f, 0.0f, -0.5f);

	glUseProgram(UniformColorAndLightProgram.theProgram);
	glUniformMatrix4fv(UniformColorAndLightProgram.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));

	glUniform3f(UniformColorAndLightProgram.ka, 0.3f, 0.3f, 0.3f);

	glUniform1f(UniformColorAndLightProgram.spotLight.cutoffUnif, 73.0);
	glUniform1f(UniformColorAndLightProgram.spotLight.exponentUnif, 3.0);

	glUniform3fv(UniformColorAndLightProgram.spotLight.directionUnif, 1, glm::value_ptr(car->reflectorDirection()));
	glUniform3fv(UniformColorAndLightProgram.spotLight.intensityUnif, 1, glm::value_ptr(glm::vec3(1.0, 1.0, 1.0)));

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

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

	glUniformMatrix4fv(UniformColorAndLightProgram.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
	glUniform4f(UniformColorAndLightProgram.baseColorUnif, 0.72f, 0.71f, 0.35f, 1.0f);

	glUniform4fv(UniformColorAndLightProgram.lightIntensityUnif, 1, glm::value_ptr(glm::vec4(0.3f, 0.3f, 0.3f, 1.0f)));

	glm::vec3 worldLightPos(CalcLightPosition());
	
	glUniform3fv(UniformColorAndLightProgram.worldSpaceLightPosUnif, 1, glm::value_ptr(worldLightPos));

	g_pPlaneMesh->Render();

	glUseProgram(0);
	glEnable(GL_DEPTH_TEST);
}
void DrawPlant3InLoop(glutil::MatrixStack &modelMatrix)
{
	for (int i = 0; i < ARRAY_COUNT(g_leaves); i++)
	{
		const LeavesData &currLeaf = g_leaves[i];

		glutil::PushStack push(modelMatrix);

		modelMatrix.Scale(glm::vec3(g_fPlant3Width, g_fPlant3Height, g_fPlant3Length));
		modelMatrix.Translate(glm::vec3(currLeaf.fXPos, currLeaf.fYPos, currLeaf.fZPos));

		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);
		g_pCylinderMesh->Render();

		glUseProgram(0);
	}
}
Beispiel #15
0
// Rysuje samochód, zaczynaj¹c od œwiate³
void drawCar(glutil::MatrixStack &modelMatrix, glm::vec4 &lightPos) {
	drawLight(modelMatrix, lightPos);
	drawLight(modelMatrix, lightPos + glm::vec4(0.0, 0.0, nextLight, 0.0));
	glutil::PushStack push(modelMatrix);
	
	modelMatrix.Translate(glm::vec3(carPosition) + glm::vec3(1.55f, 0.0, 0.75));
	modelMatrix.Scale(3.0f, 0.8f, 2.1f);

	glm::mat4 invTransform = glm::inverse(modelMatrix.Top());
	glm::vec4 lightPosModelSpace = invTransform * lightPosCameraSpace;
	glm::vec3 directionModelSpace = direction * glm::vec3(lightPosCameraSpace);

	glUseProgram(adsShader.theProgram);
	glUniformMatrix4fv(adsShader.modelToCameraMatrixUnif, 1, GL_FALSE,
		glm::value_ptr(modelMatrix.Top()));
				
	glUniform3fv(adsShader.position, 1, glm::value_ptr(lightPosModelSpace));
	glUniform3f(adsShader.position2, lightPosModelSpace[0], lightPosModelSpace[1], lightPosModelSpace[2] + nextLight);

	g_pCubeMesh->Render("color");
}
Beispiel #16
0
void DrawShip(glutil::MatrixStack &modelMatrix)
{
	glutil::PushStack push(modelMatrix);

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

	modelMatrix.SetIdentity();
	modelMatrix.Translate(glm::vec3(0.0f, 2.0f, 50.0f));
	modelMatrix.Scale(3);
	modelMatrix.Rotate(glm::vec3(0, 1.0f, 0), -34);
	modelMatrix.Rotate(glm::vec3(0.5, 0.0, 0.5), 10);

	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.3f, 0.3f, 0.3f);
	glUniform3f(ReflectorsAndLightProgram.reflectorsProgramData.kd, 0.3f, 0.3f, 0.3f);

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

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

	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));

	glm::vec3 worldLightPos(CalcLightPosition());
	
	glUniform3fv(ReflectorsAndLightProgram.worldSpaceLightPosUnif, 1, glm::value_ptr(worldLightPos));

	g_pShip->Render();

	glUseProgram(0);
}
void DrawCandlesInLoop(glutil::MatrixStack &modelMatrix)
{
	for (int i = 0; i < ARRAY_COUNT(g_candles); i++)
	{
		const CandlesData &currCandle = g_candles[i];

		glutil::PushStack push(modelMatrix);

		float fElapsedTime = glutGet(GLUT_ELAPSED_TIME) / 1000.0f;

		modelMatrix.Scale(glm::vec3(g_fCandleWidth, currCandle.fCandleHeight, g_fCandleLength));

		modelMatrix.Translate(MoveCandlesUpAndDown(fElapsedTime, currCandle));

		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);
		g_pCylinderMesh->Render();

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

	g_SphereTimer.Update();
	float fCurrTimeThroughLoop = g_SphereTimer.GetAlpha();

	glm::vec3 pos(0.0f);

	pos.x = cosf(fCurrTimeThroughLoop * (3.14159f * 2.0f)) * g_fSphereRadius;
	pos.z = sinf(fCurrTimeThroughLoop * (3.14159f * 2.0f)) * g_fSphereRadius - 50.0f;
	pos.y = g_fSphereBaseHeight + sinf(fCurrTimeThroughLoop * (3.14159f * 2.0f)) * g_SphereDiffHeight;

	modelMatrix.Translate(pos);
	modelMatrix.Scale(10);

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

	glUseProgram(0);

}
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);
    }
}
Beispiel #20
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);
	}
}