(Mostly) updated verve implementation.

This commit is contained in:
Areloch 2019-03-07 16:23:41 -06:00
parent 775ca57047
commit 87ee749801
538 changed files with 68727 additions and 49 deletions

View file

@ -0,0 +1,154 @@
//-----------------------------------------------------------------------------
// 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/Animation/VShapeAnimationEvent.h"
#include "Verve/Extension/Animation/VShapeAnimationTrack.h"
#include "console/consoleTypes.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VShapeAnimationEvent );
//-----------------------------------------------------------------------------
VShapeAnimationEvent::VShapeAnimationEvent( void ) :
mAnimationData( String::EmptyString ),
mAutoDuration( true )
{
setLabel( "AnimationEvent" );
}
//-----------------------------------------------------------------------------
void VShapeAnimationEvent::initPersistFields( void )
{
Parent::initPersistFields();
addField( "AnimationData", TypeRealString, Offset( mAnimationData, VShapeAnimationEvent ), "The name of the Animation Sequence to play upon triggering." );
addField( "AutoDuration", TypeBool, Offset( mAutoDuration, VShapeAnimationEvent ), "Force the Event's Duration to match the length of the Animation." );
}
//-----------------------------------------------------------------------------
//
// Callback Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VShapeAnimationEvent::onTrigger( pTime, pDelta );
//
// Play the desired animation. Also account for any offet in playtime, and
// timescale.
//
//-----------------------------------------------------------------------------
void VShapeAnimationEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
{
Parent::onTrigger( pTime, pDelta );
VTorque::SceneObjectType *object = getSceneObject();
VShapeAnimationTrack *track;
if ( !object || !getTrack( track ) )
{
// Sanity!
return;
}
// Play Animation.
VTorque::playAnimation( object, track->getThreadIndex(), mAnimationData );
// Set Position.
VTorque::setAnimationPosition( object, track->getThreadIndex(), getAnimationPosition( pTime + pDelta ) );
// Set Time Scale.
VTorque::setAnimationTimeScale( object, track->getThreadIndex(), ( ( pDelta > 0 ) ? 1.f : -1.f ) );
}
//-----------------------------------------------------------------------------
//
// VShapeAnimationEvent::onComplete( pTime, pDelta );
//
// If the animation is cyclic, then it needs to be paused once the event has
// finished playing.
//
//-----------------------------------------------------------------------------
void VShapeAnimationEvent::onComplete( const S32 &pTime, const S32 &pDelta )
{
// Fetch Object.
VTorque::SceneObjectType *object = getSceneObject();
VShapeAnimationTrack *track;
if ( object && VTorque::isAnimationLooping( object, mAnimationData ) && getTrack( track ) )
{
// Pause Animation.
VTorque::pauseAnimation( object, track->getThreadIndex() );
}
}
//-----------------------------------------------------------------------------
//
// Property Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VShapeAnimationEvent::getAnimationPosition( pTime );
//
// Returns the time that the animation should be positioned at, at the given
// time. This method considers whether the animation is cyclic or not and will
// return the appropriate time regardless. Time is expressed in seconds and not
// milliseconds.
//
//-----------------------------------------------------------------------------
F32 VShapeAnimationEvent::getAnimationPosition( const S32 &pTime )
{
// Fetch Object.
VSceneObjectTrack *track;
VTorque::SceneObjectType *object = getSceneObject();
if ( !getTrack( track ) || !object )
{
// Null.
return 0.f;
}
// Fetch Interp.
F32 interp = track->calculateInterp( pTime );
if ( !isControllerPlayingForward() )
{
// Flip.
interp = ( 1.f - interp );
}
// Not Looping?
if ( !VTorque::isAnimationLooping( object, mAnimationData ) )
{
// Return Interp.
return interp;
}
// Fetch Sequence Duration.
const S32 duration = ( S32 )( 1000 * VTorque::getAnimationDuration( object, mAnimationData ) );
// Fetch Loop Interp.
const S32 loopInterp = S32( mDuration * interp ) % duration;
return ( F32 )loopInterp / ( F32 )duration;
}

View file

@ -0,0 +1,69 @@
//-----------------------------------------------------------------------------
// 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_VSHAPEANIMATIONEVENT_H_
#define _VT_VSHAPEANIMATIONEVENT_H_
#ifndef _VT_VSCENEOBJECTEVENT_H_
#include "Verve/Extension/SceneObject/VSceneObjectEvent.h"
#endif
#ifndef _VT_TORQUE_ANIMATION_H_
#include "Verve/Torque/TAnimation.h"
#endif
//-----------------------------------------------------------------------------
class VShapeAnimationEvent : public VSceneObjectEvent
{
typedef VSceneObjectEvent Parent;
public:
bool mAutoDuration;
String mAnimationData;
public:
VShapeAnimationEvent( void );
static void initPersistFields( void );
// Callback Methods.
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
virtual void onComplete( const S32 &pTime, const S32 &pDelta );
// Console Declaration.
DECLARE_CONOBJECT( VShapeAnimationEvent );
public:
// Property Methods.
F32 getAnimationPosition( const S32 &pTime );
};
//-----------------------------------------------------------------------------
#endif // _VT_VSHAPEANIMATIONEVENT_H_

View file

@ -0,0 +1,185 @@
//-----------------------------------------------------------------------------
// 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/Animation/VShapeAnimationTrack.h"
#include "Verve/Extension/Animation/VShapeAnimationEvent.h"
#include "Verve/Core/VGroup.h"
#include "console/consoleTypes.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VShapeAnimationTrack );
//-----------------------------------------------------------------------------
VShapeAnimationTrack::VShapeAnimationTrack( void ) :
mThreadIndex( 0 )
{
setLabel( "AnimationTrack" );
}
//-----------------------------------------------------------------------------
void VShapeAnimationTrack::initPersistFields( void )
{
Parent::initPersistFields();
addField( "ThreadIndex", TypeS32, Offset( mThreadIndex, VShapeAnimationTrack ), "The index of the Animation Thread to play." );
}
//-----------------------------------------------------------------------------
//
// Controller Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VShapeAnimationTrack::onControllerEvent( pEvent );
//
// When the controller's state changes, this method is called. If the
// controller is paused, or stops playing, then the animation will cease to
// play. If the controller resumes play, the animation will continue.
//
// For a full list of possible events, see the 'eControllerEventType'
// declaration in VController.h.
//
//-----------------------------------------------------------------------------
bool VShapeAnimationTrack::onControllerEvent( VController::eControllerEventType pEvent )
{
if ( !Parent::onControllerEvent( pEvent ) )
{
// Skip.
return false;
}
// Enabled?
if ( !isEnabled() )
{
// Continue Processing Events.
return true;
}
switch ( pEvent )
{
case VController::k_EventPlay :
{
// Play Animation.
VTorque::setAnimationTimeScale( getSceneObject(), mThreadIndex, ( ( isControllerPlayingForward() ) ? 1.f : -1.f ) );
} break;
case VController::k_EventPause :
case VController::k_EventStop :
{
// Stop Animation.
VTorque::setAnimationTimeScale( getSceneObject(), mThreadIndex, 0.f );
} break;
}
return true;
}
//-----------------------------------------------------------------------------
//
// VShapeAnimationTrack::onControllerReset( pTime, pForward );
//
// Reset the animation state of the target object. If there is a Next Event,
// then the animation is positioned accordingly.
//
//-----------------------------------------------------------------------------
void VShapeAnimationTrack::onControllerReset( const S32 &pTime, const bool &pForward )
{
VTorque::SceneObjectType *object = getSceneObject();
if ( !object )
{
// Parent Call.
Parent::onControllerReset( pTime, pForward );
return;
}
VShapeAnimationEvent *event;
if ( getCurrentEvent( event ) )
{
// Stop Animation.
VTorque::stopAnimation( object, mThreadIndex );
}
// Parent Call.
Parent::onControllerReset( pTime, pForward );
if ( getCurrentEvent( event ) )
{
// Play Animation.
VTorque::playAnimation( object, mThreadIndex, event->mAnimationData );
// Set Position.
VTorque::setAnimationPosition( object, mThreadIndex, event->getAnimationPosition( pTime ) );
// Stop Animation.
VTorque::setAnimationTimeScale( object, mThreadIndex, 0.f );
}
}
#ifdef VT_EDITOR
//-----------------------------------------------------------------------------
//
// Debug Methods.
//
//-----------------------------------------------------------------------------
ConsoleMethod( VShapeAnimationTrack, updateTrack, void, 2, 2, "( void ) - Update the Track.\n"
"@return No return value." )
{
for ( ITreeNode *node = object->mChildNode; node != NULL; node = node->mSiblingNextNode )
{
VShapeAnimationEvent *currEvent = ( VShapeAnimationEvent* )node;
VShapeAnimationEvent *nextEvent = ( VShapeAnimationEvent* )node->mSiblingNextNode;
if ( !currEvent->mAutoDuration )
{
// Skip.
continue;
}
if ( VTorque::isAnimationLooping( object->getSceneObject(), currEvent->mAnimationData ) )
{
if ( !nextEvent )
{
// Update Duration.
currEvent->setDuration( object->getControllerDuration() - currEvent->getTriggerTime() );
}
else
{
// Update Duration.
currEvent->setDuration( mAbs( nextEvent->getTriggerTime() - currEvent->getTriggerTime() ) );
}
}
else
{
// Update Duration.
currEvent->setDuration( ( S32 )( 1000 * VTorque::getAnimationDuration( object->getSceneObject(), currEvent->mAnimationData ) ) );
}
}
}
#endif

View file

@ -0,0 +1,64 @@
//-----------------------------------------------------------------------------
// 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_VSHAPEANIMATIONTRACK_H_
#define _VT_VSHAPEANIMATIONTRACK_H_
#ifndef _VT_VSCENEOBJECTTRACK_H_
#include "Verve/Extension/SceneObject/VSceneObjectTrack.h"
#endif
#ifndef _VT_TORQUE_ANIMATION_H_
#include "Verve/Torque/TAnimation.h"
#endif
//-----------------------------------------------------------------------------
class VShapeAnimationTrack : public VSceneObjectTrack
{
typedef VSceneObjectTrack Parent;
U32 mThreadIndex;
public:
VShapeAnimationTrack( void );
static void initPersistFields( void );
// Controller Methods.
virtual bool onControllerEvent( VController::eControllerEventType pEvent );
virtual void onControllerReset( const S32 &pTime, const bool &pForward );
// Console Declaration.
DECLARE_CONOBJECT( VShapeAnimationTrack );
public:
inline U32 &getThreadIndex( void ) { return mThreadIndex; };
};
//-----------------------------------------------------------------------------
#endif // _VT_VSHAPEANIMATIONTRACK_H_

View 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 );
}

View 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_

View 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 );
}

View 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_

View 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();
}

View 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_

View 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;
}

View 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_

View file

@ -0,0 +1,75 @@
//-----------------------------------------------------------------------------
// 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/Director/VDirectorEvent.h"
#include "console/consoleTypes.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VDirectorEvent );
//-----------------------------------------------------------------------------
VDirectorEvent::VDirectorEvent( void ) :
mTarget( String::EmptyString )
{
// Void.
}
void VDirectorEvent::initPersistFields( void )
{
Parent::initPersistFields();
addField( "Target", TypeRealString, Offset( mTarget, VDirectorEvent ), "The name of the CameraGroup that will be activated upon triggering." );
}
//-----------------------------------------------------------------------------
//
// Controller Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VDirectorEvent::onTrigger( pTime, pDelta );
//
// Cut the camera to the target group.
//
//-----------------------------------------------------------------------------
void VDirectorEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
{
Parent::onTrigger( pTime, pDelta );
// Fetch Controller.
VController *controller = getController();
// Valid Target?
VCameraGroup *targetGroup = NULL;
if ( !controller->getObject( mTarget, targetGroup ) )
{
Con::warnf( "VDirectorEvent::onTrigger() - Invalid Target Group specified." );
return;
}
// Change Camera.
targetGroup->setActive();
}

View file

