当前位置: 首页>>代码示例>>C++>>正文


C++ Mtx44类代码示例

本文整理汇总了C++中Mtx44的典型用法代码示例。如果您正苦于以下问题:C++ Mtx44类的具体用法?C++ Mtx44怎么用?C++ Mtx44使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Mtx44类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ReflectXZPlane

void MS::ReflectXZPlane()
{
    Mtx44 mat;
    mat.SetToReflectionXZplane();
    ms.top() = ms.top() * mat;
}
开发者ID:MonkeyD-IchiJou,项目名称:OHEngine-OuterHeaven-,代码行数:6,代码来源:MatrixStack.cpp

示例2: glClearColor

void PLANET5::Init()
{
	// Init VBO here
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Set background color
	glEnable(GL_DEPTH_TEST); // Enable depth buffer and depth testing
	glEnable(GL_CULL_FACE); // Enable back face culling
	// Enable blending
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // Default to fill mode
	//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

	// Generate a default VAO for now
	glGenVertexArrays(1, &m_vertexArrayID);
	glBindVertexArray(m_vertexArrayID);
	m_programID = LoadShaders("Shader//Texture.vertexshader", "Shader//Text.fragmentshader");
	m_parameters[U_MVP] = glGetUniformLocation(m_programID, "MVP");
	m_parameters[U_MODELVIEW] = glGetUniformLocation(m_programID, "MV");
	m_parameters[U_MODELVIEW_INVERSE_TRANSPOSE] = glGetUniformLocation(m_programID, "MV_inverse_transpose");
	m_parameters[U_MATERIAL_AMBIENT] = glGetUniformLocation(m_programID, "material.kAmbient");
	m_parameters[U_MATERIAL_DIFFUSE] = glGetUniformLocation(m_programID, "material.kDiffuse");
	m_parameters[U_MATERIAL_SPECULAR] = glGetUniformLocation(m_programID, "material.kSpecular");
	m_parameters[U_MATERIAL_SHININESS] = glGetUniformLocation(m_programID, "material.kShininess");
	m_parameters[U_LIGHT0_TYPE] = glGetUniformLocation(m_programID, "lights[0].type");
	m_parameters[U_LIGHT0_POSITION] = glGetUniformLocation(m_programID, "lights[0].position_cameraspace");
	m_parameters[U_LIGHT0_COLOR] = glGetUniformLocation(m_programID, "lights[0].color");
	m_parameters[U_LIGHT0_POWER] = glGetUniformLocation(m_programID, "lights[0].power");
	m_parameters[U_LIGHT0_KC] = glGetUniformLocation(m_programID, "lights[0].kC");
	m_parameters[U_LIGHT0_KL] = glGetUniformLocation(m_programID, "lights[0].kL");
	m_parameters[U_LIGHT0_KQ] = glGetUniformLocation(m_programID, "lights[0].kQ");
	m_parameters[U_LIGHTENABLED] = glGetUniformLocation(m_programID, "lightEnabled");

	m_parameters[U_LIGHT1_TYPE] = glGetUniformLocation(m_programID, "lights[1].type");
	m_parameters[U_LIGHT1_POSITION] = glGetUniformLocation(m_programID, "lights[1].position_cameraspace");
	m_parameters[U_LIGHT1_COLOR] = glGetUniformLocation(m_programID, "lights[1].color");
	m_parameters[U_LIGHT1_POWER] = glGetUniformLocation(m_programID, "lights[1].power");
	m_parameters[U_LIGHT1_KC] = glGetUniformLocation(m_programID, "lights[1].kC");
	m_parameters[U_LIGHT1_KL] = glGetUniformLocation(m_programID, "lights[1].kL");
	m_parameters[U_LIGHT1_KQ] = glGetUniformLocation(m_programID, "lights[1].kQ");
	m_parameters[U_LIGHT1_SPOTDIRECTION] = glGetUniformLocation(m_programID, "lights[1].spotDirection");
	m_parameters[U_LIGHT1_COSCUTOFF] = glGetUniformLocation(m_programID, "lights[1].cosCutoff");
	m_parameters[U_LIGHT1_COSINNER] = glGetUniformLocation(m_programID, "lights[1].cosInner");
	m_parameters[U_LIGHT1_EXPONENT] = glGetUniformLocation(m_programID, "lights[1].exponent");

	m_parameters[U_NUMLIGHTS] = glGetUniformLocation(m_programID, "numLights"); //in case you missed out practical 7
	m_parameters[U_TEXT_ENABLED] = glGetUniformLocation(m_programID, "textEnabled");
	m_parameters[U_TEXT_COLOR] = glGetUniformLocation(m_programID, "textColor");

	// Get a handle for our "colorTexture" uniform
	m_parameters[U_COLOR_TEXTURE_ENABLED] = glGetUniformLocation(m_programID, "colorTextureEnabled");
	m_parameters[U_COLOR_TEXTURE] = glGetUniformLocation(m_programID, "colorTexture");
	glUseProgram(m_programID);

	//variable to rotate geometry

	//Initialize camera settings
	camera.Init(Vector3(0, 5, 100), Vector3(0, 5, 0), Vector3(0, 1, 0));

	meshList[GEO_AXES] = MeshBuilder::GenerateAxes("AXES", 1000, 1000, 1000);

	Mtx44 projection;
	projection.SetToPerspective(45.f, 4.f / 3.f, 0.1f, 100000.f);
	projectionStack.LoadMatrix(projection);

	light[0].type = Light::LIGHT_POINT;
	light[0].position.Set(0, 48, 0);
	light[0].color.Set(1, 1, 1);
	light[0].power = 1.f;
	light[0].kC = 1.f;
	light[0].kL = 0.01f;
	light[0].kQ = 0.001f;

	light[1].type = Light::LIGHT_DIRECTIONAL;
	light[1].position.Set(0, 300, -400);
	light[1].color.Set(1, 1, 1);
	light[1].power = 1;
	light[1].kC = 1.f;
	light[1].kL = 0.01f;
	light[1].kQ = 0.001f;
	light[1].cosCutoff = cos(Math::DegreeToRadian(45));
	light[1].cosInner = cos(Math::DegreeToRadian(30));
	light[1].exponent = 3.f;
	light[1].spotDirection.Set(0.f, 1.f, 0.f);

	// Make sure you pass uniform parameters after glUseProgram()
	glUniform1i(m_parameters[U_LIGHT0_TYPE], light[0].type);
	glUniform3fv(m_parameters[U_LIGHT0_COLOR], 1, &light[0].color.r);
	glUniform1f(m_parameters[U_LIGHT0_POWER], light[0].power);
	glUniform1f(m_parameters[U_LIGHT0_KC], light[0].kC);
	glUniform1f(m_parameters[U_LIGHT0_KL], light[0].kL);
	glUniform1f(m_parameters[U_LIGHT0_KQ], light[0].kQ);

	glUniform1i(m_parameters[U_LIGHT1_TYPE], light[1].type);
	glUniform3fv(m_parameters[U_LIGHT1_COLOR], 1, &light[1].color.r);
	glUniform1f(m_parameters[U_LIGHT1_POWER], light[1].power);
	glUniform1f(m_parameters[U_LIGHT1_KC], light[1].kC);
	glUniform1f(m_parameters[U_LIGHT1_KL], light[1].kL);
	glUniform1f(m_parameters[U_LIGHT1_KQ], light[1].kQ);

//.........这里部分代码省略.........
开发者ID:hermitlt3,项目名称:SP2Folder,代码行数:101,代码来源:Planet5.cpp

示例3: GetCursorPos

void Camera2::Update(double dt)
{
	//Mouse shit
	POINT currentposition_;
	GetCursorPos(&currentposition_);
	static const float CAMERA_SPEED = 40.f;
	//Move front
	if (Application::IsKeyPressed('W'))
	{
		Vector3 view = (target - position).Normalized();
		view.y = 0;
		position += (view * dt * 10.f);
		target += (view * dt * 10.f);
	}

	//Move Back
	if (Application::IsKeyPressed('S'))
	{
		Vector3 view = (target - position).Normalized();
		view.y = 0;
		position -= (view * dt * 10.f);
		target -= (view * dt * 10.f);
	}

	//Move Right
	if (Application::IsKeyPressed('D'))
	{
		Vector3 view = (target - position).Normalized();
		Vector3 right=view.Cross(up);
		right.y = 0;
		position += (right * dt * 10.f);
		target += (right * dt * 10.f);
	}
	//Move Left
	if (Application::IsKeyPressed('A'))
	{
		Vector3 view = (target - position).Normalized();
		Vector3 right = view.Cross(up);
		right.y = 0;
		position -= (right * dt * 10.f);
		target -= (right * dt * 10.f);
	}
	//Rotate up
	if (Application::IsKeyPressed(VK_UP)) //Pitch
	{
		//Original
		float pitch = (float)(CAMERA_SPEED * dt);
		/*Vector3 view = (target - position).Normalized();
		Vector3 right = view.Cross(up);
		right.y = 0;
		right.Normalize();
		up = right.Cross(view).Normalized();
		Mtx44 rotation;
		rotation.SetToRotation(pitch, right.x, right.y, right.z);
		position = rotation * position;*/
		// FOr FP view
		Vector3 view = (target - position).Normalized();
		Vector3 right = view.Cross(up);
		up = right.Cross(view).Normalized();
		Mtx44 rotation;
		rotation.SetToRotation(pitch, right.x, right.y, right.z);
		view = rotation * view;
		target = position + view;

	}
	//Rotate Down
	if (Application::IsKeyPressed(VK_DOWN)) //Pitch, down
	{
		float pitch = (float)(-CAMERA_SPEED * dt);
		//Original
		/*Vector3 view = (target - position).Normalized();
		Vector3 right = view.Cross(up);
		right.y = 0;
		right.Normalize();
		up = right.Cross(view).Normalized();
		Mtx44 rotation;
		rotation.SetToRotation(pitch, right.x, right.y, right.z);
		position = rotation * position;*/
		//Fp Camera
		Vector3 view = (target - position).Normalized();
		Vector3 right = view.Cross(up);
		up = right.Cross(view).Normalized();
		Mtx44 rotation;
		rotation.SetToRotation(pitch, right.x, right.y, right.z);
		view = rotation * view;
		target = position + view;
	}
	//Rotate Right
	if (Application::IsKeyPressed(VK_RIGHT))
	{
		float yaw = (float)(-CAMERA_SPEED * dt);
		//Original
		/*	Mtx44 rotation;
		rotation.SetToRotation(yaw, 0, 1, 0);
		position = rotation * position;
		up = rotation * up;*/
		//FP camera
		Vector3 view = (target - position).Normalized();
		Mtx44 rotation;
		rotation.SetToRotation(yaw, 0, 1, 0);
//.........这里部分代码省略.........
开发者ID:HighwindEasy,项目名称:Compg,代码行数:101,代码来源:Camera2.cpp

示例4: glClear

void Assignment1::Render()
{
	// Render VBO here
	
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	Mtx44 translate, rotate, scale;
	Mtx44 model;
	Mtx44 view;
	Mtx44 projection;
	Mtx44 MVP;

	translate.SetToIdentity();
	rotate.SetToIdentity();
	scale.SetToIdentity();
	model.SetToIdentity();
	view.SetToIdentity();

	projection.SetToOrtho(-40, 40, -30, 30, -10, 10);

	glEnableVertexAttribArray(0);// 1st attribute buffer: vertices 
	glEnableVertexAttribArray(1); // 2nd attribute buffer : colors
	//<landscape>
	scale.SetToScale(125, 125, 125);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(0,-125,1);
	model = translate * rotate * scale; 
	MVP = projection * view * model; 
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[LANDSCAPE_1]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[LANDSCAPE_1]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 5);

	model.SetToIdentity();

	scale.SetToScale(20, 20, 20);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(25, 0, 0);
	model = translate * rotate * scale; 
	MVP = projection * view * model; 
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[LANDSCAPE_1]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[LANDSCAPE_1]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 5);

	model.SetToIdentity();

	scale.SetToScale(50, 20, 20);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(10, -5, -0.5);
	model = translate * rotate * scale; 
	MVP = projection * view * model; 
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); 
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[LANDSCAPE_1]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[LANDSCAPE_1]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 5);
	//</landscape>

	//<cloud>
	scale.SetToScale(10, 10, 10);
	rotate.SetToRotation(25, 0, 0, 1);
	translate.SetToTranslation(cloudMovement , 25, 0.5f);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[CLOUDS_2]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[CLOUDS_2]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 12);

	//</cloud>
	//<sun>
	scale.SetToScale(5, 5, 5);
	rotate.SetToRotation(rotateAngle, 0, 0, 1);
	translate.SetToTranslation(-25, 20, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[SUN_3]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[SUN_3]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 9);
	
	//</sun>
	//<explosion>
	scale.SetToScale(explosionSize, explosionSize, explosionSize);
	rotate.SetToRotation(explosionRotation, 0, 0, 1);
	translate.SetToTranslation(-25, 20, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[EXPLOSION_4]);
