Esempio n. 1
0
//=================================================================================================
void CreateCharacterPanel::Update(float dt)
{
	RenderUnit();
	UpdateUnit(dt);

	// obracanie
	if(PointInRect(GUI.cursor_pos, INT2(pos.x+228,pos.y+94), INT2(128,256)) && Key.Focus() && focus)
	{
		if(Key.Down(VK_LBUTTON))
			unit->rot = clip(unit->rot - float(GUI.cursor_pos.x - pos.x - 228 - 64)/16*dt);
		//dist = clamp(dist + GUI.mouse_wheel, -3.f, -1.f);
	}

	if(mode == PickClass)
	{
		for(int i=0; i<5; ++i)
		{
			bts[i].mouse_focus = focus;
			bts[i].Update(dt);
		}
	}
	else
	{
		for(int i=0; i<2; ++i)
		{
			bts2[i].mouse_focus = focus;
			bts2[i].Update(dt);
		}

		if(!game->IsOnline())
		{
			checkbox.mouse_focus = focus;
			checkbox.Update(dt);
		}

		for(int i=0; i<5; ++i)
		{
			slider[i].mouse_focus = focus;
			slider[i].Update(dt);
		}
	}

	if(focus && Key.Focus() && Key.PressedRelease(VK_ESCAPE))
		Event((GuiEvent)IdCancel);
}
void LocationEditor::Render()
{
    //
    // Render our buildings
	
	g_app->m_renderer->SetObjectLighting();
    LevelFile *levelFile = g_app->m_location->m_levelFile;
    for( int i = 0; i < levelFile->m_buildings.Size(); ++i )
    {
        if( levelFile->m_buildings.ValidIndex(i) )
        {
            Building *b = levelFile->m_buildings.GetData(i);
            b->Render(0.0);
        }
    } 
    g_app->m_renderer->UnsetObjectLighting();
	if (m_mode == ModeBuilding)
	{
		for( int i = 0; i < levelFile->m_buildings.Size(); ++i )
		{
			if( levelFile->m_buildings.ValidIndex(i) )
			{
				Building *b = levelFile->m_buildings.GetData(i);
				b->RenderAlphas(0.0);
				b->RenderLink();
			}
		}
	}


	// 
	// Render camera mounts

	{
		g_app->m_renderer->SetObjectLighting();
		Shape *camShape = g_app->m_resource->GetShape("camera.shp");
		Matrix34 mat;
		
		for (int i = 0; i < g_app->m_location->m_levelFile->m_cameraMounts.Size(); ++i)
		{
			CameraMount *mount = g_app->m_location->m_levelFile->m_cameraMounts[i];
			Vector3 camToMount = g_app->m_camera->GetPos() - mount->m_pos;
			if (camToMount.Mag() < 20.0) continue;
			mat.OrientFU(mount->m_front, mount->m_up);
			mat.pos = mount->m_pos;
			camShape->Render(0.0, mat);
		}
	    g_app->m_renderer->UnsetObjectLighting();
	}


    g_app->m_renderer->UnsetObjectLighting();


	// 
	// Render our instant units
	
	for (int i = 0; i < levelFile->m_instantUnits.Size(); ++i)
	{
		InstantUnit *iu = levelFile->m_instantUnits.GetData(i);
		RenderUnit(iu);
	}

	switch (m_mode)
	{
		case ModeLandTile:			RenderModeLandTile();				break;
		case ModeLandFlat:			RenderModeLandFlat();				break;
		case ModeBuilding:			RenderModeBuilding();				break;
		case ModeLight:													break;
		case ModeInstantUnit:		RenderModeInstantUnit();			break;
		case ModeCameraMount:		RenderModeCameraMount();			break;
	}

	
	//
	// Render axes

	float sizeX = g_app->m_location->m_landscape.GetWorldSizeX() / 2;
	float sizeZ = g_app->m_location->m_landscape.GetWorldSizeZ() / 2;
	RenderArrow(Vector3(10, 200, 0), Vector3(sizeX, 200, 0), 4.0);
	glBegin(GL_LINES);
		glVertex3f(sizeX,      250, 0);
		glVertex3f(sizeX + 90, 150, 0);
		glVertex3f(sizeX,      150, 0);
		glVertex3f(sizeX + 90, 250, 0);
	glEnd();
	glDisable(GL_BLEND);
	glDisable(GL_LINE_SMOOTH);

	RenderArrow(Vector3(0, 200, 10), Vector3(0, 200, sizeZ), 4.0);
	glBegin(GL_LINES);
		glVertex3f(0, 250, sizeZ);
		glVertex3f(0, 250, sizeZ + 90);
		glVertex3f(0, 250, sizeZ);
		glVertex3f(0, 150, sizeZ + 90);
		glVertex3f(0, 150, sizeZ);
		glVertex3f(0, 150, sizeZ + 90);
	glEnd();
	glDisable(GL_BLEND);
	glDisable(GL_LINE_SMOOTH);


    //
    // Render targetting crosshair

    g_app->m_renderer->SetupMatricesFor2D();
	glColor3ub(255,255,255);
    glLineWidth( 1.0 );
    glBegin( GL_LINES );
        glVertex2i( g_app->m_renderer->ScreenW()/2, g_app->m_renderer->ScreenH()/2 - 30 );
        glVertex2i( g_app->m_renderer->ScreenW()/2, g_app->m_renderer->ScreenH()/2 + 30 );

        glVertex2i( g_app->m_renderer->ScreenW()/2 - 30, g_app->m_renderer->ScreenH()/2 );
        glVertex2i( g_app->m_renderer->ScreenW()/2 + 30, g_app->m_renderer->ScreenH()/2 );
    glEnd();
    g_app->m_renderer->SetupMatricesFor3D();
    

	CHECK_OPENGL_STATE();
}