@ -0,0 +1,61 @@
//-----------------------------------------------------------------------------
// 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_VDIRECTOREVENT_H_
#define _VT_VDIRECTOREVENT_H_
#ifndef _VT_VEVENT_H_
#include "Verve/Core/VEvent.h"
#endif
#ifndef _VT_VCAMERAGROUP_H_
#include "Verve/Extension/Camera/VCameraGroup.h"
#endif
//-----------------------------------------------------------------------------
class VDirectorEvent : public VEvent
{
typedef VEvent Parent;
public:
String mTarget;
public:
VDirectorEvent( void );
static void initPersistFields( void );
// Event Methods.
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
// Console Declaration.
DECLARE_CONOBJECT( VDirectorEvent );
};
//-----------------------------------------------------------------------------
#endif // _VT_VDIRECTOREVENT_H_

View file

@ -0,0 +1,57 @@
//-----------------------------------------------------------------------------
// 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/Director/VDirectorGroup.h"
#include "Verve/Extension/Director/VDirectorTrack.h"
#include "Verve/Extension/Camera/VCameraGroup.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VDirectorGroup );
//-----------------------------------------------------------------------------
VDirectorGroup::VDirectorGroup( void ) :
mActiveCamera( NULL )
{
setLabel( "DirectorGroup" );
};
//-----------------------------------------------------------------------------
//
// VDirectorGroup::getDirectorTrack();
//
// Returns the DirectorTrack reference.
//
//-----------------------------------------------------------------------------
VDirectorTrack *VDirectorGroup::getDirectorTrack( void )
{
for ( ITreeNode *node = mChildNode; node != NULL; node = node->mSiblingNextNode )
{
if ( VDirectorTrack *track = dynamic_cast<VDirectorTrack*>( node ) )
{
// Return Track.
return track;
}
}
// Invalid Track.
return NULL;
}

View 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_VDIRECTORGROUP_H_
#define _VT_VDIRECTORGROUP_H_
#ifndef _VT_VGROUP_H_
#include "Verve/Core/VGroup.h"
#endif
//-----------------------------------------------------------------------------
class VDirectorTrack;
class VCameraGroup;
//-----------------------------------------------------------------------------
class VDirectorGroup : public VGroup
{
typedef VGroup Parent;
protected:
// Camera.
VCameraGroup *mActiveCamera;
public:
VDirectorGroup( void );
VDirectorTrack *getDirectorTrack( void );
// Console Declaration.
DECLARE_CONOBJECT( VDirectorGroup );
};
//-----------------------------------------------------------------------------
#endif // _VT_VDIRECTORGROUP_H_

View file

@ -0,0 +1,63 @@
//-----------------------------------------------------------------------------
// 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/Director/VDirectorTrack.h"
#include "math/mMathFn.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VDirectorTrack );
//-----------------------------------------------------------------------------
VDirectorTrack::VDirectorTrack( void )
{
setLabel( "DirectorTrack" );
}
#ifdef VT_EDITOR
//-----------------------------------------------------------------------------
//
// Debug Methods.
//
//-----------------------------------------------------------------------------
ConsoleMethod( VDirectorTrack, updateTrack, void, 2, 2, "( void ) - Update the Track.\n"
"@return No return value." )
{
for ( ITreeNode *node = object->mChildNode; node != NULL; node = node->mSiblingNextNode )
{
VEvent *currEvent = ( VEvent* )node;
VEvent *nextEvent = ( VEvent* )node->mSiblingNextNode;
if ( !nextEvent )
{
// Update Duration.
currEvent->setDuration( object->getControllerDuration() - currEvent->getTriggerTime() );
}
else
{
// Update Duration.
currEvent->setDuration( mAbs( nextEvent->getTriggerTime() - currEvent->getTriggerTime() ) );
}
}
}
#endif

View file

@ -0,0 +1,47 @@
//-----------------------------------------------------------------------------
// 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_VDIRECTORTRACK_H_
#define _VT_VDIRECTORTRACK_H_
#ifndef _VT_VTRACK_H_
#include "Verve/Core/VTrack.h"
#endif
//-----------------------------------------------------------------------------
class VDirectorTrack : public VTrack
{
typedef VTrack Parent;
public:
VDirectorTrack( void );
// Console Declaration.
DECLARE_CONOBJECT( VDirectorTrack );
};
//-----------------------------------------------------------------------------
#endif // _VT_VDIRECTORTRACK_H_

View file

@ -0,0 +1,82 @@
//-----------------------------------------------------------------------------
// 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/VController.h"
#include "Verve/Extension/Director/VSceneJumpEvent.h"
#include "Verve/Extension/Director/VDirectorGroup.h"
#include "Verve/Extension/Director/VDirectorTrack.h"
#include "Verve/Extension/Director/VDirectorEvent.h"
#include "console/consoleTypes.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VSceneJumpEvent );
//-----------------------------------------------------------------------------
VSceneJumpEvent::VSceneJumpEvent( void ) :
mTarget( String::EmptyString )
{
setLabel( "SceneJumpEvent" );
}
void VSceneJumpEvent::initPersistFields( void )
{
Parent::initPersistFields();
addField( "Target", TypeRealString, Offset( mTarget, VSceneJumpEvent ), "The name of the Scene that the controller will jump to upon triggering." );
}
//-----------------------------------------------------------------------------
//
// Controller Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VSceneJumpEvent::onTrigger( pTime, pDelta );
//
// Tell the controller to jump to a new scene.
//
//-----------------------------------------------------------------------------
void VSceneJumpEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
{
Parent::onTrigger( pTime, pDelta );
VDirectorTrack *track = getController()->getDirectorTrack();
if ( !track )
{
// Invalid Track.
return;
}
// Get Event.
VDirectorEvent *event;
if ( !track->getObject( mTarget, event ) )
{
// Can't Jump.
return;
}
// Go To Scene.
getController()->jump( VController::k_JumpTime, event->getTriggerTime() );
}

View file

@ -0,0 +1,57 @@
//-----------------------------------------------------------------------------
// 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_VSCENEJUMPEVENT_H_
#define _VT_VSCENEJUMPEVENT_H_
#ifndef _VT_VEVENT_H_
#include "Verve/Core/VEvent.h"
#endif
//-----------------------------------------------------------------------------
class VSceneJumpEvent : public VEvent
{
typedef VEvent Parent;
public:
String mTarget;
public:
VSceneJumpEvent( void );
static void initPersistFields( void );
// Event Methods.
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
// Console Declaration.
DECLARE_CONOBJECT( VSceneJumpEvent );
};
//-----------------------------------------------------------------------------
#endif // _VT_VSCENEJUMPEVENT_H_

View file

@ -0,0 +1,32 @@
//-----------------------------------------------------------------------------
// 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/Director/VSceneJumpTrack.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VSceneJumpTrack );
//-----------------------------------------------------------------------------
VSceneJumpTrack::VSceneJumpTrack( void )
{
setLabel( "SceneJumpTrack" );
}

View file

@ -0,0 +1,47 @@
//-----------------------------------------------------------------------------
// 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_VSCENEJUMPTRACK_H_
#define _VT_VSCENEJUMPTRACK_H_
#ifndef _VT_VTRACK_H_
#include "Verve/Core/VTrack.h"
#endif
//-----------------------------------------------------------------------------
class VSceneJumpTrack : public VTrack
{
typedef VTrack Parent;
public:
VSceneJumpTrack( void );
// Console Declaration.
DECLARE_CONOBJECT( VSceneJumpTrack );
};
//-----------------------------------------------------------------------------
#endif // _VT_VSCENEJUMPTRACK_H_

View file

@ -0,0 +1,130 @@
//-----------------------------------------------------------------------------
// 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/VController.h"
#include "Verve/Extension/Director/VSlowMoEvent.h"
#include "console/consoleTypes.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VSlowMoEvent );
//-----------------------------------------------------------------------------
VSlowMoEvent::VSlowMoEvent( void ) :
mTimeScale( 1.f ),
mTimeScaleTickDelta( 0.f )
{
setLabel( "SlowMoEvent" );
}
void VSlowMoEvent::initPersistFields( void )
{
Parent::initPersistFields();
addField( "TimeScale", TypeF32, Offset( mTimeScale, VSlowMoEvent ), "The Time Scale to be applied to the Root Controller." );
}
//-----------------------------------------------------------------------------
//
// Controller Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VSlowMoEvent::onTrigger( pTime, pDelta );
//
//
//
//-----------------------------------------------------------------------------
void VSlowMoEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
{
Parent::onTrigger( pTime, pDelta );
VController *controller = getController();
if ( !controller )
{
// Invalid Controller.
return;
}
// Instant Update?
if ( getDuration() == 0 )
{
// Apply & Return.
controller->setTimeScale( mTimeScale );
return;
}
// Determine the Number of Ticks.
const F32 tickCount = ( ( F32 )getDuration() ) / TickMs;
// Determine the Tick Delta.
mTimeScaleTickDelta = ( mTimeScale - controller->getTimeScale() ) / tickCount;
}
//-----------------------------------------------------------------------------
//
// VSlowMoEvent::onUpdate( pTime, pDelta );
//
//
//
//-----------------------------------------------------------------------------
void VSlowMoEvent::onUpdate( const S32 &pTime, const S32 &pDelta )
{
Parent::onUpdate( pTime, pDelta );
VController *controller = getController();
if ( !controller )
{
// Invalid Controller.
return;
}
// Fetch Current Time Scale.
const F32 timeScale = controller->getTimeScale();
// Apply Update.
controller->setTimeScale( timeScale + mTimeScaleTickDelta );
}
//-----------------------------------------------------------------------------
//
// VSlowMoEvent::onComplete( pTime, pDelta );
//
//
//
//-----------------------------------------------------------------------------
void VSlowMoEvent::onComplete( const S32 &pTime, const S32 &pDelta )
{
Parent::onComplete( pTime, pDelta );
VController *controller = getController();
if ( !controller )
{
// Invalid Controller.
return;
}
// Tidy Up.
controller->setTimeScale( mTimeScale );
}

View 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_VSLOWMOEVENT_H_
#define _VT_VSLOWMOEVENT_H_
#ifndef _VT_VEVENT_H_
#include "Verve/Core/VEvent.h"
#endif
//-----------------------------------------------------------------------------
class VSlowMoEvent : public VEvent
{
typedef VEvent Parent;
public:
F32 mTimeScale;
F32 mTimeScaleTickDelta;
public:
VSlowMoEvent( void );
static void initPersistFields( void );
// Event Methods.
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
virtual void onUpdate( const S32 &pTime, const S32 &pDelta );
virtual void onComplete( const S32 &pTime, const S32 &pDelta );
// Console Declaration.
DECLARE_CONOBJECT( VSlowMoEvent );
};
//-----------------------------------------------------------------------------
#endif // _VT_VSLOWMOEVENT_H_

View file

@ -0,0 +1,93 @@
//-----------------------------------------------------------------------------
// 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/Director/VSlowMoTrack.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VSlowMoTrack );
//-----------------------------------------------------------------------------
VSlowMoTrack::VSlowMoTrack( void )
{
setLabel( "SlowMoTrack" );
}
//-----------------------------------------------------------------------------
//
// Controller Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VSlowMoTrack::onControllerEvent( pEvent );
//
// ...
//
// For a full list of possible events, see the 'eControllerEventType'
// declaration in VController.h.
//
//-----------------------------------------------------------------------------
bool VSlowMoTrack::onControllerEvent( VController::eControllerEventType pEvent )
{
if ( !Parent::onControllerEvent( pEvent ) )
{
// Skip.
return false;
}
// Enabled?
if ( !isEnabled() )
{
// Continue Processing Events.
return true;
}
switch ( pEvent )
{
case VController::k_EventStop :
{
// Reset Time Scale.
getController()->setTimeScale( ( isControllerPlayingForward() ) ? 1.f : -1.f );
} break;
}
return true;
}
//-----------------------------------------------------------------------------
//
// VSlowMoTrack::onControllerReset( pTime, pForward );
//
// ...
//
//-----------------------------------------------------------------------------
void VSlowMoTrack::onControllerReset( const S32 &pTime, const bool &pForward )
{
// Parent Reset.
Parent::onControllerReset( pTime, pForward );
// Reset Time Scale.
getController()->setTimeScale( ( pForward ) ? 1.f : -1.f );
}

View file

