afxAnimClip.cpp
Engine/source/afx/ce/afxAnimClip.cpp
Public Defines
define
myOffset(field) (field, )
Public Functions
ConsoleDocClass(afxAnimClipData , "@brief A datablock that specifies an Animation Clip <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">effect.\n\n</a>" "An Animation Clip forces <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> target <a href="/coding/class/classshapebase/">ShapeBase</a>-derived object, such as <a href="/coding/class/classplayer/">Player</a> or AIPlayer, <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> perform <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> particular " "animation sequence. Animation Clip does not supply any <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> animation data, but simply selects, by name, <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> " "sequence that is already defined in the target. Animation Clip can also target <a href="/coding/class/classafxmodel/">afxModel</a> effects within the same " "choreographer." "\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "The target of an Animation Clip is the constraint <a href="/coding/file/pointer_8h/#pointer_8h_1adb82dfe18535e9a30aa97d275f82bd55">source</a> object specified by the posConstraint field of the enclosing " "effect wrapper. The target must be <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/class/classshapebase/">ShapeBase</a>-derived object, or an <a href="/coding/class/classafxmodel/">afxModel</a> and it must contain an animation " "sequence with the same name as the clipName field." "\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "Animation Clip controls the rate of animation playback and can even play <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> sequence in reverse. When an Animation " "Clip selects <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> blended animation sequence, it is mixed with the current animation instead of replacing it. Animation " "Clips can be used <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> activate multiple, overlapping blend sequences." "\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "Normally when an Animation Clip is applied <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> user-controlled Player, any interactive user actions will override the " "animation selected by the clip, but Animation Clips can be configured <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> temporarily block out some user actions <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> " "the duration of the clip." "\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">afxEffects\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">AFX\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Datablocks\n</a>" )
Detailed Description
Public Defines
myOffset(field) (field, )
Public Functions
ConsoleDocClass(afxAnimClipData , "@brief A datablock that specifies an Animation Clip <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">effect.\n\n</a>" "An Animation Clip forces <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> target <a href="/coding/class/classshapebase/">ShapeBase</a>-derived object, such as <a href="/coding/class/classplayer/">Player</a> or AIPlayer, <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> perform <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> particular " "animation sequence. Animation Clip does not supply any <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> animation data, but simply selects, by name, <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> " "sequence that is already defined in the target. Animation Clip can also target <a href="/coding/class/classafxmodel/">afxModel</a> effects within the same " "choreographer." "\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "The target of an Animation Clip is the constraint <a href="/coding/file/pointer_8h/#pointer_8h_1adb82dfe18535e9a30aa97d275f82bd55">source</a> object specified by the posConstraint field of the enclosing " "effect wrapper. The target must be <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/class/classshapebase/">ShapeBase</a>-derived object, or an <a href="/coding/class/classafxmodel/">afxModel</a> and it must contain an animation " "sequence with the same name as the clipName field." "\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "Animation Clip controls the rate of animation playback and can even play <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> sequence in reverse. When an Animation " "Clip selects <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> blended animation sequence, it is mixed with the current animation instead of replacing it. Animation " "Clips can be used <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> activate multiple, overlapping blend sequences." "\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "Normally when an Animation Clip is applied <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> user-controlled Player, any interactive user actions will override the " "animation selected by the clip, but Animation Clips can be configured <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> temporarily block out some user actions <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> " "the duration of the clip." "\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">afxEffects\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">AFX\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Datablocks\n</a>" )
IMPLEMENT_CO_DATABLOCK_V1(afxAnimClipData )
1 2 3//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 4// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames 5// Copyright (C) 2015 Faust Logic, Inc. 6// 7// Permission is hereby granted, free of charge, to any person obtaining a copy 8// of this software and associated documentation files (the "Software"), to 9// deal in the Software without restriction, including without limitation the 10// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 11// sell copies of the Software, and to permit persons to whom the Software is 12// furnished to do so, subject to the following conditions: 13// 14// The above copyright notice and this permission notice shall be included in 15// all copies or substantial portions of the Software. 16// 17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23// IN THE SOFTWARE. 24// 25//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 26 27#include "afx/arcaneFX.h" 28 29#include "console/consoleTypes.h" 30#include "core/stream/bitStream.h" 31 32#include "afx/ce/afxAnimClip.h" 33 34//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 35// afxAnimClipData 36 37IMPLEMENT_CO_DATABLOCK_V1(afxAnimClipData); 38 39ConsoleDocClass( afxAnimClipData, 40 "@brief A datablock that specifies an Animation Clip effect.\n\n" 41 42 "An Animation Clip forces a target ShapeBase-derived object, such as Player or AIPlayer, to perform a particular " 43 "animation sequence. Animation Clip does not supply any new animation data, but simply selects, by name, a " 44 "sequence that is already defined in the target. Animation Clip can also target afxModel effects within the same " 45 "choreographer." 46 "\n\n" 47 48 "The target of an Animation Clip is the constraint source object specified by the posConstraint field of the enclosing " 49 "effect wrapper. The target must be a ShapeBase-derived object, or an afxModel and it must contain an animation " 50 "sequence with the same name as the clipName field." 51 "\n\n" 52 53 "Animation Clip controls the rate of animation playback and can even play a sequence in reverse. When an Animation " 54 "Clip selects a blended animation sequence, it is mixed with the current animation instead of replacing it. Animation " 55 "Clips can be used to activate multiple, overlapping blend sequences." 56 "\n\n" 57 58 "Normally when an Animation Clip is applied to a user-controlled Player, any interactive user actions will override the " 59 "animation selected by the clip, but Animation Clips can be configured to temporarily block out some user actions for " 60 "the duration of the clip." 61 "\n\n" 62 63 "@ingroup afxEffects\n" 64 "@ingroup AFX\n" 65 "@ingroup Datablocks\n" 66); 67 68afxAnimClipData::afxAnimClipData() 69{ 70 clip_name = ST_NULLSTRING; 71 rate = 1.0f; 72 pos_offset = 0.0; 73 trans = 0.12f; 74 flags = 0; 75 76 ignore_disabled = false; 77 ignore_enabled = false; 78 is_death_anim = false; 79 lock_anim = false; 80 ignore_first_person = false; 81 ignore_third_person = false; 82} 83 84afxAnimClipData::afxAnimClipData(const afxAnimClipData& other, bool temp_clone) : GameBaseData(other, temp_clone) 85{ 86 clip_name = other.clip_name; 87 rate = other.rate; 88 pos_offset = other.pos_offset; 89 trans = other.trans; 90 flags = other.flags; 91 92 expand_flags(); 93} 94 95void afxAnimClipData::onStaticModified(const char* slot, const char* newValue) 96{ 97 Parent::onStaticModified(slot, newValue); 98 merge_flags(); 99} 100 101#define myOffset(field) Offset(field, afxAnimClipData) 102 103void afxAnimClipData::initPersistFields() 104{ 105 addField("clipName", TYPEID< StringTableEntry >(), myOffset(clip_name), 106 "The name of an animation sequence to be played by a ShapeBase-derived object to which this effect is " 107 "constrained. Also works on afxModel effects.\n" 108 "default: \"\"\n"); 109 addField("rate", TYPEID< F32 >(), myOffset(rate), 110 "The desired playback speed for the sequence. A value of 1.0 indicates forward playback at a normal rate. Negative " 111 "values cause the sequence to play backwards.\n" 112 "default: 1.0\n"); 113 addField("posOffset", TYPEID< F32 >(), myOffset(pos_offset), 114 "Sets a starting offset for the selected animation clip. It directly specifies an animation thread position in the 0.0 to " 115 "1.0 range as a fraction of the clip's duration.\n" 116 "default: 1.0\n"); 117 addField("transitionTime", TYPEID< F32 >(), myOffset(trans), 118 "The duration in which the active animation overlaps and blends into the sequence selected by the animation clip.\n" 119 "default: 0.12\n"); 120 addField("ignoreCorpse", TYPEID< bool >(), myOffset(ignore_disabled), 121 "Specifies if the animation clip should not be applied to corpses or anything else with a disabled damage state.\n" 122 "default: false\n"); 123 addField("ignoreLiving", TYPEID< bool >(), myOffset(ignore_enabled), 124 "Specifies if the animation clip should not be applied to living objects or anything else with an enabled damage " 125 "state.\n" 126 "default: false\n"); 127 addField("treatAsDeathAnim", TYPEID< bool >(), myOffset(is_death_anim), 128 "Indicates if the animation clip is a death animation. If the target object dies during the effect, this will prevent " 129 "the object from playing another standard death animation after this clip finishes.\n" 130 "default: false\n"); 131 addField("lockAnimation", TYPEID< bool >(), myOffset(lock_anim), 132 "Indicates if user control of a Player should be temporarily blocked during the clip. (See afxAnimLockData.)\n" 133 "default: false\n"); 134 addField("ignoreFirstPerson", TYPEID< bool >(), myOffset(ignore_first_person), 135 "If true, the clip will not be played on targets that are the control object and the camera is in first person mode.\n" 136 "default: false\n"); 137 addField("ignoreThirdPerson", TYPEID< bool >(), myOffset(ignore_third_person), 138 "If true, the clip will not be played on targets that are the control object and the camera is in third person mode.\n" 139 "default: false\n"); 140 141 // synonyms 142 addField("ignoreDisabled", TYPEID< bool >(), myOffset(ignore_disabled), 143 "A synonym for ignoreLiving."); 144 addField("ignoreEnabled", TYPEID< bool >(), myOffset(ignore_enabled), 145 "A synonym for ignoreCorpse."); 146 147 Parent::initPersistFields(); 148} 149 150bool afxAnimClipData::onAdd() 151{ 152 if (Parent::onAdd() == false) 153 return false; 154 155 return true; 156} 157 158void afxAnimClipData::packData(BitStream* stream) 159{ 160 Parent::packData(stream); 161 162 merge_flags(); 163 164 stream->writeString(clip_name); 165 stream->write(rate); 166 stream->write(pos_offset); 167 stream->write(trans); 168 stream->write(flags); 169} 170 171void afxAnimClipData::unpackData(BitStream* stream) 172{ 173 Parent::unpackData(stream); 174 175 clip_name = stream->readSTString(); 176 stream->read(&rate); 177 stream->read(&pos_offset); 178 stream->read(&trans); 179 stream->read(&flags); 180 181 expand_flags(); 182} 183 184bool afxAnimClipData::writeField(StringTableEntry fieldname, const char* value) 185{ 186 if (!Parent::writeField(fieldname, value)) 187 return false; 188 189 // don't write the synonyms 190 if( fieldname == StringTable->insert("ignoreDisabled") ) 191 return false; 192 if( fieldname == StringTable->insert("ignoreEnabled") ) 193 return false; 194 195 return true; 196} 197 198void afxAnimClipData::expand_flags() 199{ 200 ignore_disabled = ((flags & IGNORE_DISABLED) != 0); 201 ignore_enabled = ((flags & IGNORE_ENABLED) != 0); 202 lock_anim = ((flags & BLOCK_USER_CONTROL) != 0); 203 is_death_anim = ((flags & IS_DEATH_ANIM) != 0); 204 ignore_first_person = ((flags & IGNORE_FIRST_PERSON) != 0); 205 ignore_third_person = ((flags & IGNORE_THIRD_PERSON) != 0); 206} 207 208void afxAnimClipData::merge_flags() 209{ 210 flags = (((ignore_disabled) ? IGNORE_DISABLED : 0) | 211 ((ignore_enabled) ? IGNORE_ENABLED : 0) | 212 ((lock_anim) ? BLOCK_USER_CONTROL : 0) | 213 ((ignore_first_person) ? IGNORE_FIRST_PERSON : 0) | 214 ((ignore_third_person) ? IGNORE_THIRD_PERSON : 0) | 215 ((is_death_anim) ? IS_DEATH_ANIM : 0)); 216} 217 218//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 219