GlsAnimation Library  1.0.6
Provides classes and functions to support animating GL Studio objects programmatically or with script files
Namespaces | Data Structures | Typedefs | Functions | Variables
disti Namespace Reference

Namespaces

 Detail
 

Data Structures

class  GlsAnimation
 Base class for all animations. More...
 
class  GlsAnimationCollection
 Contains a set of animations that are played in parallel with the SetKey() method. More...
 
class  GlsAnimationJuggler
 A class used to schedule and manage multiple animations. More...
 
class  GlsAnimationObserver
 
class  GlsAnimationObserverBase
 
class  GlsAnimationReversalAdapter
 
class  GlsAnimationSubsetAdapter
 
struct  GlsBackEaseInInterpolator
 
struct  GlsBackEaseInOutInterpolator
 
struct  GlsBackEaseOutInterpolator
 
struct  GlsBounceEaseInInterpolator
 
struct  GlsBounceEaseInOutInterpolator
 
struct  GlsBounceEaseOutInterpolator
 
struct  GlsCircularEaseInInterpolator
 
struct  GlsCircularEaseInOutInterpolator
 
struct  GlsCircularEaseOutInterpolator
 
struct  GlsColorInterpolationAdapter
 
struct  GlsCubicEaseInInterpolator
 
struct  GlsCubicEaseInOutInterpolator
 
struct  GlsCubicEaseOutInterpolator
 
struct  GlsElasticEaseInInterpolator
 
struct  GlsElasticEaseInOutInterpolator
 
struct  GlsElasticEaseOutInterpolator
 
struct  GlsExponentialEaseInInterpolator
 
struct  GlsExponentialEaseInOutInterpolator
 
struct  GlsExponentialEaseOutInterpolator
 
struct  GlsGatedInterpolator
 
class  GlsKeyframeAnimation
 
class  GlsKeyframeCurve
 Class template for keyframe curves of different types (double, Vector, etc.) More...
 
class  GlsKeyframeCurveBase
 Base class for the keyframe curve class template. More...
 
struct  GlsKeyframeInterpolator
 An abstract base class for all keyframe interpolators. More...
 
struct  GlsLinearInterpolator
 
struct  GlsQuadraticEaseInInterpolator
 
struct  GlsQuadraticEaseInOutInterpolator
 
struct  GlsQuadraticEaseOutInterpolator
 
struct  GlsQuarticEaseInInterpolator
 
struct  GlsQuarticEaseInOutInterpolator
 
struct  GlsQuarticEaseOutInterpolator
 
struct  GlsQuinticEaseInInterpolator
 
struct  GlsQuinticEaseInOutInterpolator
 
struct  GlsQuinticEaseOutInterpolator
 
struct  GlsSinusoidalEaseInInterpolator
 
struct  GlsSinusoidalEaseInOutInterpolator
 
struct  GlsSinusoidalEaseOutInterpolator
 
struct  GlsSphericalLinearInterpolator
 
struct  GlsSphericalLinearInterpolator< GlsQuaternionD >
 Implementation of GlsSphericalLinearInterpolator for quaternions. More...
 
struct  GlsSphericalLinearInterpolator< Vector >
 

Typedefs

typedef GlsAnimationReversalAdapter GlsAnimationReverser
 Alias for backwards compatibility. More...
 

Functions

void SetGlsAnimationParentChildRelationship (DisplayObject *parent, DisplayObject *child)
 Establishes a parent-child relationship like that in Adobe After Effects that does not exist in the GL Studio geometry hierarchy and should not be introduced there because that hierarchy was created and may need to be recreated programmatically (e.g., by importing a PSD file). More...
 
void DumpResourceNames (DisplayFrame *const displayFrame, std::ostream &stream)
 
GlsAnimation::Ptr LoadAnimationScript (const std::string &filename)
 Loads an animation sequence from a script file. More...
 
std::vector< GlsAnimation::PtrLoadAnimationZip (const std::string &filename)
 Loads a set of animation sequences from a zip file. More...
 
template<class Value >
GlsKeyframeInterpolator< Value >::Ptr CreateInterpolator (const std::string &name, typename Detail::enable_if< !Detail::is_same2< Value, glsColor, std::string >::value >::type *=0)
 