@ -0,0 +1,52 @@
//-----------------------------------------------------------------------------
// 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_VSLOWMOTRACK_H_
#define _VT_VSLOWMOTRACK_H_
#ifndef _VT_VTRACK_H_
#include "Verve/Core/VTrack.h"
#endif
//-----------------------------------------------------------------------------
class VSlowMoTrack : public VTrack
{
typedef VTrack Parent;
public:
VSlowMoTrack( void );
// Controller Methods.
bool onControllerEvent( VController::eControllerEventType pEvent );
void onControllerReset( const S32 &pTime, const bool &pForward );
// Console Declaration.
DECLARE_CONOBJECT( VSlowMoTrack );
};
//-----------------------------------------------------------------------------
#endif // _VT_VSLOWMOTRACK_H_

View file

@ -0,0 +1,111 @@
//-----------------------------------------------------------------------------
// 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/GUI/VFadeEvent.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VFadeEvent );
//-----------------------------------------------------------------------------
VFadeEvent::VFadeEvent( void )
{
setLabel( "FadeEvent" );
}
//-----------------------------------------------------------------------------
//
// Callback Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VFadeEvent::onTrigger( pTime, pDelta );
//
// Start the fade sequence if a valid fade control can be found.
//
//-----------------------------------------------------------------------------
void VFadeEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
{
Parent::onTrigger( pTime, pDelta );
// Fetch GUI Control.
VFadeControl *fadeControl;
if ( !Sim::findObject( "VFadeControlGUI", fadeControl ) )
{
// Invalid.
return;
}
// Start Fade.
fadeControl->start( getFadeType(), mDuration );
// Set Elapsed Time.
fadeControl->mElapsedTime = mAbs( pTime - getStartTime() );
}
//-----------------------------------------------------------------------------
//
// VFadeEvent::onComplete( pTime, pDelta );
//
// Tidy up the fade control once the event has finished.
//
//-----------------------------------------------------------------------------
void VFadeEvent::onComplete( const S32 &pTime, const S32 &pDelta )
{
Parent::onTrigger( pTime, pDelta );
// Fetch GUI Control.
VFadeControl *fadeControl;
if ( !Sim::findObject( "VFadeControlGUI", fadeControl ) )
{
// Invalid.
return;
}
// Set Elapsed Time.
fadeControl->mElapsedTime = mDuration;
}
//-----------------------------------------------------------------------------
//
// Property Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VFadeEvent::getFadeType();
//
// Returns the type of fade (in or out) that this event will use. Zero and Even
// indices will Fade Out, while Odd numbers will Fade In.
//
//-----------------------------------------------------------------------------
VFadeControl::eFadeType VFadeEvent::getFadeType( void )
{
if ( !isControllerPlayingForward() )
{
return ( getIndex() % 2 == 0 ) ? VFadeControl::k_TypeOut : VFadeControl::k_TypeIn;
}
return ( getIndex() % 2 == 0 ) ? VFadeControl::k_TypeIn : VFadeControl::k_TypeOut;
}

View 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_VFADEEVENT_H_
#define _VT_VFADEEVENT_H_
#ifndef _VT_VEVENT_H_
#include "Verve/Core/VEvent.h"
#endif
#ifndef _VT_VFADECONTROL_H_
#include "Verve/GUI/VFadeControl.h"
#endif
//-----------------------------------------------------------------------------
class VFadeEvent : public VEvent
{
typedef VEvent Parent;
public:
VFadeEvent( void );
// Callback Methods.
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
virtual void onComplete( const S32 &pTime, const S32 &pDelta );
// Console Declaration.
DECLARE_CONOBJECT( VFadeEvent );
public:
VFadeControl::eFadeType getFadeType( void );
};
//-----------------------------------------------------------------------------
#endif // _VT_VFADEEVENT_H_

View file

@ -0,0 +1,139 @@
//-----------------------------------------------------------------------------
// 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/GUI/VFadeTrack.h"
#include "Verve/Extension/GUI/VFadeEvent.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VFadeTrack );
//-----------------------------------------------------------------------------
VFadeTrack::VFadeTrack( void )
{
setLabel( "FadeTrack" );
}
//-----------------------------------------------------------------------------
//
// Controller Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VFadeTrack::onControllerEvent( pEvent );
//
// When the controller's state changes, this method is called. If the
// controller is paused, or stops playing, then the fade control will cease
// playing. If the controller resumes play, the fade control will continue.
//
// For a full list of possible events, see the 'eControllerEventType'
// declaration in VController.h.
//
//-----------------------------------------------------------------------------
bool VFadeTrack::onControllerEvent( VController::eControllerEventType pEvent )
{
if ( !Parent::onControllerEvent( pEvent ) )
{
// Skip.
return false;
}
// Enabled?
if ( !isEnabled() )
{
// Continue Processing Events.
return true;
}
// Fetch the next Event.
VFadeEvent *event;
if ( !getNextEvent( event ) )
{
// No Event.
return true;
}
// Fetch GUI Control.
VFadeControl *fadeControl = dynamic_cast<VFadeControl*>( Sim::findObject( "VFadeControlGui" ) );
if ( !fadeControl )
{
// No Control.
return true;
}
switch ( pEvent )
{
case VController::k_EventPlay:
{
// Play?
const S32 &time = getControllerTime();
fadeControl->mActive = ( time > event->getTriggerTime()
&& time < event->getFinishTime() ) ;
} break;
case VController::k_EventPause :
case VController::k_EventStop :
{
// Pause.
fadeControl->mActive = false;
} break;
}
return true;
}
//-----------------------------------------------------------------------------
//
// VFadeTrack::onControllerReset( pTime, pForward );
//
// Reset the fade state of the fade control.
//
//-----------------------------------------------------------------------------
void VFadeTrack::onControllerReset( const S32 &pTime, const bool &pForward )
{
Parent::onControllerReset( pTime, pForward );
// Fetch GUI Control.
VFadeControl *fadeControl;
if ( !Sim::findObject( "VFadeControlGUI", fadeControl ) )
{
// Invalid.
return;
}
VFadeEvent *event;
if ( !getNextEvent( event ) )
{
// No Events.
return;
}
// Apply Settings.
fadeControl->mActive = false;
fadeControl->mFadeType = event->getFadeType();
fadeControl->mDuration = event->getDuration();
fadeControl->mElapsedTime = getMax( pTime - event->getTriggerTime(), 0 );
}

View file

@ -0,0 +1,52 @@
//-----------------------------------------------------------------------------
// 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_VFADETRACK_H_
#define _VT_VFADETRACK_H_
#ifndef _VT_VTRACK_H_
#include "Verve/Core/VTrack.h"
#endif
//-----------------------------------------------------------------------------
class VFadeTrack : public VTrack
{
typedef VTrack Parent;
public:
VFadeTrack( void );
// Controller Methods.
virtual bool onControllerEvent( VController::eControllerEventType pEvent );
virtual void onControllerReset( const S32 &pTime, const bool &pForward );
// Console Declaration.
DECLARE_CONOBJECT( VFadeTrack );
};
//-----------------------------------------------------------------------------
#endif // _VT_VFADETRACK_H_

View file

@ -0,0 +1,32 @@
//-----------------------------------------------------------------------------
// 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/Game/VSpawnSphereGroup.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VSpawnSphereGroup );
//-----------------------------------------------------------------------------
VSpawnSphereGroup::VSpawnSphereGroup( void )
{
setLabel( "SpawnSphereGroup" );
};

View file

@ -0,0 +1,47 @@
//-----------------------------------------------------------------------------
// 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_VSPAWNSPHEREGROUP_H_
#define _VT_VSPAWNSPHEREGROUP_H_
#ifndef _VT_VSCENEOBJECTGROUP_H_
#include "Verve/Extension/SceneObject/VSceneObjectGroup.h"
#endif
//-----------------------------------------------------------------------------
class VSpawnSphereGroup : public VSceneObjectGroup
{
typedef VSceneObjectGroup Parent;
public:
VSpawnSphereGroup( void );
// Console Declaration.
DECLARE_CONOBJECT( VSpawnSphereGroup );
};
//-----------------------------------------------------------------------------
#endif // _VT_VSPAWNSPHEREGROUP_H_

View file

@ -0,0 +1,68 @@
//-----------------------------------------------------------------------------
// 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/Game/VSpawnSphereSpawnTargetEvent.h"
#include "Verve/Extension/Game/VSpawnSphereSpawnTargetTrack.h"
#include "console/consoleTypes.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VSpawnSphereSpawnTargetEvent );
//-----------------------------------------------------------------------------
VSpawnSphereSpawnTargetEvent::VSpawnSphereSpawnTargetEvent( void )
{
setLabel( "SpawnTargetEvent" );
}
void VSpawnSphereSpawnTargetEvent::initPersistFields( void )
{
Parent::initPersistFields();
}
//-----------------------------------------------------------------------------
//
// Callback Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VSpawnSphereSpawnTargetEvent::onTrigger( pTime, pDelta );
//
// Spawn the Target.
//
//-----------------------------------------------------------------------------
void VSpawnSphereSpawnTargetEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
{
Parent::onTrigger( pTime, pDelta );
// Fetch Track.
VSpawnSphereSpawnTargetTrack *track;
if ( !getTrack( track ) )
{
return;
}
// Spawn the Target.
track->spawnTarget();
}

View file

@ -0,0 +1,56 @@
//-----------------------------------------------------------------------------
// 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_VSPAWNSPHERESPAWNTARGETEVENT_H_
#define _VT_VSPAWNSPHERESPAWNTARGETEVENT_H_
#ifndef _VT_VSCENEOBJECTEVENT_H_
#include "Verve/Extension/SceneObject/VSceneObjectEvent.h"
#endif
#ifndef _VT_TORQUE_SPAWNSPHERE_H_
#include "Verve/Torque/TSpawnSphere.h"
#endif
//-----------------------------------------------------------------------------
class VSpawnSphereSpawnTargetEvent : public VSceneObjectEvent
{
typedef VEvent Parent;
public:
VSpawnSphereSpawnTargetEvent( void );
static void initPersistFields( void );
// Event Methods.
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
// Console Declaration.
DECLARE_CONOBJECT( VSpawnSphereSpawnTargetEvent );
};
//-----------------------------------------------------------------------------
#endif // _VT_VSPAWNSPHERESPAWNTARGETEVENT_H_

View file

@ -0,0 +1,155 @@
//-----------------------------------------------------------------------------
// 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/Game/VSpawnSphereSpawnTargetTrack.h"
#include "Verve/Torque/TSpawnSphere.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VSpawnSphereSpawnTargetTrack );
//-----------------------------------------------------------------------------
VSpawnSphereSpawnTargetTrack::VSpawnSphereSpawnTargetTrack( void )
{
setLabel( "SpawnTargetTrack" );
}
void VSpawnSphereSpawnTargetTrack::initPersistFields( void )
{
// Parent Call.
Parent::initPersistFields();
addField( "DespawnOnLoop", TypeBool, Offset( mDespawnOnLoop, VSpawnSphereSpawnTargetTrack ), "Despawn all targets when the Controller loops?" );
addField( "DespawnOnStop", TypeBool, Offset( mDespawnOnStop, VSpawnSphereSpawnTargetTrack ), "Despawn all targets when the Controller stops playing?" );
}
//-----------------------------------------------------------------------------
//
// Controller Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VSpawnSphereSpawnTargetTrack::onControllerEvent( pEvent );
//
// For a full list of possible events, see the 'eControllerEventType'
// declaration in VController.h.
//
//-----------------------------------------------------------------------------
bool VSpawnSphereSpawnTargetTrack::onControllerEvent( VController::eControllerEventType pEvent )
{
if ( !Parent::onControllerEvent( pEvent ) )
{
// Skip.
return false;
}
// Enabled?
if ( !isEnabled() )
{
// Continue Processing Events.
return true;
}
switch ( pEvent )
{
case VController::k_EventLoop :
{
if ( mDespawnOnLoop )
{
despawnTargets();
}
} break;
case VController::k_EventStop :
{
if ( mDespawnOnStop )
{
despawnTargets();
}
} break;
}
return true;
}
//-----------------------------------------------------------------------------
//
// Spawn Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VSpawnSphereSpawnTargetTrack::spawnTarget( pTime, pForward );
//
// Spawn an Object.
//
//-----------------------------------------------------------------------------
void VSpawnSphereSpawnTargetTrack::spawnTarget( void )
{
VTorque::SpawnSphereType *object;
if ( !getSceneObject( object ) )
{
return;
}
// Spawn the Object.
SimObject *spawnedObject = object->spawnObject();
// Scene Object?
VTorque::SceneObjectType *sceneObject = dynamic_cast<VTorque::SceneObjectType*>( spawnedObject );
if ( sceneObject )
{
sceneObject->setPosition( object->getPosition() );
}
// Valid?
if ( spawnedObject )
{
// Add Reference.
mSpawnList.addObject( spawnedObject );
}
}
//-----------------------------------------------------------------------------
//
// VSpawnSphereSpawnTargetTrack::despawnTargets();
//
// Despawn all of the objects spawned by this track.
//
//-----------------------------------------------------------------------------
void VSpawnSphereSpawnTargetTrack::despawnTargets( void )
{
while( mSpawnList.size() > 0 )
{
// Fetch the Last Object
SimObject *object = mSpawnList.last();
// Remove it.
mSpawnList.popObject();
// Delete the Object.
object->deleteObject();
}
}

