Пример #1
0
//----------------------------------------------------------------------------
void Rope::OnIdle ()
{
    MeasureTime();
    MoveCamera();
    if ( MoveObject() )
        m_spkScene->UpdateGS(0.0f);

    float fCurrIdle = GetTimeInSeconds();
    float fDiff = fCurrIdle - m_fLastIdle;
    if ( fDiff >= 0.001f )
    {
        m_fLastIdle = fCurrIdle;

        DoPhysical();

        ms_spkRenderer->ClearBuffers();
        if ( ms_spkRenderer->BeginScene() )
        {
            ms_spkRenderer->Draw(m_spkScene);
            ms_spkRenderer->EndScene();
        }
        ms_spkRenderer->DisplayBackBuffer();
    }

    UpdateClicks();
}
Пример #2
0
//----------------------------------------------------------------------------
void GelatinCube::OnIdle ()
{
    MeasureTime();

    bool bNeedSort = MoveCamera();
    if ( MoveObject() )
    {
        m_spkScene->UpdateGS(0.0f);
        bNeedSort = true;
    }
    if ( bNeedSort )
        m_spkBox->SortFaces(ms_spkCamera->GetDirection());

#ifndef SINGLE_STEP
    DoPhysical();
#endif

    ms_spkRenderer->ClearBuffers();
    if ( ms_spkRenderer->BeginScene() )
    {
        ms_spkRenderer->Draw(m_spkScene);
        DrawFrameRate(8,GetHeight()-8,ColorRGB::WHITE);
        ms_spkRenderer->EndScene();
    }
    ms_spkRenderer->DisplayBackBuffer();

    UpdateClicks();
}
Пример #3
0
//----------------------------------------------------------------------------
bool BouncingBall::OnKeyDown (unsigned char key, int x, int y)
{
    if (WindowApplication3::OnKeyDown(key, x, y))
    {
        return true;
    }

    switch (key)
    {
    case 'w':  // toggle wireframe
    case 'W':
        mWireState->Enabled = !mWireState->Enabled;
        return true;
    case 's':  // toggle scaling
        mBall->DoAffine() = !mBall->DoAffine();
        return true;
#ifdef SINGLE_STEP
    case 'g':
        mSimTime += mSimDelta;
        DoPhysical();
        return true;
#endif
    }

    return false;
}
Пример #4
0
void World::Update(TimeSpan time, TimeSpan timeDelta)
{
    DoPhysical(time, timeDelta);

    // 
    // 
    //

    //if(timeDelta.TotalSeconds() == 0.0)
    //{
    //    timeDelta += TimeSpan(1);
    //}

    //ball_.Update(timeDelta);
    //RigidBody::StepSimulation(timeDelta);
}
Пример #5
0
//----------------------------------------------------------------------------
void WaterDropFormation::OnIdle ()
{
    MeasureTime();

#ifndef SINGLE_STEP
    float fCurrSeconds = GetTimeInSeconds();
    float fDiff = fCurrSeconds - m_fLastSeconds;
    if ( fDiff >= 0.033333f )
    {
        DoPhysical();
        m_fLastSeconds = fCurrSeconds;
    }
#endif

    DoVisual();
    UpdateClicks();
}
Пример #6
0
//----------------------------------------------------------------------------
void WaterDropFormation::OnKeyDown (unsigned char ucKey, int, int)
{
    if ( ucKey == 'q' || ucKey == 'Q' || ucKey == KEY_ESCAPE )
    {
        RequestTermination();
        return;
    }

    switch ( ucKey )
    {
    case 'w':  // toggle wireframe
    case 'W':
        m_spkWireframe->Enabled() = !m_spkWireframe->Enabled();
        return;

#ifdef SINGLE_STEP
    case 'g':
        DoPhysical();
        return;
#endif
    }
}
Пример #7
0
//----------------------------------------------------------------------------
void Cloth::OnIdle ()
{
    MeasureTime();
    MoveCamera();

    if ( MoveObject() )
        m_spkScene->UpdateGS(0.0f);

#ifndef SINGLE_STEP
    DoPhysical();
#endif

    ms_spkRenderer->ClearBuffers();
    if ( ms_spkRenderer->BeginScene() )
    {
        ms_spkRenderer->Draw(m_spkScene);
        DrawFrameRate(8,GetHeight()-8,ColorRGB::BLACK);
        ms_spkRenderer->EndScene();
    }
    ms_spkRenderer->DisplayBackBuffer();

    UpdateClicks();
}
Пример #8
0
//----------------------------------------------------------------------------
void GelatinCube::OnKeyDown (unsigned char ucKey, int iX, int iY)
{
    if ( ucKey == 'q' || ucKey == 'Q' || ucKey == KEY_ESCAPE )
    {
        RequestTermination();
        return;
    }

    switch ( ucKey )
    {
    case 'w':  // toggle wireframe
    case 'W':
        m_spkWireframe->Enabled() = !m_spkWireframe->Enabled();
        break;

#ifdef SINGLE_STEP
    case 'g':
    case 'G':
        DoPhysical();
        break;
#endif
    }
}
Пример #9
0
//----------------------------------------------------------------------------
void Rope::OnKeyDown (unsigned char ucKey, int iX, int iY)
{
    if ( ucKey == 'q' || ucKey == 'Q' || ucKey == KEY_ESCAPE )
    {
        RequestTermination();
        return;
    }

    int i;

    switch ( ucKey )
    {
    case 'g':
        DoPhysical();
        break;
    case 'w':  // toggle wireframe
    case 'W':
        m_spkWireframe->Enabled() = !m_spkWireframe->Enabled();
        break;
    case 'm':  // decrease mass
        if ( m_pkModule->GetMass(1) > 0.05f )
        {
            for (i = 1; i < m_pkModule->GetNumParticles()-1; i++)
                m_pkModule->SetMass(i,m_pkModule->GetMass(i)-0.01f);
        }
        break;
    case 'M':  // increase mass
        for (i = 1; i < m_pkModule->GetNumParticles()-1; i++)
            m_pkModule->SetMass(i,m_pkModule->GetMass(i)+0.01f);
        break;
    case 'c':  // decrease spring constant
        if ( m_pkModule->Constant(0) > 0.05f )
        {
            for (i = 0; i < m_pkModule->GetNumSprings(); i++)
                m_pkModule->Constant(i) -= 0.01f;
        }
        break;
    case 'C':  // increase spring constant
        for (i = 0; i < m_pkModule->GetNumSprings(); i++)
            m_pkModule->Constant(i) += 0.01f;
        break;
    case 'l':  // decrease spring resting length
        if ( m_pkModule->Length(0) > 0.05f )
        {
            for (i = 0; i < m_pkModule->GetNumSprings(); i++)
                m_pkModule->Length(i) -= 0.01f;
        }
        break;
    case 'L':  // increase spring resting length
        for (i = 0; i < m_pkModule->GetNumSprings(); i++)
            m_pkModule->Length(i) += 0.01f;
        break;
    case 'f':  // toggle wind force on/off
    case 'F':
        m_pkModule->EnableWind() = !m_pkModule->EnableWind();
        break;
    case 'r':  // toggle random wind direction change on/off
    case 'R':
        m_pkModule->EnableWindChange() = !m_pkModule->EnableWindChange();
        break;
    }
}