VCameraShakeEvent.cpp
Engine/source/Verve/Extension/Camera/VCameraShakeEvent.cpp
Public Functions
Detailed Description
Public Functions
IMPLEMENT_CONOBJECT(VCameraShakeEvent )
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/Core/VGroup.h" 25#include "Verve/Extension/Camera/VCameraGroup.h" 26#include "Verve/Extension/Camera/VCameraShakeEvent.h" 27 28#include "console/consoleTypes.h" 29 30//----------------------------------------------------------------------------- 31IMPLEMENT_CONOBJECT( VCameraShakeEvent ); 32//----------------------------------------------------------------------------- 33 34VCameraShakeEvent::VCameraShakeEvent( void ) : 35 mAmplitude( Point3F::Zero ), 36 mFalloff( 10.f ), 37 mFrequency( Point3F::Zero ) 38{ 39 // Clear Label. 40 setLabel( "CameraShakeEvent" ); 41} 42 43void VCameraShakeEvent::initPersistFields( void ) 44{ 45 Parent::initPersistFields(); 46 47 addField( "Amplitude", TypePoint3F, Offset( mAmplitude, VCameraShakeEvent ), "Amplitude of the Camera Shake event." ); 48 addField( "Falloff", TypeF32, Offset( mFalloff, VCameraShakeEvent ), "Falloff of the Camera Shake event." ); 49 addField( "Frequency", TypePoint3F, Offset( mFrequency, VCameraShakeEvent ), "Frequency of the Camera Shake event." ); 50} 51 52//----------------------------------------------------------------------------- 53// 54// Controller Methods. 55// 56//----------------------------------------------------------------------------- 57 58//----------------------------------------------------------------------------- 59// 60// VCameraShakeEvent::onTrigger( pTime, pDelta ); 61// 62// Start shaking the camera. Also account for any offet in playtime, and 63// timescale. 64// 65//----------------------------------------------------------------------------- 66void VCameraShakeEvent::onTrigger( const S32 &pTime, const S32 &pDelta ) 67{ 68 Parent::onTrigger( pTime, pDelta ); 69 70 // Fetch Group. 71 VCameraGroup *group; 72 if ( !getGroup( group ) || !group->isActive() ) 73 { 74 // Inactive. 75 return; 76 } 77 78 // Duration. 79 //const F32 duration = ( mDuration - mAbs( pTime - getStartTime() ) ) / ( 1000.f * mFabs( getControllerTimeScale() ) ); 80 const F32 duration = ( mDuration - mAbs( pTime - getStartTime() ) ) / 1000.f; 81 82 // Shake Camera. 83 VTorque::startCameraShake( duration, mFalloff, mAmplitude, mFrequency ); 84} 85