View file

@ -0,0 +1,69 @@
//-----------------------------------------------------------------------------
// 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_VSPAWNSPHERESPAWNTARGETTRACK_H_
#define _VT_VSPAWNSPHERESPAWNTARGETTRACK_H_
#ifndef _VT_VSCENEOBJECTTRACK_H_
#include "Verve/Extension/SceneObject/VSceneObjectTrack.h"
#endif
#ifndef _VT_TORQUE_LIGHTOBJECT_H_
#include "Verve/Torque/TLightObject.h"
#endif
//-----------------------------------------------------------------------------
class VSpawnSphereSpawnTargetTrack : public VSceneObjectTrack
{
typedef VSceneObjectTrack Parent;
protected:
SimSet mSpawnList;
bool mDespawnOnStop;
bool mDespawnOnLoop;
public:
VSpawnSphereSpawnTargetTrack( void );
static void initPersistFields( void );
// Controller Methods.
virtual bool onControllerEvent( VController::eControllerEventType pEvent );
// Spawn Methods.
virtual void spawnTarget( void );
virtual void despawnTargets( void );
// Console Declaration.
DECLARE_CONOBJECT( VSpawnSphereSpawnTargetTrack );
};
//-----------------------------------------------------------------------------
#endif // _VT_VSPAWNSPHERESPAWNTARGETTRACK_H_

View file

@ -0,0 +1,92 @@
//-----------------------------------------------------------------------------
// 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/LightObject/VLightObjectAnimationEvent.h"
#include "console/consoleTypes.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VLightObjectAnimationEvent );
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
VLightObjectAnimationEvent::VLightObjectAnimationEvent( void ) :
mAnimationData( NULL )
{
setLabel( "AnimationEvent" );
}
void VLightObjectAnimationEvent::initPersistFields( void )
{
Parent::initPersistFields();
addField( "AnimationData", TYPEID<VTorque::LightAnimationDataType>(), Offset( mAnimationData, VLightObjectAnimationEvent ) );
}
//-----------------------------------------------------------------------------
//
// Callback Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VLightObjectAnimationEvent::onTrigger( pTime, pDelta );
//
// When this Event is triggered the light object will begin to play the target
// animation.
//
//-----------------------------------------------------------------------------
void VLightObjectAnimationEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
{
Parent::onTrigger( pTime, pDelta );
// Fetch the Light Object.
VTorque::LightObjectType *lightObject;
if ( getSceneObject( lightObject ) )
{
// Play the Animation.
VTorque::playAnimation( lightObject, mAnimationData );
}
}
//-----------------------------------------------------------------------------
//
// VLightObjectAnimationEvent::onComplete( pTime, pDelta );
//
// The current animation played by the light object will be paused when this
// Event completes its updates.
//
//-----------------------------------------------------------------------------
void VLightObjectAnimationEvent::onComplete( const S32 &pTime, const S32 &pDelta )
{
Parent::onTrigger( pTime, pDelta );
// Fetch the Light Object.
VTorque::LightObjectType *lightObject;
if ( getSceneObject( lightObject ) )
{
// Pause the Animation.
VTorque::pauseAnimation( lightObject );
}
}

View file

@ -0,0 +1,62 @@
//-----------------------------------------------------------------------------
// 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_VLIGHTOBJECTANIMATIONEVENT_H_
#define _VT_VLIGHTOBJECTANIMATIONEVENT_H_
#ifndef _VT_VSCENEOBJECTEVENT_H_
#include "Verve/Extension/SceneObject/VSceneObjectEvent.h"
#endif
#ifndef _VT_TORQUE_LIGHTOBJECT_H_
#include "Verve/Torque/TLightObject.h"
#endif
//-----------------------------------------------------------------------------
class VLightObjectAnimationEvent : public VSceneObjectEvent
{
typedef VEvent Parent;
public:
SimObjectPtr<VTorque::LightAnimationDataType> mAnimationData;
public:
VLightObjectAnimationEvent( void );
static void initPersistFields( void );
// Event Methods.
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
virtual void onComplete( const S32 &pTime, const S32 &pDelta );
// Console Declaration.
DECLARE_CONOBJECT( VLightObjectAnimationEvent );
};
//-----------------------------------------------------------------------------
#endif // _VT_VLIGHTOBJECTANIMATIONEVENT_H_

View file

@ -0,0 +1,118 @@
//-----------------------------------------------------------------------------
// 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/LightObject/VLightObjectAnimationTrack.h"
#include "Verve/Extension/LightObject/VLightObjectAnimationEvent.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VLightObjectAnimationTrack );
//-----------------------------------------------------------------------------
VLightObjectAnimationTrack::VLightObjectAnimationTrack( void )
{
setLabel( "AnimationTrack" );
}
//-----------------------------------------------------------------------------
//
// Controller Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VLightObjectAnimationTrack::onControllerEvent( pEvent );
//
//
//
//-----------------------------------------------------------------------------
bool VLightObjectAnimationTrack::onControllerEvent( VController::eControllerEventType pEvent )
{
if ( !Parent::onControllerEvent( pEvent ) )
{
// Skip.
return false;
}
// Enabled?
if ( !isEnabled() )
{
// Continue Processing Events.
return true;
}
// Fetch the Light Object.
VTorque::LightObjectType *lightObject;
if ( !getSceneObject( lightObject ) )
{
// Skip.
return true;
}
switch ( pEvent )
{
case VController::k_EventPlay :
{
// Play Animation?
VLightObjectAnimationEvent *event;
if ( getCurrentEvent( event ) )
{
// Play.
VTorque::playAnimation( lightObject );
}
} break;
case VController::k_EventPause :
case VController::k_EventStop :
{
// Stop the Animation.
VTorque::pauseAnimation( lightObject );
} break;
}
return true;
}
//-----------------------------------------------------------------------------
//
// VLightObjectAnimationTrack::onControllerReset( pTime, pForward );
//
//
//
//-----------------------------------------------------------------------------
void VLightObjectAnimationTrack::onControllerReset( const S32 &pTime, const bool &pForward )
{
// Default Reset.
Parent::onControllerReset( pTime, pForward );
// Fetch the Light Object.
VTorque::LightObjectType *lightObject;
if ( getSceneObject( lightObject ) )
{
// Stop the Animation.
VTorque::pauseAnimation( lightObject );
}
}

View file

@ -0,0 +1,56 @@
//-----------------------------------------------------------------------------
// 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_VLIGHTOBJECTANIMATIONTRACK_H_
#define _VT_VLIGHTOBJECTANIMATIONTRACK_H_
#ifndef _VT_VSCENEOBJECTTRACK_H_
#include "Verve/Extension/SceneObject/VSceneObjectTrack.h"
#endif
#ifndef _VT_TORQUE_LIGHTOBJECT_H_
#include "Verve/Torque/TLightObject.h"
#endif
//-----------------------------------------------------------------------------
class VLightObjectAnimationTrack : public VSceneObjectTrack
{
typedef VSceneObjectTrack Parent;
public:
VLightObjectAnimationTrack( void );
// Controller Methods.
virtual bool onControllerEvent( VController::eControllerEventType pEvent );
virtual void onControllerReset( const S32 &pTime, const bool &pForward );
// Console Declaration.
DECLARE_CONOBJECT( VLightObjectAnimationTrack );
};
//-----------------------------------------------------------------------------
#endif // _VT_VLIGHTOBJECTANIMATIONTRACK_H_

View file

@ -0,0 +1,32 @@
//-----------------------------------------------------------------------------
// 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/LightObject/VLightObjectGroup.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VLightObjectGroup );
//-----------------------------------------------------------------------------
VLightObjectGroup::VLightObjectGroup( void )
{
setLabel( "LightObjectGroup" );
};

View file

@ -0,0 +1,47 @@
//-----------------------------------------------------------------------------
// 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_VLIGHTOBJECTGROUP_H_
#define _VT_VLIGHTOBJECTGROUP_H_
#ifndef _VT_VSCENEOBJECTGROUP_H_
#include "Verve/Extension/SceneObject/VSceneObjectGroup.h"
#endif
//-----------------------------------------------------------------------------
class VLightObjectGroup : public VSceneObjectGroup
{
typedef VSceneObjectGroup Parent;
public:
VLightObjectGroup( void );
// Console Declaration.
DECLARE_CONOBJECT( VLightObjectGroup );
};
//-----------------------------------------------------------------------------
#endif // _VT_VLIGHTOBJECTGROUP_H_

View file

@ -0,0 +1,70 @@
//-----------------------------------------------------------------------------
// 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/LightObject/VLightObjectToggleEvent.h"
#include "console/consoleTypes.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VLightObjectToggleEvent );
//-----------------------------------------------------------------------------
VLightObjectToggleEvent::VLightObjectToggleEvent( void ) :
mEventType( VSharedEnum::k_ActionTurnOn )
{
setLabel( "ToggleEvent" );
}
void VLightObjectToggleEvent::initPersistFields( void )
{
Parent::initPersistFields();
addField( "Action", TYPEID<VActionToggle>(), Offset( mEventType, VLightObjectToggleEvent ) );
}
//-----------------------------------------------------------------------------
//
// Callback Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VLightObjectToggleEvent::onTrigger( pTime, pDelta );
//
// Toggle the Light Object.
//
//-----------------------------------------------------------------------------
void VLightObjectToggleEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
{
Parent::onTrigger( pTime, pDelta );
VTorque::LightObjectType *lightObject;
if ( getSceneObject( lightObject ) )
{
// Turn On?
const bool turnOn = ( mEventType == VSharedEnum::k_ActionTurnOn );
// Toggle Light.
VTorque::setLightObjectOn( lightObject, turnOn );
}
}

View file

@ -0,0 +1,65 @@
//-----------------------------------------------------------------------------
// 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_VLIGHTOBJECTTOGGLEEVENT_H_
#define _VT_VLIGHTOBJECTTOGGLEEVENT_H_
#ifndef _VT_VSCENEOBJECTEVENT_H_
#include "Verve/Extension/SceneObject/VSceneObjectEvent.h"
#endif
#ifndef _VT_TORQUE_LIGHTOBJECT_H_
#include "Verve/Torque/TLightObject.h"
#endif
#ifndef _VT_VSHAREDENUM_H_
#include "Verve/Core/Util/VSharedEnum.h"
#endif
//-----------------------------------------------------------------------------
class VLightObjectToggleEvent : public VSceneObjectEvent
{
typedef VEvent Parent;
public:
VSharedEnum::eActionToggle mEventType;
public:
VLightObjectToggleEvent( void );
static void initPersistFields( void );
// Event Methods.
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
// Console Declaration.
DECLARE_CONOBJECT( VLightObjectToggleEvent );
};
//-----------------------------------------------------------------------------
#endif // _VT_VLIGHTOBJECTTOGGLEEVENT_H_

View file

@ -0,0 +1,63 @@
//-----------------------------------------------------------------------------
// 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/LightObject/VLightObjectToggleTrack.h"
#include "Verve/Extension/LightObject/VLightObjectToggleEvent.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VLightObjectToggleTrack );
//-----------------------------------------------------------------------------
VLightObjectToggleTrack::VLightObjectToggleTrack( void )
{
setLabel( "ToggleTrack" );
}
//-----------------------------------------------------------------------------
//
// Controller Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VLightObjectToggleTrack::onControllerReset( pTime, pForward );
//
// Enable or Disable the light object after a reset.
//
//-----------------------------------------------------------------------------
void VLightObjectToggleTrack::onControllerReset( const S32 &pTime, const bool &pForward )
{
// Default Reset.
Parent::onControllerReset( pTime, pForward );
VLightObjectToggleEvent *event;
VTorque::LightObjectType *lightObject;
if ( getSceneObject( lightObject ) && getPreviousEvent( event ) )
{
// Turn On?
const bool turnOn = ( event->mEventType == VSharedEnum::k_ActionTurnOn );
// Toggle the Light.
VTorque::setLightObjectOn( lightObject, turnOn );
}
}

