Пример #1
0
SendProp SendPropQuaternion(
	char *pVarName,
	int offset,
	int sizeofVar,
	int nBits,					// Number of bits to use when encoding.
	int flags,
	float fLowValue,			// For floating point, low and high values.
	float fHighValue,			// High value. If HIGH_DEFAULT, it's (1<<nBits).
	SendVarProxyFn varProxy
	)
{
	SendProp ret;

	if(varProxy == SendProxy_QuaternionToQuaternion)
	{
		Assert(sizeofVar == sizeof(Quaternion));
	}

	if ( nBits == 32 )
		flags |= SPROP_NOSCALE;

	ret.m_Type = DPT_Quaternion;
	ret.m_pVarName = pVarName;
	ret.SetOffset( offset );
	ret.m_nBits = nBits;
	ret.SetFlags( flags );
	ret.m_fLowValue = fLowValue;
	ret.m_fHighValue = fHighValue;
	ret.m_fHighLowMul = AssignRangeMultiplier( ret.m_nBits, ret.m_fHighValue - ret.m_fLowValue );
	ret.SetProxyFn( varProxy );
	if( ret.GetFlags() & (SPROP_COORD | SPROP_NOSCALE | SPROP_NORMAL) )
		ret.m_nBits = 0;

	return ret;
}
Пример #2
0
SendProp SendPropQAngles(
	char *pVarName,
	int offset,
	int sizeofVar,
	int nBits,
	int flags,
	SendVarProxyFn varProxy
	)
{
	SendProp ret;

	if(varProxy == SendProxy_AngleToFloat)
	{
		Assert(sizeofVar == 4);
	}

	if ( nBits == 32 )
		flags |= SPROP_NOSCALE;

	ret.m_Type = DPT_Vector;
	ret.m_pVarName = pVarName;
	ret.SetOffset( offset );
	ret.m_nBits = nBits;
	ret.SetFlags( flags );
	ret.m_fLowValue = 0.0f;
	ret.m_fHighValue = 360.0f;
	ret.m_fHighLowMul = AssignRangeMultiplier( ret.m_nBits, ret.m_fHighValue - ret.m_fLowValue );

	ret.SetProxyFn( varProxy );

	return ret;
}
Пример #3
0
SendProp SendPropFloat(
    const char *pVarName,
    // Variable name.
    int offset,			// Offset into container structure.
    int sizeofVar,
    int nBits,			// Number of bits to use when encoding.
    int flags,
    float fLowValue,		// For floating point, low and high values.
    float fHighValue,		// High value. If HIGH_DEFAULT, it's (1<<nBits).
    SendVarProxyFn varProxy
)
{
    SendProp ret;

    if ( varProxy == SendProxy_FloatToFloat )
    {
        Assert( sizeofVar == 0 || sizeofVar == 4 );
    }

    if ( nBits <= 0 || nBits == 32 )
    {
        flags |= SPROP_NOSCALE;
        fLowValue = 0.f;
        fHighValue = 0.f;
    }
    else
    {
        if(fHighValue == HIGH_DEFAULT)
            fHighValue = (1 << nBits);

        if (flags & SPROP_ROUNDDOWN)
            fHighValue = fHighValue - ((fHighValue - fLowValue) / (1 << nBits));
        else if (flags & SPROP_ROUNDUP)
            fLowValue = fLowValue + ((fHighValue - fLowValue) / (1 << nBits));
    }

    ret.m_Type = DPT_Float;
    ret.m_pVarName = pVarName;
    ret.SetOffset( offset );
    ret.m_nBits = nBits;
    ret.SetFlags( flags );
    ret.m_fLowValue = fLowValue;
    ret.m_fHighValue = fHighValue;
    ret.m_fHighLowMul = AssignRangeMultiplier( ret.m_nBits, ret.m_fHighValue - ret.m_fLowValue );
    ret.SetProxyFn( varProxy );
    if( ret.GetFlags() & (SPROP_COORD | SPROP_NOSCALE | SPROP_NORMAL | SPROP_COORD_MP | SPROP_COORD_MP_LOWPRECISION | SPROP_COORD_MP_INTEGRAL ) )
        ret.m_nBits = 0;

    return ret;
}