Ejemplo n.º 1
0
void CEngineSprite::SetFrame( RenderMode_t nRenderMode, int nFrame )
{
	if ( IsAVI() )
	{
		avi->SetFrame( m_hAVIMaterial, nFrame );
		return;
	}

#if !defined( _X360 ) || defined( BINK_ENABLED_FOR_X360 )
	if ( IsBIK() )
	{
		bik->SetFrame( m_hBIKMaterial, nFrame );
		return;
	}
#endif

	IMaterial *pMaterial = m_material[nRenderMode];
	if ( !pMaterial )
		return;

	IMaterialVar* pFrameVar = pMaterial->FindVarFast( "$frame", &frameCache );
	if ( pFrameVar )
	{
		pFrameVar->SetIntValue( nFrame );
	}
}
Ejemplo n.º 2
0
IMaterial *CEngineSprite::GetMaterial( RenderMode_t nRenderMode, int nFrame ) 
{
	if ( nRenderMode == kRenderNone || nRenderMode == kRenderEnvironmental )
		return NULL;

	if ( IsAVI() )
	{
		avi->SetFrame( m_hAVIMaterial, nFrame );
		return m_material[ 0 ];	// render mode is ignored for avi
	}

#if !defined( _X360 ) || defined( BINK_ENABLED_FOR_X360 )
	if ( IsBIK() )
	{
		bik->SetFrame( m_hBIKMaterial, nFrame );
		return m_material[ 0 ]; // render mode is ignored for bink
	}
#endif
	
	IMaterial *pMaterial = m_material[nRenderMode];
	Assert( pMaterial );
	if ( pMaterial == NULL )
		return NULL;

	IMaterialVar* pFrameVar = pMaterial->FindVarFast( "$frame", &frameCache );
	if ( pFrameVar )
	{
		pFrameVar->SetIntValue( nFrame );
	}

	return pMaterial;
} 
Ejemplo n.º 3
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : frame - 
//			x - 
//			y - 
//			*prcSubRect - 
//-----------------------------------------------------------------------------
void CEngineSprite::DrawFrameOfSize( int frame, int x, int y, int iWidth, int iHeight, const wrect_t *prcSubRect )
{
	// FIXME: If we ever call this with AVIs, need to have it call GetTexCoordRange and make that work
	Assert( !IsAVI() && !IsBIK() );

	float fLeft = 0;
	float fRight = 1;
	float fTop = 0;
	float fBottom = 1;

	if ( prcSubRect )
	{
		AdjustSubRect( this, frame, &fLeft, &fRight, &fTop, &fBottom, &iWidth, &iHeight, prcSubRect );
	}

	if ( giScissorTest && !Scissor( x, y, iWidth, iHeight, fLeft, fTop, fRight, fBottom ) )
		return;

	SetFrame( frame );

	CMatRenderContextPtr pRenderContext( materials );
	IMesh* pMesh = pRenderContext->GetDynamicMesh( true, NULL, NULL, GetMaterial() );

	CMeshBuilder meshBuilder;
	meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 );

	float color[3];
	GetHUDSpriteColor( color );
	
	meshBuilder.Color3fv( color );
	meshBuilder.TexCoord2f( 0, fLeft, fTop );
	meshBuilder.Position3f( x, y, 0.0f );
	meshBuilder.AdvanceVertex();

	meshBuilder.Color3fv( color );
	meshBuilder.TexCoord2f( 0, fRight, fTop );
	meshBuilder.Position3f( x + iWidth, y, 0.0f );
	meshBuilder.AdvanceVertex();

	meshBuilder.Color3fv( color );
	meshBuilder.TexCoord2f( 0, fRight, fBottom );
	meshBuilder.Position3f( x + iWidth, y + iHeight, 0.0f );
	meshBuilder.AdvanceVertex();

	meshBuilder.Color3fv( color );
	meshBuilder.TexCoord2f( 0, fLeft, fBottom );
	meshBuilder.Position3f( x, y + iHeight, 0.0f );
	meshBuilder.AdvanceVertex();

	meshBuilder.End();
	pMesh->Draw();
}
Ejemplo n.º 4
0
void CEngineSprite::SetFrame( float frame )
{
	if ( IsAVI() )
	{
		avi->SetFrame( m_hAVIMaterial, frame );
	}
	else if ( IsBIK() )
	{
		bik->SetFrame( m_hBIKMaterial, frame );
	}
	else
	{
		IMaterialVar* pFrameVar = m_material->FindVarFast( "$frame", &frameCache );
		if (pFrameVar)
		{
			pFrameVar->SetFloatValue( frame );
		}
		return;
	}
}
Ejemplo n.º 5
0
//-----------------------------------------------------------------------------
// Returns the texture coordinate range	used to draw the sprite
//-----------------------------------------------------------------------------
void CEngineSprite::GetTexCoordRange( float *pMinU, float *pMinV, float *pMaxU, float *pMaxV )
{
	*pMaxU = 1.0f; 
	*pMaxV = 1.0f;
	if ( IsAVI() )
	{
		avi->GetTexCoordRange( m_hAVIMaterial, pMaxU, pMaxV );
	}
	if ( IsBIK() )
	{
		bik->GetTexCoordRange( m_hBIKMaterial, pMaxU, pMaxV );
	}
	float flOOWidth = ( m_width != 0 ) ? 1.0f / m_width : 1.0f;
	float flOOHeight = ( m_height!= 0 ) ? 1.0f / m_height : 1.0f;

	*pMinU = 0.5f * flOOWidth; 
	*pMinV = 0.5f * flOOHeight;
	*pMaxU = (*pMaxU) - (*pMinU);
	*pMaxV = (*pMaxV) - (*pMinV);
}
Ejemplo n.º 6
0
//-----------------------------------------------------------------------------
// Returns the texture coordinate range	used to draw the sprite
//-----------------------------------------------------------------------------
void CEngineSprite::GetTexCoordRange( float *pMinU, float *pMinV, float *pMaxU, float *pMaxV )
{
	*pMaxU = 1.0f; 
	*pMaxV = 1.0f;
	if ( IsAVI() )
	{
		avi->GetTexCoordRange( m_hAVIMaterial, pMaxU, pMaxV );
	}
#if !defined( _X360 ) || defined( BINK_ENABLED_FOR_X360 )
	if ( IsBIK() )
	{
		bik->GetTexCoordRange( m_hBIKMaterial, pMaxU, pMaxV );
	}
#endif
	float flOOWidth = ( m_width != 0 ) ? 1.0f / m_width : 1.0f;
	float flOOHeight = ( m_height!= 0 ) ? 1.0f / m_height : 1.0f;

	*pMinU = 0.5f * flOOWidth; 
	*pMinV = 0.5f * flOOHeight;
	*pMaxU = (*pMaxU) - (*pMinU);
	*pMaxV = (*pMaxV) - (*pMinV);
}