View 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_VLIGHTOBJECTTOGGLETRACK_H_
#define _VT_VLIGHTOBJECTTOGGLETRACK_H_
#ifndef _VT_VSCENEOBJECTTRACK_H_
#include "Verve/Extension/SceneObject/VSceneObjectTrack.h"
#endif
#ifndef _VT_TORQUE_LIGHTOBJECT_H_
#include "Verve/Torque/TLightObject.h"
#endif
//-----------------------------------------------------------------------------
class VLightObjectToggleTrack : public VSceneObjectTrack
{
typedef VSceneObjectTrack Parent;
public:
VLightObjectToggleTrack( void );
// Controller Methods.
virtual void onControllerReset( const S32 &pTime, const bool &pForward );
// Console Declaration.
DECLARE_CONOBJECT( VLightObjectToggleTrack );
};
//-----------------------------------------------------------------------------
#endif // _VT_VLIGHTOBJECTTOGGLETRACK_H_

View file

@ -0,0 +1,212 @@
//-----------------------------------------------------------------------------
// 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/VController.h"
#include "Verve/Core/VGroup.h"
#include "Verve/Extension/Motion/VMotionEvent.h"
#include "Verve/Extension/Motion/VMotionTrack.h"
#include "console/consoleTypes.h"
#include "math/mMathFn.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VMotionEvent );
//-----------------------------------------------------------------------------
VMotionEvent::VMotionEvent( void )
{
setLabel( "MotionEvent" );
}
//-----------------------------------------------------------------------------
//
// Callback Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VMotionEvent::onTrigger( pDelta, pDelta );
//
// The path object is told to move to the next node. If this event corresponds
// to Node 0, the object will move to Node 1. If the object reaches the node
// before the next event is triggered, then the object will stop moving.
//
// The object's position is only reset when the track is reset and not when an
// event is triggered.
//
//-----------------------------------------------------------------------------
void VMotionEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
{
Parent::onTrigger( pTime, pDelta );
// Fetch Parent Track.
VMotionTrack *track;
if ( !getTrack( track ) )
{
// Invalid Track.
return;
}
// Fetch Path & Reference Object.
VTorque::PathObjectType *path = track->getPath();
VTorque::SceneObjectType *object = getSceneObject();
if ( !path || !object )
{
// Invalid.
return;
}
// Valid Destination Node?
if ( !isControllerLooping() && !getNextEvent() )
{
// Clear Active.
VTorque::setPathObjectActive( path, object, false );
// Quit.
return;
}
// Set Active.
VTorque::setPathObjectActive( path, object, true );
// Apply Speed.
VTorque::setPathObjectSpeed( path, object, getObjectSpeed() );
}
//-----------------------------------------------------------------------------
//
// Reference Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VMotionTrack::getPath();
//
// Returns the path that this track is referencing.
//
//-----------------------------------------------------------------------------
VTorque::PathObjectType *VMotionEvent::getPath( void )
{
// Fetch Track.
VMotionTrack *track;
if ( !getTrack( track ) )
{
// Invalid.
return NULL;
}
// Return Path.
return track->getPath();
}
//-----------------------------------------------------------------------------
//
// VMotionTrack::getObjectSpeed();
//
// Determine the Speed that an object must move at to travel over the segment
// length of the Path.
//
//-----------------------------------------------------------------------------
F32 VMotionEvent::getObjectSpeed( void )
{
// Fetch Parent Track.
VMotionTrack *track;
if ( !getTrack( track ) )
{
// Invalid Track.
return 0.f;
}
// Fetch Path & Reference Object.
VTorque::PathObjectType *path = track->getPath();
VTorque::SceneObjectType *object = getSceneObject();
if ( !path || !object )
{
// Invalid Object(s).
return 0.f;
}
// Fetch Node Index.
const S32 &srcNodeIndex = getNodeIndex( ( isControllerPlayingForward() ) ? 0 : -1 );
// Fetch the Next Event.
VEvent *nextEvent = getNextEvent();
// Valid Destination Node?
if ( !isControllerLooping() && !nextEvent )
{
// No Next Node.
return 0.f;
}
// Valid Next Node?
if ( nextEvent )
{
// Fetch Segment Length & Duration.
const F32 &length = VTorque::getPathNodeLength( path, srcNodeIndex );
const F32 &duration = mAbs( getTriggerTime() - nextEvent->getTriggerTime() );
// Speed = Distance / Duration.
return ( length / ( duration / 1000.f ) );
}
// Playing Forwards?
if ( isControllerPlayingForward() )
{
// Fetch the First Event.
VEvent *firstEvent = dynamic_cast<VEvent*>( track->getChild() );
// Fetch Segment Length & Duration.
const F32 &length = VTorque::getPathNodeLength( path, srcNodeIndex );
const F32 &duration = ( getControllerDuration() - getTriggerTime() ) + firstEvent->getTriggerTime();
// Speed = Distance / Duration.
return ( length / ( duration / 1000.f ) );
}
// Fetch the Last Event.
VEvent *lastEvent = dynamic_cast<VEvent*>( track->getLastChild() );
// Fetch Segment Length & Duration.
const F32 &length = VTorque::getPathNodeLength( path, srcNodeIndex );
const F32 &duration = ( getControllerDuration() - lastEvent->getTriggerTime() ) + getTriggerTime();
// Speed = Distance / Duration.
return ( length / ( duration / 1000.f ) );
}
//-----------------------------------------------------------------------------
//
// VMotionEvent::getNodeIndex( pDelta );
//
// Returns the index of the path node associated with this event object.
//
//-----------------------------------------------------------------------------
S32 VMotionEvent::getNodeIndex( const S32 &pDelta )
{
// Fetch Event Count.
const S32 eventCount = ( ( VTreeNode* )getParent() )->size();
// Return Index.
return ( getIndex() + pDelta ) % eventCount;
}

View file

@ -0,0 +1,61 @@
//-----------------------------------------------------------------------------
// 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_VMOTIONEVENT_H_
#define _VT_VMOTIONEVENT_H_
#ifndef _VT_VSCENEOBJECTEVENT_H_
#include "Verve/Extension/SceneObject/VSceneObjectEvent.h"
#endif
#ifndef _VT_TORQUE_MOTION_H_
#include "Verve/Torque/TMotion.h"
#endif
//-----------------------------------------------------------------------------
class VMotionEvent : public VSceneObjectEvent
{
typedef VSceneObjectEvent Parent;
public:
VMotionEvent( void );
// Event Methods.
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
// Reference Methods.
virtual VTorque::PathObjectType *getPath( void );
F32 getObjectSpeed( void );
S32 getNodeIndex( const S32 &pDelta = 0 );
// Console Declaration.
DECLARE_CONOBJECT( VMotionEvent );
};
//-----------------------------------------------------------------------------
#endif // _VT_VMOTIONEVENT_H_

View file