template<class Value >
GlsKeyframeInterpolator< Value >::Ptr CreateInterpolator (const std::string &name, typename Detail::enable_if< Detail::is_same< Value, glsColor >::value >::type *=0)
 
template<class Value >
GlsKeyframeInterpolator< Value >::Ptr CreateInterpolator (const std::string &name, typename Detail::enable_if< Detail::is_same< Value, std::string >::value >::type *=0)
 
template<class Value >
GlsKeyframeCurve< Value >::Ptr CreateTweenerCurve (const Value &begin, const Value &end, const GlsAnimation::Key &duration, const std::string &tweenerName)
 
template<class Fn >
GlsAnimationObserverBase::Ptr CreateOnStartedCallback (const Fn &fn)
 
template<class Fn >
GlsAnimationObserverBase::Ptr CreateOnUpdatedCallback (const Fn &fn)
 
template<class Fn >
GlsAnimationObserverBase::Ptr CreateOnCompletedCallback (const Fn &fn)
 

Variables

const std::string g_linearInterpTag = "linear"
 Linear interpolator tag. More...
 
const std::string g_gatedInterpTag = "gated"
 Gated interpolator tag. More...
 
const std::string g_slerpTag = "slerp"
 Spherical Linear Interpolation tag (only supported by Vector and Quaternion) More...
 
const std::string g_quadInTag = "quadraticIn"
 Quadratic In interpolator tag. More...
 
const std::string g_quadOutTag = "quadraticOut"
 Quadratic Out interpolator tag. More...
 
const std::string g_quadInOUtTag = "quadraticInAndOut"
 Quadratic In and Out interpolator tag. More...
 
const std::string g_cubeInTag = "cubicIn"
 Cubic In interpolator tag. More...
 
const std::string g_cubeOutTag = "cubicOut"
 Cubic Out interpolator tag. More...
 
const std::string g_cubeInOutTag = "cubicInAndOut"
 Cubic In and Out interpolator tag. More...
 
const std::string g_quartInTag = "quarticIn"
 Quartic In interpolator tag. More...
 
const std::string g_quartOutTag = "quarticOut"
 Quartic Out interpolator tag. More...
 
const std::string g_quartInOutTag = "quarticInAndOut"
 Quartic In and Out interpolator tag. More...
 
const std::string g_quintInTag = "quinticIn"
 Quintic In interpolator tag. More...
 
const std::string g_quintOutTag = "quinticOut"
 Quintic Out interpolator tag. More...
 
const std::string g_quintInOutTag = "quinticInAndOut"
 Quintic In and Out interpolator tag. More...
 
const std::string g_sinInTag = "sinusoidalIn"
 Sinusoidal In interpolator tag. More...
 
const std::string g_sinOutTag = "sinusoidalOut"
 Sinusoidal Out interpolator tag. More...
 
const std::string g_sinInOutTag = "sinusoidalInAndOut"
 Sinusoidal In and Out interpolator tag. More...
 
const std::string g_expoInTag = "exponentIn"
 Exponent In interpolator tag. More...
 
const std::string g_expoOutTag = "exponentOut"
 Exponent Out interpolator tag. More...
 
const std::string g_expoInOutTag = "exponentInAndOut"
 Exponent In and Out interpolator tag. More...
 
const std::string g_circleInTag = "circularIn"
 Circular In interpolator tag. More...
 
const std::string g_circleOutTag = "circularOut"
 Circular Out interpolator tag. More...
 
const std::string g_circleInOutTag = "circularInAndOut"
 Circular In and Out interpolator tag. More...
 
const std::string g_elasticInTag = "elasticIn"
 Elastic In interpolator tag. More...
 
const std::string g_elasticOutTag = "elasticOut"
 Elastic Out interpolator tag. More...
 
const std::string g_elasticInOutTag = "elasticInAndOut"
 Elastic In and Out interpolator tag. More...
 
const std::string g_bounceInTag = "bounceIn"
 Bounce In interpolator tag. More...
 
const std::string g_bounceOutTag = "bounceOut"
 Bounce Out interpolator tag. More...
 