//.........这里部分代码省略.........
开发者ID:Li-Zhaoyuan,项目名称:KappaCOMG,代码行数:101,代码来源:Assignment1.cpp

示例5: glClear

void SceneText::Render()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	Mtx44 perspective;
	perspective.SetToPerspective(45.0f, 4.0f / 3.0f, 0.1f, 10000.0f);
	//perspective.SetToOrtho(-80, 80, -60, 60, -1000, 1000);
	projectionStack.LoadMatrix(perspective);
	
	// Camera matrix
	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
					);
	// Model matrix : an identity matrix (model will be at the origin)
	modelStack.LoadIdentity();

	if(lights[0].type == Light::LIGHT_DIRECTIONAL)
	{
		Vector3 lightDir(lights[0].position.x, lights[0].position.y, lights[0].position.z);
		Vector3 lightDirection_cameraspace = viewStack.Top() * lightDir;
		glUniform3fv(m_parameters[U_LIGHT0_POSITION], 1, &lightDirection_cameraspace.x);
	}
	else if(lights[0].type == Light::LIGHT_SPOT)
	{
		Position lightPosition_cameraspace = viewStack.Top() * lights[0].position;
		glUniform3fv(m_parameters[U_LIGHT0_POSITION], 1, &lightPosition_cameraspace.x);
		Vector3 spotDirection_cameraspace = viewStack.Top() * lights[0].spotDirection;
		glUniform3fv(m_parameters[U_LIGHT0_SPOTDIRECTION], 1, &spotDirection_cameraspace.x);
	}
	else
	{
		Position lightPosition_cameraspace = viewStack.Top() * lights[0].position;
		glUniform3fv(m_parameters[U_LIGHT0_POSITION], 1, &lightPosition_cameraspace.x);
	}
	if(lights[1].type == Light::LIGHT_DIRECTIONAL)
	{
		Vector3 lightDir(lights[1].position.x, lights[1].position.y, lights[1].position.z);
		Vector3 lightDirection_cameraspace = viewStack.Top() * lightDir;
		glUniform3fv(m_parameters[U_LIGHT1_POSITION], 1, &lightDirection_cameraspace.x);
	}
	else if(lights[1].type == Light::LIGHT_SPOT)
	{
		Position lightPosition_cameraspace = viewStack.Top() * lights[1].position;
		glUniform3fv(m_parameters[U_LIGHT1_POSITION], 1, &lightPosition_cameraspace.x);
		Vector3 spotDirection_cameraspace = viewStack.Top() * lights[1].spotDirection;
		glUniform3fv(m_parameters[U_LIGHT1_SPOTDIRECTION], 1, &spotDirection_cameraspace.x);
	}
	else
	{
		Position lightPosition_cameraspace = viewStack.Top() * lights[1].position;
		glUniform3fv(m_parameters[U_LIGHT1_POSITION], 1, &lightPosition_cameraspace.x);
	}
	
	RenderMesh(meshList[GEO_AXES], false);
	
	modelStack.PushMatrix();
	modelStack.Translate(lights[0].position.x, lights[0].position.y, lights[0].position.z);
	RenderMesh(meshList[GEO_LIGHTBALL], false);
	modelStack.PopMatrix();

	/** crosshair **/
	RenderMeshIn2D(meshList[GEO_CROSSHAIR], false);

	RenderSkybox();

	// perspective;
	////perspective.SetToPerspective(45.0f, 4.0f / 3.0f, 0.1f, 10000.0f);
	//perspective.SetToOrtho(-80, 80, -60, 60, -1000, 1000);
	//projectionStack.LoadMatrix(perspective);
	//viewStack.LoadIdentity();
	//
	//modelStack.PushMatrix();
	////modelStack.Translate(20, 0, -20);
	////modelStack.Scale(0.1f, 0.1f, 0.1f);
	//modelStack.Scale(50, 50, 50);
	////RenderMesh(meshList[GEO_QUAD], false);
	//RenderText(meshList[GEO_TEXT], "HelloWorld", Color(0, 1, 0));
	//modelStack.PopMatrix();
	modelStack.PushMatrix();
	modelStack.Translate(-20, 0, -20);
	RenderMesh(meshList[GEO_OBJECT], false);
	modelStack.PopMatrix();
	
	modelStack.PushMatrix();
	modelStack.Translate(20, 0, -20);
	RenderMesh(meshList[GEO_OBJECT], true);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Scale(10, 10, 10);
	//RenderText(meshList[GEO_TEXT], "Hello World", Color(0, 1, 0));
	RenderText(meshList[GEO_TEXT], "Hello World", Color(0, 1, 0));
	modelStack.PopMatrix();

	//On screen text
	std::ostringstream ss;
	ss.precision(5);
	ss << "FPS: " << fps;
