Exemple #1
0
void AppClass::Update(void)
{
	//Update the system so it knows how much time has passed since the last call
	m_pSystem->UpdateTime();

	//Is the arcball active?
	if (m_bArcBall == true)
		ArcBall();

	//Is the first person camera active?
	if (m_bFPC == true)
		CameraRotation();

	//Calculate Camera
	m_pCameraMngr->CalculateView();

	//Indicate the FPS
	int nFPS = m_pSystem->GetFPS();
	//print info into the console
	printf("FPS: %d            \r", nFPS);//print the Frames per Second
										  //Print info on the screen
	m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);
	m_pMeshMngr->Print("FPS:");
	m_pMeshMngr->Print(std::to_string(nFPS), RERED);
}
void AppClass::Update(void)
{
	//Update the system so it knows how much time has passed since the last call
	m_pSystem->UpdateTime();

	//Update the information on the Mesh manager I will not check for collision detection so the argument is false
	m_pMeshMngr->Update();

	//Calculate the arcball
	ArcBall();
	
	//Is the first person camera active?
	if (m_bFPC == true)
		CameraRotation();

	//Modify model's ModelToWorld matrix
	m_pMeshMngr->SetModelMatrix(ToMatrix4(m_qArcBall), "Unikitty");

	//Add a model to the render list
	m_pMeshMngr->AddInstanceToRenderList("ALL");

	//Calculate Camera
	m_pCameraMngr->CalculateView();

	//Indicate the FPS
	int nFPS = m_pSystem->GetFPS();

	//Print info on the screen
	m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);
	m_pMeshMngr->Print("FPS:");
	m_pMeshMngr->Print(std::to_string(nFPS), RERED);
}
void ApplicationClass::Update (void)
{
	m_pSystem->UpdateTime(); //Update the system
	printf("FPS: %d \r", m_pSystem->FPS);//print the Frames per Second

	//Check if the objects models have been read
	static bool bObjectSelected = false;
	if(!bObjectSelected)
	{
		if(m_pModelManager->GetNumberOfInstances() > 0)
		{
			m_sSelectedObject = m_pModelManager->m_vInstance[0]->GetName();
			bObjectSelected = true;
		}
	}

	//Arcball rotation
	if(m_bArcBall == true)
		ArcBall();

	//First person camera movement
	if(m_bFPC == true)
		CameraRotation();

	m_pBSMngr->Update();
	m_pBBMngr->Update();
}
void AppClass::Update(void)
{
#pragma region Does not need changes
	//Sets the camera
	m_pCameraMngr->SetPositionTargetAndView(vector3(0.0f, 25.0f, 0.0f), vector3(0.0f, 0.0f, 0.0f), -REAXISZ);

	//Update the system's time
	m_pSystem->UpdateTime();

	//Update the mesh manager's time without updating for collision detection
	m_pMeshMngr->Update();

	//First person camera movement
	if (m_bFPC == true)
		CameraRotation();

	//Call the arcball method
	ArcBall();

	//This matrices will just orient the objects to the camera
	matrix4 rotateX = glm::rotate(IDENTITY_M4, 90.0f, vector3(1.0f, 0.0f, 0.0f));
	matrix4 rotateY = glm::rotate(IDENTITY_M4, 90.0f, vector3(0.0f, 1.0f, 0.0f));

	//This matrices will hold the relative transformation of the Moon and the Earth
	matrix4 distanceEarth = glm::translate(11.0f, 0.0f, 0.0f);
	matrix4 distanceMoon = glm::translate(2.0f, 0.0f, 0.0f);
#pragma endregion

#pragma region YOUR CODE GOES HERE
	//Calculate the position of the Earth
	m_m4Earth = glm::rotate(IDENTITY_M4, m_fEarthTimer, vector3(0.0f, 1.0f, 0.0f));			//Rotate earth around the moon.
	m_m4Earth *= distanceEarth;																//Move earth to its solar orbit distance.
	m_m4Earth = glm::rotate(m_m4Earth, 90.0f, vector3(0.0f, 0.0f, 1.0f));					//Rotate earth sideways to align torus.
	m_m4Earth = glm::rotate(m_m4Earth, 360 * m_fEarthTimer, vector3(1.0f, 0.0f, 0.0f));		//Rotate earth 360 times/year.

	//Calculate the position of the Moon
	m_m4Moon = glm::translate(IDENTITY_M4, glm::vec3(m_m4Earth[3]));						//Move the moon to the earth's position.
	m_m4Moon = glm::rotate(m_m4Moon, 360 * -m_fMoonTimer, vector3(0.0f, 1.0f, 0.0f));		//Rotate the moon at 1/28th the earth's rotation.
	m_m4Moon = glm::translate(m_m4Moon, vector3(2.0f, 0.0f, 0.0f));							//Translate the moon to its orbital distance.
	m_m4Moon = glm::rotate(m_m4Moon, 90.0f, vector3(0.0f, 0.0f, 1.0f));						//Rotate the moon sideways to align torus.
#pragma endregion

#pragma region Print info
	printf("Earth Day: %.3f, Moon Orbit: %.3f\r", m_fEarthTimer, m_fMoonTimer);//print the Frames per Second
	
	//Indicate the FPS
	int nFPS = m_pSystem->GetFPS();
	//Print info on the screen
	m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);
	m_pMeshMngr->Print("Earth Day: ", REWHITE);
	m_pMeshMngr->PrintLine(std::to_string(m_fEarthTimer), REBLUE);
	m_pMeshMngr->Print("Moon Orbit: ", REWHITE);
	m_pMeshMngr->PrintLine(std::to_string(m_fMoonTimer), REBLUE);
	m_pMeshMngr->Print("FPS:");
	m_pMeshMngr->Print(std::to_string(nFPS), RERED);
