示例#1
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	SortData::DrawTriList()
{
	Start_Timer(GOS_Draw_Time);

#ifdef LAB_ONLY
	if(dontSeeMe == true)
#endif
	{
		if(texture2==0)
		{
			GOSVertex *v = (GOSVertex *)vertices;
			if ((v[0].z >= 0.0f) &&
				(v[0].z < 1.0f) &&
				(v[1].z >= 0.0f) &&  
				(v[1].z < 1.0f) && 
				(v[2].z >= 0.0f) &&  
				(v[2].z < 1.0f))
			{
				gos_DrawTriangles( (GOSVertex *)vertices, numVertices);
			}
		}
		else
		{
			STOP(("GOS doesnt suppert gos_DrawTriangles for gos_VERTEX_2UV yet."));
//			gos_DrawTriangles( (GOSVertex2UV *)vertices, numVertices);
		}
	}
	Stop_Timer(GOS_Draw_Time);
}
示例#2
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	SortData::DrawPointCloud()
{
	Verify(texture2==0);
	Start_Timer(GOS_Draw_Time);

#ifdef LAB_ONLY
	if(dontSeeMe == true)
#endif
	{

		GOSVertex pArray[32*3];

		float size = (float)numIndices;
		
		if( size == 0 )
		{
			size = 2.4f;
		}
		else
		{
			size *= 2.4f;
		}

		int Triangle = 0, Vertex = 0;
	//
	// Warning! - These points need clipping!
	//
		for( int i=numVertices; i; i-- )
		{
			pArray[Triangle+0] = *((GOSVertex *)vertices + Vertex);
			pArray[Triangle+1] = *((GOSVertex *)vertices + Vertex);
			pArray[Triangle+2] = *((GOSVertex *)vertices + Vertex);

			pArray[Triangle+1].x += size;
			pArray[Triangle+2].y += size;

			Triangle +=3;
			Vertex++;

			if( Triangle==32*3 || i==1)
			{
				if ((pArray[0].z >= 0.0f) &&
					(pArray[0].z < 1.0f) &&
					(pArray[1].z >= 0.0f) &&  
					(pArray[1].z < 1.0f) && 
					(pArray[2].z >= 0.0f) &&  
					(pArray[2].z < 1.0f))
				{
					gos_DrawTriangles( pArray, Triangle );
				}

				Triangle=0;
			}
		}
	}
	Stop_Timer(GOS_Draw_Time);
}
示例#3
0
void MechBayScreen::drawWeightMeter(long xOffset, long yOffset)
{
		// there are 20 rays, each 9 degrees
	// they should be 50 pixels long
	float currentDropWeight = LogisticsData::instance->getCurrentDropWeight();
	float maxDropWeight = LogisticsData::instance->getMaxDropWeight();
	long numAddBars = 0;
	long numRemoveBars = 0;

	long addColor = 0;
	long removeColor = 0;		

	long numberOfBars = 20;
	if ( maxDropWeight != 0 )
	{
		float percent = currentDropWeight/maxDropWeight;
		percent *= 20.f;
		numberOfBars = percent + .5;
	}

	if ( addWeightAnim.isAnimating() && !addWeightAnim.isDone() )
	{
		addColor = addWeightAnim.getColor();
		float percent = (currentDropWeight - addWeightAmount) / maxDropWeight;
		percent *= 20.f;
		numAddBars = percent + .5;
		numAddBars = numberOfBars - numAddBars;
	}

	if ( removeWeightAnim.isAnimating() && !removeWeightAnim.isDone() )
	{
		addColor = removeWeightAnim.getColor();
		float percent = removeWeightAmount / maxDropWeight;
		percent *= 20.f;
		numRemoveBars = percent + .5;
	}

	gos_VERTEX v[3];
	for ( int i = 0; i <3; i++ )
	{
		v[i].u = 0.f;
		v[i].v = 0.f;
		v[i].rhw = .5;
		v[i].z = 0.f;
		v[i].argb = 0;
		v[i].frgb = 0;
		v[i].x = weightCenterX + xOffset;
		v[i].y = weightCenterY + yOffset;
	}
	 
	float curArc = 180.f;
	float curX = 50.f * cos( DEGREES_TO_RADS * curArc );
	float curY = 50.f * sin( DEGREES_TO_RADS * curArc );
	for ( i= 0; i < numberOfBars + numRemoveBars; i++ )
	{

		v[1].x = curX + weightCenterX + xOffset;
		v[1].y = curY + weightCenterY + yOffset;

		curArc += 9.f;
		curX = 50.f * cos( DEGREES_TO_RADS * curArc );
		curY = 50.f * sin( DEGREES_TO_RADS * curArc );

		v[2].x = curX + weightCenterX + xOffset;
		v[2].y = curY + weightCenterY + yOffset;

		if ( i >= numberOfBars - numAddBars )
			v[0].argb = v[1].argb = v[2].argb = addColor;
		else if ( i >= numberOfBars )
			v[0].argb = v[1].argb = v[2].argb = removeColor;
		else
			v[0].argb = v[1].argb = v[2].argb = interpolateColor( weightStartColor, weightEndColor, i * .05 );

		gos_DrawTriangles( v, 3 );
		

	}


	dropWeightMeter.render(xOffset, yOffset);
}
示例#4
0
void GameTacMap::render()
{
	if (turn < 2)		//Terrain not setup yet.  Left,Right,Top,Bottom are poopy!
		return;

	gos_VERTEX corners[5];

	gos_SetRenderState( gos_State_AlphaMode, gos_Alpha_OneZero );

	gos_SetRenderState( gos_State_Specular,FALSE );
	gos_SetRenderState( gos_State_AlphaTest, FALSE );
			
	gos_SetRenderState( gos_State_Filter, gos_FilterNone );
	gos_SetRenderState( gos_State_ZWrite, 0 );
	gos_SetRenderState( gos_State_ZCompare, 0 );
	gos_SetRenderState( gos_State_Texture, textureHandle );


	for ( int i = 0; i < 4; ++i )
	{
		corners[i].rhw = 1.0f;
		corners[i].argb = 0xffffffff;
		corners[i].frgb = 0;
		corners[i].z = 0.0f;
	}


	corners[0].x = corners[2].x = left;
	corners[1].x = corners[3].x = right;
	corners[3].y = corners[2].y = bottom;
	corners[0].y = corners[1].y = top;

	corners[0].u = 2.f/(float)bmpWidth;
	corners[3].u = 128.f/(float)bmpWidth;
	corners[2].u = 2.f/(float)bmpWidth;
	corners[1].u = 128.f/(float)bmpWidth;
	corners[0].v = 2.f/(float)bmpWidth;
	corners[3].v = 128.f/(float)bmpHeight;
	corners[2].v = 128.f/(float)bmpHeight;
	corners[1].v = 2.f/(float)bmpWidth;
	
	gos_DrawTriangles( corners, 3 );
	gos_DrawTriangles( &corners[1], 3 );


	Stuff::Vector2DOf<long> screen;
	Stuff::Vector4D 		nScreen;
	Stuff::Vector3D			world;

	//-----------------------------------------------------------
	// Render the objective markers
	long count = 0;
	for ( EList< CObjective*, CObjective* >::EIterator iter =  Team::home->objectives.Begin();
		!iter.IsDone(); iter++ )
	{
		//We are there.  Start flashing.
		if ((objectiveAnimationId == count) && objectiveNumFlashes)
		{
			objectiveFlashTime += g_deltaTime;
			if ( objectiveFlashTime > .5f )
			{
				objectiveFlashTime = 0.0f;
				objectiveNumFlashes--;
			}
			else if ( objectiveFlashTime > 0.25f)
			{
				(*iter)->RenderMarkers(this, 0);
			}

			if (objectiveNumFlashes == 0)
			{
				//Flashing is done.  We now return you to your regularly scheduled program.
				objectiveAnimationId = 0;
			}
		}
		else
		{
			(*iter)->RenderMarkers(this, 0);
		}

		count++;
	}

	
	// this is the little viewing rect

	// Routine that InverseProjects is slightly less accurate but an order of magnitude faster.
	// Can make more accurate later at very little expense to performance.
	// Easy to fix with camera later.  -fs

	screen.x = 1;
	screen.y = 1;
	
	nScreen.x = nScreen.y = 1.0f;
	nScreen.z = nScreen.w = 0.0f;
	
	eye->inverseProjectZ( nScreen, world );
	worldToTacMap( world, corners[0] );

	screen.y = Environment.screenHeight - 1;
	nScreen.y = (Environment.screenHeight * 0.6667f) - 1;
	nScreen.z = nScreen.w = 0.0f;
	eye->inverseProjectZ( nScreen, world );
	worldToTacMap( world, corners[1] );

	screen.x = Environment.screenWidth - 1;
	nScreen.x = Environment.screenWidth - 1;
	nScreen.z = nScreen.w = 0.0f;
	eye->inverseProjectZ( nScreen, world );
	worldToTacMap( world, corners[2] );

	screen.y = 1;
	nScreen.y = 1;
	nScreen.z = nScreen.w = 0.0f;
	eye->inverseProjectZ( nScreen, world );
	worldToTacMap( world, corners[3] );

	corners[0].argb = 0xffffffff;
	corners[1].argb = 0xffffffff;
	corners[2].argb = 0xffffffff;
	corners[3].argb = 0xffffffff;
	corners[0].u = corners[1].u = 0.078125f;
	corners[3].u = corners[2].u = .99875f;
	corners[0].v = corners[3].v = 0.078125f;
	corners[1].v = corners[2].v = .99875f;
	corners[4] = corners[0];

	gos_SetRenderState( gos_State_AlphaMode, gos_Alpha_AlphaInvAlpha);
	gos_SetRenderState( gos_State_ShadeMode, gos_ShadeGouraud);
	gos_SetRenderState( gos_State_MonoEnable, 0);
	gos_SetRenderState( gos_State_Perspective, 0);
	gos_SetRenderState( gos_State_Clipping, 2);
	gos_SetRenderState( gos_State_AlphaTest, 0);
	gos_SetRenderState( gos_State_Specular, 0);
	gos_SetRenderState( gos_State_Dither, 1);
	gos_SetRenderState( gos_State_TextureMapBlend, gos_BlendModulate);
	gos_SetRenderState( gos_State_Filter, gos_FilterBiLinear);
	gos_SetRenderState( gos_State_TextureAddress, gos_TextureWrap );
	gos_SetRenderState( gos_State_ZCompare, 0);
	gos_SetRenderState(	gos_State_ZWrite, 0);
	DWORD gosTextureHandle = mcTextureManager->get_gosTextureHandle(viewRectHandle);

	gos_SetRenderState( gos_State_Texture, gosTextureHandle );

	gos_DrawQuads( &corners[0], 4 );

	unsigned long colors[MAX_MOVERS];
	unsigned long ringColors[MAX_MOVERS];
	Stuff::Vector3D positions[MAX_MOVERS];
	unsigned long ranges[MAX_MOVERS];
	bool		  selected[MAX_MOVERS];

	count = 0;

	//------------------------------------------------------------
	// draw non-movers, must do separate check for vehicles, I'm not sure they
	// have sensors
	for ( i = 0; i < MAX_TEAMS; ++i )
	{
		TeamSensorSystem* pSys = SensorManager->getTeamSensor( i );
		
		if ( pSys )
		{
			for ( int j = 0; j < pSys->numSensors; ++j )
			{
				SensorSystem* pSensor = pSys->sensors[j];

				if ( !pSensor )
					continue;

				if ( pSensor->owner->isDestroyed() || pSensor->owner->isDisabled() || pSensor->owner->getStatus() == OBJECT_STATUS_SHUTDOWN )
					continue;

				if ( pSensor->getRange() < 1.1 || pSensor->broken)
					continue;

				if (!pSensor->owner->getTeam())
					continue;

				ObjectClass objClass = pSensor->owner->getObjectClass();

				unsigned long colorBlip = pSensor->owner->getSelected() ? 0xff4bff4b : 0xff00cc00;
				unsigned long colorRing = 0xff00cc00;

			
				if ( pSensor->owner->getTeam()->isNeutral( Team::home ) )
				{
					colorBlip = pSensor->owner->getSelected() ? 0xff4c4cff : 0xff0000ff;
					colorRing = 0xff0000ff;
				}
				else if ( pSensor->owner->getTeam()->isEnemy( Team::home ) ) // enemy
				{
					
					{
						colorBlip = pSensor->owner->getSelected() ? 0xffff3f3f : 0xffff0000;
						colorRing = 0xffff0000;
					}
				}

				if ( objClass != BATTLEMECH && objClass != GROUNDVEHICLE)
				{
					if ( objClass == ARTILLERY )
					{
						// blink
						s_lastBlinkTime += g_deltaTime;
						if ( s_lastBlinkTime > s_blinkLength )
						{
							colorBlip = 0;
							colorRing = 0;
							s_lastBlinkTime = 0.f;
						}

					}

					colors[count] = colorBlip;
					ringColors[count] = colorRing;
					ranges[count] = pSensor->getRange();
					selected[count] = 0;
					positions[count] = pSensor->owner->getPosition();
					count++;

				}
			}
		}
	}

	unsigned long colorBlip, colorRing;

	//-----------------------------------------------------	
	// draw the movers
	for (i=0;i<(ObjectManager->numMovers);i++)
	{
		MoverPtr mover = ObjectManager->getMover(i);
		if (mover && mover->getExists() && !(mover->isDestroyed() || mover->isDisabled()))
		{
			SensorSystem* pSensor = mover->getSensorSystem();
			float range = pSensor ? pSensor->getRange() : 0;
			long contactStatus = mover->getContactStatus(Team::home->getId(), true);
			if (mover->getTeamId() == Team::home->id)
			{
				if (mover->getCommanderId() == Commander::home->getId())
				{
					if (mover->isOnGUI())
					{
						colorBlip = mover->getSelected() ? 0xff4bff4b : 0xff00cc00;
						mover->getStatus() == OBJECT_STATUS_SHUTDOWN ? colorRing = 0 : colorRing =  0xff00cc00;
					}
					else
						continue;
				}
				else
				{
					if (mover->isOnGUI() && land->IsGameSelectTerrainPosition(mover->getPosition()) && mover->pathLocks)
					{
						colorBlip = mover->getSelected() ? 0xff4b4bff : 0xff0000cc;
						mover->getStatus() == OBJECT_STATUS_SHUTDOWN ? colorRing = 0 : colorRing =  0xff0000cc;
					}
					else
						continue;
				}
			}
			else if (g_dbgShowMovers || (MPlayer && MPlayer->allUnitsDestroyed[MPlayer->commanderID]) || ((mover->getTeamId() != Team::home->id)
				&&  ( contactStatus != CONTACT_NONE )
				&&  (mover->getStatus() != OBJECT_STATUS_SHUTDOWN) 
				&&  (!mover->hasNullSignature())
				&&	(mover->getEcmRange() <= 0.0f) ) )	//Do not draw ECM mechs!!)
			{
				//Not on our side.  Draw by contact status
				colorBlip = mover->getSelected() ? 0xffff3f3f : 0xffff0000;
				colorRing = 0xffff0000;
				
			}
			else
				continue;

			colors[count] = colorBlip;
			ringColors[count] = colorRing;
			ranges[count] = range;
			selected[count] = mover->getSelected();
			positions[count] = mover->getPosition();
			count++;

		}
	}

	for ( i = 0; i < count; i++ )
	{
		drawSensor( positions[i], ranges[i], ringColors[i] );
	}
	bool bSel = 0; // draw unselected first
	for ( int j = 0; j < 2; j++ )
	{
		for ( int i = 0; i < count; i++ )
		{
			if ( selected[i] == bSel )
			{
				drawBlip( positions[i], colors[i], DOT_BLIP );
			}
		}
		bSel = 1;
	}



}