Example #1
0
void drawRadar(){
		//Set up orthographic projection for radar
		mat4 projection1 = perspective(45.0f, window.window_aspect, 0.01f, 10.0f);
		glm::mat4 Projection2 = glm::ortho( -10.0f, 10.0f, -10.0f, 00.0f,1.0f, 10.0f);
		glm::mat4 View       = glm::lookAt(
			glm::vec3(0,0,5), // Camera is at (0,0,5), in World Space
			glm::vec3(0,0,0), // and looks at the origin
			glm::vec3(0,1,0)  // Head is up (set to 0,-1,0 to look upside-down)
		);  
			
		mat4 another = View;
		mat4 healthBarMatrix = View;
		another = translate(another, vec3(8.5,-8.5,0));
		
		another = rotate(another, 90.0f, vec3(0,1,0));
		another = rotate(another, 90.0f, vec3(0,0,1));

		healthBarMatrix = translate(healthBarMatrix, vec3(-9.5,-0.5,0));
		
		//healthBarMatrix = rotate(healthBarMatrix, 90.0f, vec3(0,1,0));
		healthBarMatrix = rotate(healthBarMatrix, -90.0f, vec3(0,0,1));
		healthBarMatrix = scale(healthBarMatrix, vec3(0.05f, userTeam.soldiers[0].health/10.f, 0.05f));

		if(userTeam.soldiers[0].health < 50){
			healthBar.color = vec3(1.f, userTeam.soldiers[0].health/50.f, 0.f);
		}
		else{
			healthBar.color = vec3(1.f - (userTeam.soldiers[0].health-50.f)/50.f, 1.f, 0.f);
		}
		healthBar.Draw(Projection2, healthBarMatrix, tod, 0);

		mat4 radar = another;

		//Radar display
		
		int radarBlipTime = current_timeDisplay * 1000;
		float radarBlip = 0.0015 * (radarBlipTime%1000);
		radar = scale(radar, vec3(radarBlip, radarBlip, radarBlip));
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
		disc.color = vec3(0,1,0);
		disc.Draw(Projection2, radar, tod, 0);

		another = scale(another, vec3(1.5, 1.5, 1.5));
		disc.Draw(Projection2, another, tod, 0);

		

		glPolygonMode(GL_FRONT_AND_BACK, window.wireframe ? GL_LINE : GL_FILL);
		disc.color = vec3(0,0.25,0);
		disc.Draw(Projection2, another, tod, 0);

		another = translate(View, vec3(8.5 - ((3/104.6)*transX),-8.6 + ((3/104.6)*transZ),0));
		usr.Draw(Projection2, another, tod, 0);

		stringstream ammo (stringstream::in | stringstream::out);
		ammo << userTeam.soldiers[0].ammo;
		activeTextDisplay(("Ammo: " + ammo.str()).c_str(), -0.95f, -0.85f, 16);
}
Example #2
0
void DisplayCylinder()
{
	Window * window = Window::FindCurrentWindow(windows);
	if (window->handle == BAD_GL_VALUE)
		return;

	glViewport(0, 0, window->size.x, window->size.y);

	vector<string> strings;
	strings.push_back("This is a test.");

	vec4 crimson(0.6f , 0.0f , 0.0f , 1.0f);
	vec3 ambient = vec3(0.1f , 0.1f , 0.1f);
	vec3 specular = vec3(1.0f , 1.0f , 1.0f);
	vec3 diffuse = vec3(0.0f , 0.0f , 0.8f);

	glClearColor(crimson.r , crimson.g , crimson.b , crimson.a);
	glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
	glEnable(GL_DEPTH_TEST);
	mat4 model_matrix = rotate(mat4() , radians(window->LocalTime() * 30.0f) , vec3(0.0f, 1.0f, 0.0f));
	model_matrix = scale(model_matrix , vec3(3.0f , 3.0f , 3.0f));

	mat4 view_matrix = lookAt(vec3(0.0f , 0.0f , 10.0f) , vec3(0.0f , 0.0f , 0.0f) , vec3(0.0f , 1.0f , 0.0f));
	mat4 projection_matrix = perspective(radians(window->fovy) , window->aspect , window->near_distance , window->far_distance);
	phong_shader.Use(model_matrix , view_matrix , projection_matrix);
	phong_shader.SetMaterial(diffuse , specular , 64.0f , ambient);
	phong_shader.SetLightPosition(vec3(0.0f , 0.0f , 1000.0f));
	phong_shader.SelectSubroutine(PhongShader::PHONG_WITH_TEXTURE);
	phong_shader.EnableTexture(textures[1] , 0);
	cylinder2.Draw(false);
	phong_shader.UnUse();
	if (window->draw_normals)
	{
		constant_shader.Use(model_matrix , view_matrix , projection_matrix);
		constant_shader.SetMaterial(diffuse , specular , 64.0f , vec3(1.0f , 1.0f , 1.0f));
		cylinder2.Draw(true);
		constant_shader.UnUse();
	}
	AdaptFreetype(our_font , scale(mat4(), vec3(0.01f, 0.01f, 0.01f)) , lookAt(vec3(0.0f , 0.0f , 10.0f) , vec3(0.0f , 0.0f , 0.0f) , vec3(0.0f , 1.0f , 0.0f)) , perspective(radians(window->fovy) , window->aspect , window->near_distance , window->far_distance) , strings , -400 , 0);
	glutSwapBuffers();
}
Example #3
0
void Render(D3D::GraphicDevice& device, Helper::SpectatorCoords& ,
			Cylinder& cylinder)
{
	D3D::GraphicDevice::DC dc( device, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, Colors::Gray, 1.0f, 0 );
	cylinder.Draw();
}
Example #4
0
void DrawScene(Window * window)
{
	phong_shader.GLReturnedError("DrawScene() - entering");
#ifdef MOVE
	mat4 m = rotate(mat4() , radians(window->LocalTime() * 30.0f) , vec3(0.0f , 1.0f , 0.2f));
	m = translate(m, vec3(0.0f, 11.5f * cos(window->LocalTime() * 0.5f) + 2.0f, 11.5f * sin(window->LocalTime() * 0.5f) + 2.0f));
#else
	mat4 m;
#endif // MOVE

	mat4 view_matrix = lookAt(vec3(m * vec4(eye, 1.0f)), cop, up);
	mat4 model_matrix;
	mat4 projection_matrix = perspective(radians(window->fovy), window->aspect, window->near_distance, window->far_distance);

	vec3 z_axis = vec3(0.0f, 0.0f, 1.0f);
	vec3 y_axis = vec3(0.0f, 1.0f, 0.0f);
	vec3 ambient = vec3(0.1f, 0.1f, 0.1f);
	vec3 specular = vec3(1.0f, 1.0f, 1.0f);
	float c_offset = radians(45.0f);

	glViewport(0, 0, window->size.x, window->size.y);

	const int count_of_shapes = 4;

	for (unsigned int i = 0; i < instances.size(); i++)
	{
		model_matrix = translate(mat4(), instances[i].position);
		model_matrix = rotate(model_matrix, radians(window->LocalTime() * instances[i].rate) + instances[i].offset, y_axis);
		if (i % count_of_shapes == 3)
			model_matrix = scale(model_matrix, vec3(0.25f, 0.25f, 0.25f));

		phong_shader.Use(model_matrix, view_matrix, projection_matrix);
		phong_shader.SetMaterial(instances[i].diffuse, specular, 32.0f, ambient);
		phong_shader.SetLightPosition(vec3(0.0f, 0.0f, 1000.0f));

		switch (i % count_of_shapes)
		{
		case 0:
			disc1.Draw(false);
			break;
		case 1:
			disc3.Draw(false);
			break;
		case 2:
			plane2.Draw(false);
			break;
		case 3:
			cube.Draw(false);
			break;
		}
		phong_shader.UnUse();

		#ifdef SHOW_NORMALS
		if (i == 0)
		{
			constant_shader.Use(model_matrix, view_matrix, projection_matrix);
			constant_shader.SetMaterial(vec3(0.0f, 0.0f, 0.8f), specular, 128.0f, vec3(1.0f, 0.0f, 0.0f));
			disc1.Draw(true);
			constant_shader.UnUse();
		}
		#endif
	}

	model_matrix = mat4();
	mat4 mz = model_matrix;
	model_matrix = scale(model_matrix, vec3(0.5f, 0.5f, 16.0f));

	phong_shader.Use(model_matrix, view_matrix, projection_matrix);
	phong_shader.SetMaterial(vec3(0.0f, 0.0f, 0.8f), specular, 128.0f, ambient);
	phong_shader.SetLightPosition(vec3(0.0f, 1000.0f, 0.0f));
	cylinder1.Draw(false);
	phong_shader.UnUse();

#ifdef SHOW_NORMALS
	constant_shader.Use(model_matrix, view_matrix, projection_matrix);
	constant_shader.SetMaterial(vec3(0.0f, 0.0f, 0.8f), specular, 128.0f, vec3(1.0f, 1.0f, 1.0f));
	cylinder.Draw(true);
	constant_shader.UnUse();
#endif

	model_matrix = rotate(mz, radians(90.0f), y_axis);
	model_matrix = scale(model_matrix, vec3(0.5f, 0.5f, 16.0f));
	phong_shader.Use(model_matrix, view_matrix, projection_matrix);
	phong_shader.SetMaterial(vec3(1.0f, 0.0f, 0.0f), specular, 128.0f, ambient);
	phong_shader.SetLightPosition(vec3(0.0f, 1000.0f, 0.0f));
	cylinder1.Draw(false);
	phong_shader.UnUse();

	model_matrix = rotate(mz, radians(-90.0f), vec3(1.0f, 0.0f, 0.0f));
	model_matrix = scale(model_matrix, vec3(0.5f, 0.5f, 16.0f));
	phong_shader.Use(model_matrix, view_matrix, projection_matrix);
	phong_shader.SetMaterial(vec3(0.0f, 1.0f, 0.0f), specular, 128.0f, ambient);
	phong_shader.SetLightPosition(vec3(0.0f, 1000.0f, 0.0f));
	cylinder1.Draw(false);
	phong_shader.UnUse();

	cylinder1.UpdateValues(TestUpdate, window->LocalTime(), nullptr);
}
Example #5
0
void Render()
{
	md3dDevice->ClearRenderTargetView(mRenderTargetView, mClearColor);
	md3dDevice->ClearDepthStencilView(mDepthStencilView, D3D10_CLEAR_DEPTH|D3D10_CLEAR_STENCIL, 1.0f, 0);
	md3dDevice->OMSetDepthStencilState(0, 0);

	md3dDevice->OMSetBlendState(0, blendFactor, 0xffffffff);

	//draw Trees
	mTrees.draw(GetCamera().getPos(), GetCamera().view()*GetCamera().proj());

	D3D10_TECHNIQUE_DESC techDesc;
	fxU.setRenderUtil(techDesc);

	for(UINT p = 0; p < techDesc.Passes; ++p)
	{
		//draw Cube
		pWave->render(fxU,p);

		//draw Cube "Tower"
		for (UINT i=0; i < mTowers.size(); ++i)
		{
			fxU.setMfx(GetCamera().wvp(mTowers.at(i).getWorld()), mTowers.at(i).getWorld(), 1, nrOfTowers[i]);
			fxU.ApplyPassByIndex(p);
			mTowers.at(i).Draw();
		}

		//draw Pyramid
		fxU.setMfx(GetCamera().wvp(mPyramid.getWorld()), mPyramid.getWorld(), 2, 3);
		fxU.ApplyPassByIndex(p);
		mPyramid.Draw();

		//draw Cylinder
		fxU.setMfx(GetCamera().wvp(mCylinder.getWorld()), mCylinder.getWorld(), 3, 6);
		fxU.ApplyPassByIndex(p);
		mCylinder.Draw();

		//draw Terrain
		//fxU.setMfx(GetCamera().wvp(mTerrain.getWorld()), mTerrain.getWorld(), 0, 9);
		//fxU.ApplyPassByIndex(p);
		//mTerrain.Draw();

		fxU.setMfx(GetCamera().wvp(land.getWorld()), land.getWorld(), 0, 9);
		fxU.ApplyPassByIndex(p);
		land.draw();
	}

	//draw gui
	gui.Render();

	//draw grid
	qtc.draw(GetCamera().view(), GetCamera().proj(), grid);

	//draw Sky
	sky.draw(GetCamera().view(), GetCamera().proj(), GetCamera().getPos(), mLight.lightType);

	//draw Fire
	fire.draw(GetCamera().view(), GetCamera().proj());
	
	md3dDevice->OMSetBlendState(0, blendFactor, 0xffffffff);
	
	//draw Rain
	rain.draw(GetCamera().view(), GetCamera().proj());
	
	mSwapChain->Present(0, 0);
}