#pragma endregion

	m_fEarthTimer += .05;//Increase Moon timer
	m_fMoonTimer = m_fEarthTimer / 28.0f; //divide by the moon's day
}
void AppClass::Update(void)
{
	
	//Update the system's time
	m_pSystem->UpdateTime();

	//Update the mesh manager's time without updating for collision detection
	m_pMeshMngr->Update();

	//First person camera movement
	if (m_bFPC == true)
		CameraRotation();

	//Call the arcball method
	ArcBall();
		
	//Adds all loaded instance to the render list
	m_pMeshMngr->AddInstanceToRenderList("ALL");

	//Indicate the FPS
	int nFPS = m_pSystem->GetFPS();
	//print info into the console
	//printf("FPS: %d            \r", nFPS);//print the Frames per Second
	//Print info on the screen
	m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);

	m_pMeshMngr->PrintLine("Selection: Press Space for sound!");
	
	m_pMeshMngr->Print("FPS:");
	m_pMeshMngr->Print(std::to_string(nFPS), RERED);
}
void AppClass::Update(void)
{
	//Update the system's time
	m_pSystem->UpdateTime();

	//Update the mesh manager's time without updating for collision detection
	m_pMeshMngr->Update();

	//First person camera movement
	if (m_bFPC == true)
		CameraRotation();

	//Call the arcball method
	ArcBall();
	
	//Set the model matrix for the first model to be the arcball
	m_pMeshMngr->SetModelMatrix(ToMatrix4(m_qArcBall), "All");

	m_pBall->Update();
	if (m_pBall->IsColliding(m_pBoxT) || m_pBall->IsColliding(m_pBoxB))
	{
		vector3 v3Velocity = m_pBall->GetVelocity();
		v3Velocity.y *= -1;
		m_pBall->SetVelocity(v3Velocity);
	}
	if (m_pBall->IsColliding(m_pBoxR) || m_pBall->IsColliding(m_pBoxL))
	{
		vector3 v3Velocity = m_pBall->GetVelocity();
		v3Velocity.x *= -1;
		m_pBall->SetVelocity(v3Velocity);
	}

	if (m_pBall->IsColliding(m_pPalletR) || m_pBall->IsColliding(m_pPalletL))
	{
		vector3 v3Velocity = m_pBall->GetVelocity();
		v3Velocity.x *= -1;
		m_pBall->SetVelocity(v3Velocity);
	}

	//Add objects to the render list
	m_pBall->AddToRenderList(true);
	m_pBoxT->AddToRenderList(true);
	m_pBoxB->AddToRenderList(true);
	m_pBoxL->AddToRenderList(true);
	m_pBoxR->AddToRenderList(true);
	m_pPalletL->AddToRenderList(true);
	m_pPalletR->AddToRenderList(true);

	//Indicate the FPS
	int nFPS = m_pSystem->GetFPS();
	m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);

	m_pMeshMngr->Print("Selection: ");
	m_pMeshMngr->PrintLine(m_pMeshMngr->GetInstanceGroupName(m_selection.first, m_selection.second), REYELLOW);
	
	m_pMeshMngr->Print("FPS:");
	m_pMeshMngr->Print(std::to_string(nFPS), RERED);
}
Exemple #7
0
void AppClass::Update(void)
{
	//Update the system's time
	m_pSystem->UpdateTime();

	//Update the mesh manager's time without updating for collision detection
	m_pMeshMngr->Update();

	//First person camera movement
	if (m_bFPC == true)
		CameraRotation();

	//Call the arcball method
	ArcBall();

	//Calculate delta and total times
	static double dTotalTime = 0.0; //Total time of the simulation
	double dDeltaTime = m_pSystem->LapClock(); //time difference between function calls
	dTotalTime += dDeltaTime; //Incrementing the time differences 

	float fStartTime = 0.0f;
	float fEndTime = 5.0f;
	float fAngle = MapValue(static_cast<float>(dTotalTime), fStartTime, fEndTime, 0.0f, 360.0f);
	m_m4Steve = glm::rotate(IDENTITY_M4, fAngle, REAXISZ);

	static float fStartHeight = 0.0f;
	static float fEndHeight = 5.0f;
	float fPercent = MapValue(static_cast<float>(dTotalTime), fStartTime, fEndTime, 0.0f, 1.0f);
	float fHeight = glm::lerp(fStartHeight, fEndHeight, fPercent);
	m_m4Steve = m_m4Steve * glm::translate(vector3(0.0f, fHeight, 0.0f));
	if (fPercent > 1.0f)
	{
		std::swap(fStartHeight, fEndHeight);
		dTotalTime = 0.0;
	}

	//Set the model matrix
	m_pMeshMngr->SetModelMatrix(m_m4Steve, "Steve");
	
	//Adds all loaded instance to the render list
	m_pMeshMngr->AddInstanceToRenderList("ALL");

	//Indicate the FPS
	int nFPS = m_pSystem->GetFPS();
	//Print info on the screen
	m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);
	m_pMeshMngr->Print("Seconds:");
	m_pMeshMngr->PrintLine(std::to_string(dTotalTime), RERED);
	m_pMeshMngr->Print("FPS:");
	m_pMeshMngr->Print(std::to_string(nFPS), RERED);
}
void AppClass::Update(void)
{
	//Update the system's time
	m_pSystem->UpdateTime();

	//Update the mesh manager's time without updating for collision detection
	m_pMeshMngr->Update();

	//First person camera movement
	if (m_bFPC == true)
		CameraRotation();

	//Call the arcball method
	ArcBall();

	//Lets us know how much time has passed since the last call
	double fTimeSpan = m_pSystem->LapClock();

	//cumulative time
	static double fRunTime = 0.0f;
	fRunTime += fTimeSpan;

	matrix4 mOrientation = glm::rotate(IDENTITY_M4, m_v3Rotation.x, vector3(1.0f, 0.0f, 0.0f));
	mOrientation = mOrientation * glm::rotate(IDENTITY_M4, m_v3Rotation.y, vector3(0.0f, 1.0f, 0.0f));
	mOrientation = mOrientation * glm::rotate(IDENTITY_M4, m_v3Rotation.z, vector3(0.0f, 0.0f, 1.0f));

	vector3 v3Start(0.0f, 0.0f, 0.0f);
	vector3 v3End(0.0f, 90.0f, 0.0f);
	static float fDifference = 0.0f;
	fDifference += 0.1f;
	fDifference = MapValue(static_cast<float>(fRunTime), 0.0f, 10.0f, 0.0f, 1.0f);

	float fPosition = glm::lerp(v3Start, v3End, fDifference).y;

	mOrientation = glm::rotate(IDENTITY_M4, fPosition, vector3(0.0f, 1.0f, 0.0f));

	m_pMeshMngr->SetModelMatrix(mOrientation, "Steve");
	
	//Adds all loaded instance to the render list
	m_pMeshMngr->AddInstanceToRenderList("ALL");

	//Indicate the FPS
	int nFPS = m_pSystem->GetFPS();
	//print info into the console
	//printf("FPS: %d            \r", nFPS);//print the Frames per Second
	//Print info on the screen
	m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);

	m_pMeshMngr->Print("FPS:");
	m_pMeshMngr->Print(std::to_string(nFPS), RERED);
}
void ApplicationClass::Update (void)
{
	m_pSystem->UpdateTime(); //Update the system
	
	//Arcball rotation
	if(m_bArcBall == true)
		ArcBall();

	//First person camera movement
	if(m_bFPC == true)
		CameraRotation();
	
	printf("FPS: %d \r", m_pSystem->FPS);//print the Frames per Second
}
void AppClass::Update(void)
{
	//Update the system's time
	m_pSystem->UpdateTime();

	//Update the mesh manager's time without updating for collision detection
	m_pMeshMngr->Update(false);

	//First person camera movement
	if (m_bFPC == true)
		CameraRotation();

	ArcBall();

	//Set the model matrices for both objects and Bounding Spheres
	m_pMeshMngr->SetModelMatrix(glm::translate(m_v3O1) * ToMatrix4(m_qArcBall), "Steve");
	m_pMeshMngr->SetModelMatrix(glm::translate(m_v3O2), "Creeper");

	//Set the model matrix to the Bounding Object
	m_pBOMngr->SetModelMatrix(m_pMeshMngr->GetModelMatrix("Steve"), "Steve");
	m_pBOMngr->SetModelMatrix(m_pMeshMngr->GetModelMatrix("Creeper"), "Creeper");

	m_pBOMngr->Update();//Update collision detection
	
	//m_pBOMngr->DisplaySphere(-1, REWHITE);
	m_pBOMngr->DisplayReAlligned();
	//m_pBOMngr->DisplayOriented(-1, REWHITE);

	//Adds all loaded instance to the render list
	m_pMeshMngr->AddInstanceToRenderList("ALL");

	//Indicate the FPS
	int nFPS = m_pSystem->GetFPS();
	//print info into the console
	printf("FPS: %d            \r", nFPS);//print the Frames per Second
	//Print info on the screen
	m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);

	std::vector<int> list = m_pBOMngr->GetCollidingVector(0);
	m_pMeshMngr->Print("Object 0 colliding with: ", REBLUE);
	for (uint n = 0; n < list.size(); n++)
	{
		m_pMeshMngr->Print(std::to_string(list[n]) + " ", REYELLOW);
	}
	m_pMeshMngr->PrintLine(" ");
	
	m_pMeshMngr->Print("FPS:");
	m_pMeshMngr->Print(std::to_string(nFPS), RERED);
}
void AppClass::Update(void)
{
	//Update the system's time
	m_pSystem->UpdateTime();

	//Update the mesh manager's time without updating for collision detection
	m_pMeshMngr->Update();

	//First person camera movement
	if (m_bFPC == true)
		CameraRotation();

	//Call the arcball method
	ArcBall();

	dynamicsWorld->stepSimulation(1 / 60.0f, 1);

	btTransform trans;
	btVector3 position;
	btQuaternion orientation;
	vector3 v3Position;
	quaternion qOrientation;
	matrix4 mToWorld;
	for (int n = 0; n < m_nCubes; n++)
	{
		fallRigidBody[n]->getMotionState()->getWorldTransform(trans);
		position = trans.getOrigin();
		orientation = trans.getRotation();
		v3Position = vector3(position.getX(), position.getY(), position.getZ());
		qOrientation = quaternion(orientation.getW(), orientation.getX(), orientation.getY(), orientation.getZ());
		mToWorld = glm::translate(matrix4(1.0f), v3Position) * glm::mat4_cast(qOrientation);
		m_pMeshMngr->SetModelMatrix(mToWorld, n);
	}

	//Adds all loaded instance to the render list
	m_pMeshMngr->AddInstanceToRenderList("ALL");

	// m_pMeshMngr->AddPlaneToQueue(glm::rotate(IDENTITY_M4, 90.0f, REAXISX) * glm::scale(vector3(100.0f)), REBLACK);

	//Indicate the FPS
	int nFPS = m_pSystem->GetFPS();
	//print info into the console
	//printf("FPS: %d            \r", nFPS);//print the Frames per Second
	//Print info on the screen
	m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);
	m_pMeshMngr->Print("FPS:");
	m_pMeshMngr->Print(std::to_string(nFPS), RERED);
}
void AppClass::Update(void)
{
	//Update the system's time
	m_pSystem->UpdateTime();

	//Update the mesh manager's time without updating for collision detection
	m_pMeshMngr->Update(false);

	//First person camera movement
	if (m_bFPC == true)
		CameraRotation();

	ArcBall();

	//Set the model matrices for both objects and Bounding Spheres
	m_pMeshMngr->SetModelMatrix(glm::translate(m_v3O1) * ToMatrix4(m_qArcBall), "Steve");
	m_pMeshMngr->SetModelMatrix(glm::translate(m_v3O2), "Creeper");

	m_pBB1->SetModelMatrix(m_pMeshMngr->GetModelMatrix("Steve"));
	m_pBB2->SetModelMatrix(m_pMeshMngr->GetModelMatrix("Creeper"));

	//Add a representation of the Spheres to the render list
	vector3 v3Color = REWHITE;
	if (m_pBB1->IsColliding(m_pBB2))
		v3Color = RERED;

	m_pMeshMngr->AddCubeToQueue(glm::translate(m_pBB1->GetCenterGlobal()) * glm::scale(m_pBB1->GetHalfWidthG() * 2.0f), v3Color, WIRE);
	m_pMeshMngr->AddCubeToQueue(glm::translate(m_pBB2->GetCenterGlobal()) * glm::scale(m_pBB2->GetHalfWidthG() * 2.0f), v3Color, WIRE);

	m_pMeshMngr->AddCubeToQueue(m_pBB1->GetModelMatrix() * glm::translate(IDENTITY_M4, m_pBB1->GetCenterLocal()) * glm::scale(m_pBB1->GetHalfWidth() * 2.0f), v3Color, WIRE);
	m_pMeshMngr->AddCubeToQueue(m_pBB2->GetModelMatrix() * glm::translate(IDENTITY_M4, m_pBB2->GetCenterLocal()) * glm::scale(m_pBB2->GetHalfWidth() * 2.0f), v3Color, WIRE);

	//Adds all loaded instance to the render list
	m_pMeshMngr->AddInstanceToRenderList("ALL");

	//Indicate the FPS
	int nFPS = m_pSystem->GetFPS();
	//print info into the console
	printf("FPS: %d            \r", nFPS);//print the Frames per Second
	//Print info on the screen
	m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);
	m_pMeshMngr->Print("FPS:");
	m_pMeshMngr->Print(std::to_string(nFPS), RERED);
}
Exemple #13
0
void AppClass::Update(void)
{
	//Update the system's time
	m_pSystem->UpdateTime();

	//Update the mesh manager's time without updating for collision detection
	m_pMeshMngr->Update(false);

	//First person camera movement
	if (m_bFPC == true)
		CameraRotation();

	ArcBall();

	//Set the model matrices for both objects and Bounding Spheres
	m_pMeshMngr->SetModelMatrix(glm::translate(m_v3O1) * ToMatrix4(m_qArcBall), "Steve");
	m_pMeshMngr->SetModelMatrix(glm::translate(m_v3O2), "Creeper");
	m_pMeshMngr->SetModelMatrix(glm::translate(m_v3O3), "Zombie");
	
	//set the matricies of the BO's 
	m_pBOMngr->SetBOMatrix("Steve", m_pMeshMngr->GetModelMatrix("Steve"));
	m_pBOMngr->SetBOMatrix("Creeper", m_pMeshMngr->GetModelMatrix("Creeper"));
	m_pBOMngr->SetBOMatrix("Zombie", m_pMeshMngr->GetModelMatrix("Zombie"));

	//Check the Collisions of all of the Bounding Objects
	m_pBOMngr->CheckCollisions();

	//Render Bounding Objects
	// **Like with the Mesh Manager, use the keyword "ALL" to render all stored BO's,
	// or use the name of a model to only render that one.**
	m_pBOMngr->RenderBoundingObjects("ALL");

	//Adds all loaded instance to the render list
	m_pMeshMngr->AddInstanceToRenderList("ALL");

	//Indicate the FPS
	int nFPS = m_pSystem->GetFPS();
	//print info into the console
	printf("FPS: %d            \r", nFPS);//print the Frames per Second
	//Print info on the screen
	m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);
	m_pMeshMngr->Print("FPS:");
	m_pMeshMngr->Print(std::to_string(nFPS), RERED);
}
Exemple #14
0
void AppClass::Update(void)
{
	//Update the system so it knows how much time has passed since the last call
	m_pSystem->UpdateTime();

	//Is the arcball active?
	if (m_bArcBall == true)
		m_qArcBall = ArcBall();

	//Is the first person camera active?
	if (m_bFPC == true)
		CameraRotation();

	//Calculate Camera
	m_pCamera->CalculateView();

	//print info into the console
	printf("FPS: %d            \r", m_pSystem->GetFPS());//print the Frames per Second
}
void AppClass::Update(void)
{
	//Update the system's time
	m_pSystem->UpdateTime();

	//Update the mesh manager's time without updating for collision detection
	m_pMeshMngr->Update();

	//First person camera movement
	if (m_bFPC == true)
		CameraRotation();

	ArcBall();

	//Set the model matrices for both objects and Bounding Spheres
	m_pMeshMngr->SetModelMatrix(glm::translate(m_v3O1) * ToMatrix4(m_qArcBall), "Steve");
	m_pMeshMngr->SetModelMatrix(glm::translate(m_v3O2), "Creeper");

	//Adds all loaded instance to the render list
	m_pMeshMngr->AddInstanceToRenderList("ALL");

	//Indicate the FPS
	int nFPS = m_pSystem->GetFPS();
	bool bAreColliding = false;

	//Collision check goes here
	m_pMeshMngr->Print("x:" + std::to_string( m_v3Center1.x ) + " ", RERED);
	m_pMeshMngr->Print("y:" + std::to_string(m_v3Center1.y) + " ", RERED);
	m_pMeshMngr->Print("z:" + std::to_string(m_v3Center1.z) + " ", RERED);
	m_pMeshMngr->PrintLine("");

	//print info into the console
	printf("FPS: %d            \r", nFPS);//print the Frames per Second
	//Print info on the screen
	m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);
	if (bAreColliding)
		m_pMeshMngr->PrintLine("They are colliding! >_<", RERED);
	else
		m_pMeshMngr->PrintLine("They are not colliding! =)", REGREEN);
	m_pMeshMngr->Print("FPS:");
	m_pMeshMngr->Print(std::to_string(nFPS), RERED);
}
void AppClass::Update(void)
{
    //Update the system's time
    m_pSystem->UpdateTime();

    //First person camera movement
    if (m_bFPC == true)
        CameraRotation();

    //Call the arcball method
    ArcBall();

    //Indicate the FPS
    int nFPS = m_pSystem->GetFPS();

    //Print info on the screen
    m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);
    m_pMeshMngr->Print("FPS:");
    m_pMeshMngr->Print(std::to_string(nFPS), RERED);
}
void AppClass::Update(void)
{
#pragma region Does not need changes

	//Update the system's time
	m_pSystem->UpdateTime();

	//Update the mesh manager's time without updating for collision detection
	m_pMeshMngr->Update();

	//First person camera movement
	if (m_bFPC == true)
		CameraRotation();

	//Call the arcball method
	ArcBall();

	//This matrices will just orient the objects to the camera
	matrix4 rotateX = glm::rotate(IDENTITY_M4, 90.0f, vector3(1.0f, 0.0f, 0.0f));
	matrix4 rotateY = glm::rotate(IDENTITY_M4, 90.0f, vector3(0.0f, 1.0f, 0.0f));

#pragma endregion

#pragma region YOUR CODE GOES HERE
	
	
#pragma endregion

#pragma region Print info
	//Indicate the FPS
	int nFPS = m_pSystem->GetFPS();
	//Print info on the screen
	m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);
	m_pMeshMngr->Print("FPS:");
	m_pMeshMngr->Print(std::to_string(nFPS), RERED);
