Torque3D Documentation / _generateds / colladaAppSequence.cpp

colladaAppSequence.cpp

Engine/source/ts/collada/colladaAppSequence.cpp

More...

Detailed Description

 1
 2//-----------------------------------------------------------------------------
 3// Copyright (c) 2012 GarageGames, LLC
 4//
 5// Permission is hereby granted, free of charge, to any person obtaining a copy
 6// of this software and associated documentation files (the "Software"), to
 7// deal in the Software without restriction, including without limitation the
 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 9// sell copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21// IN THE SOFTWARE.
22//-----------------------------------------------------------------------------
23
24#include "platform/platform.h"
25
26#include "ts/collada/colladaExtensions.h"
27#include "ts/collada/colladaAppSequence.h"
28
29
30ColladaAppSequence::ColladaAppSequence(const domAnimation_clip* clip)
31   : pClip(clip), clipExt(new ColladaExtension_animation_clip(clip))
32{
33   seqStart = pClip->getStart();
34   seqEnd = pClip->getEnd();
35}
36
37ColladaAppSequence::~ColladaAppSequence()
38{
39   delete clipExt;
40}
41
42const char* ColladaAppSequence::getName() const
43{
44   return _GetNameOrId(pClip);
45}
46
47S32 ColladaAppSequence::getNumTriggers()
48{
49   return clipExt->triggers.size();
50}
51
52void ColladaAppSequence::getTrigger(S32 index, TSShape::Trigger& trigger)
53{
54   trigger.pos = clipExt->triggers[index].time;
55   trigger.state = clipExt->triggers[index].state;
56}
57
58U32 ColladaAppSequence::getFlags() const
59{
60   U32 flags = 0;
61   if (clipExt->cyclic) flags |= TSShape::Cyclic;
62   if (clipExt->blend)  flags |= TSShape::Blend;
63   return flags;
64}
65
66F32 ColladaAppSequence::getPriority()
67{
68   return clipExt->priority;
69}
70
71F32 ColladaAppSequence::getBlendRefTime()
72{
73   return clipExt->blendReferenceTime;
74}
75
76void ColladaAppSequence::setActive(bool active)
77{
78   for (S32 iAnim = 0; iAnim < getClip()->getInstance_animation_array().getCount(); iAnim++) {
79      domAnimation* anim = daeSafeCast<domAnimation>(getClip()->getInstance_animation_array()[iAnim]->getUrl().getElement());
80      if (anim)
81         setAnimationActive(anim, active);
82   }
83}
84
85void ColladaAppSequence::setAnimationActive(const domAnimation* anim, bool active)
86{
87   // Enabled/disable data channels for this animation
88   for (S32 iChannel = 0; iChannel < anim->getChannel_array().getCount(); iChannel++) {
89      domChannel* channel = anim->getChannel_array()[iChannel];
90      AnimData* animData = reinterpret_cast<AnimData*>(channel->getUserData());
91      if (animData)
92         animData->enabled = active;
93   }
94
95   // Recurse into child animations
96   for (S32 iAnim = 0; iAnim < anim->getAnimation_array().getCount(); iAnim++)
97      setAnimationActive(anim->getAnimation_array()[iAnim], active);
98}
99