//.........这里部分代码省略.........
开发者ID:barryHub20,项目名称:SP3,代码行数:101,代码来源:SceneText.cpp

示例6: glClearColor


//.........这里部分代码省略.........
	m_parameters[U_LIGHT0_KQ] = glGetUniformLocation(m_programID, "lights[0].kQ");
	m_parameters[U_LIGHT0_TYPE] = glGetUniformLocation(m_programID, "lights[0].type");
	m_parameters[U_LIGHT0_SPOTDIRECTION] = glGetUniformLocation(m_programID, "lights[0].spotDirection");
	m_parameters[U_LIGHT0_COSCUTOFF] = glGetUniformLocation(m_programID, "lights[0].cosCutoff");
	m_parameters[U_LIGHT0_COSINNER] = glGetUniformLocation(m_programID, "lights[0].cosInner");
	m_parameters[U_LIGHT0_EXPONENT] = glGetUniformLocation(m_programID, "lights[0].exponent");
	m_parameters[U_LIGHTENABLED] = glGetUniformLocation(m_programID, "lightEnabled");
	m_parameters[U_NUMLIGHTS] = glGetUniformLocation(m_programID, "numLights");
	m_parameters[U_COLOR_TEXTURE_ENABLED] = glGetUniformLocation(m_programID, "colorTextureEnabled");
	m_parameters[U_COLOR_TEXTURE] = glGetUniformLocation(m_programID, "colorTexture");
	m_parameters[U_TEXT_ENABLED] = glGetUniformLocation(m_programID, "textEnabled");
	m_parameters[U_TEXT_COLOR] = glGetUniformLocation(m_programID, "textColor");

	glUseProgram(m_programID);

	light[0].type = Light::LIGHT_SPOT;
	light[0].position.Set(camera.position.x, camera.position.y, camera.position.z);
	light[0].color.Set(1, 1, 1);
	light[0].power = 2.0f;
	light[0].kC = 1.f;
	light[0].kL = 0.01f;
	light[0].kQ = 0.001f;
	light[0].cosCutoff = cos(Math::DegreeToRadian(30));
	light[0].cosInner = cos(Math::DegreeToRadian(15));
	light[0].exponent = 3.f;
	light[0].spotDirection.Set(-(camera.target.x - camera.position.x), -(camera.target.y - camera.position.y), -(camera.target.z - camera.position.z));

	// Pass information
	glUniform1i(m_parameters[U_NUMLIGHTS], 1);

	glUniform1i(m_parameters[U_LIGHT0_TYPE], light[0].type);
	glUniform3fv(m_parameters[U_LIGHT0_COLOR], 1, &light[0].color.r);
	glUniform1f(m_parameters[U_LIGHT0_POWER], light[0].power);
	glUniform1f(m_parameters[U_LIGHT0_KC], light[0].kC);
	glUniform1f(m_parameters[U_LIGHT0_KL], light[0].kL);
	glUniform1f(m_parameters[U_LIGHT0_KQ], light[0].kQ);
	glUniform1f(m_parameters[U_LIGHT0_COSCUTOFF], light[0].cosCutoff);
	glUniform1f(m_parameters[U_LIGHT0_COSINNER], light[0].cosInner);
	glUniform1f(m_parameters[U_LIGHT0_EXPONENT], light[0].exponent);

	//Initialize camera settings
	camera.Init(Vector3(0, 10, 0), Vector3(0, 15, 1), Vector3(0, 1, 0));

	meshList[GEO_AXES] = MeshBuilder::GenerateAxes("reference", 1000, 1000, 1000);

	meshList[GEO_LIGHTBALL] = MeshBuilder::GenerateSphere("lightball", Color(1, 1, 1), 10, 20);

	meshList[GEO_FRONT] = MeshBuilder::GenerateQuad("front", Color(1, 1, 1));
	meshList[GEO_FRONT]->textureID = LoadTGA("Image//SkyBox1_front.tga");
	meshList[GEO_LEFT] = MeshBuilder::GenerateQuad("left", Color(1, 1, 1));
	meshList[GEO_LEFT]->textureID = LoadTGA("Image//SkyBox1_left.tga");
	meshList[GEO_RIGHT] = MeshBuilder::GenerateQuad("right", Color(1, 1, 1));
	meshList[GEO_RIGHT]->textureID = LoadTGA("Image//SkyBox1_right.tga");
	meshList[GEO_TOP] = MeshBuilder::GenerateQuad("top", Color(1, 1, 1));
	meshList[GEO_TOP]->textureID = LoadTGA("Image//SkyBox1_up.tga");
	meshList[GEO_BOTTOM] = MeshBuilder::GenerateQuad("SkyBox1_down", Color(1, 1, 1));
	meshList[GEO_BOTTOM]->textureID = LoadTGA("Image//SkyBox1_down.tga");
	meshList[GEO_BACK] = MeshBuilder::GenerateQuad("SkyBox1_back", Color(1, 1, 1));
	meshList[GEO_BACK]->textureID = LoadTGA("Image//SkyBox1_back.tga");

	meshList[GEO_QUAD] = MeshBuilder::GenerateQuad("SceneOpening", Color(0, 0, 0));

	meshList[GEO_TEXT] = MeshBuilder::GenerateText("text", 16, 16);
	meshList[GEO_TEXT]->textureID = LoadTGA("Image//calibri.tga");

	meshList[GEO_PLANETFLOOR] = MeshBuilder::GenerateQuad("planet floor", Color(1, 1, 1));
	meshList[GEO_PLANETFLOOR]->textureID = LoadTGA("Image//PlanetFloor.tga");

	meshList[GEO_FACILITYOUT] = MeshBuilder::GenerateOBJ("Facility Outer", "OBJ//FacilityOUT.obj");
	meshList[GEO_FACILITYOUT]->textureID = LoadTGA("Image//FacilityOUT.tga");

	meshList[GEO_FACILITYOUTWALL] = MeshBuilder::GenerateQuad("FacilityOUT wall", Color(1, 1, 1));
	meshList[GEO_FACILITYOUTWALL]->textureID = LoadTGA("Image//OutsideWALL.tga");

	meshList[GEO_DEADBODY] = MeshBuilder::GenerateOBJ("Pile of dead body", "OBJ//DeadBody.obj");
	meshList[GEO_DEADBODY]->textureID = LoadTGA("Image//DeadBody.tga");

	Mtx44 projection;
	projection.SetToPerspective(45.f, 16.f / 9.f, 0.1f, 10000.f);
	projectionStack.LoadMatrix(projection);

	 rotateCamX = false;
	 MoveCamera1 = 0;
	 camera_check1 = true;
	 camera_check2 = false;
	 camera_check3 = false;
	 rotateCamY = false;
	 RotateCamera = 0;

	 wokeUp = true;
	 check1 = true;
	 check2 = false;
	 check3 = false;
	 eyeOpening = 0;

	 text1 = false;
	 text2 = false;

	// All Switches Debounce Key
}
开发者ID:BuddhaProgram,项目名称:SP2-PDEntertainment,代码行数:101,代码来源:OpeningCutScene2.cpp