const std::string g_bounceInOutTag = "bounceInAndOut"
 Bounce In and Out interpolator tag. More...
 
const std::string g_backInTag = "backIn"
 Back In interpolator tag. More...
 
const std::string g_backOutTag = "backOut"
 Back Out interpolator tag. More...
 
const std::string g_backInOutTag = "backInAndOut"
 Back In and Out interpolator tag. More...
 

Typedef Documentation

Alias for backwards compatibility.

Definition at line 485 of file gls_animation.h.

Function Documentation

template<class Value >
GlsKeyframeInterpolator<Value>::Ptr disti::CreateInterpolator ( const std::string &  name,
typename Detail::enable_if< !Detail::is_same2< Value, glsColor, std::string >::value >::type *  = 0 
)

Create a curve animation

Parameters
nameThe name of the curve to create.
Returns
The interpolator. Null if the interpolator name was not recognized.
Note
The unnamed parameter allows for type overloading via SFINAE. See documentation for std::enable_if.

Definition at line 788 of file gls_animation.h.

789  {
790  if( name.empty() )
791  {
792  return typename GlsKeyframeInterpolator<Value>::Ptr( new typename Detail::DefaultInterpolator<Value>::Type() );
793  }
794  else if( name == g_linearInterpTag )
795  {
796  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsLinearInterpolator<Value>() );
797  }
798  else if( name == g_gatedInterpTag )
799  {
800  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsGatedInterpolator<Value>() );
801  }
802  else if( name == g_slerpTag )
803  {
804  return Detail::CreateSlerp<Value>();
805  }
806  else if( name == g_quadInTag )
807  {
808  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuadraticEaseInInterpolator<Value>() );
809  }
810  else if( name == g_quadOutTag )
811  {
812  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuadraticEaseOutInterpolator<Value>() );
813  }
814  else if( name == g_quadInOUtTag )
815  {
816  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuadraticEaseInOutInterpolator<Value>() );
817  }
818  else if( name == g_cubeInTag )
819  {
820  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsCubicEaseInInterpolator<Value>() );
821  }
822  else if( name == g_cubeOutTag )
823  {
824  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsCubicEaseOutInterpolator<Value>() );
825  }
826  else if( name == g_cubeInOutTag )
827  {
828  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsCubicEaseInOutInterpolator<Value>() );
829  }
830  else if( name == g_quartInTag )
831  {
832  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuarticEaseInInterpolator<Value>() );
833  }
834  else if( name == g_quartOutTag )
835  {
836  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuarticEaseOutInterpolator<Value>() );
837  }
838  else if( name == g_quartInOutTag )
839  {
840  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuarticEaseInOutInterpolator<Value>() );
841  }
842  else if( name == g_quintInTag )
843  {
844  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuinticEaseInInterpolator<Value>() );
845  }
846  else if( name == g_quintOutTag )
847  {
848  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuinticEaseOutInterpolator<Value>() );
849  }
850  else if( name == g_quintInOutTag )
851  {
852  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsQuinticEaseInOutInterpolator<Value>() );
853  }
854  else if( name == g_sinInTag )
855  {
856  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsSinusoidalEaseInInterpolator<Value>() );
857  }
858  else if( name == g_sinOutTag )
859  {
860  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsSinusoidalEaseOutInterpolator<Value>() );
861  }
862  else if( name == g_sinInOutTag )
863  {
864  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsSinusoidalEaseInOutInterpolator<Value>() );
865  }
866  else if( name == g_expoInTag )
867  {
868  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsExponentialEaseInInterpolator<Value>() );
869  }
870  else if( name == g_expoOutTag )
871  {
872  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsExponentialEaseOutInterpolator<Value>() );
873  }
874  else if( name == g_expoInOutTag )
875  {
876  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsExponentialEaseInOutInterpolator<Value>() );
877  }
878  else if( name == g_circleInTag )
879  {
880  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsCircularEaseInInterpolator<Value>() );
881  }
882  else if( name == g_circleOutTag )
883  {
884  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsCircularEaseOutInterpolator<Value>() );
885  }
886  else if( name == g_circleInOutTag )
887  {
888  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsCircularEaseInOutInterpolator<Value>() );
889  }
890  else if( name == g_elasticInTag )
891  {
892  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsElasticEaseInInterpolator<Value>() );
893  }
894  else if( name == g_elasticOutTag )
895  {
896  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsElasticEaseOutInterpolator<Value>() );
897  }
898  else if( name == g_elasticInOutTag )
899  {
900  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsElasticEaseInOutInterpolator<Value>() );
901  }
902  else if( name == g_bounceInTag )
903  {
904  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsBounceEaseInInterpolator<Value>() );
905  }
906  else if( name == g_bounceOutTag )
907  {
908  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsBounceEaseOutInterpolator<Value>() );
909  }
910  else if( name == g_bounceInOutTag )
911  {
912  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsBounceEaseInOutInterpolator<Value>() );
913  }
914  else if( name == g_backInTag )
915  {
916  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsBackEaseInInterpolator<Value>() );
917  }
918  else if( name == g_backOutTag )
919  {
920  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsBackEaseOutInterpolator<Value>() );
921  }
922  else if( name == g_backInOutTag )
923  {
924  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsBackEaseInOutInterpolator<Value>() );
925  }
926 
927  std::cerr << "GlsAnimation: Unreqcognized interpolator requested: " << name << ".\n";
928  return typename GlsKeyframeInterpolator<Value>::Ptr();
929  }
const std::string g_circleInTag
Circular In interpolator tag.
const std::string g_expoInOutTag
Exponent In and Out interpolator tag.
const std::string g_expoOutTag
Exponent Out interpolator tag.
const std::string g_quadOutTag
Quadratic Out interpolator tag.
const std::string g_cubeOutTag
Cubic Out interpolator tag.
const std::string g_cubeInTag
Cubic In interpolator tag.
const std::string g_elasticInTag
Elastic In interpolator tag.
const std::string g_quartInOutTag
Quartic In and Out interpolator tag.
const std::string g_quintOutTag
Quintic Out interpolator tag.
const std::string g_linearInterpTag
Linear interpolator tag.
const std::string g_quartInTag
Quartic In interpolator tag.
const std::string g_sinInTag
Sinusoidal In interpolator tag.
const std::string g_quintInTag
Quintic In interpolator tag.
const std::string g_cubeInOutTag
Cubic In and Out interpolator tag.
const std::string g_bounceInTag
Bounce In interpolator tag.
const std::string g_gatedInterpTag
Gated interpolator tag.
const std::string g_quartOutTag
Quartic Out interpolator tag.
const std::string g_expoInTag
Exponent In interpolator tag.
const std::string g_sinInOutTag
Sinusoidal In and Out interpolator tag.
const std::string g_bounceOutTag
Bounce Out interpolator tag.
const std::string g_backOutTag
Back Out interpolator tag.
const std::string g_quadInOUtTag
Quadratic In and Out interpolator tag.
const std::string g_sinOutTag
Sinusoidal Out interpolator tag.
const std::string g_quintInOutTag
Quintic In and Out interpolator tag.
const std::string g_backInOutTag
Back In and Out interpolator tag.
const std::string g_slerpTag
Spherical Linear Interpolation tag (only supported by Vector and Quaternion)
stdortr1::shared_ptr< GlsKeyframeInterpolator > Ptr
Alias for easier reading.
Definition: gls_keyframe.h:166
const std::string g_elasticInOutTag
Elastic In and Out interpolator tag.
const std::string g_backInTag
Back In interpolator tag.
const std::string g_circleOutTag
Circular Out interpolator tag.
const std::string g_elasticOutTag
Elastic Out interpolator tag.
const std::string g_circleInOutTag
Circular In and Out interpolator tag.
const std::string g_bounceInOutTag
Bounce In and Out interpolator tag.
const std::string g_quadInTag
Quadratic In interpolator tag.
template<class Value >
GlsKeyframeInterpolator<Value>::Ptr disti::CreateInterpolator ( const std::string &  name,
typename Detail::enable_if< Detail::is_same< Value, glsColor >::value >::type *  = 0 
)

