Ejemplo n.º 1
0
void Billboard_Test::Init(Scene * scene)
{
	BillboardPtr ptr = scene->AddBillboard();
	Billboard * b = ptr.Get();
	b->SetSize(20.0f, 20.0f);
	b->UseDiffuseTexture(true);
	b->SetDiffuseTexture("assets/fire.png");

	StaticVert verts[4];

	verts[0].pos = Vector3(-1.0f, -1.0f, 0.0f);
	verts[1].pos = Vector3(-1.0f, 1.0f, 0.0f);
	verts[2].pos = Vector3(1.0f, 1.0f, 0.0f);
	verts[3].pos = Vector3(1.0f, -1.0f, 0.0f);

	verts[0].u = 0.0f;
	verts[0].v = 1.0f;

	verts[1].u = 0.0f;
	verts[1].v = 0.0f;

	verts[2].u = 1.0f;
	verts[2].v = 0.0f;

	verts[3].u = 1.0f;
	verts[3].v = 1.0f;
	unsigned int ind[] = { 0, 1, 3, 1, 3, 2 };

	ModelCreator<StaticVert> creator;
	creator.StartMesh();
	creator.SetTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
	creator.SetDrawMethod(DM_DRAW_INDEXED);
	creator.SetVertexBuffer(verts, sizeof(verts), sizeof(StaticVert));
	creator.SetIndexBuffer(ind, 6);
	creator.EndMesh();

	StaticEntityPtr triPtr = scene->AddStaticEntity(creator, "tri");
	StaticEntity * tri = triPtr.Get();
	tri->Illuminate(false);
	tri->SetPosition(50.0f, 0.0f, 0.0f);
	tri->SetScale(20.0f, 20.0f, 2.0f);

	Material * mat = tri->GetMaterial(0);
	mat->UseDiffuseMap(true);
	mat->SetDiffuseMap("assets/fire.png");
	mat->SetEmmisivePower(1);
}
Ejemplo n.º 2
0
bool FuelCell::Load(File*)
{
  Vec3f p = GetPos();
  float s = 5.0f; // TODO CONFIG

  m_aabb.Set(p.x - s, p.x + s, p.y - s, p.y + s, p.z - s, p.z + s); 
  FuelNode* sm = new FuelNode;
  sm->SetAABB(m_aabb);

  SetSceneNode(sm);

  Billboard* bb = new Billboard;
  Texture* tex = (Texture*)TheResourceManager::Instance()->GetRes("flare.png");
  bb->SetTexture(tex);
  bb->SetSize(30.0f); // TODO CONFIG
  bb->SetAABB(m_aabb);

  sm->AddChild(bb);

  return true;
}
Ejemplo n.º 3
0
void init()
{
	glClearColor(0.5, 0.5, 1.0, 1);
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

	// Note that the light is defined in the eye or camera frame.
	GLfloat light_position[] = {0.0, 0.0, 0.0, 1.0};

	GLfloat ambient[] = {0.3, 0.3, 0.3, 1};
	GLfloat diffuse[] = {1.0, 1.0, 1.0, 1};
	GLfloat specular[] = {1.0, 1.0, 1.0, 1};

	glLightfv(GL_LIGHT0, GL_POSITION, light_position);

	glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
	glLightfv(GL_LIGHT0, GL_SPECULAR, specular);

	glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
	glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);

	glShadeModel(GL_SMOOTH);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_NORMALIZE);

	glEnable(GL_LIGHTING);	
	glEnable(GL_LIGHT0);

	// Generate display list for the surveillance camera.
	surveillanceCameraID = glGenLists(1);
	
	glNewList(surveillanceCameraID, GL_COMPILE);
	surveillanceCamera.Draw();
	glEndList();

	// Generate display list for the car.
	carID = glGenLists(1);
	glNewList(carID, GL_COMPILE);
	car.Draw();
	glEndList();



	board.SetLocation(boardPos);
	board.SetOrientation(boarddirection);
	board.SetSize(3, 2.5);
	board.ReadFile("Square.ppm");

	board2.SetLocation(boardPos2);
	board2.SetOrientation(boarddirection2);
	board2.SetSize(5, 3.5);
	board2.ReadFile("wendys.ppm");

	// Generate the display list for terrain, including road and grass.
	terrainID = glGenLists(1);
	glNewList(terrainID, GL_COMPILE);
	glDisable(GL_LIGHTING);

	// Grass
	glColor3f(0, 0.7, 0);
	glBegin(GL_QUADS);
		glVertex3f(-1000, 0, 1000);
		glVertex3f(-10, 0, 1000);
		glVertex3f(-10, 0, 10);
		glVertex3f(-1000, 0, 10);

		glVertex3f(10, 0, 1000);
		glVertex3f(1000, 0, 1000);
		glVertex3f(1000, 0, 10);
		glVertex3f(10, 0, 10);

		glVertex3f(10, 0, -10);
		glVertex3f(1000, 0, -10);
		glVertex3f(1000, 0, -1000);
		glVertex3f(10, 0, -1000);

		glVertex3f(-1000, 0, -10);
		glVertex3f(-10, 0, -10);
		glVertex3f(-10, 0, -1000);
		glVertex3f(-1000, 0, -1000);
	glEnd();

	// Roads
	glBegin(GL_QUADS);
		glColor3f(0.2, 0.2, 0.2);

		glVertex3f(-10, 0, 1000);
		glVertex3f(10, 0, 1000);
		glVertex3f(10, 0, -1000);
		glVertex3f(-10, 0, -1000);

		glVertex3f(-1000, 0, 10);
		glVertex3f(1000, 0, 10);
		glVertex3f(1000, 0, -10);
		glVertex3f(-1000, 0, -10);
	glEnd();

	// Yellow line South
	glBegin(GL_POLYGON);
		glColor3f(1, 1, 0);
		glVertex3f(-0.1, 0.05, 1000);
		glVertex3f(0.1, 0.05, 1000);
		glVertex3f(0.1, 0.05, 10);
		glVertex3f(-0.1, 0.05, 10);
	glEnd();
	// Yellow line North
	glBegin(GL_POLYGON);
	glColor3f(1, 1, 0);
	glVertex3f(-0.1, 0.05, -1000);
	glVertex3f(0.1, 0.05, -1000);
	glVertex3f(0.1, 0.05, -10);
	glVertex3f(-0.1, 0.05, -10);
	glEnd();
	// Yellow line west
	glBegin(GL_POLYGON);
	glColor3f(1, 1, 0);
	glVertex3f(-1000, 0.05, -0.1);
	glVertex3f(-1000, 0.05, 0.1);
	glVertex3f(-10, 0.05, 0.1);
	glVertex3f(-10, 0.05, -0.1);
	glEnd();
	// Yellow line east
	glBegin(GL_POLYGON);
	glColor3f(1, 1, 0);
	glVertex3f(1000, 0.05, -0.1);
	glVertex3f(1000, 0.05, 0.1);
	glVertex3f(10, 0.05, 0.1);
	glVertex3f(10, 0.05, -0.1);
	glEnd();
	// white dashed line South
	for (int i = 10; i <= 1000; i)
	{
		glBegin(GL_POLYGON);
		glColor3f(1, 1, 1);
		glVertex3f(4.9, 0.05, i);
		glVertex3f(5.1, 0.05, i);
		glVertex3f(5.1, 0.05, i + 3);
		glVertex3f(4.9, 0.05, i + 3);
		glEnd();
		i += 13;
	}
	
	for (int i = 10; i <= 1000; i)
	{
		glBegin(GL_POLYGON);
		glColor3f(1, 1, 1);
		glVertex3f(-4.9, 0.05, i);
		glVertex3f(-5.1, 0.05, i);
		glVertex3f(-5.1, 0.05, i + 3);
		glVertex3f(-4.9, 0.05, i + 3);
		glEnd();
		i += 13;
	}
	// white dashed line north
	for (int i = -10; i >= -1000; i)
	{
		glBegin(GL_POLYGON);
		glColor3f(1, 1, 1);
		glVertex3f(-4.9, 0.05, i);
		glVertex3f(-5.1, 0.05, i);
		glVertex3f(-5.1, 0.05, i - 3);
		glVertex3f(-4.9, 0.05, i - 3);
		glEnd();
		i -= 13;
	}

	for (int i = -10; i >= -1000; i)
	{
		glBegin(GL_POLYGON);
		glColor3f(1, 1, 1);
		glVertex3f(4.9, 0.05, i);
		glVertex3f(5.1, 0.05, i);
		glVertex3f(5.1, 0.05, i - 3);
		glVertex3f(4.9, 0.05, i - 3);
		glEnd();
		i -= 13;
	}
	// white dashed line west
	for (int i = -10; i >= -1000; i)
	{
		glBegin(GL_POLYGON);
		glColor3f(1, 1, 1);
		glVertex3f(i, 0.05, 4.9);
		glVertex3f(i, 0.05, 5.1);
		glVertex3f(i - 3, 0.05, 5.1);
		glVertex3f(i - 3, 0.05, 4.9);
		glEnd();
		i -= 13;
	}

	for (int i = -10; i >= -1000; i)
	{
		glBegin(GL_POLYGON);
		glColor3f(1, 1, 1);
		glVertex3f(i, 0.05, -4.9);
		glVertex3f(i, 0.05, -5.1);
		glVertex3f(i - 3, 0.05,-5.1);
		glVertex3f(i - 3, 0.05, -4.9);
		glEnd();
		i -= 13;
	}
	// white dashed line east
	for (int i = 10; i <= 1000; i)
	{
		glBegin(GL_POLYGON);
		glColor3f(1, 1, 1);
		glVertex3f(i, 0.05, -4.9);
		glVertex3f(i, 0.05, -5.1);
		glVertex3f(i + 3, 0.05, -5.1);
		glVertex3f(i + 3, 0.05, -4.9);
		glEnd();
		i += 13;
	}
	
	for (int i = 10; i <= 1000; i)
	{
		glBegin(GL_POLYGON);
		glColor3f(1, 1, 1);
		glVertex3f(i, 0.05, 4.9);
		glVertex3f(i, 0.05, 5.1);
		glVertex3f(i + 3, 0.05, 5.1);
		glVertex3f(i + 3, 0.05, 4.9);
		glEnd();
		i += 13;
	}




	glEndList();
}