示例7: Update

void Helicopter::Update(double dt, bool controlling)
{
    static const float THRUST_SPEED = 10.f;
    static const float THRUST_LIMIT = 5.f;
    static const float TURN_SPEED = 100.f;

    bool piloting = false;

    if (controlling) {
        if (Application::IsKeyPressed('W'))
        {
            if (thrustSpeed < THRUST_LIMIT)
                thrustSpeed += (float)(THRUST_SPEED * dt);

            piloting = true;
        }
        if (Application::IsKeyPressed('S'))
        {
            if (thrustSpeed > -THRUST_LIMIT)
                thrustSpeed -= (float)(THRUST_SPEED * dt);

            piloting = true;
        }

        if (Application::IsKeyPressed('A'))
        {
            float yaw = (float)(TURN_SPEED * dt);

            rotateYaw += yaw;
            camera.Rotate(yaw, 0, 1, 0);

            Mtx44 rotate;
            rotate.SetToRotation(yaw, 0, 1, 0);
            thrustDir = rotate * thrustDir;
            frontDir = rotate * frontDir;
            right = rotate * right;
        }
        if (Application::IsKeyPressed('D'))
        {
            float yaw = (float)(-TURN_SPEED * dt);

            rotateYaw += yaw;
            camera.Rotate(yaw, 0, 1, 0);

            Mtx44 rotate;
            rotate.SetToRotation(yaw, 0, 1, 0);
            thrustDir = rotate * thrustDir;
            frontDir = rotate * frontDir;
            right = rotate * right;
        }
        if (Application::IsKeyPressed(VK_NUMPAD8))
        {
            float pitch = (float)(-TURN_SPEED * dt);

            rotatePitch += pitch;
            //camera.Rotate(pitch, right.x, right.y, right.z);

            Mtx44 rotate;
            rotate.SetToRotation(pitch, right.x, right.y, right.z);
            thrustDir = rotate * thrustDir;
            frontDir = rotate * frontDir;
            std::cout << frontDir << std::endl;
        }
        if (Application::IsKeyPressed(VK_NUMPAD5))
        {
            float pitch = (float)(TURN_SPEED * dt);

            rotatePitch += pitch;
            //camera.Rotate(pitch, right.x, right.y, right.z);

            Mtx44 rotate;
            rotate.SetToRotation(pitch, right.x, right.y, right.z);
            thrustDir = rotate * thrustDir;
            frontDir = rotate * frontDir;
        }
        if (Application::IsKeyPressed(VK_NUMPAD4))
        {
            float roll = (float)(-TURN_SPEED * dt);

            rotateRoll += roll;

            Mtx44 rotate;
            rotate.SetToRotation(roll, frontDir.x, frontDir.y, frontDir.z);
            thrustDir = rotate * thrustDir;
            right = rotate * right;
        }
        if (Application::IsKeyPressed(VK_NUMPAD6))
        {
            float roll = (float)(TURN_SPEED * dt);

            rotateRoll += roll;

            Mtx44 rotate;
            rotate.SetToRotation(roll, frontDir.x, frontDir.y, frontDir.z);
            thrustDir = rotate * thrustDir;
            right = rotate * right;
        }
    }
    if (!piloting) {
        if (thrustSpeed > 0.f) {
//.........这里部分代码省略.........
开发者ID:zenden145,项目名称:SP2_Team18,代码行数:101,代码来源:Helicopter.cpp

示例8: Translate

void MS::Translate(float translateX, float translateY, float translateZ) {
	Mtx44 mat;
	mat.SetToTranslation(translateX, translateY, translateZ);
	ms.top() = ms.top() * mat;
}
开发者ID:Chongjx,项目名称:Alpha,代码行数:5,代码来源:MatrixStack.cpp

示例9:

MS::MS() {
	Mtx44 mat;
	mat.SetToIdentity();
	ms.push(mat);
}
开发者ID:Chongjx,项目名称:Alpha,代码行数:5,代码来源:MatrixStack.cpp

示例10: Rotate

void MS::Rotate(float degrees, float axisX, float axisY, float axisZ) {
	Mtx44 mat;
	mat.SetToRotation(degrees, axisX, axisY, axisZ);
	ms.top() = ms.top() * mat;
}
开发者ID:Chongjx,项目名称:Alpha,代码行数:5,代码来源:MatrixStack.cpp

示例11: Scale

void MS::Scale(float scaleX, float scaleY, float scaleZ) {
	Mtx44 mat;
	mat.SetToScale(scaleX, scaleY, scaleZ);
	ms.top() = ms.top() * mat;
}
开发者ID:Chongjx,项目名称:Alpha,代码行数:5,代码来源:MatrixStack.cpp

示例12: glClear

void Assignment1::Render()
{
	// Clear color buffer & depth every frame
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	Mtx44 translate, rotate, scale;
	Mtx44 model;
	Mtx44 view;
	Mtx44 projection;
	Mtx44 MVP;

	translate.SetToIdentity();
	rotate.SetToIdentity();
	scale.SetToIdentity();
	model.SetToIdentity();
	view.SetToIdentity(); // no need camera for now, set it at World's origin
	projection.SetToOrtho(-40, +40, -30, +30, -10, +10); // Our world is a cube defined by these boundaries
	glEnableVertexAttribArray(0); // 1st attribute buffer : vertices
	glEnableVertexAttribArray(1); // 2nd attribute buffer : colors
	////////////////////This Section Places the Objects////////////////////
	//Ground();
	{
		scale.SetToScale(50, 50, 50);
		rotate.SetToRotation(0, 0, 0, 1);
		translate.SetToTranslation(-40, -48, -1);
		model = translate * rotate * scale;
		MVP = projection * view * model;
		glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

		glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_RECTANGLE]);
		glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
		glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_RECTANGLE]);
		glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
		// Draw the Rectangle
		glDrawArrays(GL_TRIANGLE_FAN, 0, 4);

		scale.SetToScale(50, 50, 50);
		rotate.SetToRotation(0, 0, 0, 1);
		translate.SetToTranslation(-40, -60, -0);
		model = translate * rotate * scale;
		MVP = projection * view * model;
		glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

		glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_RECTANGLE]);
		glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
		glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_BLUECOLOR]);
		glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
		// Draw the Rectangle
		glDrawArrays(GL_TRIANGLE_FAN, 0, 4);

	}
