コード例 #1
0
void AppClass::InitVariables(void)
{
	//Set the camera at a position other than the default
	m_pCameraMngr->SetPositionTargetAndView(
		vector3(0.0f, 0.0f, 35.0f),
		vector3(0.0f, 0.0f, 0.0f),
		REAXISY);

	m_nObjects = 100;

	m_pMatrix = new matrix4[m_nObjects];
	m_pSphere = new PrimitiveClass[m_nObjects];

	vector3 v3Start(-m_nObjects, 0.0f, 0.0f);
	vector3 v3End(m_nObjects, 0.0f, 0.0f);

	vector3 v3Current;
	
	for (uint i = 0; i < m_nObjects; i++)
	{
		float fPercent = MapValue(
									static_cast<float>(i), // Value to change
									0.0f,					// Original Min
									static_cast<float>(m_nObjects-1),//Original Max
									0.0f,					//New Min
									1.0f);					//Nem Max
		v3Current = glm::lerp(v3Start, v3End, fPercent);
		m_pSphere[i].GenerateSphere(0.5f, 5, RERED/*vector3(1.0f, 0.0f, 0.0f)*/);
		m_pMatrix[i] = glm::translate(v3Current);
	}
}
コード例 #2
0
ファイル: AppClass.cpp プロジェクト: dwels/ReEngineApp_2015s
void AppClass::InitVariables(void)
{
	//m_selection = std::pair<int, int>(-1, -1);
	////Set the camera at a position other than the default
	//m_pCameraMngr->SetPositionTargetAndView(vector3(0.0f, 2.5f, 12.0f), vector3(0.0f, 2.5f, 11.0f), REAXISY);

	//m_pLightMngr->SetColor(REWHITE, 0);
	//m_pLightMngr->SetIntensity(0.1f, 0);
	//m_pLightMngr->SetColor(REWHITE, 1);
	//m_pLightMngr->SetIntensity(0.5f, 1);
	//m_pLightMngr->SetPosition(vector3(0.0f, 1.0f,-1.0f), 1);

	////Load a model onto the Mesh manager
	////m_pMeshMngr->LoadModel("tests\\Cubev.fbx", "Unikitty");
	//int nCubes = 10;
	//vector3 v3Start(-nCubes/2.0f, 0.0f, -nCubes / 2.0f);
	//m_pMeshMngr->LoadModel("Cube.obj", "ElCubo");
	//m_pMeshMngr->SetShaderProgramByName("ElCubo", "Phong");
	//for (uint n = 0; n < nCubes; n++)
	//{
	//	if (v3Start != vector3(0.0f))
	//	{
	//		String sName = "Cube_" + std::to_string(n);
	//		m_pMeshMngr->LoadModel("Cube.obj", sName, false, glm::translate(v3Start));
	//		m_pMeshMngr->SetShaderProgramByName(sName, "Phong");
	//	}
	//	v3Start += vector3(1.0f, 0.0f, 1.0f);
	//}

	m_pCameraMngr->SetPositionTargetAndView(
		vector3(0.0f, 2.5f, 12.0f),
		vector3(0.0f, 2.5f, 11.0f),
		vector3(0.0f, 1.0f, 0.0f));

	m_nObjects = 10;

	m_pSphere = new PrimitiveClass[m_nObjects];
	m_pMatrix = new matrix4[m_nObjects];

	vector3 v3Start(-static_cast<float>(m_nObjects),0.0f,0.0f);
	vector3 v3End(static_cast<float>(m_nObjects), 0.0f, 0.0f);
	vector3 v3Current = glm::lerp(v3Start,v3End,1.0f);

	for (uint i = 0; i < m_nObjects; i++)
	{
		float fPercent = MapValue(
			static_cast<float>(i),				//value to change
			0.0f,								//original min
			static_cast<float>(m_nObjects) -1,		//original max
			0.0f,								//new min
			1.0f								//new max
			);
		m_pSphere[i].GenerateSphere(0.5f, 5, RERED);
		vector3 v3Current = glm::lerp(v3Start, v3End, fPercent);
		m_pMatrix[i] = glm::translate(v3Current);
	}
}
コード例 #3
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;

	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);
}
コード例 #4
0
void AppClass::Update(void)
{
#pragma region Does not change anything here
	//Update the system's time
	m_pSystem->UpdateTime();

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

#pragma region Does not need changes but feel free to change anything here
	//Lets us know how much time has passed since the last call
	double fTimeSpan = m_pSystem->LapClock(); //Delta time (between frame calls)

	//cumulative time
	static double fRunTime = 0.0f; //How much time has passed since the program started
	fRunTime += fTimeSpan; 
#pragma endregion

#pragma region Your Code goes here
	m_pMeshMngr->SetModelMatrix(IDENTITY_M4, "WallEye");
	
	//loop through all locations, move from point to point.
	for (uint i = 0; i < m_dataSize; i++)
	{
        float fPercent = MapValue(
            static_cast<float>(i),
            0.0f,
            static_cast<float>(m_dataSize),
            0.0f,
            1.0f
            );

        //If on the last point, we want to make sure to go to the 1st position.
        //this doesn't actually move... anything...
        if ( i != m_dataSize) 
        {
            //this needs to take one i position and move it to the next but it doesn't so RIP
            vector3 v3Start(static_cast<float>(m_dataSize), 0.0f, 0.0f);
            vector3 v3End = glm::lerp(v3Start, v3End, static_cast<float>(1));

            vector3 v3Current = glm::lerp(v3Start, v3End, fPercent);
            m_pMatrix[i] = glm::translate(v3Current);
        }
        else 
        {
            vector3 v3Start(static_cast<float>(m_dataSize), 0.0f, 0.0f);
            vector3 v3End = glm::lerp(v3Start, v3End, static_cast<float>(1));

            vector3 v3Current = glm::lerp(v3Start, v3End, fPercent);
            m_pMatrix[i] = glm::translate(v3Current);
        }
	}

#pragma endregion

#pragma region Does not need changes but feel free to change anything here
	//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);
#pragma endregion
}