@ -0,0 +1,442 @@
//-----------------------------------------------------------------------------
// 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/Motion/VMotionTrack.h"
#include "Verve/Extension/Motion/VMotionEvent.h"
#include "console/consoleTypes.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VMotionTrack );
//-----------------------------------------------------------------------------
VMotionTrack::VMotionTrack( void ) :
mDataReference( String::EmptyString ),
mOrientationMode( "FREE" ),
mOrientationData( String::EmptyString ),
mRelative( false )
{
setLabel( "MotionTrack" );
}
void VMotionTrack::initPersistFields( void )
{
Parent::initPersistFields();
addField( "Reference", TypeRealString, Offset( mDataReference, VMotionTrack ), "The name of the data field referencing the object to be attached to the path." );
addProtectedField( "OrientationMode", TypeRealString, Offset( mOrientationMode, VMotionTrack ), &setOrientationMode, &defaultProtectedGetFn, "The orientation mode of the object attached to the path." );
addProtectedField( "OrientationData", TypeRealString, Offset( mOrientationData, VMotionTrack ), &setOrientationData, &defaultProtectedGetFn, "The name of the data field holding the orientation data (used for Orientation Modes, ToObject & ToPoint)." );
addField( "Relative", TypeBool, Offset( mRelative, VMotionTrack ), "Attach the object with an offset based on its initial position." );
}
//-----------------------------------------------------------------------------
//
// Controller Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VMotionTrack::onControllerEvent( pEvent );
//
// When the controller's state changes, this method is called. If the
// controller is paused, then the path object will cease to move. If the
// controller resumes play, the object will continue on its path.
//
// For a full list of possible events, see the 'eControllerEventType'
// declaration in VController.h.
//
//-----------------------------------------------------------------------------
bool VMotionTrack::onControllerEvent( VController::eControllerEventType pEvent )
{
if ( !Parent::onControllerEvent( pEvent ) )
{
// Skip.
return false;
}
// Enabled?
if ( !isEnabled() )
{
// Continue Processing Events.
return true;
}
// Fetch Path & Reference Object.
VTorque::PathObjectType *path = getPath();
VTorque::SceneObjectType *object = getSceneObject();
if ( !path || !object || !VTorque::isPathObjectAttached( path, object ) )
{
// Invalid.
return true;
}
switch ( pEvent )
{
case VController::k_EventPlay :
{
// Continue Advancing.
VTorque::setPathObjectActive( path, object, true );
} break;
case VController::k_EventPause :
{
// Stop Advancing.
VTorque::setPathObjectActive( path, object, false );
} break;
case VController::k_EventStop :
{
// Detach the Object.
detachObject();
} break;
}
return true;
}
//-----------------------------------------------------------------------------
//
// VMotionTrack::onControllerReset( pTime, pForward );
//
// Reposition the path object on the path appropriately. The position is
// interpolated between two nodes, the last node and the next node. These
// correspond to the last and current events.
//
//-----------------------------------------------------------------------------
void VMotionTrack::onControllerReset( const S32 &pTime, const bool &pForward )
{
// Parent Reset.
Parent::onControllerReset( pTime, pForward );
// Valid Track?
// Note: We must have at least 2 Events/Nodes to path.
if ( size() < 2 )
{
// Invalid.
return;
}
// Get Object References.
VController *controller = getController();
VTorque::PathObjectType *path = getPath();
VTorque::SceneObjectType *object = getSceneObject();
if ( !controller || !path || !object )
{
// Invalid Object(s).
return;
}
// Attached?
if ( !VTorque::isPathObjectAttached( path, object ) )
{
// No, Attach Now.
attachObject();
}
// Reset Object.
resetObject( pTime );
}
//-----------------------------------------------------------------------------
//
// Reference Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VMotionTrack::getPath();
//
// Returns the path that this track is referencing.
//
//-----------------------------------------------------------------------------
VTorque::PathObjectType *VMotionTrack::getPath( void )
{
// Fetch the Controller.
VController *controller = getController();
if ( !controller )
{
// Invalid Controller.
return NULL;
}
// Evalulate the Data Field.
String fieldValue;
if ( controller->getDataValue( mDataReference, fieldValue ) )
{
// Return Object.
return dynamic_cast<VTorque::PathObjectType*>( Sim::findObject( fieldValue ) );
}
// No Data!
return NULL;
}
//-----------------------------------------------------------------------------
//
// VMotionTrack::attachObject();
//
// Attach the underlying Scene Object to the target Path at the first Node.
// Default settings are applied and must be updated after the object is
// attached.
//
//-----------------------------------------------------------------------------
void VMotionTrack::attachObject( void )
{
// Get Object References.
VTorque::PathObjectType *path = getPath();
VTorque::SceneObjectType *object = getSceneObject();
if ( !path || !object )
{
// Invalid Object(s).
return;
}
// Object Attached?
if ( VTorque::isPathObjectAttached( path, object ) )
{
// Already Attached.
return;
}
// Fetch Forwards.
const bool &forward = isControllerPlayingForward();
// Select the Node.
const S32 node = ( forward ) ? 0 : ( size() - 1 );
// Fetch the value from the controller data table.
String orientationDataValue = String::EmptyString;
if ( mOrientationData != String::EmptyString
&& !getController()->getDataValue( mOrientationData, orientationDataValue ) )
{
// Sanity!
Con::warnf( "Unable to located the value for the given orientation data key, '%s'", mOrientationData );
// Clear.
orientationDataValue = String::EmptyString;
}
// Attach Object.
VTorque::attachPathObject( path, object, forward, mRelative, node, -1, mOrientationMode, orientationDataValue );
}
//-----------------------------------------------------------------------------
//
// VMotionTrack::detachObject( void );
//
//
//
//-----------------------------------------------------------------------------
void VMotionTrack::detachObject( void )
{
// Get Object References.
VTorque::PathObjectType *path = getPath();
VTorque::SceneObjectType *object = getSceneObject();
if ( !path || !object )
{
// Invalid Object(s).
return;
}
// Object Attached?
if ( !VTorque::isPathObjectAttached( path, object ) )
{
// Not Attached.
return;
}
// Detach.
VTorque::detachPathObject( path, object );
}
//-----------------------------------------------------------------------------
//
// VMotionTrack::resetObject( pTime );
//
//
//
//-----------------------------------------------------------------------------
void VMotionTrack::resetObject( const S32 &pTime )
{
// Get Object References.
VTorque::PathObjectType *path = getPath();
VTorque::SceneObjectType *object = getSceneObject();
if ( !path || !object )
{
// Invalid Object(s).
return;
}
// Fetch Controller Info.
const bool &isPlaying = isControllerPlaying();
const bool &isPlayingForward = isControllerPlayingForward();
const bool &isLooping = isControllerLooping();
// Init Variables.
bool objectActive = false;
F32 objectInterp = 0.f;
F32 objectSpeed = 0.f;
S32 srcNodeIndex = 0;
S32 dstNodeIndex = 0;
VMotionEvent *event;
if ( !getNextEvent( event ) || event->getTriggerTime() == pTime )
{
// Note: This case deals with a target time that is greater than the
// trigger time of the Last Event on this track. It will clamp
// the position of the object to the corresponding node of the
// Last Event.
// Note: If pTime is exactly equal to the Next Event's trigger time,
// then it will set the Source Node to the Last Node and
// set its Interp to 0.f - which is incorrect!
if ( !event || event->getTriggerTime() != pTime )
{
// Fetch the Last Event.
getPreviousEvent( event );
}
// Set the Info.
objectInterp = 0.f;
objectSpeed = event->getObjectSpeed();
srcNodeIndex = event->getNodeIndex();
dstNodeIndex = srcNodeIndex;
}
else if ( !event->getPreviousEvent() )
{
// Note: This case deals with a target time that is less than the
// trigger time of the First Event on this track. It will clamp
// the position of the object to the corresponding node of the
// First Event.
// Set the Info.
objectInterp = 0.f;
objectSpeed = event->getObjectSpeed();
srcNodeIndex = event->getNodeIndex();
dstNodeIndex = srcNodeIndex;
}
else
{
// Note: This case deals with a target time that is between two Events
// on this track. It will position the object on the path,
// between the two nodes corresponding to the Events.
// Fetch the Last Event.
VMotionEvent *lastEvent;
getPreviousEvent( lastEvent );
// Set the Info.
objectActive = isPlaying;
objectInterp = calculateInterp( pTime );
objectSpeed = lastEvent->getObjectSpeed();
srcNodeIndex = event->getNodeIndex( ( isPlayingForward ) ? -1 : 1 );
dstNodeIndex = event->getNodeIndex();
}
// Set Active.
VTorque::setPathObjectActive( path, object, objectActive );
// Set Forward.
VTorque::setPathObjectForward( path, object, isPlayingForward );
// Set Speed.
VTorque::setPathObjectSpeed( path, object, objectSpeed );
// Set Current Node.
VTorque::setPathObjectNode( path, object, srcNodeIndex );
// Set End Node.
VTorque::setPathObjectEndNode( path, object, ( ( isLooping ) ? -1 : ( size() - 1 ) ) );
// Set Interp.
VTorque::setPathObjectInterp( path, object, objectInterp );
}
//-----------------------------------------------------------------------------
//
// Static Field Methods.
//
//-----------------------------------------------------------------------------
bool VMotionTrack::setOrientationMode( void *pObject, const char *pArray, const char *pData )
{
// Fetch Track.
VMotionTrack *track = static_cast<VMotionTrack*>( pObject );
// Store Data.
track->mOrientationMode = pData;
VTorque::PathObjectType *path = track->getPath();
VTorque::SceneObjectType *object = track->getSceneObject();
if ( VTorque::isPathObjectAttached( path, object ) )
{
// Set Orientation Mode.
VTorque::setPathObjectOrientation( path, object, track->mOrientationMode, track->mOrientationData );
}
return false;
}
bool VMotionTrack::setOrientationData( void *pObject, const char *pArray, const char *pData )
{
// Fetch Track.
VMotionTrack *track = static_cast<VMotionTrack*>( pObject );
// Store Data.
track->mOrientationData = pData;
VTorque::PathObjectType *path = track->getPath();
VTorque::SceneObjectType *object = track->getSceneObject();
if ( VTorque::isPathObjectAttached( path, object ) )
{
// Set Orientation Mode.
VTorque::setPathObjectOrientation( path, object, track->mOrientationMode, track->mOrientationData );
}
return false;
}
#ifdef VT_EDITOR
//-----------------------------------------------------------------------------
//
// Debug Methods.
//
//-----------------------------------------------------------------------------
ConsoleMethod( VMotionTrack, getPath, S32, 2, 2, "( void ) - Get the path object this track references.\n"
"@return Returns the SimObjectID for the object." )
{
// Fetch Path.
SimObject *pathReference = object->getPath();
// Return.
return ( pathReference ) ? pathReference->getId() : 0;
}
#endif

View file

@ -0,0 +1,85 @@
//-----------------------------------------------------------------------------
// 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_VMOTIONTRACK_H_
#define _VT_VMOTIONTRACK_H_
#ifndef _VT_VSCENEOBJECTTRACK_H_
#include "Verve/Extension/SceneObject/VSceneObjectTrack.h"
#endif
#ifndef _VT_TORQUE_MOTION_H_
#include "Verve/Torque/TMotion.h"
#endif
//-----------------------------------------------------------------------------
class VMotionTrack : public VSceneObjectTrack
{
typedef VSceneObjectTrack Parent;
public:
// Reference Members.
String mDataReference;
// Path Members.
String mOrientationMode;
String mOrientationData;
bool mRelative;
public:
VMotionTrack( void );
static void initPersistFields( void );
// Controller Methods.
virtual bool onControllerEvent( VController::eControllerEventType pEvent );
virtual void onControllerReset( const S32 &pTime, const bool &pForward );
// Reference Methods.
VTorque::PathObjectType *getPath( void );
void attachObject( void );
void detachObject( void );
void resetObject( const S32 &pTime );
// Console Declaration.
DECLARE_CONOBJECT( VMotionTrack );
protected:
// Static Field Methods.
static bool setOrientationMode( void *pObject, const char *pArray, const char *pData );
static bool setOrientationData( void *pObject, const char *pArray, const char *pData );
};
//-----------------------------------------------------------------------------
#endif // _VT_VMOTIONTRACK_H_

View file

@ -0,0 +1,32 @@
//-----------------------------------------------------------------------------
// 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/ParticleEffect/VParticleEffectGroup.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VParticleEffectGroup );
//-----------------------------------------------------------------------------
VParticleEffectGroup::VParticleEffectGroup( void )
{
setLabel( "ParticleEffectGroup" );
};

View file

@ -0,0 +1,47 @@
//-----------------------------------------------------------------------------
// 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_VPARTICLEEFFECTGROUP_H_
#define _VT_VPARTICLEEFFECTGROUP_H_
#ifndef _VT_VSCENEOBJECTGROUP_H_
#include "Verve/Extension/SceneObject/VSceneObjectGroup.h"
#endif
//-----------------------------------------------------------------------------
class VParticleEffectGroup : public VSceneObjectGroup
{
typedef VSceneObjectGroup Parent;
public:
VParticleEffectGroup( void );
// Console Declaration.
DECLARE_CONOBJECT( VParticleEffectGroup );
};
//-----------------------------------------------------------------------------
#endif // _VT_VPARTICLEEFFECTGROUP_H_

View file

@ -0,0 +1,70 @@
//-----------------------------------------------------------------------------
// 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/ParticleEffect/VParticleEffectToggleEvent.h"
#include "console/consoleTypes.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VParticleEffectToggleEvent );
//-----------------------------------------------------------------------------
VParticleEffectToggleEvent::VParticleEffectToggleEvent( void ) :
mEventType( VSharedEnum::k_ActionTurnOn )
{
setLabel( "ToggleEvent" );
}
void VParticleEffectToggleEvent::initPersistFields( void )
{
Parent::initPersistFields();
addField( "Action", TYPEID<VActionToggle>(), Offset( mEventType, VParticleEffectToggleEvent ) );
}
//-----------------------------------------------------------------------------
//
// Callback Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VParticleEffectToggleEvent::onTrigger( pTime, pDelta );
//
// Toggle the Particle Effect.
//
//-----------------------------------------------------------------------------
void VParticleEffectToggleEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
{
Parent::onTrigger( pTime, pDelta );
VTorque::ParticleEffectType *particleEffect;
if ( getSceneObject( particleEffect ) )
{
// Turn On?
const bool turnOn = ( mEventType == VSharedEnum::k_ActionTurnOn );
// Toggle Particle Effect.
VTorque::setParticleEffectOn( particleEffect, turnOn );
}
}

View file

@ -0,0 +1,65 @@
//-----------------------------------------------------------------------------
// 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_VPARTICLEFFECTTOGGLEEVENT_H_
#define _VT_VPARTICLEFFECTTOGGLEEVENT_H_
#ifndef _VT_VSCENEOBJECTEVENT_H_
#include "Verve/Extension/SceneObject/VSceneObjectEvent.h"
#endif
#ifndef _VT_TORQUE_PARTICLEEFFECT_H_
#include "Verve/Torque/TParticleEffect.h"
#endif
#ifndef _VT_VSHAREDENUM_H_
#include "Verve/Core/Util/VSharedEnum.h"
#endif
//-----------------------------------------------------------------------------
class VParticleEffectToggleEvent : public VSceneObjectEvent
{
typedef VEvent Parent;
public:
VSharedEnum::eActionToggle mEventType;
public:
VParticleEffectToggleEvent( void );
static void initPersistFields( void );
// Event Methods.
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
// Console Declaration.
DECLARE_CONOBJECT( VParticleEffectToggleEvent );
};
//-----------------------------------------------------------------------------
#endif // _VT_VPARTICLEFFECTTOGGLEEVENT_H_

View file

@ -0,0 +1,63 @@
//-----------------------------------------------------------------------------
// 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/ParticleEffect/VParticleEffectToggleTrack.h"
#include "Verve/Extension/ParticleEffect/VParticleEffectToggleEvent.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VParticleEffectToggleTrack );
//-----------------------------------------------------------------------------
VParticleEffectToggleTrack::VParticleEffectToggleTrack( void )
{
setLabel( "ToggleTrack" );
}
//-----------------------------------------------------------------------------
//
// Controller Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VParticleEffectToggleTrack::onControllerReset( pTime, pForward );
//
// Enable or Disable the particle effect after a reset.
//
//-----------------------------------------------------------------------------
void VParticleEffectToggleTrack::onControllerReset( const S32 &pTime, const bool &pForward )
{
// Default Reset.
Parent::onControllerReset( pTime, pForward );
VParticleEffectToggleEvent *event;
VTorque::ParticleEffectType *particleEffect;
if ( getSceneObject( particleEffect ) && getPreviousEvent( event ) )
{
// Turn On?
const bool turnOn = ( event->mEventType == VSharedEnum::k_ActionTurnOn );
// Toggle the Particle Effect.
VTorque::setParticleEffectOn( particleEffect, turnOn );
}
}

View 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_VPARTICLEEFFECTTOGGLETRACK_H_
#define _VT_VPARTICLEEFFECTTOGGLETRACK_H_
#ifndef _VT_VSCENEOBJECTTRACK_H_
#include "Verve/Extension/SceneObject/VSceneObjectTrack.h"
#endif
#ifndef _VT_TORQUE_PARTICLEEFFECT_H_
#include "Verve/Torque/TParticleEffect.h"
#endif
//-----------------------------------------------------------------------------
class VParticleEffectToggleTrack : public VSceneObjectTrack
{
typedef VSceneObjectTrack Parent;
public:
VParticleEffectToggleTrack( void );
// Controller Methods.
virtual void onControllerReset( const S32 &pTime, const bool &pForward );
// Console Declaration.
DECLARE_CONOBJECT( VParticleEffectToggleTrack );
};
//-----------------------------------------------------------------------------
#endif // _VT_VPARTICLEEFFECTTOGGLETRACK_H_

