Torque3D Documentation / _generateds / VHumanoidActorData.cpp

VHumanoidActorData.cpp

Engine/source/Verve/VActor/Humanoid/VHumanoidActorData.cpp

More...

Detailed Description

Public Variables

VActorData::sAnimationSequence animSequenceLookup []
VActorData::sPhysicsState physStateLookup []

Public Functions

IMPLEMENT_CO_DATABLOCK_V1(VHumanoidActorData )

 1
 2//-----------------------------------------------------------------------------
 3// Verve
 4// Copyright (C) 2014 - Violent Tulip
 5//
 6// Permission is hereby granted, free of charge, to any person obtaining a copy
 7// of this software and associated documentation files (the "Software"), to
 8// deal in the Software without restriction, including without limitation the
 9// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10// sell copies of the Software, and to permit persons to whom the Software is
11// furnished to do so, subject to the following conditions:
12//
13// The above copyright notice and this permission notice shall be included in
14// all copies or substantial portions of the Software.
15//
16// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22// IN THE SOFTWARE.
23//-----------------------------------------------------------------------------
24#include "VHumanoidActorData.h"
25#include "VHumanoidAnimationStates.h"
26#include "VHumanoidPhysicsStates.h"
27
28//-----------------------------------------------------------------------------
29// Animation Table.
30//-----------------------------------------------------------------------------
31
32static VActorData::sAnimationSequence animSequenceLookup[] =
33    {
34        // State Based Animations.
35        { VHumanoidActorData::k_IdleAnimation,           "root",     0.0f, ActorAnimationStateInstance( HumanoidIdle )         },
36
37        { VHumanoidActorData::k_WalkForwardAnimation,    "walk",     0.1f, ActorAnimationStateInstance( HumanoidWalkForward )  },
38        { VHumanoidActorData::k_WalkBackwardAnimation,   "walkback", 0.1f, ActorAnimationStateInstance( HumanoidWalkBackward ) },
39
40        { VHumanoidActorData::k_RunForwardAnimation,     "run",      0.1f, ActorAnimationStateInstance( HumanoidRunForward )   },
41        { VHumanoidActorData::k_RunBackwardAnimation,    "runback",  0.1f, ActorAnimationStateInstance( HumanoidRunBackward )  },
42
43        { VHumanoidActorData::k_SwimIdleAnimation,       "swimroot", 1.0f, ActorAnimationStateInstance( HumanoidSwimIdle )     },
44        { VHumanoidActorData::k_SwimForwardAnimation,    "swim",     1.0f, ActorAnimationStateInstance( HumanoidSwimForward )  },
45        { VHumanoidActorData::k_SwimBackwardAnimation,   "swimback", 1.0f, ActorAnimationStateInstance( HumanoidSwimBackward ) },
46
47        // Support Animations.
48        { VHumanoidActorData::k_HeadHorizontalAnimation, "headside" },
49        { VHumanoidActorData::k_HeadVerticalAnimation,   "head"     },
50
51        { VHumanoidActorData::k_ArmsUpDownAnimation,     "look"     },
52    };
53
54//-----------------------------------------------------------------------------
55// Physics Table.
56//-----------------------------------------------------------------------------
57
58static VActorData::sPhysicsState physStateLookup[] =
59    {
60        { VHumanoidActorData::k_OnGroundPhysics, 0.f, ActorPhysicsStateInstance( HumanoidOnGround ) },
61        { VHumanoidActorData::k_InAirPhysics,    0.f, ActorPhysicsStateInstance( HumanoidInAir )    },
62        { VHumanoidActorData::k_InWaterPhysics,  0.f, ActorPhysicsStateInstance( HumanoidInWater )  },
63    };
64
65//-----------------------------------------------------------------------------
66IMPLEMENT_CO_DATABLOCK_V1( VHumanoidActorData );
67//-----------------------------------------------------------------------------
68
69VHumanoidActorData::VHumanoidActorData( void )
70{
71    // Void.
72};
73
74bool VHumanoidActorData::preload( bool pServer, String &pErrorStr )
75{
76    if ( !Parent::preload( pServer, pErrorStr ) )
77    {
78        return false;
79    }
80
81    // Initialise Animation List.
82    if ( !initAnimationSequenceList( sizeof( animSequenceLookup ) /  sizeof( VActorData::sAnimationSequence ), &animSequenceLookup[0] ) )
83    {
84        Con::errorf( "VHumanoidActorData::preload() - Failed to Initialise Actor Animations." );
85        return false;
86    }
87
88    // Initialise Physics State List.
89    if ( !initPhysicsStateList( sizeof( physStateLookup ) /  sizeof( VActorData::sPhysicsState ), &physStateLookup[0] ) )
90    {
91        Con::errorf( "VHumanoidActorData::preload() - Failed to Initialise Actor Physics States." );
92        return false;
93    }
94
95    // Valid Load.
96    return true;
97}
98