Overload for colors which creates a double interpolator of the given interpolation name and then wraps it in a GlsColorInterpolationAdapter.

Parameters
nameThe name of the interpolator.
Returns
The interpolator. Null if the interpolator name was not recognized.
See also
GlsColorInterpolationAdapter

Definition at line 938 of file gls_animation.h.

939  {
940  typename GlsKeyframeInterpolator<double>::Ptr interpolator = CreateInterpolator<double>( name );
941  if( !interpolator )
942  {
943  return typename GlsKeyframeInterpolator<Value>::Ptr();
944  }
945  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsColorInterpolationAdapter( interpolator ) );
946  }
stdortr1::shared_ptr< GlsKeyframeInterpolator > Ptr
Alias for easier reading.
Definition: gls_keyframe.h:166
template<class Value >
GlsKeyframeInterpolator<Value>::Ptr disti::CreateInterpolator ( const std::string &  name,
typename Detail::enable_if< Detail::is_same< Value, std::string >::value >::type *  = 0 
)

Overload for strings

Parameters
nameThe name of the interpolator. (Note: only gated is supported for strings.)
Returns
The interpolator. Null if the interpolator name was not recognized.
Note
Prints a message to the console if an interpolator other than gated is requested.
The unnamed parameter allows for type overloading via SFINAE. See documentation for std::enable_if.

