mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 16:25:42 +00:00
(Mostly) updated verve implementation.
This commit is contained in:
parent
775ca57047
commit
87ee749801
538 changed files with 68727 additions and 49 deletions
259
Engine/modules/Verve/VActor/Humanoid/VHumanoidActor.cpp
Normal file
259
Engine/modules/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/modules/Verve/VActor/Humanoid/VHumanoidActor.h
Normal file
84
Engine/modules/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/modules/Verve/VActor/Humanoid/VHumanoidActorData.cpp
Normal file
96
Engine/modules/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/modules/Verve/VActor/Humanoid/VHumanoidActorData.h
Normal file
81
Engine/modules/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_
|
||||
|
|
@ -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/modules/Verve/VActor/Humanoid/VHumanoidPhysicsStates.cpp
Normal file
113
Engine/modules/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.
|
||||
}
|
||||
|
|
@ -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_
|
||||
Loading…
Add table
Add a link
Reference in a new issue