diff options
| author | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:31:46 -0800 |
|---|---|---|
| committer | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:46:31 -0800 |
| commit | f56bb35301836e56582a575a75864392a0177875 (patch) | |
| tree | de61ddd39de3e7df52759711950b4c288592f0dc /mp/src/game/client/fx_staticline.cpp | |
| parent | Mark some more files as text. (diff) | |
| download | source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip | |
Fix line endings. WHAMMY.
Diffstat (limited to 'mp/src/game/client/fx_staticline.cpp')
| -rw-r--r-- | mp/src/game/client/fx_staticline.cpp | 332 |
1 files changed, 166 insertions, 166 deletions
diff --git a/mp/src/game/client/fx_staticline.cpp b/mp/src/game/client/fx_staticline.cpp index ddad1e63..0e6e5a86 100644 --- a/mp/src/game/client/fx_staticline.cpp +++ b/mp/src/game/client/fx_staticline.cpp @@ -1,166 +1,166 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $Workfile: $
-// $Date: $
-// $NoKeywords: $
-//=============================================================================//
-#include "cbase.h"
-#include "clientsideeffects.h"
-#include "fx_staticline.h"
-#include "materialsystem/imaterial.h"
-#include "materialsystem/imesh.h"
-#include "view.h"
-
-// memdbgon must be the last include file in a .cpp file!!!
-#include "tier0/memdbgon.h"
-
-/*
-==================================================
-CFXStaticLine
-==================================================
-*/
-
-CFXStaticLine::CFXStaticLine( const char *name, const Vector& start, const Vector& end, float scale, float life, const char *shader, unsigned int flags )
-: CClientSideEffect( name )
-{
- assert( materials );
- if ( materials == NULL )
- return;
-
- // Create a material...
- m_pMaterial = materials->FindMaterial( shader, TEXTURE_GROUP_CLIENT_EFFECTS );
- m_pMaterial->IncrementReferenceCount();
-
- //Fill in the rest of the fields
- m_vecStart = start;
- m_vecEnd = end;
- m_uiFlags = flags;
- m_fLife = life;
- m_fScale = scale * 0.5f;
-}
-
-CFXStaticLine::~CFXStaticLine( void )
-{
- Destroy();
-}
-
-//==================================================
-// Purpose: Draw the primitive
-// Input: frametime - the time, this frame
-//==================================================
-
-void CFXStaticLine::Draw( double frametime )
-{
- Vector lineDir, viewDir, cross;
- Vector tmp;
-
- // Update the effect
- Update( frametime );
-
- // Get the proper orientation for the line
- VectorSubtract( m_vecEnd, m_vecStart, lineDir );
- VectorSubtract( m_vecEnd, CurrentViewOrigin(), viewDir );
-
- cross = lineDir.Cross( viewDir );
-
- VectorNormalize( cross );
-
- CMatRenderContextPtr pRenderContext( materials );
-
- //Bind the material
- IMesh* pMesh = pRenderContext->GetDynamicMesh( true, NULL, NULL, m_pMaterial );
- CMeshBuilder meshBuilder;
-
- meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 );
-
- bool flipVertical = (m_uiFlags & FXSTATICLINE_FLIP_VERTICAL) != 0;
- bool flipHorizontal = (m_uiFlags & FXSTATICLINE_FLIP_HORIZONTAL ) != 0;
-
- //Setup our points
- VectorMA( m_vecStart, -m_fScale, cross, tmp );
- meshBuilder.Position3fv( tmp.Base() );
- meshBuilder.Normal3fv( cross.Base() );
- if (flipHorizontal)
- meshBuilder.TexCoord2f( 0, 0.0f, 1.0f );
- else if (flipVertical)
- meshBuilder.TexCoord2f( 0, 0.0f, 0.0f );
- else
- meshBuilder.TexCoord2f( 0, 1.0f, 1.0f );
- meshBuilder.Color4ub( 255, 255, 255, 255 );
- meshBuilder.AdvanceVertex();
-
- VectorMA( m_vecStart, m_fScale, cross, tmp );
- meshBuilder.Position3fv( tmp.Base() );
- meshBuilder.Normal3fv( cross.Base() );
- if (flipHorizontal)
- meshBuilder.TexCoord2f( 0, 1.0f, 1.0f );
- else if (flipVertical)
- meshBuilder.TexCoord2f( 0, 1.0f, 0.0f );
- else
- meshBuilder.TexCoord2f( 0, 0.0f, 1.0f );
- meshBuilder.Color4ub( 255, 255, 255, 255 );
- meshBuilder.AdvanceVertex();
-
- VectorMA( m_vecEnd, m_fScale, cross, tmp );
- meshBuilder.Position3fv( tmp.Base() );
- meshBuilder.Normal3fv( cross.Base() );
- if (flipHorizontal)
- meshBuilder.TexCoord2f( 0, 1.0f, 0.0f );
- else if (flipVertical)
- meshBuilder.TexCoord2f( 0, 1.0f, 1.0f );
- else
- meshBuilder.TexCoord2f( 0, 0.0f, 0.0f );
- meshBuilder.Color4ub( 255, 255, 255, 255 );
- meshBuilder.AdvanceVertex();
-
- VectorMA( m_vecEnd, -m_fScale, cross, tmp );
- meshBuilder.Position3fv( tmp.Base() );
- meshBuilder.Normal3fv( cross.Base() );
- if (flipHorizontal)
- meshBuilder.TexCoord2f( 0, 0.0f, 0.0f );
- else if (flipVertical)
- meshBuilder.TexCoord2f( 0, 0.0f, 1.0f );
- else
- meshBuilder.TexCoord2f( 0, 1.0f, 0.0f );
- meshBuilder.Color4ub( 255, 255, 255, 255 );
- meshBuilder.AdvanceVertex();
-
- meshBuilder.End();
- pMesh->Draw();
-}
-
-//==================================================
-// Purpose: Returns whether or not the effect is still active
-// Output: true if active
-//==================================================
-
-bool CFXStaticLine::IsActive( void )
-{
- return ( m_fLife > 0.0 ) ? true : false;
-}
-
-//==================================================
-// Purpose: Destroy the effect and its local resources
-//==================================================
-
-void CFXStaticLine::Destroy( void )
-{
- //Release the material
- if ( m_pMaterial != NULL )
- {
- m_pMaterial->DecrementReferenceCount();
- m_pMaterial = NULL;
- }
-}
-
-//==================================================
-// Purpose: Perform any necessary updates
-// Input: frametime - the time, this frame
-//==================================================
-
-void CFXStaticLine::Update( double frametime )
-{
- m_fLife -= frametime;
-}
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $Workfile: $ +// $Date: $ +// $NoKeywords: $ +//=============================================================================// +#include "cbase.h" +#include "clientsideeffects.h" +#include "fx_staticline.h" +#include "materialsystem/imaterial.h" +#include "materialsystem/imesh.h" +#include "view.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +/* +================================================== +CFXStaticLine +================================================== +*/ + +CFXStaticLine::CFXStaticLine( const char *name, const Vector& start, const Vector& end, float scale, float life, const char *shader, unsigned int flags ) +: CClientSideEffect( name ) +{ + assert( materials ); + if ( materials == NULL ) + return; + + // Create a material... + m_pMaterial = materials->FindMaterial( shader, TEXTURE_GROUP_CLIENT_EFFECTS ); + m_pMaterial->IncrementReferenceCount(); + + //Fill in the rest of the fields + m_vecStart = start; + m_vecEnd = end; + m_uiFlags = flags; + m_fLife = life; + m_fScale = scale * 0.5f; +} + +CFXStaticLine::~CFXStaticLine( void ) +{ + Destroy(); +} + +//================================================== +// Purpose: Draw the primitive +// Input: frametime - the time, this frame +//================================================== + +void CFXStaticLine::Draw( double frametime ) +{ + Vector lineDir, viewDir, cross; + Vector tmp; + + // Update the effect + Update( frametime ); + + // Get the proper orientation for the line + VectorSubtract( m_vecEnd, m_vecStart, lineDir ); + VectorSubtract( m_vecEnd, CurrentViewOrigin(), viewDir ); + + cross = lineDir.Cross( viewDir ); + + VectorNormalize( cross ); + + CMatRenderContextPtr pRenderContext( materials ); + + //Bind the material + IMesh* pMesh = pRenderContext->GetDynamicMesh( true, NULL, NULL, m_pMaterial ); + CMeshBuilder meshBuilder; + + meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); + + bool flipVertical = (m_uiFlags & FXSTATICLINE_FLIP_VERTICAL) != 0; + bool flipHorizontal = (m_uiFlags & FXSTATICLINE_FLIP_HORIZONTAL ) != 0; + + //Setup our points + VectorMA( m_vecStart, -m_fScale, cross, tmp ); + meshBuilder.Position3fv( tmp.Base() ); + meshBuilder.Normal3fv( cross.Base() ); + if (flipHorizontal) + meshBuilder.TexCoord2f( 0, 0.0f, 1.0f ); + else if (flipVertical) + meshBuilder.TexCoord2f( 0, 0.0f, 0.0f ); + else + meshBuilder.TexCoord2f( 0, 1.0f, 1.0f ); + meshBuilder.Color4ub( 255, 255, 255, 255 ); + meshBuilder.AdvanceVertex(); + + VectorMA( m_vecStart, m_fScale, cross, tmp ); + meshBuilder.Position3fv( tmp.Base() ); + meshBuilder.Normal3fv( cross.Base() ); + if (flipHorizontal) + meshBuilder.TexCoord2f( 0, 1.0f, 1.0f ); + else if (flipVertical) + meshBuilder.TexCoord2f( 0, 1.0f, 0.0f ); + else + meshBuilder.TexCoord2f( 0, 0.0f, 1.0f ); + meshBuilder.Color4ub( 255, 255, 255, 255 ); + meshBuilder.AdvanceVertex(); + + VectorMA( m_vecEnd, m_fScale, cross, tmp ); + meshBuilder.Position3fv( tmp.Base() ); + meshBuilder.Normal3fv( cross.Base() ); + if (flipHorizontal) + meshBuilder.TexCoord2f( 0, 1.0f, 0.0f ); + else if (flipVertical) + meshBuilder.TexCoord2f( 0, 1.0f, 1.0f ); + else + meshBuilder.TexCoord2f( 0, 0.0f, 0.0f ); + meshBuilder.Color4ub( 255, 255, 255, 255 ); + meshBuilder.AdvanceVertex(); + + VectorMA( m_vecEnd, -m_fScale, cross, tmp ); + meshBuilder.Position3fv( tmp.Base() ); + meshBuilder.Normal3fv( cross.Base() ); + if (flipHorizontal) + meshBuilder.TexCoord2f( 0, 0.0f, 0.0f ); + else if (flipVertical) + meshBuilder.TexCoord2f( 0, 0.0f, 1.0f ); + else + meshBuilder.TexCoord2f( 0, 1.0f, 0.0f ); + meshBuilder.Color4ub( 255, 255, 255, 255 ); + meshBuilder.AdvanceVertex(); + + meshBuilder.End(); + pMesh->Draw(); +} + +//================================================== +// Purpose: Returns whether or not the effect is still active +// Output: true if active +//================================================== + +bool CFXStaticLine::IsActive( void ) +{ + return ( m_fLife > 0.0 ) ? true : false; +} + +//================================================== +// Purpose: Destroy the effect and its local resources +//================================================== + +void CFXStaticLine::Destroy( void ) +{ + //Release the material + if ( m_pMaterial != NULL ) + { + m_pMaterial->DecrementReferenceCount(); + m_pMaterial = NULL; + } +} + +//================================================== +// Purpose: Perform any necessary updates +// Input: frametime - the time, this frame +//================================================== + +void CFXStaticLine::Update( double frametime ) +{ + m_fLife -= frametime; +} |