示例#1
0
void cBSPDemoCallbacks::OnEvent( TSREvent& _event )
{
	switch ( _event.type )
    {
        case TWISTER_KEYDOWN:
#ifdef ENABLE_EDITING
            if ( KEYDOWN( TWISTER_KEY_p ) )
            {
                Painting* pNewPainting = new Painting();
                char paintingName[ 128 ];
                sprintf( paintingName, "database//objects//painting%d.txt", g_pPaintings->m_Paintings.size() );
                pNewPainting->SetName( paintingName );
                FormulateViewMatrix( g_pCamera, pNewPainting->m_Transform );
                pNewPainting->Save();
            }
            if ( KEYDOWN( TWISTER_KEY_1 ) )
            {
                if ( g_pCurrentPainting )
                {
                    TSRMatrix4& transform = g_pCurrentPainting->m_Transform;
                    TSRMatrix4 rot;
                    rot.MakeIdent();
                    rot.IsAxisRotation( TSRVector3( 1.0f, 0.0f, 0.0f ), PI / 2.0f );
                    transform = rot * transform ;
                    g_pCurrentPainting->Save();
                }
            }
            if ( KEYDOWN( TWISTER_KEY_2 ) )
            {
                if ( g_pCurrentPainting )
                {
                    TSRMatrix4& transform = g_pCurrentPainting->m_Transform;
                    TSRMatrix4 rot;
                    rot.MakeIdent();
                    rot.IsAxisRotation( TSRVector3( 0.0f, 1.0f, 0.0f ), PI / 2.0f );
                    transform = rot * transform ;
                    g_pCurrentPainting->Save();
                }
            }
            if ( KEYDOWN( TWISTER_KEY_3 ) )
            {
                if ( g_pCurrentPainting )
                {
                    TSRMatrix4& transform = g_pCurrentPainting->m_Transform;
                    TSRMatrix4 rot;
                    rot.MakeIdent();
                    rot.IsAxisRotation( TSRVector3( 0.0f, 0.0f, 1.0f ), PI / 2.0f );
                    transform = rot * transform ;
                    g_pCurrentPainting->Save();
                }
            }
            if ( KEYDOWN( TWISTER_KEY_n ) )
            {
                g_PaintingsIndex++;
                
                if ( g_PaintingsIndex == g_pPaintings->m_Paintings.size() )
                {
                    g_PaintingsIndex = 0;
                }
                
                g_pCurrentPainting = g_pPaintings->m_Paintings[g_PaintingsIndex];
            }
            if ( KEYDOWN( TWISTER_KEY_v ) )
            {
                g_bDebugRenderLights = !g_bDebugRenderLights;
                break;
            }
#endif // ENABLE_EDITING
            if ( KEYDOWN( TWISTER_KEY_l ) )
            {
                TSRColor4 LightColor;
                LightColor.r = fastabs( m_pWorld->m_Camera.m_Fwd.x );
                LightColor.g = fastabs( m_pWorld->m_Camera.m_Fwd.y );
                LightColor.b = fastabs( m_pWorld->m_Camera.m_Fwd.z );
                LightColor.a = 4.0f;
                LightsManager()->AddPointLight( m_pWorld->m_Camera.m_Loc, LightColor, 100.0f );
            }
            if ( KEYDOWN( TWISTER_KEY_k ) )
            {
                if ( LightsManager()->m_SceneLightsContext.GetPointLightsCount() > 0 )
                {
                    SAFE_DELETE( LightsManager()->m_SceneLightsContext.m_PointLights.back() );
                    LightsManager()->m_SceneLightsContext.m_PointLights.pop_back();
                }
            }
            break;
    }
}