/////////////////////////////////////////////////////////////////////////////////
	//Mountains();
	scale.SetToScale(5, 5, 5);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-40, -9, -2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3); 

	
	scale.SetToScale(6, 6, 6);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-36, -9, -2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);
	scale.SetToScale(5, 5, 5);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-32, -9, -2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);
	//Mountains();
	scale.SetToScale(8, 8, 8);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-30, -9, -2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP
//.........这里部分代码省略.........
开发者ID:HighwindEasy,项目名称:Compg,代码行数:101,代码来源:Assignment1.cpp

示例13: LoadShaders

void SceneText::Init()
{
    // Load vertex and fragment shaders
    m_programID = LoadShaders(
                      "Shader//Texture.vertexshader",
                      "Shader//Text.fragmentshader"
                  );
    // Get a handle for our "MVP" uniform
    m_parameters[U_MVP] = glGetUniformLocation(m_programID, "MVP");
    m_parameters[U_MODELVIEW] = glGetUniformLocation(m_programID, "MV");
    m_parameters[U_MODELVIEW_INVERSE_TRANSPOSE] = glGetUniformLocation(m_programID, "MV_inverse_transpose");
    m_parameters[U_MATERIAL_AMBIENT] = glGetUniformLocation(m_programID, "material.kAmbient");
    m_parameters[U_MATERIAL_DIFFUSE] = glGetUniformLocation(m_programID, "material.kDiffuse");
    m_parameters[U_MATERIAL_SPECULAR] = glGetUniformLocation(m_programID, "material.kSpecular");
    m_parameters[U_MATERIAL_SHININESS] = glGetUniformLocation(m_programID, "material.kShininess");
    m_parameters[U_LIGHT0_POSITION] = glGetUniformLocation(m_programID, "lights[0].position_cameraspace");
    m_parameters[U_LIGHT0_COLOR] = glGetUniformLocation(m_programID, "lights[0].color");
    m_parameters[U_LIGHT0_POWER] = glGetUniformLocation(m_programID, "lights[0].power");
    m_parameters[U_LIGHT0_KC] = glGetUniformLocation(m_programID, "lights[0].kC");
    m_parameters[U_LIGHT0_KL] = glGetUniformLocation(m_programID, "lights[0].kL");
    m_parameters[U_LIGHT0_KQ] = glGetUniformLocation(m_programID, "lights[0].kQ");
    m_parameters[U_LIGHT0_TYPE] = glGetUniformLocation(m_programID, "lights[0].type");
    m_parameters[U_LIGHT0_SPOTDIRECTION] = glGetUniformLocation(m_programID, "lights[0].spotDirection");
    m_parameters[U_LIGHT0_COSCUTOFF] = glGetUniformLocation(m_programID, "lights[0].cosCutoff");
    m_parameters[U_LIGHT0_COSINNER] = glGetUniformLocation(m_programID, "lights[0].cosInner");
    m_parameters[U_LIGHT0_EXPONENT] = glGetUniformLocation(m_programID, "lights[0].exponent");
    m_parameters[U_NUMLIGHTS] = glGetUniformLocation(m_programID, "numLights");
    m_parameters[U_LIGHTENABLED] = glGetUniformLocation(m_programID, "lightEnabled");
    m_parameters[U_COLOR_TEXTURE_ENABLED] = glGetUniformLocation(m_programID, "colorTextureEnabled");
    m_parameters[U_COLOR_TEXTURE] = glGetUniformLocation(m_programID, "colorTexture");
    m_parameters[U_TEXT_ENABLED] = glGetUniformLocation(m_programID, "textEnabled");
    m_parameters[U_TEXT_COLOR] = glGetUniformLocation(m_programID, "textColor");

    // Use our shader
    glUseProgram(m_programID);

    // Enable depth test
    glEnable(GL_DEPTH_TEST);

    // Enable culling
    glEnable(GL_CULL_FACE);

    // Enable blending
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    // Generate a default VAO for now
    glGenVertexArrays(1, &m_vertexArrayID);
    glBindVertexArray(m_vertexArrayID);

    Mtx44 projection;
    projection.SetToPerspective(45.0f, 4.0f / 3.0f, 0.1f, 2000.0f);
    projectionStack.LoadMatrix(projection);

    // Set background color to dark blue
    glClearColor(0.0f, 0.0f, 0.4f, 0.0f);

    camera.Init(Vector3(0, 0, 10), Vector3(0, 0, 0), Vector3(0, 1, 0));

    //MESH GENERATORS
    meshList[GEO_AXES] = MeshBuilder::GenerateAxes("axis", 1000, 1000, 1000);
    meshList[GEO_FRONT] = MeshBuilder::GenerateQuad("front", Color(1, 1, 1));
    meshList[GEO_FRONT]->textureID = LoadTGA("Image//front.tga");
    meshList[GEO_BACK] = MeshBuilder::GenerateQuad("back", Color(1, 1, 1));
    meshList[GEO_BACK]->textureID = LoadTGA("Image//back.tga");
    meshList[GEO_LEFT] = MeshBuilder::GenerateQuad("left", Color(1, 1, 1));
    meshList[GEO_LEFT]->textureID = LoadTGA("Image//left.tga");
    meshList[GEO_RIGHT] = MeshBuilder::GenerateQuad("right", Color(1, 1, 1));
    meshList[GEO_RIGHT]->textureID = LoadTGA("Image//right.tga");
    meshList[GEO_TOP] = MeshBuilder::GenerateQuad("top", Color(1, 1, 1));
    meshList[GEO_TOP]->textureID = LoadTGA("Image//top.tga");
    meshList[GEO_BOTTOM] = MeshBuilder::GenerateQuad("bottom", Color(1, 1, 1));
    meshList[GEO_BOTTOM]->textureID = LoadTGA("Image//bottom.tga");

    meshList[GEO_LIGHTBALL] = MeshBuilder::GenerateSphere("sphere", Color(1, 1, 1));

    meshList[GEO_TEXT] = MeshBuilder::GenerateText("text", 16, 16);
    meshList[GEO_TEXT]->textureID = LoadTGA("Image//calibri.tga");


    //meshList[GEO_MODEL1] = MeshBuilder::GenerateOBJ("model1", "OBJ//chair.obj");
    //meshList[GEO_MODEL1]->textureID = LoadTGA("Image//chair.tga");
    //meshList[GEO_MODEL2] = MeshBuilder::GenerateOBJ("model2", "OBJ//dart.obj");
    //meshList[GEO_MODEL2]->textureID = LoadTGA("Image//dart.tga");
    //meshList[GEO_MODEL3] = MeshBuilder::GenerateOBJ("model3", "OBJ//dartboard.obj");
    //meshList[GEO_MODEL3]->textureID = LoadTGA("Image//dartboard.tga");
    //meshList[GEO_MODEL4] = MeshBuilder::GenerateOBJ("model4", "OBJ//doorman.obj");
    //meshList[GEO_MODEL4]->textureID = LoadTGA("Image//doorman.tga");
    //meshList[GEO_MODEL5] = MeshBuilder::GenerateOBJ("model5", "OBJ//shoe.obj");
    //meshList[GEO_MODEL5]->textureID = LoadTGA("Image//shoe.tga");
    //meshList[GEO_MODEL6] = MeshBuilder::GenerateOBJ("model6", "OBJ//winebottle.obj");
    //meshList[GEO_MODEL6]->textureID = LoadTGA("Image//winebottle.tga");

    meshList[GEO_VEHICLE_SPACE_AIR] = MeshBuilder::GenerateOBJ("model_air", "OBJ//vehicle_space_air.obj");
    //meshList[GEO_VEHICLE_SPACE_AIR]->textureID = LoadTGA("Image//chair.tga");

    meshList[GEO_VEHICLE_SPACE_LAND] = MeshBuilder::GenerateOBJ("model_land", "OBJ//vehicle_space_land.obj");
    //meshList[GEO_VEHICLE_SPACE_LAND]->textureID = LoadTGA("Image//chair.tga");

    //setting up light object
//.........这里部分代码省略.........
开发者ID:zhiternn,项目名称:SP2_Team18_SureA,代码行数:101,代码来源:SceneText.cpp

示例14: Perspective

void MS::Perspective(double fovy, double aspect, double zNear, double zFar) {
	Mtx44 mat;
	mat.SetToPerspective(fovy, aspect, zNear, zFar);
	ms.top() = ms.top() * mat;
}
开发者ID:MonkeyD-IchiJou,项目名称:OHEngine-OuterHeaven-,代码行数:5,代码来源:MatrixStack.cpp

示例15: switch

void SecurityCam::update(const double &dt, Vector3 &playerPos, std::vector<GameObject*> m_goList)
{

	Vector3 SCPos = pos;
	Vector3 SCLookat = Lookat;

	SCPos.y = SCLookat.y = 0;

	switch(c_State)
	{
	case SPOTTED:
		{
			float rotationdiff = (CalAnglefromPosition(playerPos, pos, true) - CalAnglefromPosition(Lookat, pos, true)) * 2.f;

			Mtx44 rotation;
			Lookat = Lookat - pos;
			f_rotationLimiter += rotationdiff * static_cast<float>(dt);
			rotation.SetToRotation(rotationdiff * static_cast<float>(dt), 0, 1, 0);
			Lookat = rotation * Lookat;
			Lookat = Lookat + pos;

			//Check whether player is still in the fov of security camera
			if (((isVisible(SCPos, SCLookat, static_cast<float>(f_cameraFOV), playerPos)) && (SCPos - playerPos).LengthSquared() < f_cameraRange))
			{
				//Give player 1 sec to prevent detection by the security camera
				if (alerttimer < 1)
				{
					alerttimer += static_cast<float>(dt);
				}
				else
				{
					c_State = FOUND;
					alerttimer = 0;
				}
			}
			else
			{
				//if player is no longer in the fov of the security camera
				c_State = NOTFOUND;
				alerttimer = 0;
			}
		}
		break;

	case FOUND:
		{
			float rotationdiff = (CalAnglefromPosition(playerPos, pos, true) - CalAnglefromPosition(Lookat, pos, true));

			if (rotationdiff >= 180)
			{
				Mtx44 rotation;
				Lookat = Lookat - pos;
				rotation.SetToRotation(-360, 0, 1, 0);
				Lookat = rotation * Lookat;
				Lookat = Lookat + pos;
				rotationdiff -= 360;
			}
			else if (rotationdiff <= -180)
			{
				Mtx44 rotation;
				Lookat = Lookat - pos;
				rotation.SetToRotation(360, 0, 1, 0);
				Lookat = rotation * Lookat;
				Lookat = Lookat + pos;
				rotationdiff += 360;
			}

			Mtx44 rotation;
			Lookat = Lookat - pos;
			f_rotationLimiter += rotationdiff * static_cast<float>(dt);
			rotation.SetToRotation(rotationdiff * 2 * static_cast<float>(dt), 0, 1, 0);
			Lookat = rotation * Lookat;
			Lookat = Lookat + pos;

			//Alert all the ai to the camera's position
			if (b_alertAI)
			{
				for (std::vector<GameObject*>::iterator it = m_goList.begin(); it != m_goList.end(); it++)
				{
					GameObject *go = (GameObject *)*it;
					AI *ai = dynamic_cast<AI*>(go);
					if (ai != NULL)
					{
						if (ai->getState() == AI::WALKING)
						{
							ai->setState(AI::ALERT);
							ai->setcurrentLookat(pos);
							ai->setDestination(pos);
						}
					}
				}
				b_alertAI = false;
			}
			else
			{
				if (!isVisible(pos, Lookat, f_cameraFOV, playerPos) || (playerPos - pos).LengthSquared() > f_cameraRange)
				{
					c_State = NOTFOUND;
				}
			}
//.........这里部分代码省略.........
开发者ID:Auranapse,项目名称:Studio-Project-3---Potato-Locomotive,代码行数:101,代码来源:SecurityCam.cpp


注:本文中的Mtx44类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。