Torque3D Documentation / _generateds / VPostEffectToggleTrack.cpp

VPostEffectToggleTrack.cpp

Engine/source/Verve/Extension/PostEffect/VPostEffectToggleTrack.cpp

More...

Detailed Description

Public Functions

IMPLEMENT_CONOBJECT(VPostEffectToggleTrack )

  1
  2//-----------------------------------------------------------------------------
  3// Verve
  4// Copyright (C) 2014 - Violent Tulip
  5//
  6// Permission is hereby granted, free of charge, to any person obtaining a copy
  7// of this software and associated documentation files (the "Software"), to
  8// deal in the Software without restriction, including without limitation the
  9// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 10// sell copies of the Software, and to permit persons to whom the Software is
 11// furnished to do so, subject to the following conditions:
 12//
 13// The above copyright notice and this permission notice shall be included in
 14// all copies or substantial portions of the Software.
 15//
 16// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 17// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 18// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 19// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 20// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 21// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 22// IN THE SOFTWARE.
 23//-----------------------------------------------------------------------------
 24#include "Verve/Extension/PostEffect/VPostEffectToggleTrack.h"
 25#include "Verve/Extension/PostEffect/VPostEffectToggleEvent.h"
 26#include "Verve/Extension/Camera/VCameraGroup.h"
 27
 28#include "console/consoleTypes.h"
 29
 30//-----------------------------------------------------------------------------
 31IMPLEMENT_CONOBJECT( VPostEffectToggleTrack );
 32//-----------------------------------------------------------------------------
 33
 34VPostEffectToggleTrack::VPostEffectToggleTrack( void ) : 
 35        mPostEffect( NULL )
 36{
 37    setLabel( "PostEffectTrack" );
 38}
 39
 40void VPostEffectToggleTrack::initPersistFields( void )
 41{
 42    Parent::initPersistFields();
 43
 44    addField( "PostEffect", TYPEID<VTorque::PostEffectType>(), Offset( mPostEffect, VPostEffectToggleTrack ), "The name of the PostEffect object to be triggered." );
 45}
 46
 47//-----------------------------------------------------------------------------
 48//
 49// Camera Methods.
 50//
 51//-----------------------------------------------------------------------------
 52
 53//-----------------------------------------------------------------------------
 54// 
 55// VPostEffectToggleTrack::onCameraEvent( pEvent );
 56// 
 57// When the Camera changes, this method is called on both the outgoing and
 58// incoming Camera Groups.
 59// 
 60// For a full list of possible events, see the 'eCameraEventType' declaration
 61// in VCameraGroup.h.
 62// 
 63//-----------------------------------------------------------------------------
 64bool VPostEffectToggleTrack::onCameraEvent( const VCameraGroup::eCameraEventType &pEvent )
 65{
 66    // Parent Call.
 67    if ( !Parent::onCameraEvent( pEvent ) )
 68    {
 69        // Skip.
 70        return false;
 71    }
 72
 73    // Enabled?
 74    if ( !isEnabled() || !mPostEffect.isValid() )
 75    {
 76        // Quit Now.
 77        return true;
 78    }
 79
 80    switch( pEvent )
 81    {
 82        case VCameraGroup::k_EventActivate :
 83            {
 84
 85                VPostEffectToggleEvent *event;
 86                if ( getPreviousEvent( event ) && event->mEventType == VSharedEnum::k_ActionTurnOn )
 87                {
 88                    // Toggle Post Effect On.
 89                    VTorque::setPostEffectOn( mPostEffect, true );
 90                }
 91
 92            } break;
 93
 94        case VCameraGroup::k_EventDeactivate :
 95            {
 96
 97                // Turn Post Effect Off.
 98                VTorque::setPostEffectOn( mPostEffect, false );
 99
100            } break;
101    }
102
103    return true;
104}
105