View file

@ -0,0 +1,77 @@
//-----------------------------------------------------------------------------
// 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/PostEffect/VPostEffectToggleEvent.h"
#include "Verve/Extension/PostEffect/VPostEffectToggleTrack.h"
#include "Verve/Extension/Camera/VCameraGroup.h"
#include "console/consoleTypes.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VPostEffectToggleEvent );
//-----------------------------------------------------------------------------
VPostEffectToggleEvent::VPostEffectToggleEvent( void ) :
mEventType( VSharedEnum::k_ActionTurnOn )
{
setLabel( "ToggleEvent" );
}
void VPostEffectToggleEvent::initPersistFields( void )
{
Parent::initPersistFields();
addField( "Action", TYPEID<VActionToggle>(), Offset( mEventType, VPostEffectToggleEvent ) );
}
//-----------------------------------------------------------------------------
//
// Callback Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VPostEffectToggleEvent::onTrigger( pTime, pDelta );
//
// Only enable this effect if the parent group is currently active.
//
//-----------------------------------------------------------------------------
void VPostEffectToggleEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
{
Parent::onTrigger( pTime, pDelta );
// Fetch Parent Objects.
VCameraGroup *group;
VPostEffectToggleTrack *track;
if ( ( !getGroup( group ) || !group->isActive() ) || !getTrack( track ) )
{
// Quit.
return;
}
// Turn On?
const bool turnOn = ( mEventType == VSharedEnum::k_ActionTurnOn );
// Enable Effect.
VTorque::setPostEffectOn( track->getPostEffect(), turnOn );
}

View file

@ -0,0 +1,65 @@
//-----------------------------------------------------------------------------
// 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_VPOSTEFFECTTOGGLEEVENT_H_
#define _VT_VPOSTEFFECTTOGGLEEVENT_H_
#ifndef _VT_VEVENT_H_
#include "Verve/Core/VEvent.h"
#endif
#ifndef _VT_TORQUE_POSTEFFECT_H_
#include "Verve/Torque/TPostEffect.h"
#endif
#ifndef _VT_VSHAREDENUM_H_
#include "Verve/Core/Util/VSharedEnum.h"
#endif
//-----------------------------------------------------------------------------
class VPostEffectToggleEvent : public VEvent
{
typedef VEvent Parent;
public:
VSharedEnum::eActionToggle mEventType;
public:
VPostEffectToggleEvent( void );
static void initPersistFields( void );
// Event Methods.
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
// Console Declaration.
DECLARE_CONOBJECT( VPostEffectToggleEvent );
};
//-----------------------------------------------------------------------------
#endif // _VT_VPOSTEFFECTTOGGLEEVENT_H_

View file

@ -0,0 +1,103 @@
//-----------------------------------------------------------------------------
// 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/PostEffect/VPostEffectToggleTrack.h"
#include "Verve/Extension/PostEffect/VPostEffectToggleEvent.h"
#include "Verve/Extension/Camera/VCameraGroup.h"
#include "console/consoleTypes.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VPostEffectToggleTrack );
//-----------------------------------------------------------------------------
VPostEffectToggleTrack::VPostEffectToggleTrack( void ) :
mPostEffect( NULL )
{
setLabel( "PostEffectTrack" );
}
void VPostEffectToggleTrack::initPersistFields( void )
{
Parent::initPersistFields();
addField( "PostEffect", TYPEID<VTorque::PostEffectType>(), Offset( mPostEffect, VPostEffectToggleTrack ), "The name of the PostEffect object to be triggered." );
}
//-----------------------------------------------------------------------------
//
// Camera Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VPostEffectToggleTrack::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 VPostEffectToggleTrack::onCameraEvent( const VCameraGroup::eCameraEventType &pEvent )
{
// Parent Call.
if ( !Parent::onCameraEvent( pEvent ) )
{
// Skip.
return false;
}
// Enabled?
if ( !isEnabled() || !mPostEffect.isValid() )
{
// Quit Now.
return true;
}
switch( pEvent )
{
case VCameraGroup::k_EventActivate :
{
VPostEffectToggleEvent *event;
if ( getPreviousEvent( event ) && event->mEventType == VSharedEnum::k_ActionTurnOn )
{
// Toggle Post Effect On.
VTorque::setPostEffectOn( mPostEffect, true );
}
} break;
case VCameraGroup::k_EventDeactivate :
{
// Turn Post Effect Off.
VTorque::setPostEffectOn( mPostEffect, false );
} break;
}
return true;
}

View file

@ -0,0 +1,65 @@
//-----------------------------------------------------------------------------
// 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_VPOSTEFFECTTOGGLETRACK_H_
#define _VT_VPOSTEFFECTTOGGLETRACK_H_
#ifndef _VT_VCAMERATRACK_H_
#include "Verve/Extension/Camera/VCameraTrack.h"
#endif
#ifndef _VT_TORQUE_POSTEFFECT_H_
#include "Verve/Torque/TPostEffect.h"
#endif
//-----------------------------------------------------------------------------
class VPostEffectToggleTrack : public VCameraTrack
{
typedef VCameraTrack Parent;
protected:
SimObjectPtr<VTorque::PostEffectType> mPostEffect;
public:
VPostEffectToggleTrack( void );
static void initPersistFields( void );
// Camera Methods.
bool onCameraEvent( const VCameraGroup::eCameraEventType &pEvent );
// Console Declaration.
DECLARE_CONOBJECT( VPostEffectToggleTrack );
public:
VTorque::PostEffectType *getPostEffect( void ) { return mPostEffect; };
};
//-----------------------------------------------------------------------------
#endif // _VT_VPOSTEFFECTTOGGLETRACK_H_

View file

@ -0,0 +1,77 @@
//-----------------------------------------------------------------------------
// 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/SceneObject/VSceneObjectGroup.h"
#include "Verve/Extension/SceneObject/VSceneObjectEvent.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VSceneObjectEvent );
//-----------------------------------------------------------------------------
VSceneObjectEvent::VSceneObjectEvent( void )
{
// Void.
}
//-----------------------------------------------------------------------------
//
// Reference Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VSceneObjectEvent::getSceneObject();
//
// Returns the parent group's object reference.
//
//-----------------------------------------------------------------------------
VTorque::SceneObjectType *VSceneObjectEvent::getSceneObject( void )
{
VSceneObjectGroup *group;
if ( !getGroup( group ) )
{
// No Group!
return NULL;
}
// Return Object.
return group->getSceneObject();
}
#ifdef VT_EDITOR
//-----------------------------------------------------------------------------
//
// Debug Methods.
//
//-----------------------------------------------------------------------------
ConsoleMethod( VSceneObjectEvent, getSceneObject, S32, 2, 2, "( void ) - Get the object this group references.\n"
"@return Returns the SimObjectID for the object." )
{
// Fetch Object.
VTorque::SceneObjectType *objReference = object->getSceneObject();
// Return.
return ( objReference ) ? objReference->getId() : 0;
}
#endif

View file

@ -0,0 +1,63 @@
//-----------------------------------------------------------------------------
// 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_VSCENEOBJECTEVENT_H_
#define _VT_VSCENEOBJECTEVENT_H_
#ifndef _VT_VEVENT_H_
#include "Verve/Core/VTrack.h"
#endif
#ifndef _VT_VSCENEOBJECTGROUP_H_
#include "Verve/Extension/SceneObject/VSceneObjectGroup.h"
#endif
//-----------------------------------------------------------------------------
class VSceneObjectEvent : public VEvent
{
typedef VEvent Parent;
public:
VSceneObjectEvent( void );
// Reference Methods.
VTorque::SceneObjectType *getSceneObject( void );
template <class T> inline bool getSceneObject( T *&pSceneObject )
{
// Reference Scene Object.
pSceneObject = dynamic_cast<T*>( getSceneObject() );
// Valid?
return ( pSceneObject != NULL );
}
// Console Declaration.
DECLARE_CONOBJECT( VSceneObjectEvent );
};
//-----------------------------------------------------------------------------
#endif // _VT_VSCENEOBJECTEVENT_H_

View file

@ -0,0 +1,104 @@
//-----------------------------------------------------------------------------
// 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/SceneObject/VSceneObjectGroup.h"
#include "Verve/Core/VController.h"
#include "console/consoleTypes.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VSceneObjectGroup );
//-----------------------------------------------------------------------------
VSceneObjectGroup::VSceneObjectGroup( void ) :
mDataReference( String::EmptyString ),
mSceneObject( NULL )
{
setLabel( "SceneObjectGroup" );
};
void VSceneObjectGroup::initPersistFields( void )
{
Parent::initPersistFields();
addField( "Reference", TypeRealString, Offset( mDataReference, VSceneObjectGroup ), "The name of the data field referencing the targeted object." );
}
//-----------------------------------------------------------------------------
//
// Reference Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VSceneObjectGroup::getObject();
//
// Returns the group's object reference.
//
//-----------------------------------------------------------------------------
VTorque::SceneObjectType *VSceneObjectGroup::getSceneObject( void )
{
#ifndef VT_EDITOR
// Already Referenced?
if ( mSceneObject )
{
// Return Object.
return mSceneObject;
}
#endif
VController *controller = getController();
if ( !controller )
{
// No Controller!
return NULL;
}
String fieldValue;
if ( controller->getDataValue( mDataReference, fieldValue ) )
{
// Store Object.
mSceneObject = dynamic_cast<VTorque::SceneObjectType*>( Sim::findObject( fieldValue ) );
}
// Return.
return mSceneObject;
}
#ifdef VT_EDITOR
//-----------------------------------------------------------------------------
//
// Debug Methods.
//
//-----------------------------------------------------------------------------
ConsoleMethod( VSceneObjectGroup, getSceneObject, S32, 2, 2, "( void ) - Get the object this group references.\n"
"@return Returns the SimObjectID for the object." )
{
// Fetch Object.
VTorque::SceneObjectType *objReference = object->getSceneObject();
// Return.
return ( objReference ) ? objReference->getId() : 0;
}
#endif

View file

@ -0,0 +1,72 @@
//-----------------------------------------------------------------------------
// 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_VSCENEOBJECTGROUP_H_
#define _VT_VSCENEOBJECTGROUP_H_
#ifndef _VT_VGROUP_H_
#include "Verve/Core/VGroup.h"
#endif
#ifndef _VT_TORQUE_SCENEOBJECT_H_
#include "Verve/Torque/TSceneObject.h"
#endif
//-----------------------------------------------------------------------------
class VSceneObjectGroup : public VGroup
{
typedef VGroup Parent;
public:
// Reference Members.
String mDataReference;
VTorque::SceneObjectType *mSceneObject;
public:
VSceneObjectGroup( void );
static void initPersistFields( void );
// Reference Methods.
VTorque::SceneObjectType *getSceneObject( void );
template <class T> inline bool getSceneObject( T *&pSceneObject )
{
// Reference Scene Object.
pSceneObject = dynamic_cast<T*>( getSceneObject() );
// Valid?
return ( pSceneObject != NULL );
}
// Console Declaration.
DECLARE_CONOBJECT( VSceneObjectGroup );
};
//-----------------------------------------------------------------------------
#endif // _VT_VSCENEOBJECTGROUP_H_

View file

@ -0,0 +1,77 @@
//-----------------------------------------------------------------------------
// 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/SceneObject/VSceneObjectGroup.h"
#include "Verve/Extension/SceneObject/VSceneObjectTrack.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VSceneObjectTrack );
//-----------------------------------------------------------------------------
VSceneObjectTrack::VSceneObjectTrack( void )
{
setLabel( "SceneObjectTrack" );
}
//-----------------------------------------------------------------------------
//
// Reference Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VSceneObjectTrack::getSceneObject();
//
// Returns the parent group's object reference.
//
//-----------------------------------------------------------------------------
VTorque::SceneObjectType *VSceneObjectTrack::getSceneObject( void )
{
VSceneObjectGroup *group;
if ( !getGroup( group ) )
{
// No Group!
return NULL;
}
// Return Object.
return group->getSceneObject();
}
#ifdef VT_EDITOR
//-----------------------------------------------------------------------------
//
// Debug Methods.
//
//-----------------------------------------------------------------------------
ConsoleMethod( VSceneObjectTrack, getSceneObject, S32, 2, 2, "( void ) - Get the object this group references.\n"
"@return Returns the SimObjectID for the object." )
{
// Fetch Object.
VTorque::SceneObjectType *objReference = object->getSceneObject();
// Return.
return ( objReference ) ? objReference->getId() : 0;
}
#endif

