Beispiel #1
0
/*
============
sdUICrosshairInfo::DrawBrackets
============
*/
void sdUICrosshairInfo::DrawBrackets( const sdBounds2D& bounds, const idVec4& color ) {
	const float screenWidth = SCREEN_WIDTH * 1.0f / deviceContext->GetAspectRatioCorrection();

	float left			= bounds.GetLeft();
	float right			= bounds.GetRight();
	float top			= bounds.GetTop();
	float bottom		= bounds.GetBottom();
	float width			= bounds.GetWidth();
	float height		= bounds.GetHeight();

	idVec2 center( left + width * 0.5f, top + height * 0.5f );

	float size = width * 0.25f;

	//
	// left half
	//
	idVec4 rect;
	rect.Set( left - crosshairParts[ CP_L_BRACKET_TOP ].width, top, crosshairParts[ CP_L_BRACKET_TOP ].width, height );

	DrawThreeVerticalParts( rect, color, vec2_one, crosshairParts[ CP_L_BRACKET_TOP ], crosshairParts[ CP_L_BRACKET_CENTER ], crosshairParts[ CP_L_BRACKET_BOTTOM ] );
	
	rect.Set( right, top, crosshairParts[ CP_L_BRACKET_TOP ].width, height );
	DrawThreeVerticalParts( rect, color, vec2_one, crosshairParts[ CP_R_BRACKET_TOP ], crosshairParts[ CP_R_BRACKET_CENTER ], crosshairParts[ CP_R_BRACKET_BOTTOM ] );	
	
}
Beispiel #2
0
/*
================
sdAdEntity::UpdateImpression
================
*/
void sdAdEntity::UpdateImpression( impressionInfo_t& impression, const renderView_t& view, const sdBounds2D& viewPort ) {
	assert( adSurface );

	sdWorldToScreenConverter converter( view );

	sdBounds2D	screenBounds;
	idVec2		screenCenter;

	const idBounds& surfaceBounds	= adSurface->geometry->bounds;
	idVec3 sufaceCenter				= renderEntity.origin + ( surfaceBounds.GetCenter() * renderEntity.axis );

	impression.screenWidth	= viewPort.GetWidth();
	impression.screenHeight	= viewPort.GetHeight();

	converter.SetExtents( idVec2( impression.screenWidth, impression.screenHeight ) );
	converter.Transform( surfaceBounds, renderEntity.axis, renderEntity.origin, screenBounds );
	converter.Transform( sufaceCenter, screenCenter );

	sdBounds2D clippedImpressionBounds;
	idFrustum f;
	f.SetAxis( view.viewaxis );
	f.SetOrigin( view.vieworg );
	float dNear = 0.0f;
	float dFar	= MAX_WORLD_SIZE;
	float dLeft = idMath::Tan( DEG2RAD( view.fov_x * 0.5f ) ) * dFar;
	float dUp	= idMath::Tan( DEG2RAD( view.fov_y * 0.5f ) ) * dFar;
	f.SetSize( dNear, dFar, dLeft, dUp );
	sdWorldToScreenConverter::TransformClipped( surfaceBounds, renderEntity.axis, renderEntity.origin, clippedImpressionBounds, f, idVec2( impression.screenWidth, impression.screenHeight ) );
	impression.size		= ( clippedImpressionBounds.GetMaxs() - clippedImpressionBounds.GetMins() ).Length();

	// Angle calculation	
	idVec3 objectNormal = adSurfaceNormal * renderEntity.axis;

	impression.angle	= objectNormal * -view.viewaxis[ 0 ];

	// Offscreen determination
	impression.inView	= true;

	// If the center point is off screen, and if either of the two bounding points are offscreen
	// then the entire object is considered to be offscreen
	if ( !viewPort.ContainsPoint( screenCenter ) ) {
		if ( !viewPort.ContainsPoint( screenBounds.GetMins() ) || !viewPort.ContainsPoint( screenBounds.GetMaxs() ) ) {
			impression.inView = false;
		}
	}

	lastImpression = impression;
}