VHumanoidActor.cpp
Engine/source/Verve/VActor/Humanoid/VHumanoidActor.cpp
Public Functions
Detailed Description
Public Functions
IMPLEMENT_CO_NETOBJECT_V1(VHumanoidActor )
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 "VHumanoidActor.h" 25 26#include "core/stream/bitStream.h" 27 28//----------------------------------------------------------------------------- 29IMPLEMENT_CO_NETOBJECT_V1( VHumanoidActor ); 30//----------------------------------------------------------------------------- 31 32VHumanoidActor::VHumanoidActor( void ) 33{ 34 // Void. 35} 36 37VHumanoidActor::~VHumanoidActor( void ) 38{ 39 // Void. 40} 41 42 43 44 45//----------------------------------------------------------------------------- 46// 47// Initialisation Methods. 48// 49//----------------------------------------------------------------------------- 50 51//----------------------------------------------------------------------------- 52// 53// VHumanoidActor::onNewDataBlock( pDataBlock ); 54// 55// ... 56// 57//----------------------------------------------------------------------------- 58bool VHumanoidActor::onNewDataBlock( GameBaseData *pDataBlock, bool pReload ) 59{ 60 // Store DataBlock Reference. 61 mDataBlock = dynamic_cast<VHumanoidActorData*>( pDataBlock ); 62 63 // Valid Data? 64 if ( !mDataBlock || !Parent::onNewDataBlock( pDataBlock, pReload ) ) 65 { 66 // Invalid Data. 67 return false; 68 } 69 70 // Initialise the Controllers. 71 if ( !initAnimationController() || !initPhysicsController() ) 72 { 73 // Invalid. 74 return false; 75 } 76 77 // Initialise the Base Animation Thread. 78 mAnimationController.initBaseAnimation( VHumanoidActorData::k_IdleAnimation, 0.f, 1.f ); 79 // Initialise the Arm Animation Thread. 80 mAnimationController.initArmAnimation( VHumanoidActorData::k_ArmsUpDownAnimation, 0.5f, 1.f ); 81 82 /* 83 // Initialise Head Threads. 84 initAnimationSequence( VHumanoidActorData::k_HeadHorizontalAnimation, mHeadAnimation.HThread, 0.5f ); 85 initAnimationSequence( VHumanoidActorData::k_HeadVerticalAnimation, mHeadAnimation.VThread, 0.5f ); 86 */ 87 88 // Valid Data. 89 return true; 90} 91 92 93 94 95//----------------------------------------------------------------------------- 96// 97// Update Methods. 98// 99//----------------------------------------------------------------------------- 100 101//----------------------------------------------------------------------------- 102// 103// VHumanoidActor::processTick( pMove ); 104// 105// ... 106// 107//----------------------------------------------------------------------------- 108void VHumanoidActor::processTick( const Move *pMove ) 109{ 110 // Parent Call. 111 Parent::processTick( pMove ); 112 113 // Update Physics. 114 mPhysicsController.update( TickSec, pMove ); 115 116 // Update Container. 117 updateContainer(); 118} 119 120//----------------------------------------------------------------------------- 121// 122// VHumanoidActor::interpolateTick( pDelta ); 123// 124// ... 125// 126//----------------------------------------------------------------------------- 127void VHumanoidActor::interpolateTick( F32 pDelta ) 128{ 129 // Parent Call. 130 Parent::interpolateTick( pDelta ); 131 132 // Update Physics. 133 mPhysicsController.interpolateTick( pDelta ); 134} 135 136//----------------------------------------------------------------------------- 137// 138// VHumanoidActor::advanceTime( pDelta ); 139// 140// ... 141// 142//----------------------------------------------------------------------------- 143void VHumanoidActor::advanceTime( F32 pDelta ) 144{ 145 // Parent Call. 146 Parent::advanceTime( pDelta ); 147 148 // Valid Animation Controller? 149 if ( getAnimationController() ) 150 { 151 // Update Animations. 152 getAnimationController()->update( pDelta ); 153 } 154} 155 156//----------------------------------------------------------------------------- 157// 158// VHumanoidActor::packUpdate( pConnection, pMask, pStream ); 159// 160// ... 161// 162//----------------------------------------------------------------------------- 163U32 VHumanoidActor::packUpdate( NetConnection *pConnection, U32 pMask, BitStream *pStream ) 164{ 165 // Parent Call. 166 U32 retMask = Parent::packUpdate( pConnection, pMask, pStream ); 167 168 // Physics Controller? 169 if ( pStream->writeFlag( pMask & PhysicsMask ) ) 170 { 171 // Pack Physics. 172 retMask &= mPhysicsController.packUpdate( pConnection, pMask, pStream ); 173 } 174 175 return retMask; 176} 177 178//----------------------------------------------------------------------------- 179// 180// VHumanoidActor::unpackUpdate( pConnection, pStream ); 181// 182// ... 183// 184//----------------------------------------------------------------------------- 185void VHumanoidActor::unpackUpdate( NetConnection *pConnection, BitStream *pStream ) 186{ 187 // Parent Call. 188 Parent::unpackUpdate( pConnection, pStream ); 189 190 // Physics Controller? 191 if ( pStream->readFlag() ) 192 { 193 // Unpack Physics. 194 mPhysicsController.unpackUpdate( pConnection, pStream ); 195 } 196} 197 198 199 200 201//----------------------------------------------------------------------------- 202// 203// Animation Methods. 204// 205//----------------------------------------------------------------------------- 206 207//----------------------------------------------------------------------------- 208// 209// VHumanoidActor::initAnimationController(); 210// 211// ... 212// 213//----------------------------------------------------------------------------- 214bool VHumanoidActor::initAnimationController( void ) 215{ 216 // Reference Object. 217 mAnimationController.setObject( this ); 218 // Initialise. 219 return mAnimationController.initAnimationTable(); 220} 221 222//----------------------------------------------------------------------------- 223// 224// VHumanoidActor::getAnimationController(); 225// 226// ... 227// 228//----------------------------------------------------------------------------- 229VActorAnimationController *VHumanoidActor::getAnimationController( void ) 230{ 231 return &mAnimationController; 232} 233 234 235 236 237//----------------------------------------------------------------------------- 238// 239// VHumanoidActor::initPhysicsController(); 240// 241// ... 242// 243//----------------------------------------------------------------------------- 244bool VHumanoidActor::initPhysicsController( void ) 245{ 246 // Initialise. 247 return mPhysicsController.initPhysicsController( this ); 248} 249 250//----------------------------------------------------------------------------- 251// 252// VHumanoidActor::getAnimationController(); 253// 254// ... 255// 256//----------------------------------------------------------------------------- 257VActorPhysicsController *VHumanoidActor::getPhysicsController( void ) 258{ 259 return &mPhysicsController; 260} 261