cameraFXMgr.h
Engine/source/T3D/fx/cameraFXMgr.h
Classes:
Public Variables
Detailed Description
Public Variables
CameraFXManager gCamFXMgr
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#ifndef _CAMERAFXMGR_H_ 25#define _CAMERAFXMGR_H_ 26 27#ifndef _TORQUE_LIST_ 28#include "core/util/tList.h" 29#endif 30#ifndef _MPOINT3_H_ 31#include "math/mPoint3.h" 32#endif 33#ifndef _MMATRIX_H_ 34#include "math/mMatrix.h" 35#endif 36 37//************************************************************************** 38// Abstract camera effect template 39//************************************************************************** 40class CameraFX 41{ 42protected: 43 MatrixF mCamFXTrans; 44 F32 mElapsedTime; 45 F32 mDuration; 46 47public: 48 CameraFX(); 49 virtual ~CameraFX() { } 50 51 MatrixF & getTrans(){ return mCamFXTrans; } 52 virtual bool isExpired(){ return mElapsedTime >= mDuration; } 53 void setDuration( F32 duration ){ mDuration = duration; } 54 55 virtual void update( F32 dt ); 56}; 57 58//-------------------------------------------------------------------------- 59// Camera shake effect 60//-------------------------------------------------------------------------- 61class CameraShake : public CameraFX 62{ 63 typedef CameraFX Parent; 64 65 VectorF mFreq; // these are vectors to represent these values in 3D 66 VectorF mStartAmp; 67 VectorF mAmp; 68 VectorF mTimeOffset; 69 F32 mFalloff; 70 71public: 72 73 /// Is controlled by someone else, ignore duration and do not delete. 74 bool remoteControlled; 75 bool isAdded; 76 77 CameraShake(); 78 79 void init(); 80 void fadeAmplitude(); 81 void setFalloff( F32 falloff ){ mFalloff = falloff; } 82 void setFrequency( VectorF &freq ){ mFreq = freq; } 83 void setAmplitude( VectorF & ){ mStartAmp = amp; } 84 bool isExpired(); 85 86 virtual void update( F32 dt ); 87}; 88 89 90//************************************************************************** 91// CameraFXManager 92//************************************************************************** 93class CameraFXManager 94{ 95 typedef CameraFX * CameraFXPtr; 96 97 MatrixF mCamFXTrans; 98 typedef Torque::List<CameraFXPtr> CamFXList; 99 CamFXList mFXList; 100 101public: 102 void addFX( CameraFX *newFX ); 103 void removeFX( CameraFX *fx ); 104 void clear(); 105 MatrixF & getTrans(){ return mCamFXTrans; } 106 void update( F32 dt ); 107 108 CameraFXManager(); 109 ~CameraFXManager(); 110}; 111 112extern CameraFXManager gCamFXMgr; 113 114 115#endif 116