Esempio n. 1
0
void CShapeModule::InitParticleForCone(CVec3& localPos, CVec3& direction, float fParticleScale) const
{
    CVec3 finalPos, finalDirection;
    float fClipAngle = m_fAngle;
    BEATS_CLIP_VALUE(fClipAngle, 0, 89.99f);
    float fRadius = m_fRadius * fParticleScale;
    float fConeLength = m_fConeLength * fParticleScale;
    float fTopRadius = fRadius + fConeLength * tanf(DegreesToRadians(fClipAngle));
    CVec3 randomDirection(PARTICLE_RAND_RANGE(-1, 1), PARTICLE_RAND_RANGE(-1, 1), 0);
    randomDirection.Normalize();

    float fRadiusOnBase = m_bEmitFromShell ? fRadius : PARTICLE_RAND_RANGE(0, fRadius);
    finalPos = randomDirection * fRadiusOnBase;
    BEATS_ASSERT(!BEATS_FLOAT_EQUAL(fRadius, 0));
    fTopRadius *= (fRadiusOnBase / fRadius);
    CVec3 topPos = (m_bRandomDirection ? GetRandomDirection() : randomDirection) * fTopRadius;
    topPos.Z() = fConeLength;
    finalDirection = topPos - finalPos;
    if (!m_bEmitFromBaseOrVolume)
    {
        finalPos += (finalDirection * PARTICLE_RAND_RANGE(0, 1));
        if (m_bRandomDirection)
        {
            finalDirection = GetRandomDirection();
        }
    }
    finalDirection.Normalize();
    localPos = finalPos;
    direction = finalDirection;
}
Esempio n. 2
0
void CMouse::ClipMousePos()
{
    if (m_coopSetting & DISCL_NONEXCLUSIVE)
    {
        POINT point;
        GetCursorPos(&point);
        m_xWindowPos = point.x;
        m_yWindowPos = point.y;

        ScreenToClient(m_globalHwnd, &point);
        m_xPos = point.x;
        m_yPos = point.y;

        RECT rect;
        GetClientRect(m_globalHwnd, &rect);

        BEATS_CLIP_VALUE(m_xPos, 0, rect.right);
        BEATS_CLIP_VALUE(m_yPos, 0, rect.bottom);

    }
    else
    {
        RECT rect;
        GetClientRect(m_globalHwnd, &rect);
        long windowHeight = rect.bottom - rect.top;
        long windowWidth =rect.right - rect.left;

        m_xPos += m_curState.lX;
        m_yPos += m_curState.lY;

        BEATS_CLIP_VALUE(m_xPos, 0, windowWidth);
        BEATS_CLIP_VALUE(m_yPos, 0, windowHeight);

        //there is no difference when we are under exclusive mode.
        m_xWindowPos = m_xPos;
        m_yWindowPos = m_yPos;
    }
}
Esempio n. 3
0
float SCurveData::Evaluate(float fProgress) const
{
    float fRet = 0;
    BEATS_CLIP_VALUE(fProgress, 0, 1);
    const SCurveKey* pStartKey = nullptr;
    const SCurveKey* pEndKey = nullptr;
    float fStartTime = 0;
    float fEndTime = 0;
    BEATS_ASSERT(m_keyList.size() > 0);
    for (auto iter = m_keyList.begin(); iter != m_keyList.end(); ++iter)
    {
        if (iter->first >= fProgress)
        {
            pEndKey = &iter->second;
            fEndTime = iter->first;
            break;
        }
        pStartKey = &iter->second;
        fStartTime = iter->first;
    }
    if (pStartKey == nullptr)
    {
        BEATS_ASSERT(pEndKey != nullptr);
        fRet = pEndKey->m_fValue;
    }
    else if (pEndKey == nullptr)
    {
        BEATS_ASSERT(pStartKey != nullptr);
        fRet = pStartKey->m_fValue;
    }
    else
    {
        fRet = GetCurveValue(fProgress, fStartTime, fEndTime, pStartKey, pEndKey);
    }
    return fRet;
}