2
Copyright (c) 2008-2009 NetAllied Systems GmbH
4
This file is part of COLLADAStreamWriter.
6
Licensed under the MIT Open Source License,
7
for details please see LICENSE file or the website
8
http://www.opensource.org/licenses/mit-license.php
11
#include "COLLADASWStreamWriter.h"
12
#include "COLLADASWLibraryAnimations.h"
13
#include "COLLADASWConstants.h"
14
#include "COLLADABUUtils.h"
19
const String LibraryAnimations::LINEAR_NAME = "LINEAR";
20
const String LibraryAnimations::BEZIER_NAME = "BEZIER";
21
const String LibraryAnimations::CARDINAL_NAME = "CARDINAL";
22
const String LibraryAnimations::HERMITE_NAME = "HERMITE";
23
const String LibraryAnimations::BSPLINE_NAME = "BSPLINE";
24
const String LibraryAnimations::TCB_NAME = "TCB";
25
const String LibraryAnimations::STEP_NAME = "STEP";
28
const String LibraryAnimations::INPUT_SOURCE_ID_SUFFIX = "-input";
29
const String LibraryAnimations::OUTPUT_SOURCE_ID_SUFFIX = "-output";
30
const String LibraryAnimations::INTANGENT_SOURCE_ID_SUFFIX = "-intangent";
31
const String LibraryAnimations::OUTTANGENT_SOURCE_ID_SUFFIX = "-outtangent";
32
const String LibraryAnimations::INTERPOLATION_SOURCE_ID_SUFFIX = "-interpolation";
33
const String LibraryAnimations::TCBS_SOURCE_ID_SUFFIX = "-tcbs";
34
const String LibraryAnimations::EASES_SOURCE_ID_SUFFIX = "-eases";
35
const String LibraryAnimations::ARRAY_ID_SUFFIX = "-array";
37
const String LibraryAnimations::SAMPLER_ID_SUFFIX = "-sampler";
40
//---------------------------------------------------------------
41
void Animation::openAnimation ( const String & id, const String & name )
43
// Open a <animation> element
44
mAnimationCloser = mSW->openElement ( CSWC::CSW_ELEMENT_ANIMATION );
46
// Write the id and the name, if they are set.
49
mSW->appendAttribute ( CSWC::CSW_ATTRIBUTE_ID, id );
52
mSW->appendAttribute ( CSWC::CSW_ATTRIBUTE_NAME, name );
56
//---------------------------------------------------------------
57
void Animation::closeAnimation()
59
mAnimationCloser.close();
62
//---------------------------------------------------------------
63
LibraryAnimations::LibraryAnimations ( COLLADASW::StreamWriter * streamWriter )
64
: Library ( streamWriter, CSWC::CSW_ELEMENT_LIBRARY_ANIMATIONS ), mOpenAnimations ( NULL )
67
//---------------------------------------------------------------
68
void LibraryAnimations::openAnimation ( const String& animationId, const String& animationName )
70
// Open the tag <library_animations> if it is not already open
73
Animation* animation = new Animation ( mSW );
74
animation->openAnimation ( animationId, animationName );
76
mOpenAnimations.push_back ( animation );
79
//---------------------------------------------------------------
80
void LibraryAnimations::closeAnimation()
82
Animation* animation = mOpenAnimations.back();
83
animation->closeAnimation();
86
// Erases the animation element from the list.
87
mOpenAnimations.pop_back();
90
//---------------------------------------------------------------
91
const String & LibraryAnimations::getNameOfInterpolation ( const InterpolationType & type )
103
return CARDINAL_NAME;
119
//---------------------------------------------------------------
120
void LibraryAnimations::addSampler ( const Sampler & sampler )
123
mSW->openElement ( CSWC::CSW_ELEMENT_SAMPLER );
124
mSW->appendAttribute ( CSWC::CSW_ATTRIBUTE_ID, sampler.getId() );
126
const InputList & inputList = sampler.getInputList();
133
//---------------------------------------------------------------
134
void LibraryAnimations::addChannel ( const URI& source, const String& target )
136
mSW->openElement ( CSWC::CSW_ELEMENT_CHANNEL );
137
mSW->appendURIAttribute ( CSWC::CSW_ATTRIBUTE_SOURCE, source );
138
mSW->appendAttribute ( CSWC::CSW_ATTRIBUTE_TARGET, target );
142
//---------------------------------------------------------------
143
void LibraryAnimations::Sampler::addInput ( InputSemantic::Semantics semantic, const URI& source )
145
Input input(semantic, source);
146
mInputList.push_back ( input );
149
//------------------------------
150
LibraryAnimations::Sampler::Sampler( StreamWriter * streamWriter, const String& id )
152
, mInputList(streamWriter)
157
} //namespace COLLADASW