Exemplo n.º 1
0
void CWeaponIFMSteadyCam::ComputeViewOffset()
{
	// Update 2D spring
	if ( !m_bInSpringMode )
	{
		m_vecViewOffset = m_vecActualViewOffset;
		return;
	}

	Vector2D dir;
	Vector2DSubtract( m_vecViewOffset.AsVector2D(), m_vecActualViewOffset.AsVector2D(), dir );
	float flDist = Vector2DNormalize( dir );

	Vector2D vecForce;
	Vector2DMultiply( dir, -flDist * ifm_steadycam_2dspringconstant.GetFloat(), vecForce );
	Vector2DMA( vecForce, -ifm_steadycam_2ddragconstant.GetFloat(), m_vec2DVelocity.AsVector2D(), vecForce ); 

	Vector2DMA( m_vecViewOffset.AsVector2D(), gpGlobals->frametime, m_vec2DVelocity.AsVector2D(), m_vecViewOffset.AsVector2D() ); 
	Vector2DMA( m_vec2DVelocity.AsVector2D(), gpGlobals->frametime, vecForce, m_vec2DVelocity.AsVector2D() ); 
}
Exemplo n.º 2
0
// ----------------------------------------------------------------------------- //
// Adds shadow rendering data to a particular mesh builder
// ----------------------------------------------------------------------------- //
int DispInfo_AddShadowsToMeshBuilder( CMeshBuilder& meshBuilder,
                                      DispShadowHandle_t h, int baseIndex )
{
#ifndef SWDS
    if ( !r_DrawDisp.GetBool() )
    {
        return baseIndex;
    }

    CDispShadowDecal* pShadowDecal = &s_DispShadowDecals[h];
    int shadow = pShadowDecal->m_Shadow;
    ShadowInfo_t const& info = g_pShadowMgr->GetInfo( shadow );

    // It had better be computed by now...
    Assert( pShadowDecal->m_Flags & CDispDecalBase::FRAGMENTS_COMPUTED );

#ifdef _DEBUG
    int triCount = 0;
    int vertCount = 0;
#endif

    DispShadowFragmentHandle_t f = pShadowDecal->m_FirstFragment;
    while ( f != DISP_SHADOW_FRAGMENT_HANDLE_INVALID )
    {
        CDispShadowFragment& fragment = s_DispShadowFragments[f];

        // Add in the vertices + indices, use two loops to minimize tests...
        int i;
        for ( i = 0; i < fragment.m_nVerts - 2; ++i )
        {
            meshBuilder.Position3fv( fragment.m_Verts[i].Base() );

            // Transform + offset the texture coords
            Vector2D texCoord;
            Vector2DMultiply( fragment.m_TCoords[i].AsVector2D(), info.m_TexSize, texCoord );
            texCoord += info.m_TexOrigin;
            meshBuilder.TexCoord2fv( 0, texCoord.Base() );

            unsigned char c = g_pShadowMgr->ComputeDarkness( fragment.m_TCoords[i].z, info );
            meshBuilder.Color4ub( c, c, c, c );

            meshBuilder.AdvanceVertex();

            meshBuilder.Index( baseIndex );
            meshBuilder.AdvanceIndex();
            meshBuilder.Index( i + baseIndex + 1 );
            meshBuilder.AdvanceIndex();
            meshBuilder.Index( i + baseIndex + 2 );
            meshBuilder.AdvanceIndex();

#ifdef _DEBUG
            ++triCount;
            ++vertCount;
#endif
        }

        for ( ; i < fragment.m_nVerts; ++i )
        {
            meshBuilder.Position3fv( fragment.m_Verts[i].Base() );

            // Transform + offset the texture coords
            Vector2D texCoord;
            Vector2DMultiply( fragment.m_TCoords[i].AsVector2D(), info.m_TexSize, texCoord );
            texCoord += info.m_TexOrigin;
            meshBuilder.TexCoord2fv( 0, texCoord.Base() );

            unsigned char c = g_pShadowMgr->ComputeDarkness( fragment.m_TCoords[i].z, info );
            meshBuilder.Color4ub( c, c, c, c );

            meshBuilder.AdvanceVertex();

#ifdef _DEBUG
            ++vertCount;
#endif
        }

        baseIndex += fragment.m_nVerts;

        f = s_DispShadowFragments.Next(f);
    }

#ifdef _DEBUG
    Assert( triCount == pShadowDecal->m_nTris );
    Assert( vertCount == pShadowDecal->m_nVerts );
#endif

    return baseIndex;
#else
    return 0;
#endif
}
Exemplo n.º 3
0
Vector2D Vector2D::operator*(const Vector2D& v) const
{
	Vector2D res;
	Vector2DMultiply(*this, v, res);
	return res;
}
Exemplo n.º 4
0
Vector2D Vector2D::operator*(float fl) const
{
	Vector2D res;
	Vector2DMultiply(*this, fl, res);
	return res;
}