Definition at line 955 of file gls_animation.h.

956  {
957  if( !name.empty() && name != g_gatedInterpTag )
958  {
959  std::cerr << "LoadAnimationScript(): Strings may only use gated interpolation, not " << name << ".\n";
960  }
961  return typename GlsKeyframeInterpolator<Value>::Ptr( new GlsGatedInterpolator<Value>() );
962  }
const std::string g_gatedInterpTag
Gated interpolator tag.
stdortr1::shared_ptr< GlsKeyframeInterpolator > Ptr
Alias for easier reading.
Definition: gls_keyframe.h:166
template<class Fn >
GlsAnimationObserverBase::Ptr disti::CreateOnCompletedCallback ( const Fn &  fn)

Helper function to ease creation of an "on updated" callback with function pointers and functors; see CreateOnStartedCallback() for more details.

Definition at line 237 of file gls_animation_observer.h.

238  {
239  void(*dummy)( GlsAnimationObserverBase::ID ) = 0;
240  return GlsAnimationObserverBase::Ptr( new GlsAnimationObserver( dummy, dummy, fn ) );
241  }
unsigned int ID
Type for unique identifiers.
Definition: gls_keyframe.h:100
template<class Fn >
GlsAnimationObserverBase::Ptr disti::CreateOnStartedCallback ( const Fn &  fn)