View file

@ -0,0 +1,63 @@
//-----------------------------------------------------------------------------
// 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_VSCENEOBJECTTRACK_H_
#define _VT_VSCENEOBJECTTRACK_H_
#ifndef _VT_VTRACK_H_
#include "Verve/Core/VTrack.h"
#endif
#ifndef _VT_VSCENEOBJECTGROUP_H_
#include "Verve/Extension/SceneObject/VSceneObjectGroup.h"
#endif
//-----------------------------------------------------------------------------
class VSceneObjectTrack : public VTrack
{
typedef VTrack Parent;
public:
VSceneObjectTrack( void );
// Reference Methods.
VTorque::SceneObjectType *getSceneObject( void );
template <class T> inline bool getSceneObject( T *&pSceneObject )
{
// Reference Scene Object.
pSceneObject = dynamic_cast<T*>( getSceneObject() );
// Valid?
return ( pSceneObject != NULL );
}
// Console Declaration.
DECLARE_CONOBJECT( VSceneObjectTrack );
};
//-----------------------------------------------------------------------------
#endif // _VT_VSCENEOBJECTTRACK_H_

View file

@ -0,0 +1,101 @@
//-----------------------------------------------------------------------------
// 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/Core/VTrack.h"
#include "Verve/Extension/Script/VScriptEvent.h"
#include "console/consoleTypes.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VScriptEvent );
//-----------------------------------------------------------------------------
// Implement the Command Type enum list.
ImplementEnumType( VScriptEventCommandType, "" )
{ VScriptEvent::k_TypeExpression, "EXPRESSION" },
{ VScriptEvent::k_TypeMethod, "METHOD" },
EndImplementEnumType;
//-----------------------------------------------------------------------------
VScriptEvent::VScriptEvent( void ) :
mCommandType( k_TypeMethod ),
mCommand( String::EmptyString )
{
setLabel( "ScriptEvent" );
}
void VScriptEvent::initPersistFields( void )
{
Parent::initPersistFields();
addField( "CommandType", TYPEID<eCommandType>(), Offset( mCommandType, VScriptEvent ), "The type of command to be evaluated." );
addField( "Command", TypeRealString, Offset( mCommand, VScriptEvent ), "The command to be evaluated." );
}
//-----------------------------------------------------------------------------
//
// Callback Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VScriptEvet::onTrigger( pTime, pDelta );
//
// Execute a method or evaluate a command.
//
//-----------------------------------------------------------------------------
void VScriptEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
{
Parent::onTrigger( pTime, pDelta );
switch ( mCommandType )
{
case k_TypeExpression :
{
// Evaluate Expression.
Con::evaluate( mCommand, false, NULL );
} break;
case k_TypeMethod :
{
SimObject *object = getSceneObject();
if ( object )
{
// Execute Method.
Con::executef( object, mCommand );
}
else
{
// Execute Function.
Con::executef( mCommand );
}
} break;
}
}

View file

@ -0,0 +1,74 @@
//-----------------------------------------------------------------------------
// 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_VSCRIPTEVENT_H_
#define _VT_VSCRIPTEVENT_H_
#ifndef _VT_VSCENEOBJECTEVENT_H_
#include "Verve/Extension/SceneObject/VSceneObjectEvent.h"
#endif
//-----------------------------------------------------------------------------
class VScriptEvent : public VSceneObjectEvent
{
typedef VSceneObjectEvent Parent;
public:
enum eCommandType
{
k_TypeExpression,
k_TypeMethod,
k_TypeInvalid,
};
eCommandType mCommandType;
String mCommand;
public:
VScriptEvent( void );
static void initPersistFields( void );
// Event Methods.
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
// Console Declaration.
DECLARE_CONOBJECT( VScriptEvent );
};
//-----------------------------------------------------------------------------
// Define Types.
typedef VScriptEvent::eCommandType VScriptEventCommandType;
// Declare Enum Types.
DefineEnumType( VScriptEventCommandType );
//-----------------------------------------------------------------------------
#endif // _VT_VSCRIPTEVENT_H_

View file

@ -0,0 +1,32 @@
//-----------------------------------------------------------------------------
// 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/Script/VScriptEventTrack.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VScriptEventTrack );
//-----------------------------------------------------------------------------
VScriptEventTrack::VScriptEventTrack( void )
{
setLabel( "ScriptEventTrack" );
}

View file

@ -0,0 +1,47 @@
//-----------------------------------------------------------------------------
// 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_VSCRIPTEVENTTRACK_H_
#define _VT_VSCRIPTEVENTTRACK_H_
#ifndef _VT_VTRACK_H_
#include "Verve/Core/VTrack.h"
#endif
//-----------------------------------------------------------------------------
class VScriptEventTrack : public VTrack
{
typedef VTrack Parent;
public:
VScriptEventTrack( void );
// Console Declaration.
DECLARE_CONOBJECT( VScriptEventTrack );
};
//-----------------------------------------------------------------------------
#endif // _VT_VSCRIPTEVENTTRACK_H_

View file

@ -0,0 +1,131 @@
//-----------------------------------------------------------------------------
// 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/SoundEffect/VSoundEffectEvent.h"
#include "Verve/Extension/SoundEffect/VSoundEffectTrack.h"
#include "console/consoleTypes.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VSoundEffectEvent );
//-----------------------------------------------------------------------------
VSoundEffectEvent::VSoundEffectEvent( void ) :
mSoundEffect( NULL )
{
setLabel( "SoundEvent" );
}
void VSoundEffectEvent::initPersistFields( void )
{
Parent::initPersistFields();
addProtectedField( "SoundEffect", TYPEID<VTorque::SoundEffectType>(), Offset( mSoundEffect, VSoundEffectEvent ), &setSoundData, &defaultProtectedGetFn, "" );
}
//-----------------------------------------------------------------------------
//
// Callback Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VSoundEffectEvent::onTrigger( pTime, pDelta );
//
// Play the target sound effect. If this track belongs to a SceneObjectGroup,
// then the sound will play with the reference object's transform. If this is
// not the case, then a 2D sound will be played.
//
//-----------------------------------------------------------------------------
void VSoundEffectEvent::onTrigger( const S32 &pTime, const S32 &pDelta )
{
Parent::onTrigger( pTime, pDelta );
// Fetch Track.
VSoundEffectTrack *track;
if ( !getTrack( track ) )
{
return;
}
// Position & Pitch.
U32 position = mAbs( ( pTime + pDelta ) - getStartTime() );
F32 pitch = mFabs( getControllerTimeScale() );
if ( position < SFXStartBuffer )
{
// Zero.
position = 0;
}
VSceneObjectGroup *group;
if ( getGroup( group ) )
{
// Play Sound With Reference.
track->mSource = VTorque::playSound( mSoundEffect, group->getSceneObject(), position, pitch );
}
else
{
// Play Sound.
track->mSource = VTorque::playSound( mSoundEffect, position, pitch );
}
}
//-----------------------------------------------------------------------------
//
// Property Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VSoundEffectEvent::setDuration( pDuration );
//
// This event's duration is always set to the sound object's duration.
//
//-----------------------------------------------------------------------------
void VSoundEffectEvent::setDuration( const S32 &pDuration )
{
// Clear Duration.
mDuration = VTorque::getSoundDuration( mSoundEffect );
}
//-----------------------------------------------------------------------------
//
// Static Field Methods.
//
//-----------------------------------------------------------------------------
bool VSoundEffectEvent::setSoundData( void *pObject, const char *pArray, const char *pData )
{
// Fetch Event.
VSoundEffectEvent *event = static_cast<VSoundEffectEvent*>( pObject );
// Use Object.
event->mSoundEffect = dynamic_cast<VTorque::SoundEffectType*>( Sim::findObject( pData ) );
// Set Duration.
event->setDuration( 0 );
return false;
}

View file

@ -0,0 +1,74 @@
//-----------------------------------------------------------------------------
// 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_VSOUNDEFFECTEVENT_H_
#define _VT_VSOUNDEFFECTEVENT_H_
#ifndef _VT_VSCENEOBJECTEVENT_H_
#include "Verve/Extension/SceneObject/VSceneObjectEvent.h"
#endif
#ifndef _VT_TORQUE_SOUNDEFFECT_H_
#include "Verve/Torque/TSoundEffect.h"
#endif
//-----------------------------------------------------------------------------
class VSoundEffectEvent : public VSceneObjectEvent
{
typedef VSceneObjectEvent Parent;
enum
{
SFXStartBuffer = 100,
};
public:
SimObjectPtr<VTorque::SoundEffectType> mSoundEffect;
public:
VSoundEffectEvent( void );
static void initPersistFields( void );
static bool setSoundData( void *pObject, const char *pArray, const char *pData );
// Event Methods.
virtual void onTrigger( const S32 &pTime, const S32 &pDelta );
// Console Declaration.
DECLARE_CONOBJECT( VSoundEffectEvent );
public:
// Property Methods.
virtual void setDuration( const S32 &pDuration );
};
//-----------------------------------------------------------------------------
#endif // _VT_VSOUNDEFFECTEVENT_H_

View file

@ -0,0 +1,111 @@
//-----------------------------------------------------------------------------
// 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/SoundEffect/VSoundEffectTrack.h"
#include "Verve/Extension/SoundEffect/VSoundEffectEvent.h"
#include "console/consoleTypes.h"
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT( VSoundEffectTrack );
//-----------------------------------------------------------------------------
VSoundEffectTrack::VSoundEffectTrack( void ) :
mSource( NULL )
{
setLabel( "SoundTrack" );
}
//-----------------------------------------------------------------------------
//
// Controller Methods.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VSoundEffectTrack::onControllerEvent( pEvent );
//
// If the controller ceases playback and the track has a valid reference to a
// source provider, then the sound is stopped.
//
//-----------------------------------------------------------------------------
bool VSoundEffectTrack::onControllerEvent( VController::eControllerEventType pEvent )
{
if ( !Parent::onControllerEvent( pEvent ) )
{
// Skip.
return false;
}
// Enabled?
if ( !isEnabled() )
{
// Continue Processing Events.
return true;
}
switch ( pEvent )
{
case VController::k_EventPause :
case VController::k_EventStop :
{
#ifdef VT_EDITOR
if ( mSource )
{
// Stop Sound.
VTorque::stopSound( mSource );
// Clear Source.
mSource = NULL;
}
#endif
} break;
}
return true;
}
//-----------------------------------------------------------------------------
//
// VSoundEffectTrack::onControllerReset( pTime, pForward );
//
// If the track is reset and it has a valid reference to a source provider,
// then the sound is stopped.
//
//-----------------------------------------------------------------------------
void VSoundEffectTrack::onControllerReset( const S32 &pTime, const bool &pForward )
{
// Default Reset.
Parent::onControllerReset( pTime, pForward );
if ( mSource )
{
// Stop Sound.
VTorque::stopSound( mSource );
}
// Clear Source.
mSource = NULL;
}

View 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_VSOUNDEFFECTTRACK_H_
#define _VT_VSOUNDEFFECTTRACK_H_
#ifndef _VT_VTRACK_H_
#include "Verve/Core/VTrack.h"
#endif
#ifndef _VT_TORQUE_SOUNDEFFECT_H_
#include "Verve/Torque/TSoundEffect.h"
#endif
//-----------------------------------------------------------------------------
class VSoundEffectTrack : public VTrack
{
typedef VTrack Parent;
public:
VTorque::SoundSourceType *mSource;
public:
VSoundEffectTrack( void );
// Controller Methods.
virtual bool onControllerEvent( VController::eControllerEventType pEvent );
virtual void onControllerReset( const S32 &pTime, const bool &pForward );
// Console Declaration.
DECLARE_CONOBJECT( VSoundEffectTrack );
};
//-----------------------------------------------------------------------------
#endif // _VT_VSOUNDEFFECTTRACK_H_