Example #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);
}
Example #2
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");
}
Example #3
0
void Scene::DrawObject(const Framework::Mesh *pMesh, const std::string &meshName, 
					   const ProgramData &prog, int materialBlockIndex, int mtlIx,
					   const glutil::MatrixStack &modelMatrix)
{
	glBindBufferRange(GL_UNIFORM_BUFFER, materialBlockIndex, m_materialUniformBuffer,
		mtlIx * m_sizeMaterialBlock, sizeof(MaterialBlock));

	glm::mat3 normMatrix(modelMatrix.Top());
	normMatrix = glm::transpose(glm::inverse(normMatrix));

	glUseProgram(prog.theProgram);
	glUniformMatrix4fv(prog.modelToCameraMatrixUnif, 1, GL_FALSE,
		glm::value_ptr(modelMatrix.Top()));

	glUniformMatrix3fv(prog.normalModelToCameraMatrixUnif, 1, GL_FALSE,
		glm::value_ptr(normMatrix));
	pMesh->Render(meshName);
	glUseProgram(0);

	glBindBufferBase(GL_UNIFORM_BUFFER, materialBlockIndex, 0);
}
Example #4
0
// Rysuje kolorow¹ siatkê na danej pozycji i z danym parametrem shine
void drawColoredMesh(glutil::MatrixStack &modelMatrix, glm::vec4 &lightPos, Framework::Mesh *mesh, glm::vec3 position, float shine) {
	glutil::PushStack push(modelMatrix);
	
	modelMatrix.Translate(position);

	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);
	glUniform1f(adsShader.Shininess, shine);
	glUniform3f(adsShader.Kd, strength*0.3f, strength*0.3f, strength*0.3f);
	glUniform3f(adsShader.Ks, 0.1f, 0.1f, 0.1f);
	mesh->Render("lit-color");

	glUseProgram(0);
}
Example #5
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");
}
Example #6
0
void DrawLookAtPoint(glutil::MatrixStack &modelMatrix)
{
	glDisable(GL_DEPTH_TEST);
	glutil::PushStack push(modelMatrix);

	modelMatrix.SetIdentity();
	modelMatrix.Translate(glm::vec3(0.0f, 0.0f, -g_viewPole.GetView().radius));
		
	glUseProgram(UniformColor.theProgram);
	glUniformMatrix4fv(UniformColor.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
	g_pCylinderMesh->Render();

	glUseProgram(0);
	glEnable(GL_DEPTH_TEST);
}
Example #7
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);
}
Example #8
0
void SunLight::Render(glutil::MatrixStack &modelMatrix, FusionEngine::ShaderManager shaderManager)
{
    glm::vec4 position_cameraSpace = modelMatrix.Top() * glm::vec4(position, 1.0f);

	FusionEngine::ProgramData lightData = shaderManager.GetProgram(FusionEngine::FE_PROGRAM_LIT);
    glUseProgram(lightData.programId);

    glUniform4fv(lightData.GetUniform(FusionEngine::FE_UNIFORM_LIGHT_INTENSITY),
				 1, glm::value_ptr(lightIntensity));
    glUniform3fv(lightData.GetUniform(FusionEngine::FE_UNIFORM_CAMERA_SPACE_LIGHT_POS),
			 	 1, glm::value_ptr(position_cameraSpace));

    
    LightBlockGamma blockLightData;

    blockLightData.ambientIntensity = ambientIntensity;
    blockLightData.lightAttenuation = lightAttenuation;
    blockLightData.maxIntensity = maxIntensity;
    blockLightData.gamma = gamma;
	
	
	glBindBuffer(GL_UNIFORM_BUFFER, shaderManager.GetUniformBuffer(FusionEngine::FE_UBT_LIGHT));
    glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(blockLightData), &blockLightData);
    glBindBuffer(GL_UNIFORM_BUFFER, 0);


	FusionEngine::ProgramData litTextureData = shaderManager.GetProgram(FusionEngine::FE_PROGRAM_LIT_TEXTURE);
	glUseProgram(litTextureData.programId);

    glUniform4fv(litTextureData.GetUniform(FusionEngine::FE_UNIFORM_LIGHT_INTENSITY),
				 1, glm::value_ptr(lightIntensity));
    glUniform3fv(litTextureData.GetUniform(FusionEngine::FE_UNIFORM_CAMERA_SPACE_LIGHT_POS),
				 1, glm::value_ptr(position_cameraSpace));

    blockLightData.ambientIntensity = ambientIntensity;
    blockLightData.lightAttenuation = lightAttenuation;
    blockLightData.maxIntensity = maxIntensity;
    blockLightData.gamma = gamma;


    glBindBuffer(GL_UNIFORM_BUFFER, shaderManager.GetUniformBuffer(FusionEngine::FE_UBT_LIGHT));
    glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(blockLightData), &blockLightData);
    glBindBuffer(GL_UNIFORM_BUFFER, 0);

    glUseProgram(0);
}
Example #9
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);
}
Example #10
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);
}
Example #11
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);
}
Example #12
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 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);
	}
}
void DrawArmchair4(glutil::MatrixStack &modelMatrix)
{
	//Draw armchair 3
	glutil::PushStack push(modelMatrix);

	modelMatrix.Scale(glm::vec3(g_fArmchair3Width, g_fArmchair3Height, g_fArmchair3Length));
	modelMatrix.Translate(glm::vec3(-1.5f, 0.5f, 2.2f));

	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 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);
    }
}
Example #16
0
void Track::display(glutil::MatrixStack model_matrix)
{
	//glutil::PushStack push(model_matrix);
	//model_matrix.do_stuff(...);
	glutil::PushStack push(model_matrix);
	//model_matrix.Translate(position_);
	model_matrix.ApplyMatrix(transformation_.Top());

	glm::mat3 normal_model_to_world_matrix;

	glUseProgram(top_track_program_data_.program);
	glBindVertexArray(top_track_program_data_.vao);
	glUniformMatrix4fv(top_track_program_data_.model_to_clip_mat_unif, 1, GL_FALSE, glm::value_ptr(model_matrix.Top()));
	glUniformMatrix3fv(top_track_program_data_.normal_model_to_world_mat_unif, 1, GL_FALSE, glm::value_ptr(normal_model_to_world_matrix));
	glUniform3fv(top_track_program_data_.dir_to_light_unif, 1, glm::value_ptr(bezier_game_->get_dir_to_light()));
	glUniform4fv(top_track_program_data_.light_intensity_unif, 1, glm::value_ptr(bezier_game_->get_light_intensity()));
	glUniform4fv(top_track_program_data_.ambient_intensity_unif, 1, glm::value_ptr(bezier_game_->get_ambient_intensity()));

	glDrawArrays(GL_TRIANGLE_STRIP, 0, bezier_points_amount_ * 2);

	glBindVertexArray(0);
	glUseProgram(0);

	glUseProgram(bottom_track_program_data_.program);
	glBindVertexArray(bottom_track_program_data_.vao);
	glUniformMatrix4fv(bottom_track_program_data_.model_to_clip_mat_unif, 1, GL_FALSE, glm::value_ptr(model_matrix.Top()));
	glUniformMatrix3fv(bottom_track_program_data_.normal_model_to_world_mat_unif, 1, GL_FALSE, glm::value_ptr(normal_model_to_world_matrix));
	glUniform3fv(bottom_track_program_data_.dir_to_light_unif, 1, glm::value_ptr(bezier_game_->get_dir_to_light()));
	glUniform4fv(bottom_track_program_data_.light_intensity_unif, 1, glm::value_ptr(bezier_game_->get_light_intensity()));
	glUniform4fv(bottom_track_program_data_.ambient_intensity_unif, 1, glm::value_ptr(bezier_game_->get_ambient_intensity()));

	glDrawArrays(GL_TRIANGLE_STRIP, bezier_points_amount_ * 2, bezier_points_amount_ * 2);

	glBindVertexArray(0);
	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);
}
//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);
    }
}
Example #19
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 DrawLamp1(glutil::MatrixStack &modelMatrix)
{
	//Draw lamp 1
	glutil::PushStack push(modelMatrix);

	modelMatrix.Scale(glm::vec3(g_fLamp1Width, g_fLamp1Height, g_fLamp1Length));
	modelMatrix.Translate(glm::vec3(-3.5f, 1.0f, -3.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_pCubeTintMesh->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);
	}
}
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);
	}
}
void DrawPlant2(glutil::MatrixStack &modelMatrix)
{
	//Draw plant 2
	glutil::PushStack push(modelMatrix);

	modelMatrix.Scale(glm::vec3(g_fPlant2Width, g_fPlant2Height, g_fPlant2Length));
	modelMatrix.Translate(glm::vec3(-17.5f, 1.0f, 15.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);
}
Example #24
0
void DrawTreeTop(glutil::MatrixStack &modelMatrix, float fTrunkHeight, float fConeHeight)
{
	glutil::PushStack push(modelMatrix);

	modelMatrix.Translate(glm::vec3(0.0f, fTrunkHeight, 0.0f));
	modelMatrix.Scale(glm::vec3(3.0f, fConeHeight, 3.0f));

	glUseProgram(ColorProvided.theProgram);
	glUniformMatrix4fv(ColorProvided.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
	glUniform4f(ColorProvided.baseColorUnif, 0.0f, 0.4f, 0.0f, 1.0f);
	g_pConeMesh->Render();

	glUseProgram(0);
}
Example #25
0
void PlayerCar::display(glutil::MatrixStack model_matrix)
{
	glutil::PushStack push(model_matrix);
	
	//model_matrix.Translate(position_);
	//model_matrix.ApplyMatrix(rotation_.Top());
	//model_matrix.Scale(scale_);
	model_matrix.ApplyMatrix(transformation_.Top());

	glm::mat3 normal_model_to_world_matrix(rotation_.Top());

	glUseProgram(player_car_program_data_.program);
	glBindVertexArray(player_car_program_data_.vao);
	glUniformMatrix4fv(player_car_program_data_.model_to_clip_mat_unif, 1, GL_FALSE, glm::value_ptr(model_matrix.Top()));
	glUniformMatrix3fv(player_car_program_data_.normal_model_to_world_mat_unif, 1, GL_FALSE, glm::value_ptr(normal_model_to_world_matrix));
	glUniform3fv(player_car_program_data_.dir_to_light_unif, 1, glm::value_ptr(bezier_game_->get_dir_to_light()));
	glUniform4fv(player_car_program_data_.light_intensity_unif, 1, glm::value_ptr(bezier_game_->get_light_intensity()));
	glUniform4fv(player_car_program_data_.ambient_intensity_unif, 1, glm::value_ptr(bezier_game_->get_ambient_intensity()));
	
	glDrawElements(GL_TRIANGLES, player_car_index_data_.size(), GL_UNSIGNED_SHORT, 0);

	glBindVertexArray(0);
	glUseProgram(0);
}
//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);
    }
}
//Called to update the display.
//You should call glutSwapBuffers after all of your rendering to display what you rendered.
//If you need continuous updates of the screen, call glutPostRedisplay() at the end of the function.
void display()
{
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	glClearDepth(1.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


	if(g_pConeMesh && g_pCylinderMesh && g_pCubeTintMesh && g_pCubeColorMesh && g_pPlaneMesh)
	{
		g_camMatrix.SetMatrix(mainCharacter.AcquireCamera().CalcLookAtMatrix());

		glutil::MatrixStack modelMatrix;

		//Render the ground plane.
		{
			glutil::PushStack push(modelMatrix);
			modelMatrix.ApplyMatrix(g_camMatrix.Top());

			modelMatrix.Scale(glm::vec3(100.0f, 1.0f, 100.0f));

			glUseProgram(UniformColor.theProgram);
			glUniformMatrix4fv(UniformColor.modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
			glUniform4f(UniformColor.baseColorUnif, 0.302f, 0.416f, 0.0589f, 1.0f);
			g_pPlaneMesh->Render();
			glUseProgram(0);
		}

		//Draw the trees
		DrawForest(UniformColorTint, modelMatrix, g_camMatrix);

		//Draw the building.
		{
			glutil::PushStack push(modelMatrix);
			modelMatrix.ApplyMatrix(g_camMatrix.Top());

			modelMatrix.Translate(glm::vec3(20.0f, 0.0f, -10.0f));

			DrawParthenon(UniformColorTint, ObjectColor, modelMatrix);
		}

		//Draw the treasure
		for(int i = 0; i < COUNT; i++)
		{
			if(littleTreasures[i].IsRemoved() == false)
			{
				glutil::PushStack push(modelMatrix);
				modelMatrix.ApplyMatrix(g_camMatrix.Top());
			
				littleTreasures[i].Update();
				littleTreasures[i].Render(UniformColorTint, modelMatrix);
			}
			else
			{
				littleTreasures[i].Spawn(g_parthenonBaseVolume, g_treeVolumes, ARRAY_COUNT(g_forest), mainCharacter.GetCollisionVolume()); 
			}
		}
	}

	HandleMouse();

	glutPostRedisplay();
	glutSwapBuffers();

	userMouse.OverrideLastPosition(userMouse.GetCurrentPosition());
}