Helper function to ease creation of an "on started" callback only with function pointers and functors. The wrapped object should have a signature equivalent to void(ID). (Usually the result of this function is passed directly to the animation juggler's scheduling function.)

For example:

// Wrap a function pointer to a stand-alone function: void MyFunc( GlsAnimationJuggler::ID );
auto callback1 = CreateOnStartedCallback( &MyFunc );
// Wrap a member function call in a C++11 Lambda
auto callback2 = CreateOnStartedCallback( [=]( ID id ) { myObj->DoSomething( id ); } );
// Wrap a member function call in a TR1 bind function for pre-C++11 code; can also use std::mem_fn
GlsAnimationObserverBase::Ptr callback3 = CreateOnStartedCallback( std::bind( &MyClass::DoSomething, myObj, std::placeholders::_1 ) );
See also
GlsAnimationJuggler::Schedule()

Definition at line 217 of file gls_animation_observer.h.

218  {
219  void(*dummy)( GlsAnimationObserverBase::ID ) = 0;
220  return GlsAnimationObserverBase::Ptr( new GlsAnimationObserver( fn, dummy, dummy ) );
221  }
unsigned int ID
Type for unique identifiers.
Definition: gls_keyframe.h:100
template<class Fn >
GlsAnimationObserverBase::Ptr disti::CreateOnUpdatedCallback ( const Fn &  fn)

Helper function to ease creation of an "on updated" callback with function pointers and functors; see CreateOnStartedCallback() for more details.

Definition at line 227 of file gls_animation_observer.h.

228  {
229  void(*dummy)( GlsAnimationObserverBase::ID ) = 0;
230  return GlsAnimationObserverBase::Ptr( new GlsAnimationObserver( dummy, fn, dummy ) );
231  }
unsigned int ID
Type for unique identifiers.
Definition: gls_keyframe.h:100
template<class Value >
GlsKeyframeCurve<Value>::Ptr disti::CreateTweenerCurve ( const Value &  begin,
const Value &  end,
const GlsAnimation::Key duration,
const std::string &  tweenerName 
)

Create a "tweener" animation

Parameters
beginThe beginning keyframe's value
endThe ending keyframe's value
durationThe difference between the beginning and ending keys
tweenerNameThe name of the interpolator function.
Returns
The tweener curve. Null if the tweener name was not recognized.
Precondition
duration > 0

Definition at line 973 of file gls_animation.h.

974  {
975  DistiAssert( Detail::FloatGreaterThan( duration, 0.0 ) );
976  const typename GlsKeyframeInterpolator<Value>::Ptr interpolator = CreateInterpolator<Value>( tweenerName );
977  if( !interpolator )
978  {
979  return typename GlsKeyframeCurve<Value>::Ptr();
980  }
981  typename GlsKeyframeCurve<Value>::Ptr curve( new GlsKeyframeCurve<Value>( interpolator ) );
982  curve->AddKeyframe( 0, begin );
983  curve->AddKeyframe( duration, end );
984  return curve;
985  }
bool FloatGreaterThan(const double lhs, const double rhs, const float tolerance=g_glsAnimationFloatTolerance)
Definition: gls_keyframe.h:128
stdortr1::shared_ptr< GlsKeyframeInterpolator > Ptr
Alias for easier reading.
Definition: gls_keyframe.h:166
void disti::DumpResourceNames ( DisplayFrame *  displayFrame,
std::ostream &  stream 
)

Writes all resource names in a given display frame to the given stream

Parameters
displayFrameThe displayFrame to query
streamThe stream to write to.
Precondition
displayFrame != 0

Definition at line 739 of file gls_animation.cpp.

740  {
741  DistiAssert( displayFrame );
742  GlsResourceFilter filter;
743  filter.NamesOnly( true );
744  filter.GroupLevelsDown( -1 );
745  displayFrame->GetResources( stream, &filter );
746  }
GlsAnimation::Ptr disti::LoadAnimationScript ( const std::string &  filename)

Loads an animation sequence from a script file.

Parameters
filenameThe script filename.
Returns
An animation sequence object.

Definition at line 326 of file gls_animation_parser.cpp.

327  {
328  // Load the document
329  std::ifstream readIn( filename.c_str(), std::ios_base::ate );
330 
331  if( !readIn )
332  {
333  std::cerr << "LoadAnimationScript(): Unable to load script file " << filename << std::endl;
334  return GlsAnimation::Ptr();
335  }
336 
337  std::streampos size = readIn.tellg();
338  readIn.seekg( 0 );
339 
340  if( !readIn || size == static_cast<std::streampos>(-1) ) // tellg returns -1 on an error
341  {
342  std::cerr << "LoadAnimationScript(): Error reading from file " << filename << std::endl;
343  return GlsAnimation::Ptr();
344  }
345 
346  std::vector<char> data( static_cast<unsigned int>( size ) );
347  readIn.read( &data[0], size );
348 
349  return LoadAnimation( data, filename );
350  }
std::vector< GlsAnimation::Ptr > disti::LoadAnimationZip ( const std::string &  filename)

Loads a set of animation sequences from a zip file.

Parameters
filenameThe zip filename.
Returns
A container of animation objects.
Note
Define GLS_ANIMATION_ENABLE_ZIP_LOADING project-wide to enable this function and add zlib's z.lib to the linker path for the final executable/RSO.

Definition at line 262 of file gls_animation_parser.cpp.

263  {
264  std::vector< GlsAnimation::Ptr > animations;
265 
266 
267  unzFile zipFile = unzOpen(filename.c_str());
268 
269  if (unzGoToFirstFile(zipFile) != UNZ_OK)
270  {
271  std::cerr << "LoadAnimationZip(): Unable to open file " << filename << std::endl;
272  return animations;
273  }
274 
275  const unsigned int bufSize(4096);
276  std::vector<char> buf(bufSize);
277  unz_file_info file_info;
278  do
279  {
280 
281  if( unzGetCurrentFileInfo(zipFile, &file_info, &buf[0], bufSize - 1, NULL,0, NULL,0) != UNZ_OK )
282  {
283  std::cerr << "LoadAnimationZip(): Error getting file info from file in " << filename << std::endl;
284  continue;
285  }
286 
287  std::string zippedFilename = &buf[0];
288 
289  std::string extension = zippedFilename.substr( zippedFilename.rfind('.') + 1 );
290  std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
291  if (extension == "zip")
292  {
293  std::cerr << "LoadAnimationZip(): File '" << filename << "' contains a zip file. Nested zip files are not supported. Ignoring.\n";
294  continue;
295  }
296 
297  const uLong size = file_info.uncompressed_size;
298 
299  if( unzOpenCurrentFile(zipFile) != UNZ_OK )
300  {
301  std::cerr << "LoadAnimationZip(): Error opening file " << zippedFilename << " in file " << filename << std::endl;
302  continue;
303  }
304 
305  std::vector<char> data(size);
306 
307  if( unzReadCurrentFile(zipFile,&data[0],size) != static_cast<int>( size ) )
308  {
309  std::cerr << "LoadAnimationZip(): Error reading from file " << zippedFilename << " in file " << filename << std::endl;
310  continue;
311  }
312 
313  if( GlsAnimation::Ptr anim = LoadAnimation( data, zippedFilename ) )
314  {
315  animations.push_back( anim );
316  }
317 
318 
319  } while(unzGoToNextFile(zipFile) == UNZ_OK);
320 
321  return animations;
322  }
void disti::SetGlsAnimationParentChildRelationship ( DisplayObject *  parent,
DisplayObject *  child 
)

Establishes a parent-child relationship like that in Adobe After Effects that does not exist in the GL Studio geometry hierarchy and should not be introduced there because that hierarchy was created and may need to be recreated programmatically (e.g., by importing a PSD file).

This allows the objects to be moved, scaled, and rotated together with the animation library as they appear in After Effects. Typically, a call to this function should be added to the application's or component's Initialize() method.

Parameters
parentThe parent object
childThe child object
Note
This has some side effects such as setting the parent's InstanceName property to InstanceName()+"_Parent" and creating a Group named the parent's old name, which may impede other use of the Resources API with the parent object.
This function may also change the draw order of the child.
This will not work out of the box with multiple children.

Definition at line 716 of file gls_animation.cpp.

717  {
718  Group* const parentsGroup = parent->ParentGroup();
719  Group* const childsGroup = child->ParentGroup();
720 
721  int pos = parentsGroup->Position( parent );
722 
723  parentsGroup->DeleteObject( parent );
724  childsGroup->DeleteObject( child );
725 
726  const std::string name = parent->InstanceName();
727  parent->InstanceName( (name + "_Parent").c_str() );
728 
729  Group* group = new Group();
730  group->InstanceName( name.c_str() );
731  group->InsertObject( parent );
732  group->InsertObject( child );
733  group->SetAvailableAttributes( unsigned( DisplayObject::GLS_ATTRIBUTES_ALL ) );
734  parentsGroup->InsertObject( group, true, true, pos );
735  group->WorldRotationPoint( parent->WorldRotationPoint() );
736  }

Variable Documentation

const std::string disti::g_backInOutTag = "backInAndOut"

Back In and Out interpolator tag.

Definition at line 714 of file gls_animation.h.

const std::string disti::g_backInTag = "backIn"

Back In interpolator tag.

Definition at line 712 of file gls_animation.h.

const std::string disti::g_backOutTag = "backOut"

Back Out interpolator tag.

Definition at line 713 of file gls_animation.h.

const std::string disti::g_bounceInOutTag = "bounceInAndOut"

Bounce In and Out interpolator tag.

Definition at line 711 of file gls_animation.h.

const std::string disti::g_bounceInTag = "bounceIn"

Bounce In interpolator tag.

Definition at line 709 of file gls_animation.h.

const std::string disti::g_bounceOutTag = "bounceOut"

Bounce Out interpolator tag.

Definition at line 710 of file gls_animation.h.

const std::string disti::g_circleInOutTag = "circularInAndOut"

Circular In and Out interpolator tag.

Definition at line 705 of file gls_animation.h.

const std::string disti::g_circleInTag = "circularIn"

Circular In interpolator tag.

Definition at line 703 of file gls_animation.h.

const std::string disti::g_circleOutTag = "circularOut"

Circular Out interpolator tag.

Definition at line 704 of file gls_animation.h.

const std::string disti::g_cubeInOutTag = "cubicInAndOut"

Cubic In and Out interpolator tag.

Definition at line 690 of file gls_animation.h.

const std::string disti::g_cubeInTag = "cubicIn"

Cubic In interpolator tag.

Definition at line 688 of file gls_animation.h.

const std::string disti::g_cubeOutTag = "cubicOut"

Cubic Out interpolator tag.

Definition at line 689 of file gls_animation.h.

const std::string disti::g_elasticInOutTag = "elasticInAndOut"

Elastic In and Out interpolator tag.

Definition at line 708 of file gls_animation.h.

const std::string disti::g_elasticInTag = "elasticIn"

Elastic In interpolator tag.

Definition at line 706 of file gls_animation.h.

const std::string disti::g_elasticOutTag = "elasticOut"

Elastic Out interpolator tag.

Definition at line 707 of file gls_animation.h.

const std::string disti::g_expoInOutTag = "exponentInAndOut"

Exponent In and Out interpolator tag.

Definition at line 702 of file gls_animation.h.

const std::string disti::g_expoInTag = "exponentIn"

Exponent In interpolator tag.

Definition at line 700 of file gls_animation.h.

const std::string disti::g_expoOutTag = "exponentOut"

Exponent Out interpolator tag.

Definition at line 701 of file gls_animation.h.

const std::string disti::g_gatedInterpTag = "gated"

Gated interpolator tag.

Definition at line 683 of file gls_animation.h.

const std::string disti::g_linearInterpTag = "linear"

Linear interpolator tag.

Definition at line 682 of file gls_animation.h.

const std::string disti::g_quadInOUtTag = "quadraticInAndOut"

Quadratic In and Out interpolator tag.

Definition at line 687 of file gls_animation.h.

const std::string disti::g_quadInTag = "quadraticIn"

Quadratic In interpolator tag.

Definition at line 685 of file gls_animation.h.

const std::string disti::g_quadOutTag = "quadraticOut"

Quadratic Out interpolator tag.

Definition at line 686 of file gls_animation.h.

const std::string disti::g_quartInOutTag = "quarticInAndOut"

Quartic In and Out interpolator tag.

Definition at line 693 of file gls_animation.h.

const std::string disti::g_quartInTag = "quarticIn"

Quartic In interpolator tag.

Definition at line 691 of file gls_animation.h.

const std::string disti::g_quartOutTag = "quarticOut"

Quartic Out interpolator tag.

Definition at line 692 of file gls_animation.h.

const std::string disti::g_quintInOutTag = "quinticInAndOut"

Quintic In and Out interpolator tag.

Definition at line 696 of file gls_animation.h.

const std::string disti::g_quintInTag = "quinticIn"

Quintic In interpolator tag.

Definition at line 694 of file gls_animation.h.

const std::string disti::g_quintOutTag = "quinticOut"

Quintic Out interpolator tag.

Definition at line 695 of file gls_animation.h.

const std::string disti::g_sinInOutTag = "sinusoidalInAndOut"

Sinusoidal In and Out interpolator tag.

Definition at line 699 of file gls_animation.h.

const std::string disti::g_sinInTag = "sinusoidalIn"

Sinusoidal In interpolator tag.

Definition at line 697 of file gls_animation.h.

const std::string disti::g_sinOutTag = "sinusoidalOut"

Sinusoidal Out interpolator tag.

Definition at line 698 of file gls_animation.h.

const std::string disti::g_slerpTag = "slerp"

Spherical Linear Interpolation tag (only supported by Vector and Quaternion)

Definition at line 684 of file gls_animation.h.