mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 08:15:44 +00:00
(Mostly) updated verve implementation.
This commit is contained in:
parent
e0627973fb
commit
5a7f0f0b23
538 changed files with 68727 additions and 49 deletions
224
Engine/modules/Verve/Extension/Camera/VCameraGroup.cpp
Normal file
224
Engine/modules/Verve/Extension/Camera/VCameraGroup.cpp
Normal file
|
|
@ -0,0 +1,224 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Verve
|
||||
// Copyright (C) 2014 - Violent Tulip
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "Verve/Extension/Camera/VCameraGroup.h"
|
||||
#include "Verve/Extension/Camera/VCameraTrack.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VCameraGroup );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VCameraGroup *VCameraGroup::mActiveGroup = NULL;
|
||||
VCameraGroup::CameraChangeSignal VCameraGroup::mCameraChangeSignal;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VCameraGroup::VCameraGroup( void )
|
||||
{
|
||||
setLabel( "CameraGroup" );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Tree Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraGroup::onAttach();
|
||||
//
|
||||
// This callback subscribes this object to the controller's event signal.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VCameraGroup::onAttach( void )
|
||||
{
|
||||
Parent::onAttach();
|
||||
|
||||
// Valid Controller?
|
||||
if ( getController() )
|
||||
{
|
||||
// Subscribe to Events.
|
||||
getController()->getControllerEventSignal().notify( this, &VCameraGroup::onControllerEvent );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraGroup::onAttach();
|
||||
//
|
||||
// This callback removes this object from the controller's event signal
|
||||
// notification list.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VCameraGroup::onDetach( void )
|
||||
{
|
||||
// Valid Controller?
|
||||
if ( getController() )
|
||||
{
|
||||
// Remove Event Notification.
|
||||
getController()->getControllerEventSignal().remove( this, &VCameraGroup::onControllerEvent );
|
||||
}
|
||||
|
||||
Parent::onDetach();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraGroup::onControllerEvent( pEvent );
|
||||
//
|
||||
// When the controller's state changes, this method is called.
|
||||
//
|
||||
// For a full list of possible events, see the 'eControllerEventType'
|
||||
// declaration in VController.h.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VCameraGroup::onControllerEvent( VController::eControllerEventType pEvent )
|
||||
{
|
||||
if ( !getController() )
|
||||
{
|
||||
AssertFatal( false, "VCameraGroup::onControllerEvent() - Invalid Controller." );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enabled?
|
||||
if ( !isEnabled() )
|
||||
{
|
||||
// Continue Processing Events.
|
||||
return true;
|
||||
}
|
||||
|
||||
switch( pEvent )
|
||||
{
|
||||
#ifdef VT_EDITOR
|
||||
case VController::k_EventPause :
|
||||
#endif
|
||||
case VController::k_EventStop :
|
||||
{
|
||||
|
||||
// Clear the Camera.
|
||||
clearActiveGroup();
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Camera Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraGroup::setActive();
|
||||
//
|
||||
// Set this Group to Active.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VCameraGroup::setActive( void )
|
||||
{
|
||||
// Set Active.
|
||||
setActiveGroup( this );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraGroup::clearActiveGroup();
|
||||
//
|
||||
// Clear the Active Camera.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VCameraGroup::clearActiveGroup( void )
|
||||
{
|
||||
if ( mActiveGroup )
|
||||
{
|
||||
// Deactivate Signal.
|
||||
mActiveGroup->getCameraEventSignal().trigger( k_EventDeactivate );
|
||||
}
|
||||
|
||||
// Store.
|
||||
mActiveGroup = NULL;
|
||||
|
||||
// Clear Camera Object.
|
||||
VTorque::setCamera( NULL );
|
||||
|
||||
// Change Signal.
|
||||
getCameraChangeSignal().trigger( NULL );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraGroup::setActiveGroup( pCameraGroup );
|
||||
//
|
||||
// Change the current camera group. The actual camera object is the object that
|
||||
// the group references.
|
||||
//
|
||||
// A NULL value of pCameraGroup will clear the active camera, which generally
|
||||
// reverts to the connection's control object. The camera is also cleared when
|
||||
// the Controller stops playing.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VCameraGroup::setActiveGroup( VCameraGroup *pCameraGroup )
|
||||
{
|
||||
// Change Camera?
|
||||
if ( pCameraGroup == mActiveGroup ||
|
||||
pCameraGroup && !pCameraGroup->isEnabled() )
|
||||
{
|
||||
// Invalid Target.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( mActiveGroup )
|
||||
{
|
||||
// Deactivate Signal.
|
||||
mActiveGroup->getCameraEventSignal().trigger( k_EventDeactivate );
|
||||
}
|
||||
|
||||
// Store.
|
||||
mActiveGroup = pCameraGroup;
|
||||
|
||||
if ( mActiveGroup )
|
||||
{
|
||||
// Set Camera Object.
|
||||
VTorque::setCamera( mActiveGroup->getSceneObject() );
|
||||
|
||||
// Activate Signal.
|
||||
mActiveGroup->getCameraEventSignal().trigger( k_EventActivate );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear Camera Object.
|
||||
VTorque::setCamera( NULL );
|
||||
}
|
||||
|
||||
// Change Signal.
|
||||
getCameraChangeSignal().trigger( mActiveGroup );
|
||||
}
|
||||
97
Engine/modules/Verve/Extension/Camera/VCameraGroup.h
Normal file
97
Engine/modules/Verve/Extension/Camera/VCameraGroup.h
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Verve
|
||||
// Copyright (C) 2014 - Violent Tulip
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef _VT_VCAMERAGROUP_H_
|
||||
#define _VT_VCAMERAGROUP_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTGROUP_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectGroup.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VCONTROLLER_H
|
||||
#include "Verve/Core/VController.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VCameraGroup;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VCameraGroup : public VSceneObjectGroup
|
||||
{
|
||||
typedef VSceneObjectGroup Parent;
|
||||
|
||||
public:
|
||||
|
||||
enum eCameraEventType
|
||||
{
|
||||
k_EventActivate,
|
||||
k_EventDeactivate,
|
||||
};
|
||||
|
||||
typedef Signal<bool( const eCameraEventType & )> CameraEventSignal;
|
||||
typedef Signal<void( VCameraGroup* )> CameraChangeSignal;
|
||||
|
||||
protected:
|
||||
|
||||
static VCameraGroup *mActiveGroup;
|
||||
static CameraChangeSignal mCameraChangeSignal;
|
||||
|
||||
CameraEventSignal mCameraEventSignal;
|
||||
|
||||
public:
|
||||
|
||||
VCameraGroup( void );
|
||||
|
||||
// Tree Methods.
|
||||
|
||||
void onAttach( void );
|
||||
void onDetach( void );
|
||||
|
||||
// Controller Methods.
|
||||
|
||||
bool onControllerEvent( VController::eControllerEventType pEvent );
|
||||
|
||||
// Camera Methods.
|
||||
|
||||
inline bool isActive( void ) { return ( bool )( this == getActiveGroup() ); };
|
||||
inline VCameraGroup *getActiveGroup( void ) { return mActiveGroup; };
|
||||
|
||||
void setActive( void );
|
||||
|
||||
static void clearActiveGroup( void );
|
||||
static void setActiveGroup( VCameraGroup *pCameraGroup );
|
||||
|
||||
// Signal Methods.
|
||||
|
||||
static inline CameraChangeSignal &getCameraChangeSignal( void ) { return mCameraChangeSignal; };
|
||||
inline CameraEventSignal &getCameraEventSignal( void ) { return mCameraEventSignal; };
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VCameraGroup );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VCAMERAGROUP_H_
|
||||
83
Engine/modules/Verve/Extension/Camera/VCameraShakeEvent.cpp
Normal file
83
Engine/modules/Verve/Extension/Camera/VCameraShakeEvent.cpp
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Verve
|
||||
// Copyright (C) 2014 - Violent Tulip
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "Verve/Core/VGroup.h"
|
||||
#include "Verve/Extension/Camera/VCameraGroup.h"
|
||||
#include "Verve/Extension/Camera/VCameraShakeEvent.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VCameraShakeEvent );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VCameraShakeEvent::VCameraShakeEvent( void ) :
|
||||
mAmplitude( Point3F::Zero ),
|
||||
mFalloff( 10.f ),
|
||||
mFrequency( Point3F::Zero )
|
||||
{
|
||||
// Clear Label.
|
||||
setLabel( "CameraShakeEvent" );
|
||||
}
|
||||
|
||||
void VCameraShakeEvent::initPersistFields( void )
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField( "Amplitude", TypePoint3F, Offset( mAmplitude, VCameraShakeEvent ), "Amplitude of the Camera Shake event." );
|
||||
addField( "Falloff", TypeF32, Offset( mFalloff, VCameraShakeEvent ), "Falloff of the Camera Shake event." );
|
||||
addField( "Frequency", TypePoint3F, Offset( mFrequency, VCameraShakeEvent ), "Frequency of the Camera Shake event." );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraShakeEvent::onTrigger( pTime, pDelta );
|
||||
//
|
||||
// Start shaking the camera. Also account for any offet in playtime, and
|
||||
// timescale.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VCameraShakeEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
|
||||
{
|
||||
Parent::onTrigger( pTime, pDelta );
|
||||
|
||||
// Fetch Group.
|
||||
VCameraGroup *group;
|
||||
if ( !getGroup( group ) || !group->isActive() )
|
||||
{
|
||||
// Inactive.
|
||||
return;
|
||||
}
|
||||
|
||||
// Duration.
|
||||
//const F32 duration = ( mDuration - mAbs( pTime - getStartTime() ) ) / ( 1000.f * mFabs( getControllerTimeScale() ) );
|
||||
const F32 duration = ( mDuration - mAbs( pTime - getStartTime() ) ) / 1000.f;
|
||||
|
||||
// Shake Camera.
|
||||
VTorque::startCameraShake( duration, mFalloff, mAmplitude, mFrequency );
|
||||
}
|
||||
59
Engine/modules/Verve/Extension/Camera/VCameraShakeEvent.h
Normal file
59
Engine/modules/Verve/Extension/Camera/VCameraShakeEvent.h
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Verve
|
||||
// Copyright (C) 2014 - Violent Tulip
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef _VT_VCAMERASHAKEEVENT_H_
|
||||
#define _VT_VCAMERASHAKEEVENT_H_
|
||||
|
||||
#ifndef _VT_VEVENT_H_
|
||||
#include "Verve/Core/VEvent.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VCameraShakeEvent : public VEvent
|
||||
{
|
||||
typedef VEvent Parent;
|
||||
|
||||
public:
|
||||
|
||||
VectorF mAmplitude;
|
||||
F32 mFalloff;
|
||||
VectorF mFrequency;
|
||||
|
||||
public:
|
||||
|
||||
VCameraShakeEvent( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
// Event Methods.
|
||||
|
||||
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VCameraShakeEvent );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VCAMERASHAKEEVENT_H_
|
||||
114
Engine/modules/Verve/Extension/Camera/VCameraShakeTrack.cpp
Normal file
114
Engine/modules/Verve/Extension/Camera/VCameraShakeTrack.cpp
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Verve
|
||||
// Copyright (C) 2014 - Violent Tulip
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "Verve/Extension/Camera/VCameraShakeTrack.h"
|
||||
#include "Verve/Extension/Camera/VCameraShakeEvent.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VCameraShakeTrack );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VCameraShakeTrack::VCameraShakeTrack( void )
|
||||
{
|
||||
setLabel( "CameraShakeTrack" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Camera Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraShakeTrack::onCameraEvent( pEvent );
|
||||
//
|
||||
// When the Camera changes, this method is called on both the outgoing and
|
||||
// incoming Camera Groups.
|
||||
//
|
||||
// For a full list of possible events, see the 'eCameraEventType' declaration
|
||||
// in VCameraGroup.h.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VCameraShakeTrack::onCameraEvent( const VCameraGroup::eCameraEventType &pEvent )
|
||||
{
|
||||
// Parent Call.
|
||||
if ( !Parent::onCameraEvent( pEvent ) )
|
||||
{
|
||||
// Skip.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enabled?
|
||||
if ( !isEnabled() )
|
||||
{
|
||||
// Continue Processing Events.
|
||||
return true;
|
||||
}
|
||||
|
||||
switch( pEvent )
|
||||
{
|
||||
case VCameraGroup::k_EventActivate :
|
||||
{
|
||||
|
||||
VCameraShakeEvent *event;
|
||||
if ( getCurrentEvent( event ) )
|
||||
{
|
||||
// Re-Trigger Event.
|
||||
event->onTrigger( getControllerTime(), 0 );
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
case VCameraGroup::k_EventDeactivate :
|
||||
{
|
||||
|
||||
// Stop Camera Shake.
|
||||
VTorque::stopCameraShake();
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Controller Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraShakeTrack::onControllerReset( pTime, pForward );
|
||||
//
|
||||
// Stop all camera shake events.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VCameraShakeTrack::onControllerReset( const S32 &pTime, const bool &pForward )
|
||||
{
|
||||
// Default Reset.
|
||||
Parent::onControllerReset( pTime, pForward );
|
||||
|
||||
// Stop Camera Shake.
|
||||
VTorque::stopCameraShake();
|
||||
}
|
||||
55
Engine/modules/Verve/Extension/Camera/VCameraShakeTrack.h
Normal file
55
Engine/modules/Verve/Extension/Camera/VCameraShakeTrack.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Verve
|
||||
// Copyright (C) 2014 - Violent Tulip
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef _VT_VCAMERASHAKETRACK_H_
|
||||
#define _VT_VCAMERASHAKETRACK_H_
|
||||
|
||||
#ifndef _VT_VCAMERATRACK_H_
|
||||
#include "Verve/Extension/Camera/VCameraTrack.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VCameraShakeTrack : public VCameraTrack
|
||||
{
|
||||
typedef VCameraTrack Parent;
|
||||
|
||||
public:
|
||||
|
||||
VCameraShakeTrack( void );
|
||||
|
||||
// Camera Methods.
|
||||
|
||||
bool onCameraEvent( const VCameraGroup::eCameraEventType &pEvent );
|
||||
|
||||
// Controller Methods.
|
||||
|
||||
void onControllerReset( const S32 &pTime, const bool &pForward );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VCameraShakeTrack );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VCAMERASHAKETRACK_H_
|
||||
108
Engine/modules/Verve/Extension/Camera/VCameraTrack.cpp
Normal file
108
Engine/modules/Verve/Extension/Camera/VCameraTrack.cpp
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Verve
|
||||
// Copyright (C) 2014 - Violent Tulip
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "Verve/Extension/Camera/VCameraTrack.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CONOBJECT( VCameraTrack );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VCameraTrack::VCameraTrack( void )
|
||||
{
|
||||
setLabel( "CameraTrack" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Tree Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraTrack::onAttach();
|
||||
//
|
||||
// This callback subscribes this object to the Camera Group's event signal.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VCameraTrack::onAttach( void )
|
||||
{
|
||||
Parent::onAttach();
|
||||
|
||||
// Valid Controller & Group?
|
||||
VCameraGroup *group;
|
||||
if ( getController() && getGroup( group ) )
|
||||
{
|
||||
// Add Event Notification.
|
||||
group->getCameraEventSignal().notify( this, &VCameraTrack::onCameraEvent );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraTrack::onAttach();
|
||||
//
|
||||
// This callback removes this object from the Camera Group's event signal
|
||||
// notification list.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VCameraTrack::onDetach( void )
|
||||
{
|
||||
// Valid Controller & Group?
|
||||
VCameraGroup *group;
|
||||
if ( getController() && getGroup( group ) )
|
||||
{
|
||||
// Clear Event Notification.
|
||||
group->getCameraEventSignal().remove( this, &VCameraTrack::onCameraEvent );
|
||||
}
|
||||
|
||||
Parent::onDetach();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Camera Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VCameraTrack::onCameraEvent( pEvent );
|
||||
//
|
||||
// When the Camera changes, this method is called on both the outgoing and
|
||||
// incomming Camera Groups.
|
||||
//
|
||||
// For a full list of possible events, see the 'eCameraEventType' declaration
|
||||
// in VCameraGroup.h.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VCameraTrack::onCameraEvent( const VCameraGroup::eCameraEventType &pEvent )
|
||||
{
|
||||
if ( !getController() )
|
||||
{
|
||||
AssertFatal( false, "VCameraTrack::onControllerEvent() - Invalid Controller." );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ok.
|
||||
return true;
|
||||
}
|
||||
60
Engine/modules/Verve/Extension/Camera/VCameraTrack.h
Normal file
60
Engine/modules/Verve/Extension/Camera/VCameraTrack.h
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Verve
|
||||
// Copyright (C) 2014 - Violent Tulip
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef _VT_VCAMERATRACK_H_
|
||||
#define _VT_VCAMERATRACK_H_
|
||||
|
||||
#ifndef _VT_VSCENEOBJECTTRACK_H_
|
||||
#include "Verve/Extension/SceneObject/VSceneObjectTrack.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VCAMERAGROUP_H_
|
||||
#include "Verve/Extension/Camera/VCameraGroup.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VCameraTrack : public VSceneObjectTrack
|
||||
{
|
||||
typedef VSceneObjectTrack Parent;
|
||||
|
||||
public:
|
||||
|
||||
VCameraTrack( void );
|
||||
|
||||
// Tree Methods.
|
||||
|
||||
void onAttach( void );
|
||||
void onDetach( void );
|
||||
|
||||
// Camera Methods.
|
||||
|
||||
virtual bool onCameraEvent( const VCameraGroup::eCameraEventType &pEvent );
|
||||
|
||||
// Console Declaration.
|
||||
|
||||
DECLARE_CONOBJECT( VCameraTrack );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VCAMERATRACK_H_
|
||||
Loading…
Add table
Add a link
Reference in a new issue