mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 00:05:40 +00:00
(Mostly) updated verve implementation.
This commit is contained in:
parent
e0627973fb
commit
5a7f0f0b23
538 changed files with 68727 additions and 49 deletions
259
Engine/source/Verve/VActor/Humanoid/VHumanoidActor.cpp
Normal file
259
Engine/source/Verve/VActor/Humanoid/VHumanoidActor.cpp
Normal file
|
|
@ -0,0 +1,259 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "VHumanoidActor.h"
|
||||
|
||||
#include "core/stream/bitStream.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CO_NETOBJECT_V1( VHumanoidActor );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VHumanoidActor::VHumanoidActor( void )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
|
||||
VHumanoidActor::~VHumanoidActor( void )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Initialisation Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VHumanoidActor::onNewDataBlock( pDataBlock );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VHumanoidActor::onNewDataBlock( GameBaseData *pDataBlock, bool pReload )
|
||||
{
|
||||
// Store DataBlock Reference.
|
||||
mDataBlock = dynamic_cast<VHumanoidActorData*>( pDataBlock );
|
||||
|
||||
// Valid Data?
|
||||
if ( !mDataBlock || !Parent::onNewDataBlock( pDataBlock, pReload ) )
|
||||
{
|
||||
// Invalid Data.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Initialise the Controllers.
|
||||
if ( !initAnimationController() || !initPhysicsController() )
|
||||
{
|
||||
// Invalid.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Initialise the Base Animation Thread.
|
||||
mAnimationController.initBaseAnimation( VHumanoidActorData::k_IdleAnimation, 0.f, 1.f );
|
||||
// Initialise the Arm Animation Thread.
|
||||
mAnimationController.initArmAnimation( VHumanoidActorData::k_ArmsUpDownAnimation, 0.5f, 1.f );
|
||||
|
||||
/*
|
||||
// Initialise Head Threads.
|
||||
initAnimationSequence( VHumanoidActorData::k_HeadHorizontalAnimation, mHeadAnimation.HThread, 0.5f );
|
||||
initAnimationSequence( VHumanoidActorData::k_HeadVerticalAnimation, mHeadAnimation.VThread, 0.5f );
|
||||
*/
|
||||
|
||||
// Valid Data.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Update Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VHumanoidActor::processTick( pMove );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VHumanoidActor::processTick( const Move *pMove )
|
||||
{
|
||||
// Parent Call.
|
||||
Parent::processTick( pMove );
|
||||
|
||||
// Update Physics.
|
||||
mPhysicsController.update( TickSec, pMove );
|
||||
|
||||
// Update Container.
|
||||
updateContainer();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VHumanoidActor::interpolateTick( pDelta );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VHumanoidActor::interpolateTick( F32 pDelta )
|
||||
{
|
||||
// Parent Call.
|
||||
Parent::interpolateTick( pDelta );
|
||||
|
||||
// Update Physics.
|
||||
mPhysicsController.interpolateTick( pDelta );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VHumanoidActor::advanceTime( pDelta );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VHumanoidActor::advanceTime( F32 pDelta )
|
||||
{
|
||||
// Parent Call.
|
||||
Parent::advanceTime( pDelta );
|
||||
|
||||
// Valid Animation Controller?
|
||||
if ( getAnimationController() )
|
||||
{
|
||||
// Update Animations.
|
||||
getAnimationController()->update( pDelta );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VHumanoidActor::packUpdate( pConnection, pMask, pStream );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
U32 VHumanoidActor::packUpdate( NetConnection *pConnection, U32 pMask, BitStream *pStream )
|
||||
{
|
||||
// Parent Call.
|
||||
U32 retMask = Parent::packUpdate( pConnection, pMask, pStream );
|
||||
|
||||
// Physics Controller?
|
||||
if ( pStream->writeFlag( pMask & PhysicsMask ) )
|
||||
{
|
||||
// Pack Physics.
|
||||
retMask &= mPhysicsController.packUpdate( pConnection, pMask, pStream );
|
||||
}
|
||||
|
||||
return retMask;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VHumanoidActor::unpackUpdate( pConnection, pStream );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VHumanoidActor::unpackUpdate( NetConnection *pConnection, BitStream *pStream )
|
||||
{
|
||||
// Parent Call.
|
||||
Parent::unpackUpdate( pConnection, pStream );
|
||||
|
||||
// Physics Controller?
|
||||
if ( pStream->readFlag() )
|
||||
{
|
||||
// Unpack Physics.
|
||||
mPhysicsController.unpackUpdate( pConnection, pStream );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Animation Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VHumanoidActor::initAnimationController();
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VHumanoidActor::initAnimationController( void )
|
||||
{
|
||||
// Reference Object.
|
||||
mAnimationController.setObject( this );
|
||||
// Initialise.
|
||||
return mAnimationController.initAnimationTable();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VHumanoidActor::getAnimationController();
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
VActorAnimationController *VHumanoidActor::getAnimationController( void )
|
||||
{
|
||||
return &mAnimationController;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VHumanoidActor::initPhysicsController();
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VHumanoidActor::initPhysicsController( void )
|
||||
{
|
||||
// Initialise.
|
||||
return mPhysicsController.initPhysicsController( this );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VHumanoidActor::getAnimationController();
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
VActorPhysicsController *VHumanoidActor::getPhysicsController( void )
|
||||
{
|
||||
return &mPhysicsController;
|
||||
}
|
||||
84
Engine/source/Verve/VActor/Humanoid/VHumanoidActor.h
Normal file
84
Engine/source/Verve/VActor/Humanoid/VHumanoidActor.h
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VHUMANOIDACTOR_H_
|
||||
#define _VT_VHUMANOIDACTOR_H_
|
||||
|
||||
#ifndef _VT_VACTOR_H_
|
||||
#include "../VActor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VHUMANOIDACTORDATA_H_
|
||||
#include "VHumanoidActorData.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VHUMANOIDACTORANIMATIONCONTROLLER_H_
|
||||
#include "VHumanoidActorAnimationController.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VHUMANOIDACTORPHYSICSCONTROLLER_H_
|
||||
#include "VHumanoidActorPhysicsController.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VHumanoidActor : public VActor
|
||||
{
|
||||
typedef VActor Parent;
|
||||
|
||||
protected:
|
||||
|
||||
VHumanoidActorAnimationController mAnimationController;
|
||||
VHumanoidActorPhysicsController mPhysicsController;
|
||||
|
||||
public:
|
||||
|
||||
VHumanoidActor( void );
|
||||
~VHumanoidActor( void );
|
||||
|
||||
// Initialisation Methods.
|
||||
|
||||
bool onNewDataBlock( GameBaseData *pDataBlock, bool pReload );
|
||||
|
||||
// Update Methods.
|
||||
|
||||
void processTick( const Move *pMove );
|
||||
void interpolateTick( F32 pDelta );
|
||||
void advanceTime( F32 pDelta );
|
||||
|
||||
U32 packUpdate( NetConnection *pConnection, U32 pMask, BitStream *pStream );
|
||||
void unpackUpdate( NetConnection *pConnection, BitStream *pStream );
|
||||
|
||||
// Animation Methods.
|
||||
|
||||
bool initAnimationController( void );
|
||||
VActorAnimationController *getAnimationController( void );
|
||||
|
||||
// Physics Methods.
|
||||
|
||||
bool initPhysicsController( void );
|
||||
VActorPhysicsController *getPhysicsController( void );
|
||||
|
||||
DECLARE_CONOBJECT( VHumanoidActor );
|
||||
};
|
||||
|
||||
#endif // _VT_VHUMANOIDACTOR_H_
|
||||
|
|
@ -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.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "VHumanoidActorAnimationController.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VHumanoidActorAnimationController::VHumanoidActorAnimationController( void )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
|
||||
VHumanoidActorAnimationController::~VHumanoidActorAnimationController( void )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool VHumanoidActorAnimationController::initArmAnimation( const U32 &pIndex, const F32 &pPosition, const F32 &pTimeScale )
|
||||
{
|
||||
// Initialise Animation Ref.
|
||||
return initAnimation( mArmAnimation, pIndex, pPosition, pTimeScale );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Animation Methods
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void VHumanoidActorAnimationController::update( const F32 &pDelta )
|
||||
{
|
||||
// Parent Call.
|
||||
VActorAnimationController::update( pDelta );
|
||||
|
||||
// Update the Look Thread.
|
||||
if ( mArmAnimation.Thread )
|
||||
{
|
||||
// Set Position.
|
||||
getShapeInstance()->setPos( mArmAnimation.Thread, 0.5f );
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VHUMANOIDACTORANIMATIONCONTROLLER_H_
|
||||
#define _VT_VHUMANOIDACTORANIMATIONCONTROLLER_H_
|
||||
|
||||
#ifndef _VT_VACTORANIMATIONCONTROLLER_H_
|
||||
#include "../VActorAnimationController.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VActor;
|
||||
class VActorStateTable;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VHumanoidActorAnimationController : public VActorAnimationController
|
||||
{
|
||||
public:
|
||||
|
||||
/*
|
||||
struct sHeadAnimation
|
||||
{
|
||||
S32 HSequence;
|
||||
TSThread *HThread;
|
||||
Range HRange;
|
||||
|
||||
S32 VSequence;
|
||||
TSThread *VThread;
|
||||
Range VRange;
|
||||
|
||||
S32 FaceSequence;
|
||||
TSThread *FaceThread;
|
||||
|
||||
sHeadAnimation( void ) :
|
||||
HSequence( -1 ),
|
||||
HThread( NULL ),
|
||||
HRange( 0.f, 1.f ),
|
||||
VSequence( -1 ),
|
||||
VThread( NULL ),
|
||||
VRange( 0.f, 1.f )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
protected:
|
||||
|
||||
//sHeadAnimation mHeadAnimation;
|
||||
|
||||
sAnimationRef mHeadHAnimation;
|
||||
sAnimationRef mHeadVAnimation;
|
||||
sAnimationRef mArmAnimation;
|
||||
|
||||
public:
|
||||
|
||||
VHumanoidActorAnimationController( void );
|
||||
virtual ~VHumanoidActorAnimationController( void );
|
||||
|
||||
// Initialisation Methods.
|
||||
|
||||
bool initArmAnimation( const U32 &pIndex, const F32 &pPosition, const F32 &pTimeScale );
|
||||
|
||||
// Animation Methods.
|
||||
|
||||
void update( const F32 &pDelta );
|
||||
};
|
||||
|
||||
#endif // _VT_VACTORANIMATIONCONTROLLER_H_
|
||||
96
Engine/source/Verve/VActor/Humanoid/VHumanoidActorData.cpp
Normal file
96
Engine/source/Verve/VActor/Humanoid/VHumanoidActorData.cpp
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "VHumanoidActorData.h"
|
||||
#include "VHumanoidAnimationStates.h"
|
||||
#include "VHumanoidPhysicsStates.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Animation Table.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static VActorData::sAnimationSequence animSequenceLookup[] =
|
||||
{
|
||||
// State Based Animations.
|
||||
{ VHumanoidActorData::k_IdleAnimation, "root", 0.0f, ActorAnimationStateInstance( HumanoidIdle ) },
|
||||
|
||||
{ VHumanoidActorData::k_WalkForwardAnimation, "walk", 0.1f, ActorAnimationStateInstance( HumanoidWalkForward ) },
|
||||
{ VHumanoidActorData::k_WalkBackwardAnimation, "walkback", 0.1f, ActorAnimationStateInstance( HumanoidWalkBackward ) },
|
||||
|
||||
{ VHumanoidActorData::k_RunForwardAnimation, "run", 0.1f, ActorAnimationStateInstance( HumanoidRunForward ) },
|
||||
{ VHumanoidActorData::k_RunBackwardAnimation, "runback", 0.1f, ActorAnimationStateInstance( HumanoidRunBackward ) },
|
||||
|
||||
{ VHumanoidActorData::k_SwimIdleAnimation, "swimroot", 1.0f, ActorAnimationStateInstance( HumanoidSwimIdle ) },
|
||||
{ VHumanoidActorData::k_SwimForwardAnimation, "swim", 1.0f, ActorAnimationStateInstance( HumanoidSwimForward ) },
|
||||
{ VHumanoidActorData::k_SwimBackwardAnimation, "swimback", 1.0f, ActorAnimationStateInstance( HumanoidSwimBackward ) },
|
||||
|
||||
// Support Animations.
|
||||
{ VHumanoidActorData::k_HeadHorizontalAnimation, "headside" },
|
||||
{ VHumanoidActorData::k_HeadVerticalAnimation, "head" },
|
||||
|
||||
{ VHumanoidActorData::k_ArmsUpDownAnimation, "look" },
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Physics Table.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static VActorData::sPhysicsState physStateLookup[] =
|
||||
{
|
||||
{ VHumanoidActorData::k_OnGroundPhysics, 0.f, ActorPhysicsStateInstance( HumanoidOnGround ) },
|
||||
{ VHumanoidActorData::k_InAirPhysics, 0.f, ActorPhysicsStateInstance( HumanoidInAir ) },
|
||||
{ VHumanoidActorData::k_InWaterPhysics, 0.f, ActorPhysicsStateInstance( HumanoidInWater ) },
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CO_DATABLOCK_V1( VHumanoidActorData );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VHumanoidActorData::VHumanoidActorData( void )
|
||||
{
|
||||
// Void.
|
||||
};
|
||||
|
||||
bool VHumanoidActorData::preload( bool pServer, String &pErrorStr )
|
||||
{
|
||||
if ( !Parent::preload( pServer, pErrorStr ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Initialise Animation List.
|
||||
if ( !initAnimationSequenceList( sizeof( animSequenceLookup ) / sizeof( VActorData::sAnimationSequence ), &animSequenceLookup[0] ) )
|
||||
{
|
||||
Con::errorf( "VHumanoidActorData::preload() - Failed to Initialise Actor Animations." );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Initialise Physics State List.
|
||||
if ( !initPhysicsStateList( sizeof( physStateLookup ) / sizeof( VActorData::sPhysicsState ), &physStateLookup[0] ) )
|
||||
{
|
||||
Con::errorf( "VHumanoidActorData::preload() - Failed to Initialise Actor Physics States." );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Valid Load.
|
||||
return true;
|
||||
}
|
||||
81
Engine/source/Verve/VActor/Humanoid/VHumanoidActorData.h
Normal file
81
Engine/source/Verve/VActor/Humanoid/VHumanoidActorData.h
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VHUMANOIDACTORDATA_H_
|
||||
#define _VT_VHUMANOIDACTORDATA_H_
|
||||
|
||||
#ifndef _VT_VACTORDATA_H_
|
||||
#include "../VActorData.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
struct VHumanoidActorData : public VActorData
|
||||
{
|
||||
private:
|
||||
|
||||
typedef VActorData Parent;
|
||||
friend class VHumanoidActor;
|
||||
|
||||
public:
|
||||
|
||||
enum eAnimationList
|
||||
{
|
||||
k_IdleAnimation = Parent::k_NextAnimation + 0,
|
||||
|
||||
k_WalkForwardAnimation = Parent::k_NextAnimation + 1,
|
||||
k_WalkBackwardAnimation = Parent::k_NextAnimation + 2,
|
||||
|
||||
k_RunForwardAnimation = Parent::k_NextAnimation + 3,
|
||||
k_RunBackwardAnimation = Parent::k_NextAnimation + 4,
|
||||
|
||||
k_SwimIdleAnimation = Parent::k_NextAnimation + 5,
|
||||
k_SwimForwardAnimation = Parent::k_NextAnimation + 6,
|
||||
k_SwimBackwardAnimation = Parent::k_NextAnimation + 7,
|
||||
|
||||
k_HeadHorizontalAnimation = Parent::k_NextAnimation + 8,
|
||||
k_HeadVerticalAnimation = Parent::k_NextAnimation + 9,
|
||||
|
||||
k_ArmsUpDownAnimation = Parent::k_NextAnimation + 10,
|
||||
|
||||
k_NextAnimation = Parent::k_NextAnimation + 11,
|
||||
};
|
||||
|
||||
enum ePhysicsStateList
|
||||
{
|
||||
k_OnGroundPhysics = Parent::k_NextPhysicsState + 0,
|
||||
k_InAirPhysics = Parent::k_NextPhysicsState + 1,
|
||||
k_InWaterPhysics = Parent::k_NextPhysicsState + 2,
|
||||
|
||||
k_NextPhysicsState = Parent::k_NextPhysicsState + 3,
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
VHumanoidActorData( void );
|
||||
|
||||
virtual bool preload( bool pServer, String &pErrorStr );
|
||||
|
||||
DECLARE_CONOBJECT( VHumanoidActorData );
|
||||
};
|
||||
|
||||
#endif // _VT_VHUMANOIDACTORDATA_H_
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "VHumanoidActorPhysicsController.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VHumanoidActorPhysicsController::VHumanoidActorPhysicsController( void )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
|
||||
VHumanoidActorPhysicsController::~VHumanoidActorPhysicsController( void )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VHUMANOIDACTORPHYSICSCONTROLLER_H_
|
||||
#define _VT_VHUMANOIDACTORPHYSICSCONTROLLER_H_
|
||||
|
||||
#ifndef _VT_VACTORPHYSICSCONTROLLER_H_
|
||||
#include "../VActorPhysicsController.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VActor;
|
||||
class VActorStateTable;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VHumanoidActorPhysicsController : public VActorPhysicsController
|
||||
{
|
||||
public:
|
||||
|
||||
VHumanoidActorPhysicsController( void );
|
||||
~VHumanoidActorPhysicsController( void );
|
||||
};
|
||||
|
||||
#endif // _VT_VHUMANOIDACTORPHYSICSCONTROLLER_H_
|
||||
213
Engine/source/Verve/VActor/Humanoid/VHumanoidAnimationStates.cpp
Normal file
213
Engine/source/Verve/VActor/Humanoid/VHumanoidAnimationStates.cpp
Normal file
|
|
@ -0,0 +1,213 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "VHumanoidAnimationStates.h"
|
||||
#include "VHumanoidActor.h"
|
||||
|
||||
#include "../VActorAnimationController.h"
|
||||
#include "../VActorPhysicsController.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Implement Animation States.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ImplementActorAnimationState( HumanoidIdle, VHumanoidActorData::k_IdleAnimation );
|
||||
|
||||
ImplementActorAnimationState( HumanoidWalkForward, VHumanoidActorData::k_WalkForwardAnimation );
|
||||
ImplementActorAnimationState( HumanoidWalkBackward, VHumanoidActorData::k_WalkBackwardAnimation );
|
||||
|
||||
ImplementActorAnimationState( HumanoidRunForward, VHumanoidActorData::k_RunForwardAnimation );
|
||||
ImplementActorAnimationState( HumanoidRunBackward, VHumanoidActorData::k_RunBackwardAnimation );
|
||||
|
||||
ImplementActorAnimationState( HumanoidSwimIdle, VHumanoidActorData::k_SwimIdleAnimation );
|
||||
ImplementActorAnimationState( HumanoidSwimForward, VHumanoidActorData::k_SwimForwardAnimation );
|
||||
ImplementActorAnimationState( HumanoidSwimBackward, VHumanoidActorData::k_SwimBackwardAnimation );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Execute Animation States.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// OnGround Animation States
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ExecuteActorAnimationState( HumanoidIdle )
|
||||
{
|
||||
// Always Enter.
|
||||
return true;
|
||||
}
|
||||
|
||||
ExecuteActorAnimationState( HumanoidWalkForward )
|
||||
{
|
||||
// Fetch Controller.
|
||||
VActorPhysicsController *physicsController = pObject->getPhysicsController();
|
||||
|
||||
// On the Ground?
|
||||
if ( physicsController->getPhysicsState() != VHumanoidActorData::k_OnGroundPhysics )
|
||||
{
|
||||
// Can't Run Forward.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Fetch Velocity.
|
||||
const VectorF &velocity = physicsController->getVelocity();
|
||||
// Determine Move Speed.
|
||||
const F32 moveSpeed = mSqrt( velocity.x * velocity.x + velocity.y * velocity.y );
|
||||
|
||||
// Moving Forward & Slow Enough?
|
||||
return ( ( physicsController->getMoveState() & k_ForwardMove ) &&
|
||||
( moveSpeed < pObject->getDataBlock()->getRunSpeed() ) );
|
||||
}
|
||||
|
||||
ExecuteActorAnimationState( HumanoidWalkBackward )
|
||||
{
|
||||
// Fetch Controller.
|
||||
VActorPhysicsController *physicsController = pObject->getPhysicsController();
|
||||
|
||||
// On the Ground?
|
||||
if ( physicsController->getPhysicsState() != VHumanoidActorData::k_OnGroundPhysics )
|
||||
{
|
||||
// Can't Run Backward.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Fetch Velocity.
|
||||
const VectorF &velocity = physicsController->getVelocity();
|
||||
// Determine Move Speed.
|
||||
const F32 moveSpeed = mSqrt( velocity.x * velocity.x + velocity.y * velocity.y );
|
||||
|
||||
// Moving Backward?
|
||||
return ( ( physicsController->getMoveState() & k_BackwardMove ) &&
|
||||
( moveSpeed < pObject->getDataBlock()->getRunSpeed() ) );
|
||||
}
|
||||
|
||||
ExecuteActorAnimationState( HumanoidRunForward )
|
||||
{
|
||||
// Fetch Controller.
|
||||
VActorPhysicsController *physicsController = pObject->getPhysicsController();
|
||||
|
||||
// On the Ground?
|
||||
if ( physicsController->getPhysicsState() != VHumanoidActorData::k_OnGroundPhysics )
|
||||
{
|
||||
// Can't Run Forward.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Fetch Velocity.
|
||||
const VectorF &velocity = physicsController->getVelocity();
|
||||
// Determine Move Speed.
|
||||
const F32 moveSpeed = mSqrt( velocity.x * velocity.x + velocity.y * velocity.y );
|
||||
|
||||
// Moving Forward?
|
||||
return ( ( physicsController->getMoveState() & k_ForwardMove ) &&
|
||||
( moveSpeed >= pObject->getDataBlock()->getRunSpeed() ) );
|
||||
}
|
||||
|
||||
ExecuteActorAnimationState( HumanoidRunBackward )
|
||||
{
|
||||
// Fetch Controller.
|
||||
VActorPhysicsController *physicsController = pObject->getPhysicsController();
|
||||
|
||||
// On the Ground?
|
||||
if ( physicsController->getPhysicsState() != VHumanoidActorData::k_OnGroundPhysics )
|
||||
{
|
||||
// Can't Run Backward.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Fetch Velocity.
|
||||
const VectorF &velocity = physicsController->getVelocity();
|
||||
// Determine Move Speed.
|
||||
const F32 moveSpeed = mSqrt( velocity.x * velocity.x + velocity.y * velocity.y );
|
||||
|
||||
// Moving Backward?
|
||||
return ( ( physicsController->getMoveState() & k_BackwardMove ) &&
|
||||
( moveSpeed >= pObject->getDataBlock()->getRunSpeed() ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// InWater Animation States
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ExecuteActorAnimationState( HumanoidSwimIdle )
|
||||
{
|
||||
// Fetch Controller.
|
||||
VActorPhysicsController *physicsController = pObject->getPhysicsController();
|
||||
|
||||
// In the Water?
|
||||
if ( physicsController->getPhysicsState() != VHumanoidActorData::k_InWaterPhysics )
|
||||
{
|
||||
// Can't Swim.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Idle?
|
||||
return ( physicsController->getMoveState() & k_NullMove );
|
||||
}
|
||||
|
||||
ExecuteActorAnimationState( HumanoidSwimForward )
|
||||
{
|
||||
// Fetch Controller.
|
||||
VActorPhysicsController *physicsController = pObject->getPhysicsController();
|
||||
|
||||
// In the Water?
|
||||
if ( physicsController->getPhysicsState() != VHumanoidActorData::k_InWaterPhysics )
|
||||
{
|
||||
// Can't Swim.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Moving Around?
|
||||
return ( physicsController->getMoveState() & ( k_ForwardMove |
|
||||
k_UpMove |
|
||||
k_DownMove ) );
|
||||
}
|
||||
|
||||
ExecuteActorAnimationState( HumanoidSwimBackward )
|
||||
{
|
||||
// Fetch Controller.
|
||||
VActorPhysicsController *physicsController = pObject->getPhysicsController();
|
||||
|
||||
// In the Water?
|
||||
if ( physicsController->getPhysicsState() != VHumanoidActorData::k_InWaterPhysics )
|
||||
{
|
||||
// Can't Swim.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Moving Backward?
|
||||
return ( physicsController->getMoveState() & k_BackwardMove );
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VHUMANOIDANIMATIONSTATES_H_
|
||||
#define _VT_VHUMANOIDANIMATIONSTATES_H_
|
||||
|
||||
#ifndef _VT_VACTORANIMATIONSTATES_H_
|
||||
#include "../VActorAnimationStates.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DeclareActorAnimationState( HumanoidIdle );
|
||||
|
||||
DeclareActorAnimationState( HumanoidWalkForward );
|
||||
DeclareActorAnimationState( HumanoidWalkBackward );
|
||||
|
||||
DeclareActorAnimationState( HumanoidRunForward );
|
||||
DeclareActorAnimationState( HumanoidRunBackward );
|
||||
|
||||
DeclareActorAnimationState( HumanoidSwimIdle );
|
||||
DeclareActorAnimationState( HumanoidSwimForward );
|
||||
DeclareActorAnimationState( HumanoidSwimBackward );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VHUMANOIDANIMATIONSTATES_H_
|
||||
113
Engine/source/Verve/VActor/Humanoid/VHumanoidPhysicsStates.cpp
Normal file
113
Engine/source/Verve/VActor/Humanoid/VHumanoidPhysicsStates.cpp
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "VHumanoidPhysicsStates.h"
|
||||
#include "VHumanoidActor.h"
|
||||
|
||||
#include "../VActorPhysicsController.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Implement Physics States.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ImplementActorPhysicsState( HumanoidOnGround, VHumanoidActorData::k_OnGroundPhysics );
|
||||
ImplementActorPhysicsState( HumanoidInAir, VHumanoidActorData::k_InAirPhysics );
|
||||
ImplementActorPhysicsState( HumanoidInWater, VHumanoidActorData::k_InWaterPhysics );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Execute Animation States.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ExecuteActorPhysicsState( HumanoidOnGround )
|
||||
{
|
||||
// Fetch Controller.
|
||||
VActorPhysicsController *physicsController = pObject->getPhysicsController();
|
||||
|
||||
// On the Ground?
|
||||
if ( !physicsController->isOnGround() )
|
||||
{
|
||||
// No.
|
||||
return false;
|
||||
}
|
||||
|
||||
// On Ground.
|
||||
return true;
|
||||
}
|
||||
|
||||
ProcessActorPhysicsState( HumanoidOnGround )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ExecuteActorPhysicsState( HumanoidInAir )
|
||||
{
|
||||
// Fetch Controller.
|
||||
VActorPhysicsController *physicsController = pObject->getPhysicsController();
|
||||
|
||||
// In the Air?
|
||||
if ( !physicsController->isInAir() )
|
||||
{
|
||||
// No.
|
||||
return false;
|
||||
}
|
||||
|
||||
// In Air.
|
||||
return true;
|
||||
}
|
||||
|
||||
ProcessActorPhysicsState( HumanoidInAir )
|
||||
{
|
||||
// Apply Gravity for the Tick.
|
||||
pObject->getPhysicsController()->applyGravity( pElapsedTime );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ExecuteActorPhysicsState( HumanoidInWater )
|
||||
{
|
||||
// Fetch Controller.
|
||||
VActorPhysicsController *physicsController = pObject->getPhysicsController();
|
||||
|
||||
// Sumberged?
|
||||
if ( !physicsController->isInWater() )
|
||||
{
|
||||
// No.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Swimming
|
||||
return true;
|
||||
}
|
||||
|
||||
ProcessActorPhysicsState( HumanoidInWater )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
38
Engine/source/Verve/VActor/Humanoid/VHumanoidPhysicsStates.h
Normal file
38
Engine/source/Verve/VActor/Humanoid/VHumanoidPhysicsStates.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VHUMANOIDPHYSICSSTATES_H_
|
||||
#define _VT_VHUMANOIDPHYSICSSTATES_H_
|
||||
|
||||
#ifndef _VT_VACTORPHYSICSSTATES_H_
|
||||
#include "../VActorPhysicsStates.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
DeclareActorPhysicsState( HumanoidOnGround );
|
||||
DeclareActorPhysicsState( HumanoidInAir );
|
||||
DeclareActorPhysicsState( HumanoidInWater );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VHUMANOIDPHYSICSSTATES_H_
|
||||
52
Engine/source/Verve/VActor/Types/VEnumerators.h
Normal file
52
Engine/source/Verve/VActor/Types/VEnumerators.h
Normal 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_ENUMERATORS_H_
|
||||
#define _VT_ENUMERATORS_H_
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
enum eMove
|
||||
{
|
||||
k_NullMove = 0,
|
||||
|
||||
k_ForwardMove = ( 1 << 0 ),
|
||||
k_BackwardMove = ( 1 << 1 ),
|
||||
k_LeftMove = ( 1 << 2 ),
|
||||
k_RightMove = ( 1 << 3 ),
|
||||
k_UpMove = ( 1 << 4 ),
|
||||
k_DownMove = ( 1 << 5 ),
|
||||
|
||||
k_XMove = ( k_LeftMove | k_RightMove ),
|
||||
k_YMove = ( k_ForwardMove | k_BackwardMove ),
|
||||
k_ZMove = ( k_UpMove | k_DownMove ),
|
||||
};
|
||||
|
||||
enum eControlState
|
||||
{
|
||||
k_NullControlState = 0,
|
||||
|
||||
k_PathControlState,
|
||||
k_GoToControlState,
|
||||
};
|
||||
|
||||
#endif // _VT_ENUMERATORS_H_
|
||||
55
Engine/source/Verve/VActor/Types/VRange.h
Normal file
55
Engine/source/Verve/VActor/Types/VRange.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Verve
|
||||
// Copyright (C) 2014 - Violent Tulip
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef _VT_TYPERANGE_H_
|
||||
#define _VT_TYPERANGE_H_
|
||||
|
||||
#ifndef _TORQUE_TYPES_H_
|
||||
#include "platform/types.h"
|
||||
#endif
|
||||
|
||||
class Range
|
||||
{
|
||||
public:
|
||||
|
||||
Range( void ) :
|
||||
Min( 0.f ),
|
||||
Max( 1.f ),
|
||||
Delta( 1.f )
|
||||
{
|
||||
// Void.
|
||||
};
|
||||
|
||||
Range( F32 pMin, F32 pMax ) :
|
||||
Min( pMin ),
|
||||
Max( pMax ),
|
||||
Delta( pMax - pMin )
|
||||
{
|
||||
// Void.
|
||||
};
|
||||
|
||||
F32 Min;
|
||||
F32 Max;
|
||||
F32 Delta;
|
||||
};
|
||||
|
||||
#endif // _VT_TYPERANGE_H_
|
||||
34
Engine/source/Verve/VActor/Types/VTypes.h
Normal file
34
Engine/source/Verve/VActor/Types/VTypes.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_TYPES_H_
|
||||
#define _VT_TYPES_H_
|
||||
|
||||
#ifndef _VT_ENUMERATORS_H_
|
||||
#include "VEnumerators.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TYPERANGE_H_
|
||||
#include "VRange.h"
|
||||
#endif
|
||||
|
||||
#endif // _VT_TYPES_H_
|
||||
232
Engine/source/Verve/VActor/VActor.cpp
Normal file
232
Engine/source/Verve/VActor/VActor.cpp
Normal file
|
|
@ -0,0 +1,232 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "VActor.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CO_NETOBJECT_V1( VActor );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VActor::VActor( void ) :
|
||||
mDataBlock( NULL )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
|
||||
VActor::~VActor( void )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Initialisation Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActor::onAdd();
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VActor::onAdd( void )
|
||||
{
|
||||
if ( !Parent::onAdd() || !mDataBlock )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add to Scene.
|
||||
addToScene();
|
||||
|
||||
if ( isServerObject() )
|
||||
{
|
||||
// Script Callback.
|
||||
scriptOnAdd();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActor::onRemove();
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VActor::onRemove( void )
|
||||
{
|
||||
// Script Callback.
|
||||
scriptOnRemove();
|
||||
|
||||
// Remove From Scene.
|
||||
removeFromScene();
|
||||
|
||||
Parent::onRemove();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActor::onNewDataBlock( pDataBlock );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VActor::onNewDataBlock( GameBaseData *pDataBlock, bool pReload )
|
||||
{
|
||||
// Store DataBlock Reference.
|
||||
mDataBlock = dynamic_cast<VActorData*>( pDataBlock );
|
||||
|
||||
if ( !mDataBlock )
|
||||
{
|
||||
// Invalid Data.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Parent Call.
|
||||
return Parent::onNewDataBlock( pDataBlock, pReload );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Update Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActor::processTick( pMove );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VActor::processTick( const Move *pMove )
|
||||
{
|
||||
// Parent Call.
|
||||
Parent::processTick( pMove );
|
||||
|
||||
// Triggers?
|
||||
if ( pMove && mDamageState == Enabled )
|
||||
{
|
||||
// Handle each Image Trigger.
|
||||
const U32 imageCount = getMin( ShapeBase::MaxMountedImages, MaxTriggerKeys );
|
||||
for ( U32 i = 0; i < imageCount; i++ )
|
||||
{
|
||||
setImageTriggerState( i, pMove->trigger[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActor::packUpdate( pConnection, pMask, pStream );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
U32 VActor::packUpdate( NetConnection *pConnection, U32 pMask, BitStream *pStream )
|
||||
{
|
||||
// Parent Call.
|
||||
return Parent::packUpdate( pConnection, pMask, pStream );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActor::unpackUpdate( pConnection, pStream );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VActor::unpackUpdate( NetConnection *pConnection, BitStream *pStream )
|
||||
{
|
||||
// Parent Call.
|
||||
Parent::unpackUpdate( pConnection, pStream );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Physics Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActor::setTransform( pMatrix );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VActor::setTransform( const MatrixF &pMatrix )
|
||||
{
|
||||
Parent::setTransform( pMatrix );
|
||||
|
||||
// Server Object?
|
||||
if ( isServerObject() )
|
||||
{
|
||||
// Move Object.
|
||||
setMaskBits( MoveMask );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActor::onMount( pObject, pNode );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VActor::onMount( SceneObject *pObject, S32 pNode )
|
||||
{
|
||||
// Parent Call.
|
||||
Parent::onMount( pObject, pNode );
|
||||
|
||||
// Post Event.
|
||||
mEventSignal.trigger( k_MountEvent );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActor::onUnmount( pObject, pNode );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VActor::onUnmount( SceneObject *pObject, S32 pNode )
|
||||
{
|
||||
// Parent Call.
|
||||
Parent::onUnmount( pObject, pNode );
|
||||
|
||||
// Post Event.
|
||||
mEventSignal.trigger( k_UnmountEvent );
|
||||
}
|
||||
116
Engine/source/Verve/VActor/VActor.h
Normal file
116
Engine/source/Verve/VActor/VActor.h
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VACTOR_H_
|
||||
#define _VT_VACTOR_H_
|
||||
|
||||
#ifndef _VT_VACTORDATA_H_
|
||||
#include "VActorData.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_TYPES_H_
|
||||
#include "Types/VTypes.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class VActorAnimationController;
|
||||
class VActorPhysicsController;
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VActor : public ShapeBase
|
||||
{
|
||||
typedef ShapeBase Parent;
|
||||
|
||||
public:
|
||||
|
||||
enum eMaskBits
|
||||
{
|
||||
// Physics Bits.
|
||||
MoveMask = Parent::NextFreeMask << 0,
|
||||
PhysicsMask = ( MoveMask ),
|
||||
|
||||
NextFreeMask = Parent::NextFreeMask << 1,
|
||||
};
|
||||
|
||||
enum eEventType
|
||||
{
|
||||
k_MountEvent,
|
||||
k_UnmountEvent,
|
||||
};
|
||||
|
||||
typedef Signal<void( const eEventType& )> tEventSignal;
|
||||
|
||||
protected:
|
||||
|
||||
VActorData *mDataBlock;
|
||||
|
||||
// Event Signal.
|
||||
tEventSignal mEventSignal;
|
||||
|
||||
public:
|
||||
|
||||
VActor( void );
|
||||
~VActor( void );
|
||||
|
||||
// Initialisation Methods.
|
||||
|
||||
bool onAdd( void );
|
||||
void onRemove( void );
|
||||
|
||||
bool onNewDataBlock( GameBaseData *pDataBlock, bool pReload );
|
||||
|
||||
// Update Methods.
|
||||
|
||||
virtual void processTick( const Move *pMove );
|
||||
|
||||
virtual U32 packUpdate( NetConnection *pConnection, U32 pMask, BitStream *pStream );
|
||||
virtual void unpackUpdate( NetConnection *pConnection, BitStream *pStream );
|
||||
|
||||
DECLARE_CONOBJECT( VActor );
|
||||
|
||||
public:
|
||||
|
||||
// Accessor Methods.
|
||||
|
||||
inline VActorData *getDataBlock( void ) { return mDataBlock; };
|
||||
inline tEventSignal &getEventSignal( void ) { return mEventSignal; };
|
||||
|
||||
// Animation Methods.
|
||||
|
||||
/// Get Animation Controller.
|
||||
virtual VActorAnimationController *getAnimationController( void ) { return NULL; };
|
||||
|
||||
// Physics Methods.
|
||||
|
||||
/// Set Transform.
|
||||
virtual void setTransform( const MatrixF &pMatrix );
|
||||
|
||||
/// Get Physics Controller.
|
||||
virtual VActorPhysicsController *getPhysicsController( void ) { return NULL; };
|
||||
|
||||
/// On Mount.
|
||||
virtual void onMount( SceneObject *pObject, S32 pNode );
|
||||
/// On Unmount.
|
||||
virtual void onUnmount( SceneObject *pObject, S32 pNode );
|
||||
};
|
||||
|
||||
#endif // _VT_VACTOR_H_
|
||||
354
Engine/source/Verve/VActor/VActorAnimationController.cpp
Normal file
354
Engine/source/Verve/VActor/VActorAnimationController.cpp
Normal file
|
|
@ -0,0 +1,354 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "VActorAnimationController.h"
|
||||
|
||||
#include "VActor.h"
|
||||
#include "VActorData.h"
|
||||
#include "VActorAnimationStates.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VActorAnimationController::VActorAnimationController( void ) :
|
||||
mObject( NULL )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
|
||||
VActorAnimationController::~VActorAnimationController( void )
|
||||
{
|
||||
// Clear Table.
|
||||
mAnimationTable.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Initialisation Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActorAnimationController::initAnimationTable();
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VActorAnimationController::initAnimationTable( void )
|
||||
{
|
||||
// Valid Object?
|
||||
if ( !isValidObject() )
|
||||
{
|
||||
// No, Quit Now.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clear the Table.
|
||||
mAnimationTable.clear();
|
||||
|
||||
// Fetch Sequence List.
|
||||
VActorData::tAnimationSequenceVector *sequenceList = getObject()->getDataBlock()->getAnimationList();
|
||||
|
||||
// Initialise the Animation States.
|
||||
for ( VActorData::tAnimationSequenceVector::iterator itr = sequenceList->begin();
|
||||
itr != sequenceList->end();
|
||||
itr++ )
|
||||
{
|
||||
// Fetch Sequence Definition.
|
||||
const VActorData::sAnimationSequence &animSequence = ( *itr );
|
||||
|
||||
// Valid State?
|
||||
if ( animSequence.State )
|
||||
{
|
||||
// Register Animation.
|
||||
mAnimationTable.registerState( animSequence.State, animSequence.Priority );
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the Table.
|
||||
mAnimationTable.sort();
|
||||
|
||||
// Valid.
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActorAnimationController::initAnimation( pThread, pIndex, pPosition, pTimeScale );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VActorAnimationController::initAnimation( sAnimationRef &pAnimation, const U32 &pIndex, const F32 &pPosition, const F32 &pTimeScale )
|
||||
{
|
||||
// Valid Object & Sequence?
|
||||
if ( !isValidObject() || !isAnimationSequence( pIndex ) )
|
||||
{
|
||||
// No, Quit Now.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Store as Current Animation.
|
||||
pAnimation.Index = pIndex;
|
||||
|
||||
// Initialise Thread.
|
||||
return initAnimationThread( pAnimation.Thread, pAnimation.Index, pPosition, pTimeScale );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActorAnimationController::initAnimationThread( pThread, pIndex, pPosition, pTimeScale );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VActorAnimationController::initAnimationThread( TSThread *&pThread, const U32 &pIndex, const F32 &pPosition, const F32 &pTimeScale )
|
||||
{
|
||||
// Valid Object & Sequence?
|
||||
if ( !isValidObject() || !isAnimationSequence( pIndex ) )
|
||||
{
|
||||
// No, Quit Now.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Valid Thread?
|
||||
if ( !pThread )
|
||||
{
|
||||
// Create a Thread.
|
||||
pThread = getShapeInstance()->addThread();
|
||||
}
|
||||
|
||||
// Init the Sequence.
|
||||
getShapeInstance()->setSequence( pThread, getAnimationSequence( pIndex ), pPosition );
|
||||
|
||||
// Set Initial Time Scale.
|
||||
getShapeInstance()->setTimeScale( pThread, pTimeScale );
|
||||
|
||||
// Valid.
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActorAnimationController::initBaseAnimation( pThread, pIndex, pPosition, pTimeScale );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VActorAnimationController::initBaseAnimation( const U32 &pIndex, const F32 &pPosition, const F32 &pTimeScale )
|
||||
{
|
||||
return initAnimation( mBaseAnimation, pIndex, pPosition, pTimeScale );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Accessor Methods.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActorAnimationController::isValidObject();
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VActorAnimationController::isValidObject( void )
|
||||
{
|
||||
return ( mObject != NULL && mObject->getDataBlock() != NULL );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActorAnimationController::getObject();
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
VActor *VActorAnimationController::getObject( void )
|
||||
{
|
||||
return mObject;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActorAnimationController::setObject( pObject );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VActorAnimationController::setObject( VActor *pObject )
|
||||
{
|
||||
// Set Object.
|
||||
mObject = pObject;
|
||||
|
||||
// Set Table's Reference.
|
||||
mAnimationTable.setObject( pObject );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActorAnimationController::getShape();
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
const TSShape *VActorAnimationController::getShape( void )
|
||||
{
|
||||
if ( !isValidObject() )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return mObject->getShape();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActorAnimationController::getShapeInstance();
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
TSShapeInstance *VActorAnimationController::getShapeInstance( void )
|
||||
{
|
||||
if ( !isValidObject() )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return mObject->getShapeInstance();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Animation Methods
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void VActorAnimationController::update( const F32 &pDelta )
|
||||
{
|
||||
// Valid Objects?
|
||||
if ( !isValidObject() )
|
||||
{
|
||||
// No, Quit Now.
|
||||
return;
|
||||
}
|
||||
|
||||
// Update Animation State.
|
||||
mAnimationTable.execute();
|
||||
|
||||
// Advance Threads.
|
||||
getShapeInstance()->advanceTime( pDelta, mBaseAnimation.Thread );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActorAnimationController::isAnimationSequence( pIndex );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool VActorAnimationController::isAnimationSequence( const U32 &pIndex )
|
||||
{
|
||||
return ( getAnimationSequence( pIndex ) != -1 );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActorAnimationController::getAnimationSequence( pIndex );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
S32 VActorAnimationController::getAnimationSequence( const U32 &pIndex )
|
||||
{
|
||||
// Valid Object?
|
||||
if ( !mObject || !mObject->getDataBlock() )
|
||||
{
|
||||
// No, Invalid Sequence.
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Return Sequence.
|
||||
return mObject->getDataBlock()->getAnimationSequence( pIndex );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActorAnimationController::getAnimation( pIndex );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
U32 VActorAnimationController::getAnimation( void )
|
||||
{
|
||||
// Base Animation Initialised?
|
||||
if ( !mBaseAnimation.Thread )
|
||||
{
|
||||
// Null.
|
||||
return U32_MAX;
|
||||
}
|
||||
|
||||
// Return Current Animation.
|
||||
return mBaseAnimation.Index;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// VActorAnimationController::setAnimation( pIndex );
|
||||
//
|
||||
// ...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void VActorAnimationController::setAnimation( const U32 &pIndex )
|
||||
{
|
||||
// Base Animation Initialised?
|
||||
if ( !mBaseAnimation.Thread || mBaseAnimation.Index == pIndex )
|
||||
{
|
||||
// Don't Update.
|
||||
return;
|
||||
}
|
||||
|
||||
// Store as Current Animation.
|
||||
mBaseAnimation.Index = pIndex;
|
||||
|
||||
// Fetch the Sequence.
|
||||
const S32 &sequence = getAnimationSequence( pIndex );
|
||||
|
||||
// Valid?
|
||||
if ( sequence != -1 )
|
||||
{
|
||||
// Play the Sequence.
|
||||
getShapeInstance()->transitionToSequence( mBaseAnimation.Thread, sequence, 0.f, 0.15f, true );
|
||||
//getShapeInstance()->setSequence( mBaseAnimation.Thread, sequence, 0.f );
|
||||
}
|
||||
}
|
||||
102
Engine/source/Verve/VActor/VActorAnimationController.h
Normal file
102
Engine/source/Verve/VActor/VActorAnimationController.h
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VACTORANIMATIONCONTROLLER_H_
|
||||
#define _VT_VACTORANIMATIONCONTROLLER_H_
|
||||
|
||||
#ifndef _VT_TYPES_H_
|
||||
#include "Types/VTypes.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VACTORSTATETABLE_H_
|
||||
#include "VActorStateTable.h"
|
||||
#endif
|
||||
|
||||
#ifndef _TSSHAPEINSTANCE_H_
|
||||
#include "ts/tsShapeInstance.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VActor;
|
||||
class VActorStateTable;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VActorAnimationController
|
||||
{
|
||||
public:
|
||||
|
||||
struct sAnimationRef
|
||||
{
|
||||
U32 Index;
|
||||
TSThread *Thread;
|
||||
|
||||
sAnimationRef( void ) :
|
||||
Index( U32_MAX ),
|
||||
Thread( NULL )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
VActor *mObject;
|
||||
|
||||
VActorStateTable mAnimationTable;
|
||||
sAnimationRef mBaseAnimation;
|
||||
|
||||
public:
|
||||
|
||||
VActorAnimationController( void );
|
||||
virtual ~VActorAnimationController( void );
|
||||
|
||||
// Initialisation Methods.
|
||||
|
||||
bool initAnimationTable( void );
|
||||
bool initAnimation( sAnimationRef &pAnimation, const U32 &pIndex, const F32 &pPosition, const F32 &pTimeScale );
|
||||
bool initAnimationThread( TSThread *&pThread, const U32 &pIndex, const F32 &pPosition, const F32 &pTimeScale );
|
||||
|
||||
bool initBaseAnimation( const U32 &pIndex, const F32 &pPosition, const F32 &pTimeScale );
|
||||
|
||||
// Accessor Methods.
|
||||
|
||||
bool isValidObject( void );
|
||||
VActor *getObject( void );
|
||||
void setObject( VActor *pObject );
|
||||
|
||||
const TSShape *getShape( void );
|
||||
TSShapeInstance *getShapeInstance( void );
|
||||
|
||||
// Animation Methods.
|
||||
|
||||
virtual void update( const F32 &pDelta );
|
||||
|
||||
bool isAnimationSequence( const U32 &pIndex );
|
||||
S32 getAnimationSequence( const U32 &pIndex );
|
||||
|
||||
U32 getAnimation( void );
|
||||
void setAnimation( const U32 &pIndex );
|
||||
};
|
||||
|
||||
#endif // _VT_VACTORANIMATIONCONTROLLER_H_
|
||||
64
Engine/source/Verve/VActor/VActorAnimationStates.h
Normal file
64
Engine/source/Verve/VActor/VActorAnimationStates.h
Normal 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_VACTORANIMATIONSTATES_H_
|
||||
#define _VT_VACTORANIMATIONSTATES_H_
|
||||
|
||||
#ifndef _VT_VACTORSTATETABLE_H_
|
||||
#include "VActorStateTable.h"
|
||||
#endif
|
||||
|
||||
#ifndef _TSINGLETON_H_
|
||||
#include "core/util/tSingleton.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VActorAnimationState : public VActorState
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void exit( VActor *pObject ) {};
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define DeclareActorAnimationState( name ) \
|
||||
class VActor##name##AnimationState : public VActorAnimationState \
|
||||
{ \
|
||||
public: \
|
||||
void enter( VActor *pObject ); \
|
||||
bool execute( VActor *pObject ); \
|
||||
}
|
||||
|
||||
#define ActorAnimationStateInstance( name ) \
|
||||
Singleton<VActor##name##AnimationState>::instance()
|
||||
|
||||
#define ImplementActorAnimationState( name, sequence ) \
|
||||
void VActor##name##AnimationState::enter( VActor *pObject ) { pObject->getAnimationController()->setAnimation( sequence ); }
|
||||
|
||||
#define ExecuteActorAnimationState( name ) \
|
||||
bool VActor##name##AnimationState::execute( VActor *pObject )
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VACTORANIMATIONSTATES_H_
|
||||
170
Engine/source/Verve/VActor/VActorData.cpp
Normal file
170
Engine/source/Verve/VActor/VActorData.cpp
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "VActorData.h"
|
||||
|
||||
#include "console/consoleTypes.h"
|
||||
#include "core/stream/bitStream.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IMPLEMENT_CO_DATABLOCK_V1( VActorData );
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
VActorData::VActorData( void ) :
|
||||
mMaxStepHeight( 1.f ),
|
||||
mRunSpeed( 6.f ),
|
||||
mSubmergeCoverage( 0.25f )
|
||||
{
|
||||
// Setup Shadowing.
|
||||
shadowEnable = true;
|
||||
shadowSize = 256;
|
||||
shadowProjectionDistance = 14.0f;
|
||||
|
||||
VECTOR_SET_ASSOCIATION( mAnimationSequenceList );
|
||||
VECTOR_SET_ASSOCIATION( mPhysicsList );
|
||||
}
|
||||
|
||||
VActorData::~VActorData( void )
|
||||
{
|
||||
// Void.
|
||||
}
|
||||
|
||||
void VActorData::initPersistFields( void )
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField( "MaxStepHeight", TypeF32, Offset( mMaxStepHeight, VActorData ) );
|
||||
addField( "RunSpeed", TypeF32, Offset( mRunSpeed, VActorData ) );
|
||||
|
||||
addField( "SubmergeCoverage", TypeF32, Offset( mSubmergeCoverage, VActorData ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool VActorData::initAnimationSequenceList( const S32 &pSize, const sAnimationSequence *pTable )
|
||||
{
|
||||
if ( !mShape )
|
||||
{
|
||||
// Sanity!
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clear the List.
|
||||
mAnimationSequenceList.clear();
|
||||
|
||||
// Initialise each Animation Sequence.
|
||||
for ( U32 i = 0; i < pSize; i++ )
|
||||
{
|
||||
// Fetch Sequence Definition.
|
||||
const sAnimationSequence &animSequenceDef = pTable[i];
|
||||
|
||||
// Update Animation Details.
|
||||
sAnimationSequence animSequence = animSequenceDef;
|
||||
// Find Sequence.
|
||||
animSequence.Sequence = mShape->findSequence( animSequenceDef.Name );
|
||||
|
||||
// Store.
|
||||
mAnimationSequenceList.push_back( animSequence );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VActorData::initAnimationTransitionList( const S32 &pSize, const sAnimationTransition *pTable )
|
||||
{
|
||||
if ( !mShape )
|
||||
{
|
||||
// Sanity!
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clear the List.
|
||||
mAnimationTransitionList.clear();
|
||||
|
||||
// Store each Animation Transition.
|
||||
for ( U32 i = 0; i < pSize; i++ )
|
||||
{
|
||||
// Store.
|
||||
mAnimationTransitionList.push_back( pTable[i] );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VActorData::initPhysicsStateList( const S32 &pSize, const sPhysicsState *pTable )
|
||||
{
|
||||
// Clear the List.
|
||||
mPhysicsList.clear();
|
||||
|
||||
// Initialise each Animation Sequence.
|
||||
for ( U32 i = 0; i < pSize; i++ )
|
||||
{
|
||||
// Store.
|
||||
mPhysicsList.push_back( pTable[i] );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void VActorData::packData( BitStream *pStream )
|
||||
{
|
||||
Parent::packData( pStream );
|
||||
|
||||
pStream->write( mMaxStepHeight );
|
||||
pStream->write( mRunSpeed );
|
||||
|
||||
pStream->write( mSubmergeCoverage );
|
||||
}
|
||||
|
||||
void VActorData::unpackData( BitStream *pStream )
|
||||
{
|
||||
Parent::unpackData( pStream );
|
||||
|
||||
pStream->read( &mMaxStepHeight );
|
||||
pStream->read( &mRunSpeed );
|
||||
|
||||
pStream->read( &mSubmergeCoverage );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
S32 VActorData::getAnimationSequence( const U32 &pIndex )
|
||||
{
|
||||
// Iterate over the Registered Animations.
|
||||
for ( tAnimationSequenceVector::iterator itr = mAnimationSequenceList.begin(); itr != mAnimationSequenceList.end(); itr++ )
|
||||
{
|
||||
// Fetch Sequence Defintion.
|
||||
const sAnimationSequence &animSequence = ( *itr );
|
||||
|
||||
// Target Index?
|
||||
if ( animSequence.Index == pIndex )
|
||||
{
|
||||
// Return Sequence ID.
|
||||
return animSequence.Sequence;
|
||||
}
|
||||
}
|
||||
|
||||
// Invalid Sequence.
|
||||
return -1;
|
||||
};
|
||||
132
Engine/source/Verve/VActor/VActorData.h
Normal file
132
Engine/source/Verve/VActor/VActorData.h
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VACTORDATA_H_
|
||||
#define _VT_VACTORDATA_H_
|
||||
|
||||
#ifndef _SHAPEBASE_H_
|
||||
#include "T3D/shapeBase.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class VActor;
|
||||
class VActorStateTable;
|
||||
class VActorAnimationState;
|
||||
class VActorPhysicsState;
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
struct VActorData : public ShapeBaseData
|
||||
{
|
||||
private:
|
||||
|
||||
typedef ShapeBaseData Parent;
|
||||
friend class VActor;
|
||||
|
||||
public:
|
||||
|
||||
// Animation Data.
|
||||
|
||||
enum eAnimationList
|
||||
{
|
||||
k_NextAnimation = 0,
|
||||
};
|
||||
|
||||
struct sAnimationSequence
|
||||
{
|
||||
U32 Index;
|
||||
const char *Name;
|
||||
F32 Priority;
|
||||
|
||||
VActorAnimationState *State;
|
||||
S32 Sequence;
|
||||
};
|
||||
|
||||
struct sAnimationTransition
|
||||
{
|
||||
U32 FromIndex;
|
||||
U32 ToIndex;
|
||||
|
||||
F32 Duration;
|
||||
|
||||
bool Ordered;
|
||||
U32 Sequence;
|
||||
};
|
||||
|
||||
typedef Vector<sAnimationSequence> tAnimationSequenceVector;
|
||||
typedef Vector<sAnimationTransition> tAnimationTransitionVector;
|
||||
|
||||
// Physics Data.
|
||||
|
||||
enum ePhysicsStateList
|
||||
{
|
||||
k_NextPhysicsState = 0,
|
||||
};
|
||||
|
||||
struct sPhysicsState
|
||||
{
|
||||
U32 Index;
|
||||
F32 Priority;
|
||||
|
||||
VActorPhysicsState *State;
|
||||
};
|
||||
typedef Vector<sPhysicsState> tPhysicsStateVector;
|
||||
|
||||
protected:
|
||||
|
||||
tAnimationSequenceVector mAnimationSequenceList;
|
||||
tAnimationTransitionVector mAnimationTransitionList;
|
||||
tPhysicsStateVector mPhysicsList;
|
||||
|
||||
F32 mMaxStepHeight;
|
||||
F32 mRunSpeed;
|
||||
|
||||
F32 mSubmergeCoverage;
|
||||
|
||||
public:
|
||||
|
||||
VActorData( void );
|
||||
~VActorData( void );
|
||||
|
||||
static void initPersistFields( void );
|
||||
|
||||
virtual bool initAnimationSequenceList( const S32 &pSize, const sAnimationSequence *pTable );
|
||||
virtual bool initAnimationTransitionList( const S32 &pSize, const sAnimationTransition *pTable );
|
||||
virtual bool initPhysicsStateList( const S32 &pSize, const sPhysicsState *pTable );
|
||||
|
||||
virtual void packData( BitStream *pStream );
|
||||
virtual void unpackData( BitStream *pStream );
|
||||
|
||||
DECLARE_CONOBJECT( VActorData );
|
||||
|
||||
public:
|
||||
|
||||
tAnimationSequenceVector *getAnimationList( void ) { return &mAnimationSequenceList; };
|
||||
S32 getAnimationSequence( const U32 &pIndex );
|
||||
|
||||
tPhysicsStateVector *getPhysicsStateList( void ) { return &mPhysicsList; };
|
||||
|
||||
inline const F32 &getMaxStepHeight( void ) const { return mMaxStepHeight; };
|
||||
inline const F32 &getRunSpeed( void ) const { return mRunSpeed; };
|
||||
inline const F32 &getSumbergeCoverage( void ) const { return mSubmergeCoverage; };
|
||||
};
|
||||
|
||||
#endif // _VT_VACTORDATA_H_
|
||||
1277
Engine/source/Verve/VActor/VActorPhysicsController.cpp
Normal file
1277
Engine/source/Verve/VActor/VActorPhysicsController.cpp
Normal file
File diff suppressed because it is too large
Load diff
160
Engine/source/Verve/VActor/VActorPhysicsController.h
Normal file
160
Engine/source/Verve/VActor/VActorPhysicsController.h
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VACTORPHYSICSCONTROLLER_H_
|
||||
#define _VT_VACTORPHYSICSCONTROLLER_H_
|
||||
|
||||
#ifndef _VT_TYPES_H_
|
||||
#include "Types/VTypes.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VACTORSTATETABLE_H_
|
||||
#include "VActorStateTable.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VACTOR_H_
|
||||
#include "VActor.h"
|
||||
#endif
|
||||
|
||||
#ifndef _VT_VINTERPCONTROLLER_H_
|
||||
#include "VInterpController.h"
|
||||
#endif
|
||||
|
||||
#ifndef _BOXCONVEX_H_
|
||||
#include "collision/boxConvex.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VPath;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VActorPhysicsController
|
||||
{
|
||||
protected:
|
||||
|
||||
SimObjectPtr<VActor> mObject;
|
||||
SimObjectPtr<VPath> mMountedPath;
|
||||
|
||||
VActorStateTable mPhysicsStateTable;
|
||||
|
||||
VInterpController mInterpController;
|
||||
|
||||
U32 mPhysicsState;
|
||||
U32 mControlState;
|
||||
U32 mMoveState;
|
||||
|
||||
OrthoBoxConvex mConvex;
|
||||
|
||||
VectorF mGravity;
|
||||
VectorF mVelocity;
|
||||
|
||||
bool mOnGround;
|
||||
SimObjectPtr<SceneObject> mGroundObject;
|
||||
VectorF mGroundNormal;
|
||||
|
||||
public:
|
||||
|
||||
VActorPhysicsController( void );
|
||||
virtual ~VActorPhysicsController( void );
|
||||
|
||||
// Initialisation Methods.
|
||||
|
||||
bool initPhysicsController( VActor *pObject );
|
||||
bool initPhysicsTable( void );
|
||||
|
||||
// Accessor Methods.
|
||||
|
||||
bool isValidObject( void );
|
||||
VActor *getObject( void );
|
||||
VActorData *getObjectDataBlock( void );
|
||||
void clearObject( void );
|
||||
|
||||
virtual const U32 getControlState( void );
|
||||
virtual void clearControlState( const U32 &pControlState );
|
||||
virtual void setControlState( const U32 &pControlState );
|
||||
|
||||
virtual const bool isMoving( void );
|
||||
virtual const bool isMoving( const U32 &pMoveState );
|
||||
virtual const U32 getMoveState( void );
|
||||
virtual void clearMoveState( const U32 &pMoveState );
|
||||
virtual void setMoveState( const U32 &pMoveState );
|
||||
|
||||
virtual const bool isPathing( void );
|
||||
virtual VPath *getPathObject( void );
|
||||
|
||||
virtual const bool isInWater( void );
|
||||
virtual WaterObject *getWaterObject( void );
|
||||
|
||||
virtual const bool isOnGround( void );
|
||||
virtual const bool isInAir( void );
|
||||
inline SceneObject *getGroundObject( void ) { return mGroundObject; };
|
||||
inline const VectorF &getGroundNormal( void ) { return mGroundNormal; };
|
||||
|
||||
inline const U32 &getPhysicsState( void ) { return mPhysicsState; };
|
||||
inline void setPhysicsState( const U32 &pState ) { mPhysicsState = pState; };
|
||||
|
||||
virtual MatrixF getTransform( void );
|
||||
virtual void setTransform( const MatrixF &pTransform );
|
||||
|
||||
virtual Point3F getPosition( void );
|
||||
virtual void setPosition( const Point3F &pPosition );
|
||||
|
||||
inline VectorF getGravity( void ) { return mGravity; };
|
||||
inline void setGravity( VectorF &pGravity ) { mGravity = pGravity; };
|
||||
virtual void applyGravity( const F32 &pElapsedTime );
|
||||
|
||||
virtual VectorF getVelocity( void );
|
||||
virtual void setVelocity( const VectorF &pVelocity );
|
||||
|
||||
// Physics Methods.
|
||||
|
||||
void update( const F32 &pDelta, const Move *pMove );
|
||||
|
||||
virtual void preTickUpdate( const F32 &pDelta );
|
||||
virtual void integrateTickUpdate( const F32 &pDelta, const Move *pMove );
|
||||
virtual void postTickUpdate( const F32 &pDelta );
|
||||
|
||||
void interpolateTick( const F32 &pDelta );
|
||||
|
||||
void updateWorkingCollisionSet( void );
|
||||
|
||||
void updateMoveState( void );
|
||||
|
||||
void clearGroundStatus( void );
|
||||
void updateGroundStatus( void );
|
||||
bool findGroundContact( SceneObject *&pContactObject, Point3F &pContactPoint, VectorF &pContactNormal );
|
||||
|
||||
void processCollisions( void );
|
||||
bool findCollision( Collision *&pCollision );
|
||||
void solveCollision( Collision *pCollision );
|
||||
|
||||
// Updates Methods.
|
||||
|
||||
void onActorEvent( const VActor::eEventType &pEvent );
|
||||
|
||||
U32 packUpdate( NetConnection *pConnection, U32 pMask, BitStream *pStream );
|
||||
void unpackUpdate( NetConnection *pConnection, BitStream *pStream );
|
||||
};
|
||||
|
||||
#endif // _VT_VACTORANIMATIONCONTROLLER_H_
|
||||
72
Engine/source/Verve/VActor/VActorPhysicsStates.h
Normal file
72
Engine/source/Verve/VActor/VActorPhysicsStates.h
Normal 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_VACTORPHYSICSSTATES_H_
|
||||
#define _VT_VACTORPHYSICSSTATES_H_
|
||||
|
||||
#ifndef _VT_VACTORSTATETABLE_H_
|
||||
#include "VActorStateTable.h"
|
||||
#endif
|
||||
|
||||
#ifndef _TSINGLETON_H_
|
||||
#include "core/util/tSingleton.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
struct Move;
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VActorPhysicsState : public VActorState
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void exit( VActor *pObject ) {};
|
||||
|
||||
virtual void processTick( VActor *pObject, const F32 &pElapsedTime, const Move *pMove ) = 0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define DeclareActorPhysicsState( name ) \
|
||||
class VActor##name##PhysicsState : public VActorPhysicsState \
|
||||
{ \
|
||||
public: \
|
||||
void enter( VActor *pObject ); \
|
||||
bool execute( VActor *pObject ); \
|
||||
void processTick( VActor *pObject, const F32 &pElapsedTime, const Move *pMove ); \
|
||||
}
|
||||
|
||||
#define ActorPhysicsStateInstance( name ) \
|
||||
Singleton<VActor##name##PhysicsState>::instance()
|
||||
|
||||
#define ImplementActorPhysicsState( name, state ) \
|
||||
void VActor##name##PhysicsState::enter( VActor *pObject ) { pObject->getPhysicsController()->setPhysicsState( state ); }
|
||||
|
||||
#define ExecuteActorPhysicsState( name ) \
|
||||
bool VActor##name##PhysicsState::execute( VActor *pObject )
|
||||
|
||||
#define ProcessActorPhysicsState( name ) \
|
||||
void VActor##name##PhysicsState::processTick( VActor *pObject, const F32 &pElapsedTime, const Move *pMove )
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif // _VT_VACTORPHYSICSSTATES_H_
|
||||
155
Engine/source/Verve/VActor/VActorStateTable.cpp
Normal file
155
Engine/source/Verve/VActor/VActorStateTable.cpp
Normal 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 "VActorStateTable.h"
|
||||
#include "VActor.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool VActorStateTable::isRegisteredState( VActorState *pState )
|
||||
{
|
||||
for ( tStateConstIterator itr = mStateVector.begin(); itr != mStateVector.end(); itr++ )
|
||||
{
|
||||
// Target State?
|
||||
if ( ( *itr ).State == pState )
|
||||
{
|
||||
// Yes.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// No.
|
||||
return false;
|
||||
}
|
||||
|
||||
void VActorStateTable::clear( void )
|
||||
{
|
||||
// Clear the States.
|
||||
mLastState = NULL;
|
||||
mCurrentState = NULL;
|
||||
|
||||
// Clear the State Vector.
|
||||
mStateVector.clear();
|
||||
};
|
||||
|
||||
void VActorStateTable::sort( void )
|
||||
{
|
||||
mStateVector.sort( &_onSortCallback );
|
||||
}
|
||||
|
||||
void VActorStateTable::registerState( VActorState *pState, const F32 &pPriority )
|
||||
{
|
||||
// Already a State?
|
||||
if ( isRegisteredState( pState ) )
|
||||
{
|
||||
// Exit Now.
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the Reference.
|
||||
sStateRef entry;
|
||||
entry.State = pState;
|
||||
entry.Priority = pPriority;
|
||||
|
||||
// Push to Back.
|
||||
mStateVector.push_back( entry );
|
||||
|
||||
// Set Current?
|
||||
if ( mStateVector.size() == 1 )
|
||||
{
|
||||
// Set State.
|
||||
setState( pState );
|
||||
}
|
||||
};
|
||||
|
||||
void VActorStateTable::setState( VActorState *pState )
|
||||
{
|
||||
if ( !mObject || !pState || pState == mCurrentState )
|
||||
{
|
||||
// Invalid.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( mCurrentState )
|
||||
{
|
||||
// Exit.
|
||||
exit();
|
||||
|
||||
// Exit the Old State.
|
||||
mCurrentState->exit( mObject );
|
||||
}
|
||||
|
||||
// Update States.
|
||||
mLastState = mCurrentState;
|
||||
mCurrentState = pState;
|
||||
|
||||
// Enter.
|
||||
enter();
|
||||
|
||||
// Enter the New State.
|
||||
pState->enter( mObject );
|
||||
};
|
||||
|
||||
VActorState *VActorStateTable::execute( void )
|
||||
{
|
||||
if ( !mObject || !mCurrentState )
|
||||
{
|
||||
// Invalid.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for ( tStateConstIterator itr = mStateVector.begin(); itr != mStateVector.end(); itr++ )
|
||||
{
|
||||
// Fetch State Reference.
|
||||
const sStateRef &stateRef = ( *itr );
|
||||
|
||||
// Enter State?
|
||||
if ( stateRef.State->execute( mObject ) )
|
||||
{
|
||||
// Set the State.
|
||||
setState( stateRef.State );
|
||||
|
||||
// Return.
|
||||
return stateRef.State;
|
||||
}
|
||||
}
|
||||
|
||||
// No Valid Entries, Ouch!
|
||||
Con::warnf( "VActorStateTable::execute() - No Valid Entries." );
|
||||
|
||||
// Return Current State.
|
||||
return mCurrentState;
|
||||
}
|
||||
|
||||
S32 QSORT_CALLBACK VActorStateTable::_onSortCallback( const VActorStateTable::sStateRef *pA, const VActorStateTable::sStateRef *pB )
|
||||
{
|
||||
if ( pB->Priority > pA->Priority )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if ( pB->Priority < pA->Priority )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
134
Engine/source/Verve/VActor/VActorStateTable.h
Normal file
134
Engine/source/Verve/VActor/VActorStateTable.h
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VACTORSTATETABLE_H_
|
||||
#define _VT_VACTORSTATETABLE_H_
|
||||
|
||||
#ifndef _TVECTOR_H
|
||||
#include "core/util/tVector.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class VActor;
|
||||
class VActorStateTable;
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VActorState
|
||||
{
|
||||
public:
|
||||
|
||||
VActorState( void ) { };
|
||||
virtual ~VActorState( void ) { };
|
||||
|
||||
virtual void enter( VActor *pObject ) = 0;
|
||||
virtual bool execute( VActor *pObject ) = 0;
|
||||
virtual void exit( VActor *pObject ) = 0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VActorStateTable
|
||||
{
|
||||
public:
|
||||
|
||||
struct sStateRef
|
||||
{
|
||||
VActorState *State;
|
||||
F32 Priority;
|
||||
};
|
||||
|
||||
typedef Vector<sStateRef> tStateVector;
|
||||
typedef tStateVector::iterator tStateIterator;
|
||||
typedef tStateVector::const_iterator tStateConstIterator;
|
||||
|
||||
protected:
|
||||
|
||||
tStateVector mStateVector;
|
||||
|
||||
VActor *mObject;
|
||||
|
||||
VActorState *mLastState;
|
||||
VActorState *mCurrentState;
|
||||
|
||||
public:
|
||||
|
||||
VActorStateTable( void ) :
|
||||
mObject( NULL ),
|
||||
mLastState( NULL ),
|
||||
mCurrentState( NULL )
|
||||
{
|
||||
VECTOR_SET_ASSOCIATION( mStateVector );
|
||||
};
|
||||
|
||||
virtual ~VActorStateTable( void )
|
||||
{
|
||||
// Clear Table.
|
||||
clear();
|
||||
};
|
||||
|
||||
void registerState( VActorState *pState, const F32 &pPriority = 0.5f );
|
||||
|
||||
virtual void enter( void ) { };
|
||||
virtual VActorState *execute( void );
|
||||
virtual void exit( void ) { };
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Gets
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
inline VActor *getObject( void ) { return mObject; };
|
||||
|
||||
bool isRegisteredState( VActorState *pState );
|
||||
|
||||
inline VActorState *getCurrentState( void ) { return mCurrentState; };
|
||||
inline VActorState *getLastState( void ) { return mLastState; };
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Sets
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
void clear( void );
|
||||
void sort( void );
|
||||
|
||||
inline void setObject( VActor *pObject ) { mObject = pObject; };
|
||||
void setState( VActorState *pState );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Accessors
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
tStateConstIterator begin( void ) const { return mStateVector.begin(); };
|
||||
tStateConstIterator end( void ) const { return mStateVector.end(); };
|
||||
S32 size( void ) const { return mStateVector.size(); };
|
||||
|
||||
protected:
|
||||
|
||||
static S32 QSORT_CALLBACK _onSortCallback( const VActorStateTable::sStateRef *pA, const VActorStateTable::sStateRef *pB );
|
||||
};
|
||||
|
||||
#endif // _VT_VACTORSTATETABLE_H_
|
||||
207
Engine/source/Verve/VActor/VInterpController.h
Normal file
207
Engine/source/Verve/VActor/VInterpController.h
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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_VINTERPCONTROLLER_H_
|
||||
#define _VT_VINTERPCONTROLLER_H_
|
||||
|
||||
#ifndef _MATH_H_
|
||||
#include "math/mMath.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class VInterpController
|
||||
{
|
||||
protected:
|
||||
|
||||
Point3F mPosition[2];
|
||||
QuatF mRotation[2];
|
||||
|
||||
public:
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Interpolation Methods.
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
/// Get Position.
|
||||
Point3F getPosition( const F32 &pDelta )
|
||||
{
|
||||
// Interpolate Position.
|
||||
Point3F interpPosition;
|
||||
interpPosition.interpolate( mPosition[1], mPosition[0], pDelta );
|
||||
// Return Interpolated Point.
|
||||
return interpPosition;
|
||||
};
|
||||
|
||||
/// Get Rotation.
|
||||
QuatF getRotation( const F32 &pDelta )
|
||||
{
|
||||
// Interpolate Rotation.
|
||||
QuatF interpRotation;
|
||||
interpRotation.interpolate( mRotation[1], mRotation[0], pDelta );
|
||||
// Return Interpolated Quat.
|
||||
return interpRotation;
|
||||
};
|
||||
|
||||
/// Get Transform.
|
||||
MatrixF getTransform( const F32 &pDelta )
|
||||
{
|
||||
// Get Position.
|
||||
const Point3F interpPosition = getPosition( pDelta );
|
||||
// Get Rotation.
|
||||
const QuatF interpRotation = getRotation( pDelta );
|
||||
|
||||
// Setup Matrix.
|
||||
MatrixF transform;
|
||||
interpRotation.setMatrix( &transform );
|
||||
// Set Position.
|
||||
transform.setPosition( interpPosition );
|
||||
|
||||
// Return Matrix.
|
||||
return transform;
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Delta Methods.
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
/// Reset Delta.
|
||||
void resetDelta( const Point3F &pPosition, const QuatF &pRotation )
|
||||
{
|
||||
mPosition[0] = mPosition[1] = pPosition;
|
||||
mRotation[0] = mRotation[1] = pRotation;
|
||||
};
|
||||
|
||||
/// Reset Delta.
|
||||
void resetDelta( const MatrixF &pMatrix )
|
||||
{
|
||||
// Setup Quat.
|
||||
QuatF rotationQuat( pMatrix );
|
||||
// Reset Delta.
|
||||
resetDelta( pMatrix.getPosition(), rotationQuat );
|
||||
};
|
||||
|
||||
/// Reset Delta (Vector)
|
||||
void resetDelta( const Point3F &pPosition, const VectorF &pForwardVector )
|
||||
{
|
||||
// Assert.
|
||||
AssertFatal( pForwardVector.isUnitLength(), "VInterpController::resetDelta() - Forward Vector hasn't been Normalized." );
|
||||
|
||||
// Static Up Vector.
|
||||
static const VectorF sUpVector( 0.f, 0.f, 1.f );
|
||||
|
||||
// X-Axis.
|
||||
VectorF xVec = mCross( pForwardVector, sUpVector );
|
||||
xVec.normalize();
|
||||
// Z-Axis.
|
||||
VectorF zVec = mCross( xVec, pForwardVector );
|
||||
zVec.normalize();
|
||||
|
||||
// Setup Object Transform.
|
||||
MatrixF transform;
|
||||
transform.setColumn( 0, xVec );
|
||||
transform.setColumn( 1, pForwardVector );
|
||||
transform.setColumn( 2, zVec );
|
||||
transform.setColumn( 3, pPosition );
|
||||
|
||||
// Reset Delta.
|
||||
resetDelta( transform );
|
||||
};
|
||||
|
||||
/// Reset Delta (AngAxis)
|
||||
void resetDelta( const Point3F &pPosition, const AngAxisF &pAngAxis )
|
||||
{
|
||||
// Setup Matrix.
|
||||
MatrixF transform;
|
||||
pAngAxis.setMatrix( &transform );
|
||||
// Set Position.
|
||||
transform.setPosition( pPosition );
|
||||
|
||||
// Reset Delta.
|
||||
resetDelta( transform );
|
||||
};
|
||||
|
||||
/// Push Delta.
|
||||
void pushDelta( const Point3F &pPosition, const QuatF &pRotation )
|
||||
{
|
||||
mPosition[1] = pPosition;
|
||||
mRotation[1] = pRotation;
|
||||
};
|
||||
|
||||
/// Push Delta (Matrix)
|
||||
void pushDelta( const MatrixF &pMatrix )
|
||||
{
|
||||
// Setup Quat.
|
||||
QuatF rotationQuat( pMatrix );
|
||||
// Push Delta.
|
||||
pushDelta( pMatrix.getPosition(), rotationQuat );
|
||||
};
|
||||
|
||||
/// Push Delta (Vector)
|
||||
void pushDelta( const Point3F &pPosition, const VectorF &pForwardVector )
|
||||
{
|
||||
// Assert.
|
||||
AssertFatal( pForwardVector.isUnitLength(), "VInterpController::pushDelta() - Forward Vector hasn't been Normalized." );
|
||||
|
||||
// Static Up Vector.
|
||||
static const VectorF sUpVector( 0.f, 0.f, 1.f );
|
||||
|
||||
// X-Axis.
|
||||
VectorF xVec = mCross( pForwardVector, sUpVector );
|
||||
xVec.normalize();
|
||||
// Z-Axis.
|
||||
VectorF zVec = mCross( xVec, pForwardVector );
|
||||
zVec.normalize();
|
||||
|
||||
// Setup Object Transform.
|
||||
MatrixF transform;
|
||||
transform.setColumn( 0, xVec );
|
||||
transform.setColumn( 1, pForwardVector );
|
||||
transform.setColumn( 2, zVec );
|
||||
transform.setColumn( 3, pPosition );
|
||||
|
||||
// Push Delta.
|
||||
pushDelta( transform );
|
||||
};
|
||||
|
||||
/// Push Delta (AngAxis)
|
||||
void pushDelta( const Point3F &pPosition, const AngAxisF &pAngAxis )
|
||||
{
|
||||
// Setup Matrix.
|
||||
MatrixF transform;
|
||||
pAngAxis.setMatrix( &transform );
|
||||
// Set Position.
|
||||
transform.setPosition( pPosition );
|
||||
|
||||
// Push Delta.
|
||||
pushDelta( transform );
|
||||
};
|
||||
|
||||
/// Pop Delta.
|
||||
void popDelta( void )
|
||||
{
|
||||
mPosition[0] = mPosition[1];
|
||||
mRotation[0] = mRotation[1];
|
||||
};
|
||||
};
|
||||
|
||||
#endif // _VT_VINTERPCONTROLLER_H_
|
||||
Loading…
Add table
Add a link
Reference in a new issue