Ejemplo n.º 1
0
void MS::LookAt(double eyeX, double eyeY, double eyeZ,
				double centerX, double centerY, double centerZ,
				double upX, double upY, double upZ)
{
	Mtx44 mat;
	mat.SetToLookAt(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ);
	ms.top() = ms.top() * mat;
}
Ejemplo n.º 2
0
void SceneSkyBox::Render()
{
	// Render VBO here
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	//These will be replaced by matrix stack soon
	Mtx44 model;
	Mtx44 view;
	Mtx44 projection;

	model.SetToIdentity();
	//Set view matrix using camera settings
	view.SetToLookAt(
		camera.position.x, camera.position.y, camera.position.z,
		camera.target.x, camera.target.y, camera.target.z,
		camera.up.x, camera.up.y, camera.up.z
		);

	//Set projection matrix to perspective mode
	projection.SetToPerspective(45.0f, 4.0f / 3.0f, 0.1f, 1000.0f); //FOV, Aspect Ratio, Near plane, Far plane


	viewStack.LoadIdentity();
	viewStack.LookAt(camera.position.x, camera.position.y, camera.position.z,
		camera.target.x, camera.target.y, camera.target.z,
		camera.up.x, camera.up.y, camera.up.z);
	modelStack.LoadIdentity();

	Position lightPosition_cameraspace = viewStack.Top() * light[0].position;
	glUniform3fv(m_parameters[U_LIGHT0_POSITION], 1, &lightPosition_cameraspace.x);


	RenderMesh(meshList[GEO_AXES], false);

	modelStack.PushMatrix();
	modelStack.Translate(light[0].position.x, light[0].position.y, light[0].position.z);
	RenderMesh(meshList[GEO_LIGHTBALL], false);
	modelStack.PopMatrix();

	/*modelStack.PushMatrix();
	modelStack.Scale(10, 10, 10);
	RenderMesh(meshList[GEO_QUAD], false);
	modelStack.PopMatrix();*/
	//Loads the Skybox
	RenderSkyBox();
	//Mario
	modelStack.PushMatrix();
	modelStack.Scale(10, 10, 10);
	modelStack.Translate(0.0f, 1.f, -0.4f);
	modelStack.Rotate(90, 0.f, 1.f, 0.f);
	modelStack.Rotate(90, 0.f, 0.f, 1.f);
	RenderMesh(meshList[GEO_MARIO], false);
	modelStack.PopMatrix();


}
Ejemplo n.º 3
0
Mtx44 Camera::GetViewMatrix() const
{
	Mtx44 view;

	const Vector3 position = ReturnPosition();
	const Vector3 target = ReturnTarget();
	const Vector3 up = ReturnUp();

	view.SetToLookAt(position.x, position.y, position.z, target.x, target.y, target.z, up.x, up.y, up.z);

	return view;
}
Ejemplo n.º 4
0
void Scene3::Render()
{
	// Render VBO here
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	//Temp variables
	Mtx44 translate, rotate, scale;
	Mtx44 MVP;

	//These will be replaced by matrix stack soon
	Mtx44 model;
	Mtx44 view;
	Mtx44 projection;

	//Set all matrices to identity
	translate.SetToIdentity();
	rotate.SetToIdentity();
	scale.SetToIdentity();
	model.SetToIdentity();

	//Set view matrix using camera settings
	view.SetToLookAt(
		camera.position.x, camera.position.y, camera.position.z,
		camera.target.x, camera.target.y, camera.target.z,
		camera.up.x, camera.up.y, camera.up.z
					);

	//Set projection matrix to perspective mode
	projection.SetToPerspective(45.0f, 4.0f / 3.0f, 0.1f, 1000.0f); //FOV, Aspect Ratio, Near plane, Far plane

	model.SetToIdentity();
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
	meshList[GEO_AXES]->Render();
	

	rotate.SetToRotation(rotateAngle, 0, 0, 1);
	model = rotate;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
	/*meshList[GEO_CUBE]->Render();*/
	meshList[GEO_SPHERE]->Render();

	/*model.SetToIdentity();
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);*/
	/*meshList[GEO_CIRCLE]->Render();*/
	/*meshList[GEO_RING]->Render();*/
	
}
Ejemplo n.º 5
0
void MAINMENU::Render()
{
	// Render VBO here
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	//These will be replaced by matrix stack soon
	Mtx44 model;
	Mtx44 view;
	Mtx44 projection;

	model.SetToIdentity();
	//Set view matrix using camera settings
	view.SetToLookAt(
		camera.position.x, camera.position.y, camera.position.z,
		camera.target.x, camera.target.y, camera.target.z,
		camera.up.x, camera.up.y, camera.up.z
		);

	//Set projection matrix to perspective mode
	projection.SetToPerspective(45.0f, 4.0f / 3.0f, 0.1f, 1000.0f); //FOV, Aspect Ratio, Near plane, Far plane


	viewStack.LoadIdentity();
	viewStack.LookAt(camera.position.x, camera.position.y, camera.position.z,
		camera.target.x, camera.target.y, camera.target.z,
		camera.up.x, camera.up.y, camera.up.z);
	modelStack.LoadIdentity();
	float i = 3;
	for (st = menuList.rbegin(); st != menuList.rend(); ++st)
	{ 
		RenderTextOnScreen(meshList[TEXT], *st, Color(1, 1, 1), 3, 3, i ++);
	}
	if (c_UserInterface::GetEnum()->UI == START)
	{
		RenderTextOnScreen(meshList[TEXT], ">", Color(1, 1, 1), 3, 2, 5);
	}
	if (c_UserInterface::GetEnum()->UI == OPTIONS)
	{
		RenderTextOnScreen(meshList[TEXT], ">", Color(1, 1, 1), 3, 2, 4);
	}
	if (c_UserInterface::GetEnum()->UI == EXIT)
	{
		RenderTextOnScreen(meshList[TEXT], ">", Color(1, 1, 1), 3, 2, 3);
	}
}
Ejemplo n.º 6
0
void PLANET3::Render()
{
	// Render VBO here
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	//These will be replaced by matrix stack soon
	Mtx44 model;
	Mtx44 view;
	Mtx44 projection;

	model.SetToIdentity();
	//Set view matrix using camera settings
	view.SetToLookAt(
		camera.position.x, camera.position.y, camera.position.z,
		camera.target.x, camera.target.y, camera.target.z,
		camera.up.x, camera.up.y, camera.up.z
		);

	//Set projection matrix to perspective mode
	projection.SetToPerspective(45.0f, 4.0f / 3.0f, 0.1f, 1000.0f); //FOV, Aspect Ratio, Near plane, Far plane


	viewStack.LoadIdentity();
	viewStack.LookAt(camera.position.x, camera.position.y, camera.position.z,
		camera.target.x, camera.target.y, camera.target.z,
		camera.up.x, camera.up.y, camera.up.z);
	modelStack.LoadIdentity();

	Position lightPosition_cameraspace = viewStack.Top() * light[0].position;
	glUniform3fv(m_parameters[U_LIGHT0_POSITION], 1, &lightPosition_cameraspace.x);
	Vector3 lightDir(light[1].position.x, light[1].position.y, light[1].position.z);
	Vector3 lightDirection_cameraspace2 = viewStack.Top() * lightDir;
	glUniform3fv(m_parameters[U_LIGHT1_POSITION], 1, &lightDirection_cameraspace2.x);


	RenderMesh(meshList[GEO_AXES], false);

	modelStack.PushMatrix();
	modelStack.Translate(light[0].position.x, light[0].position.y, light[0].position.z);
	RenderMesh(meshList[GEO_LIGHTBALL], false);
	modelStack.PopMatrix();

	RenderSkyBox();
}
Ejemplo n.º 7
0
void PLANET5::Render()
{
	// Render VBO here
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	//These will be replaced by matrix stack soon
	Mtx44 model;
	Mtx44 view;
	Mtx44 projection;

	model.SetToIdentity();
	//Set view matrix using camera settings
	view.SetToLookAt(
		camera.position.x, camera.position.y, camera.position.z,
		camera.target.x, camera.target.y, camera.target.z,
		camera.up.x, camera.up.y, camera.up.z
		);

	//Set projection matrix to perspective mode
	projection.SetToPerspective(45.0f, 4.0f / 3.0f, 0.1f, 1000.0f); //FOV, Aspect Ratio, Near plane, Far plane


	viewStack.LoadIdentity();
	viewStack.LookAt(camera.position.x, camera.position.y, camera.position.z,
		camera.target.x, camera.target.y, camera.target.z,
		camera.up.x, camera.up.y, camera.up.z);
	modelStack.LoadIdentity();

	Position lightPosition_cameraspace = viewStack.Top() * light[0].position;
	glUniform3fv(m_parameters[U_LIGHT0_POSITION], 1, &lightPosition_cameraspace.x);
	Vector3 lightDir(light[1].position.x, light[1].position.y, light[1].position.z);
	Vector3 lightDirection_cameraspace2 = viewStack.Top() * lightDir;
	glUniform3fv(m_parameters[U_LIGHT1_POSITION], 1, &lightDirection_cameraspace2.x);


	RenderMesh(meshList[GEO_AXES], false);

	/*modelStack.PushMatrix();
	modelStack.Translate(light[0].position.x, light[0].position.y, light[0].position.z);
	RenderMesh(meshList[GEO_LIGHTBALL], false);
	modelStack.PopMatrix();

	/*	modelStack.PushMatrix();
	modelStack.Translate(0.f, 0.f, 0.f);
	RenderMesh(meshList[ASTEROID], false);
	modelStack.PopMatrix();*/

	std::ostringstream fps;
	fps << camera.position.x << " " << camera.position.y << " " << camera.position.z;
	std::ostringstream fpss;
	fpss << camera.target.x << " " << camera.target.y << " " << camera.target.z;
	RenderSkyBox();

	modelStack.PushMatrix();
	modelStack.Translate(0.0f, -35.0f, 0.f);
	modelStack.Rotate(rotatespin - 45, 0, 1, 0);
	modelStack.Scale(22.0f, 24.0f, 22.0f);
	RenderMesh(meshList[SPIN], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(0.0f, 8.0f, 0.f);
	modelStack.Scale(10.0f, 10.f, 10.f);
	RenderMesh(meshList[SPINCAP], false);
	modelStack.PopMatrix();


	modelStack.PushMatrix();
	modelStack.Translate(5.0f, translateButton - 6.f, 43.5f);
	modelStack.Rotate(25.0f, 1, 0, 0);
	modelStack.Scale(2.f, 3.0f, 2.f);
	RenderMesh(meshList[BUTTON], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(5.0f, -6.0f, 45.0f);
	modelStack.Rotate(-90.0f, 0, 1, 0);
	modelStack.Scale(2.0f, 2.0f, 2.0f);
	RenderMesh(meshList[BUTTONSTAND], false);
	modelStack.PopMatrix();

	//////////////////////GEMS ARE OUTRAGREOUS//////////////////////////


	modelStack.PushMatrix();
	modelStack.Translate(-50.0f, translategem1 - 5.7f, -81.5f);
	modelStack.Rotate(22.0f, 1, 0, 0);
	modelStack.Scale(2.f, 3.0f, 2.f);
	RenderMesh(meshList[BUTTON], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(-50.0f, -6.0f, -80.0f);
	modelStack.Rotate(-90.0f, 0, 1, 0);
	modelStack.Scale(2.0f, 2.0f, 2.0f);
	RenderMesh(meshList[BUTTONSTAND], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(-50.0f, flygem1, -90.0f);
	modelStack.Rotate(rotategem1, 0, 1, 0);
	modelStack.Scale(2.f, 3.0f, 2.f);
	RenderMesh(meshList[GEM], true);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(-50.0f, -5.0f, -90.0f);
	modelStack.Scale(2.f, 2.0f, 2.f);
	RenderMesh(meshList[GEMCASE], true);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(-25.0f, translategem2 - 5.7f, -81.5f);
	modelStack.Rotate(22.0f, 1, 0, 0);
	modelStack.Scale(2.f, 3.0f, 2.f);
	RenderMesh(meshList[BUTTON], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(-25.0f, -6.0f, -80.0f);
	modelStack.Rotate(-90.0f, 0, 1, 0);
	modelStack.Scale(2.0f, 2.0f, 2.0f);
	RenderMesh(meshList[BUTTONSTAND], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(-25.0f, flygem2, -90.0f);
	modelStack.Rotate(rotategem2, 0, 1, 0);
	modelStack.Scale(2.f, 3.0f, 2.f);
	RenderMesh(meshList[GEM2], true);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(-25.0f, -5.0f, -90.0f);
	modelStack.Scale(2.f, 2.0f, 2.f);
	RenderMesh(meshList[GEMCASE], true);
	modelStack.PopMatrix();



	modelStack.PushMatrix();
	modelStack.Translate(0.0f, translategem3 - 5.7f, -81.5f);
	modelStack.Rotate(22.0f, 1, 0, 0);
	modelStack.Scale(2.f, 3.0f, 2.f);
	RenderMesh(meshList[BUTTON], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(0.0f, -6.0f, -80.0f);
	modelStack.Rotate(-90.0f, 0, 1, 0);
	modelStack.Scale(2.0f, 2.0f, 2.0f);
	RenderMesh(meshList[BUTTONSTAND], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(0.0f, flygem3, -90.0f);
	modelStack.Rotate(rotategem3, 0, 1, 0);
	modelStack.Scale(2.f, 3.0f, 2.f);
	RenderMesh(meshList[GEM3], true);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(0.0f, -5.0f, -90.0f);
	modelStack.Scale(2.f, 2.0f, 2.f);
	RenderMesh(meshList[GEMCASE], true);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(25.0f, translategem4 - 5.7f, -81.5f);
	modelStack.Rotate(22.0f, 1, 0, 0);
	modelStack.Scale(2.f, 3.0f, 2.f);
	RenderMesh(meshList[BUTTON], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(25.0f, -6.0f, -80.0f);
	modelStack.Rotate(-90.0f, 0, 1, 0);
	modelStack.Scale(2.0f, 2.0f, 2.0f);
	RenderMesh(meshList[BUTTONSTAND], false);
	modelStack.PopMatrix();


	modelStack.PushMatrix();
	modelStack.Translate(25.0f, flygem4, -90.0f);
	modelStack.Rotate(rotategem4, 0, 2, 0);
	modelStack.Scale(2.f, 3.0f, 2.f);
	RenderMesh(meshList[GEM4], true);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(25.0f, -5.0f, -90.0f);
	modelStack.Scale(2.f, 2.0f, 2.f);
	RenderMesh(meshList[GEMCASE], true);
	modelStack.PopMatrix();
	//////////////////////THEY ARE TRULY, TRULY, TRULY OUTRAGREOUS//////////////////////////


	modelStack.PushMatrix();
	modelStack.Translate(-10.0f, translateEND, -123.0f);
	modelStack.Scale(scaleFinish, scaleFinish, scaleFinish);
	RenderMesh(meshList[END], true);
	modelStack.PopMatrix();


	modelStack.PushMatrix();
	modelStack.Translate(124.0f, 12.0f, -40.f);
	modelStack.Rotate(-90.0f, 0, 1, 0);
	modelStack.Scale(10.0f, 10.0f, 3.0f);
	RenderMesh(meshList[PICFRAME], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(124.0f, 12.0f, 40.f);
	modelStack.Rotate(-90.0f, 0, 1, 0);
	modelStack.Scale(10.0f, 10.0f, 3.0f);
	RenderMesh(meshList[PICFRAME], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(-124.0f, 12.0f, -40.f);
	modelStack.Rotate(90.0f, 0, 1, 0);
	modelStack.Scale(10.0f, 10.0f, 3.0f);
	RenderMesh(meshList[PICFRAME], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(-124.0f, 12.0f, 40.f);
	modelStack.Rotate(90.0f, 0, 1, 0);
	modelStack.Scale(10.0f, 10.0f, 3.0f);
	RenderMesh(meshList[PICFRAME], false);
	modelStack.PopMatrix();

	RenderHandOnScreen();

	RenderTextOnScreen(meshList[POSITION], fps.str(), Color(0, 1, 1), 3, 10, 10);
	RenderTextOnScreen(meshList[POSITION], fpss.str(), Color(0, 1, 1), 3, 10, 7);

}