#pragma endregion

	//renamed from earth/moon timers
	m_fFrames++;
	m_fTimeElapsed = m_fFrames / m_fSimulationSpeed;
}
void AppClass::Update(void)
{
	//Update the system's time
	m_pSystem->UpdateTime();

	//Update the mesh manager's time without updating for collision detection
	m_pMeshMngr->Update();

	//First person camera movement
	if (m_bFPC == true)
		CameraRotation();

	ArcBall();

	//Set the model matrices for both objects and Bounding Spheres
	m_pMeshMngr->SetModelMatrix(glm::translate(m_v3O1) * ToMatrix4(m_qArcBall), "Steve");
	m_pMeshMngr->SetModelMatrix(glm::translate(m_v3O2), "Creeper");

	boundingObject->SetModelMatrix(m_pMeshMngr->GetModelMatrix("Steve"), 0);
	boundingObject->SetModelMatrix(m_pMeshMngr->GetModelMatrix("Creeper"), 1);

	boundingObject->CheckCollisions();

	boundingObject->RenderAllBO(m_pMeshMngr);
	
	//Adds all loaded instance to the render list
	m_pMeshMngr->AddInstanceToRenderList("ALL");

	//Indicate the FPS
	int nFPS = m_pSystem->GetFPS();

	//print info into the console
	printf("FPS: %d            \r", nFPS);//print the Frames per Second

	//Print info on the screen
	m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);
	m_pMeshMngr->Print("FPS:");
	m_pMeshMngr->Print(std::to_string(nFPS), RERED);
}
void AppClass::Update(void)
{
	m_m4Cube = IDENTITY_M4;

	//Update the system's time
	m_pSystem->UpdateTime();

	//Update the mesh manager's time without updating for collision detection
	m_pMeshMngr->Update();

	//First person camera movement
	if (m_bFPC == true)
		CameraRotation();

	//Call the arcball method
	ArcBall();
	
	//Set the model matrix for the first model to be the arcball
	m_pMeshMngr->SetModelMatrix(ToMatrix4(m_qArcBall), 0);
	
	//Adds all loaded instance to the render list
	m_pMeshMngr->AddInstanceToRenderList("ALL");

	//camMngr->GetView();
	camMngr->GetProjection(true);

	//Indicate the FPS
	int nFPS = m_pSystem->GetFPS();
	//print info into the console
	//printf("FPS: %d            \r", nFPS);//print the Frames per Second
	//Print info on the screen
	m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);

	m_pMeshMngr->Print("Selection: ");
	m_pMeshMngr->PrintLine(m_pMeshMngr->GetInstanceGroupName(m_selection.first, m_selection.second), REYELLOW);
	
	m_pMeshMngr->Print("FPS:");
	m_pMeshMngr->Print(std::to_string(nFPS), RERED);
}
void AppClass::Update(void)
{
	//Update the system's time
	m_pSystem->UpdateTime();

	//Update the mesh manager's time without updating for collision detection
	m_pMeshMngr->Update();

	//First person camera movement
	if (m_bFPC == true)
		CameraRotation();

	//Call the arcball method
	ArcBall();

	//SafeDelete(m_pRoot);
	//m_pRoot = new OctantClass(3, 2);

	//m_pMeshMngr->SetVisibleBO(REBODISPLAY::BD_NONE, "ALL", true);
	//m_pMeshMngr->m_pModelMngr->CheckCollisions(BD_OB);
	m_pRoot->CheckCollisions();
	m_pRoot->DisplayLeafs();

	//m_pMeshMngr->SetVisibleAxis(true, "ALL", true);

	m_pMeshMngr->SetModelMatrix(m_m4Model * ToMatrix4(m_qArcBall), "Plane");

	//Adds all loaded instance to the render list
	m_pMeshMngr->AddInstanceToRenderList("ALL");

	//Indicate the FPS
	int nFPS = m_pSystem->GetFPS();
	//Print info on the screen
	m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);

	m_pMeshMngr->Print("FPS:");
	m_pMeshMngr->Print(std::to_string(nFPS), RERED);
}
Exemple #21
0
void AppClass::Update(void)
{
	//Update the system's time
	m_pSystem->UpdateTime();

	//Update the mesh manager's time without updating for collision detection
	m_pMeshMngr->Update(false);

	//First person camera movement
	if (m_bFPC == true)
		CameraRotation();

	if (m_bArcBall == true){
		b_ArcBall = ArcBall();
	}

	b_Torus->UpdootPosition(vector3(m_v3Torus.x, m_v3Torus.y, m_v3Torus.z));
	b_Cone->UpdootPosition(vector3(m_v3Cone.x, m_v3Cone.y, m_v3Cone.z));


	if (glm::distance(b_Torus->getCenter(), b_Cone->getCenter()) < b_Torus->getRadius() + b_Cone->getRadius()){
		//is around cone for some reason
		m_pMeshMngr->AddSphereToQueue(glm::scale(glm::translate(glm::mat4_cast(b_ArcBall), b_Torus->getCenter()), vector3(b_Torus->getRadius() * 2.0f)), RERED, WIRE);
		//supposed to be on torus
		m_pMeshMngr->AddSphereToQueue(glm::scale(glm::translate(glm::mat4_cast(b_ArcBall), b_Cone->getCenter()), vector3(b_Cone->getRadius() * 2.0f)), RERED, WIRE);
		//Adds all loaded instance to the render list
	}
	else{
		
		//is around cone for some reason
		m_pMeshMngr->AddSphereToQueue(glm::scale(glm::translate(glm::mat4_cast(b_ArcBall), b_Torus->getCenter()), vector3(b_Torus->getRadius() * 2.0f)), REWHITE, WIRE);
		//supposed to be on torus
		m_pMeshMngr->AddSphereToQueue(glm::scale(glm::translate(glm::mat4_cast(b_ArcBall), b_Cone->getCenter()), vector3(b_Cone->getRadius() * 2.0f)), REWHITE, WIRE);
		//Adds all loaded instance to the render list
	}
	m_pMeshMngr->AddInstanceToRenderList("ALL");
}
void AppClass::Update(void)
{
	//Update the system's time
	m_pSystem->UpdateTime();

	//Update the mesh manager's time without updating for collision detection
	m_pMeshMngr->Update();

	//First person camera movement
	if (m_bFPC == true)
		CameraRotation();

	ArcBall();

	//Set the model matrices for both objects and Bounding Spheres
	m_pMeshMngr->SetModelMatrix(glm::translate(m_v3O1) * ToMatrix4(m_qArcBall), "Steve");
	m_pMeshMngr->SetModelMatrix(glm::translate(m_v3O2), "Creeper");

	//Adds all loaded instance to the render list
	m_pMeshMngr->AddInstanceToRenderList("ALL");

	//Indicate the FPS
	int nFPS = m_pSystem->GetFPS();
<<<<<<< HEAD
Exemple #23
0
void AppClass::Update(void)
{
    //Update the system's time
    m_pSystem->UpdateTime();

    //Update the mesh manager's time without updating for collision detection
    m_pMeshMngr->Update();

    //First person camera movement
    if (m_bFPC == true)
        CameraRotation();

    //Call the arcball method
    ArcBall();

    //Set the model matrix for the first model to be the arcball
    //m_pMeshMngr->SetModelMatrix(ToMatrix4(m_qArcBall), 0);

    //Adds all loaded instance to the render list
    //m_pMeshMngr->AddSkyboxToRenderList("Skybox_01.png");


    if (m_pBOMngr->GetSphereCheck()) {
        m_pBOMngr->Update();

        for (int i = 0; i < creeps; i++) {
            if (m_pBOMngr->GetBoundingObject(i)->GetIsSphereDisplayed()) {
                String sName = "Creeper" + std::to_string(i);
                m_pBOMngr->DisplaySphere(sName, RERED);
            }
        }
    }

    if (displayGeometry) {
        m_pMeshMngr->AddInstanceToRenderList("ALL");
    }
    else
    {
        m_pMeshMngr->ResetRenderList();
    }


    //Check to see if subdivisions are neccessary
    if (creeps > 1) {
        m_pOctreeHead->MakeChildrenPrime(8);

    }

    if (m_pOctreeHead->GetIsDisplayOctrees()) {
        m_pOctreeHead->Display();
    }




    //Indicate the FPS
    int nFPS = m_pSystem->GetFPS();
    //print info into the console
    //printf("FPS: %d            \r", nFPS);//print the Frames per Second
    //Print info on the screen
    m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);

    m_pMeshMngr->Print("Selection: ");
    m_pMeshMngr->PrintLine(m_pMeshMngr->GetInstanceGroupName(m_selection.first, m_selection.second), REYELLOW);

    m_pMeshMngr->Print("FPS:");
    m_pMeshMngr->PrintLine(std::to_string(nFPS), RERED);

    // If true then enable SAT
    m_pMeshMngr->Print("<K> Check Collisions: ");
    if (m_pBOMngr->GetCollisionSwitch()) {
        m_pMeshMngr->PrintLine("Spatial Optimization", REGREEN);
    }
    else {
        m_pMeshMngr->PrintLine("Brute Force", RERED);
    }

    // If true then octrees are drawn
    m_pMeshMngr->Print("<H> Display Octree: ");
    if (m_pOctreeHead->GetIsDisplayOctrees()) {
        m_pMeshMngr->PrintLine("ON", REGREEN);
    }
    else {
        m_pMeshMngr->PrintLine("OFF", RERED);
    }


    //// If true then show collisions
    //m_pMeshMngr->Print("<J> Display Collisions: ");
    //for (int i = 0; i < creeps; i++) {
    //	if (m_pBOMngr->GetBoundingObject(i)->GetIsSphereDisplayed()) {
    //		showCollisions = true;
    //	}
    //	else {
    //		showCollisions = false;
    //	}
    //}

    m_pMeshMngr->Print("<J> Display Collisions: ");
    if (m_pBOMngr->GetSphereCheck()) {
        m_pMeshMngr->PrintLine("ON", REGREEN);
    }
    else
    {
        m_pMeshMngr->PrintLine("OFF", RERED);
    }

    m_pMeshMngr->Print("<G> Display Geometry: ");
    if (displayGeometry) {
        m_pMeshMngr->PrintLine("ON", REGREEN);
    }
    else {
        m_pMeshMngr->PrintLine("OFF", RERED);
    }

    m_pMeshMngr->Print("Number of Blocks: ");
    m_pMeshMngr->PrintLine(std::to_string(creeps), REBLUE);
}
void AppClass::Update(void)
{
	//Update the system's time
	m_pSystem->UpdateTime();

	//Update the mesh manager's time without updating for collision detection
	m_pMeshMngr->Update();

	//First person camera movement
	if (m_bFPC == true)
		CameraRotation();

	//Call the arcball method
	ArcBall();

	//m_pBOMngr->Update();
	
	//Set the model matrix for the first model to be the arcball
	m_pMeshMngr->SetModelMatrix(ToMatrix4(m_qArcBall), 0);
	
	//Adds all loaded instance to the render list
	m_pMeshMngr->AddInstanceToRenderList("ALL");

	//Check Collisions
	if (useSO) 
	{
		m_pOctreeHead->CheckCollisions();
	}
	else
	{
		m_pBOMngr->Update();
	}

	if (displayOctree)
	{
		m_pOctreeHead->Draw();
	}

	//Indicate the FPS
	int nFPS = m_pSystem->GetFPS();
	//print info into the console
	//printf("FPS: %d            \r", nFPS);//print the Frames per Second
	//Print info on the screen
	m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);
	
	m_pMeshMngr->Print("FPS:");
	m_pMeshMngr->PrintLine(std::to_string(nFPS), RERED);
	m_pMeshMngr->Print("<K> Check Collisions: ");
	if (useSO)
	{
		m_pMeshMngr->PrintLine("Spatial Optimization", REGREEN);
	}
	else
	{
		m_pMeshMngr->PrintLine("Brute Force", RERED);
	}
	m_pMeshMngr->Print("<H> Display Octree: ");
	if (displayOctree)
	{
		m_pMeshMngr->PrintLine("ON", REGREEN);
	}
	else
	{
		m_pMeshMngr->PrintLine("OFF", RERED);
	}
	m_pMeshMngr->Print("<J> Display Collisions For SO: ");
	if (m_pOctreeHead->GetDisplaySphere())
	{
		m_pMeshMngr->PrintLine("ON", REGREEN);
	}
	else
	{
		m_pMeshMngr->PrintLine("OFF", RERED);
	}
	m_pMeshMngr->Print("<G> Display Collisions For Brute Force: ");
	if (m_pBOMngr->GetDisplaySphere())
	{
		m_pMeshMngr->PrintLine("ON", REGREEN);
	}
	else
	{
		m_pMeshMngr->PrintLine("OFF", RERED);
	}
}
void AppClass::Update(void)
{
	//Sets the camera
	m_pCameraMngr->SetPositionTargetAndView(vector3(0.0f, 25.0f, 0.0f), vector3(0.0f, 0.0f, 0.0f), -REAXISZ);

	//Update the system's time
	m_pSystem->UpdateTime();

	//Update the mesh manager's time without updating for collision detection
	m_pMeshMngr->Update();

	//First person camera movement
	if (m_bFPC == true)
		CameraRotation();

	//Call the arcball method
	ArcBall();

	//Adds all loaded instance to the render list
	m_pMeshMngr->AddInstanceToRenderList("ALL");

	//This matrices will just orient the objects to the camera
	matrix4 rotateX = glm::rotate(IDENTITY_M4, 90.0f, vector3(1.0f, 0.0f, 0.0f));
	matrix4 rotateY = glm::rotate(IDENTITY_M4, 90.0f, vector3(0.0f, 1.0f, 0.0f));

	//This matrices will hold the relative transformation of the Moon and the Earth
	matrix4 distanceEarth = glm::translate(11.0f, 0.0f, 0.0f);
	matrix4 distanceMoon = glm::translate(2.0f, 0.0f, 0.0f);

	//Earth's orbit around the Sun
	matrix4 orbitEarth = glm::rotate(IDENTITY_M4, m_fEarthTimer, vector3(0.0f, 1.0f, 0.0f));
	//Earth's rotation on its own axis
	matrix4 rotationEarth = glm::rotate(IDENTITY_M4, m_fEarthTimer * 28.0f, vector3(0.0f, 1.0f, 0.0f));

	//Moon's orbit around the Earth
	matrix4 orbitMoon = glm::rotate(IDENTITY_M4, m_fMoonTimer, vector3(0.0f, -1.0f, 0.0f));
	//Moon's rotation around its own axis
	matrix4 rotationMoon = glm::rotate(IDENTITY_M4, m_fMoonTimer, vector3(0.0f, 1.0f, 0.0f));

	//I will calculate the Earth position in space relative to the Sun (which is in global space)
	matrix4 earthsSpace = orbitEarth * distanceEarth;//the translation depends on the orientation of the space (Earths orbit)
	m_m4Earth = earthsSpace * rotationEarth;//the rotation of the Earth will depend on the new space
	m_m4Earth = m_m4Earth * rotateX;//Will orient the Earth to the camera now

	//I will calculate the moon's position in space relative to the Earth (earthsSpace)
	matrix4 moonsSpace = orbitMoon * distanceMoon;//the moon's translation depends on its orientation (Moons orbit)
	m_m4Moon = earthsSpace * moonsSpace;//Then we place the moons space in therms of the earth space
	m_m4Moon = m_m4Moon * rotateY * rotateX;//Then we orient the Moon to the camera)

	printf("Earth Day: %.3f, Moon Day: %.3f\r", m_fEarthTimer, m_fMoonTimer);//print the Frames per Second

	//Indicate the FPS
	int nFPS = m_pSystem->GetFPS();
	//Print info on the screen
	m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);
	m_pMeshMngr->Print("Earth Day: ", REWHITE);
	m_pMeshMngr->PrintLine(std::to_string(m_fEarthTimer), REBLUE);
	m_pMeshMngr->Print("Moon Day: ", REWHITE);
	m_pMeshMngr->PrintLine(std::to_string(m_fMoonTimer), REBLUE);
	m_pMeshMngr->Print("FPS:");
	m_pMeshMngr->Print(std::to_string(nFPS), RERED);

	m_fMoonTimer++;//Increase moon timer
	m_fEarthTimer = m_fMoonTimer / 28.0f; //divide by the moon's day
}
Exemple #26
0
void AppClass::Update(void)
{
	//Update the system's time
	m_pSystem->UpdateTime();

	//Update the mesh manager's time without updating for collision detection
	m_pMeshMngr->Update();

	//First person camera movement
	if (m_bFPC == true)
		CameraRotation();

	//Call the arcball method
	ArcBall();

	//Lets us know how much time has passed since the last call
	double fTimeSpan = m_pSystem->LapClock();

	//cumulative time
	static double fRunTime = 0.0f;
	fRunTime += fTimeSpan;

	static int nIndex = 0;

	if (fRunTime > fDuration)
	{
		fRunTime = 0.0f;
		nIndex++;
		if (nIndex == static_cast<int>(m_lPositions.size()))
		{
			nIndex = 0;
		}
	}

	vector3 v3Vector1;
	vector3 v3Vector2;
	if (nIndex >= static_cast<int>(m_lPositions.size()) - 1)
	{
		v3Vector1 = m_lPositions[static_cast<int>(m_lPositions.size()) - 1];
		v3Vector2 = m_lPositions[0];
	}
	else
	{
		v3Vector1 = m_lPositions[nIndex];
		v3Vector2 = m_lPositions[nIndex + 1];
	}

	float fPercent = MapValue(static_cast<float>(fRunTime), 0.0f, fDuration, 0.0f, 1.0f);
	vector3 v3Position = glm::lerp(v3Vector1, v3Vector2, fPercent);
	m_pMeshMngr->SetModelMatrix(glm::translate(v3Position), "WallEye");

	for (int i = 0; i < static_cast<int>(m_lPositions.size()); i++)
	{
		m_pMeshMngr->AddSphereToRenderList(glm::translate(m_lPositions[i]) * glm::scale(vector3(0.1f)), RERED, SOLID);
	}

	//Adds all loaded instance to the render list
	m_pMeshMngr->AddInstanceToRenderList("ALL");

	//Indicate the FPS
	int nFPS = m_pSystem->GetFPS();
	//print info into the console
	printf("\rfTimeSpan: %.3f, fRunSpan: %.3f, fDuration: %.3f                 ", fTimeSpan, fRunTime, fDuration);
	//Print info on the screen
	m_pMeshMngr->PrintLine(m_pSystem->GetAppName(), REYELLOW);

	m_pMeshMngr->Print("nIndex: ");
	m_pMeshMngr->PrintLine(std::to_string(nIndex));

	m_pMeshMngr->Print("fTimeSpan: ");
	m_pMeshMngr->PrintLine(std::to_string(fTimeSpan));

	m_pMeshMngr->Print("fRunSpan: ");
	m_pMeshMngr->PrintLine(std::to_string(fRunTime));

	m_pMeshMngr->Print("fDuration: ");
	m_pMeshMngr->PrintLine(std::to_string(fDuration));

	m_pMeshMngr->Print("FPS:");
	m_pMeshMngr->Print(std::to_string(nFPS), RERED);
}
void AppClass::Update(void)
{
	if (gameState == Start)
	{
		m_pMeshMngr->Print("Welcome to ", REWHITE); 
		m_pMeshMngr->PrintLine("CHUPACABRA", RERED);
		m_pMeshMngr->PrintLine("", REWHITE);
		m_pMeshMngr->PrintLine("Controls:", REWHITE);
		m_pMeshMngr->PrintLine("-Click to throw golf balls in defense of your goat!", REWHITE);
		m_pMeshMngr->PrintLine("-Press Spacebar to start \'P\' to pause wile in-game", REWHITE);
		m_pMeshMngr->PrintLine("-GET A GOOD SCORE!!!", REWHITE);
	}
	else if (gameState == Game)
	{
		//Update the system's time
		m_pSystem->UpdateTime();

		// std::cout << m_pSystem->LapClock(0) * 64.f; test expected frame-rate
		deltaTime = m_pSystem->LapClock(0);
		scaledDT = (float)(deltaTime * TIME_COEFFICIENT);

		//Update the mesh manager's time without updating for collision detection
		m_pMeshMngr->Update(false);

		//First person camera movement
		if (m_bFPC == true)
			CameraRotation();

		ArcBall();

		// navigate through the octtree
		chupManager->ClearIndices();
		//m_pRoot->ClearList();
		for (int i = 0; i < 8; i++)
		{
			pChild = m_pRoot->GetChild(i);
			//pChild->ClearList();

			for (int j = 0; j < 8; j++)
			{
				pChild = m_pRoot->GetChild(i)->GetChild(j);
				pChild->ClearList();
				// populate list
				FindChups(pChild);
			}
		}

		// check collisions in the now populated structure
		RecurseSO(m_pRoot);

		// update canyon
		canyonManager->Update(scaledDT);

		cameraFX->CameraBob();

		for (int i = 0; i < chupManager->chups.size(); i++)
		{
			chupManager->chups[i].myBO->SetModelMatrix(glm::translate(chupManager->chups[i].position));
		}

		//draw the projectiles 
		for (int i = 0; i < player->projectiles.size(); i++)
		{
			player->projectiles.at(i).Move(scaledDT);
			m_pMeshMngr->AddSphereToQueue(glm::translate(IDENTITY_M4, player->projectiles.at(i).position) * glm::scale(vector3(1.0f, 1.0f, 1.0f)));
			player->projectiles.at(i).bounding->SetModelMatrix(glm::translate(player->projectiles.at(i).position)); //move those bounding objects
		}

		player->Countdown(scaledDT);

		// update chupacabras
		chupManager->Update(scaledDT);

		//Add a representation of the Spheres to the render list
		vector3 v3Color = REWHITE;

		m_pMeshMngr->PrintLine(player->ShowScore(), REWHITE);

		if (starting)
		{
			gameState = Start; 
			starting = false; 
		}
	}
	else if (gameState == Pause)
	{
		m_pMeshMngr->PrintLine("Paused", REWHITE); 
		deltaTime = 0.0f; 
		m_pMeshMngr->Update(false); 
	}


}