Quellcode durchsuchen

Spine updates

- File cleanup, renaming for consistency
- Added ability for Skeleton to use blending, flipping
Mike Lilligreen vor 11 Jahren
Ursprung
Commit
f1e52a92ef

+ 0 - 18
engine/source/2d/assets/SkeletonAsset.cc

@@ -99,7 +99,6 @@ ConsoleSetType( TypeSkeletonAssetPtr )
 
 SkeletonAsset::SkeletonAsset() :    mSkeletonFile(StringTable->EmptyString),
                                     mAtlasFile(StringTable->EmptyString),
-                                    mScale(1),
                                     mAtlasDirty(true),
                                     mAtlas(NULL),
                                     mSkeletonData(NULL),
@@ -126,7 +125,6 @@ void SkeletonAsset::initPersistFields()
     // Fields.
     addProtectedField("AtlasFile", TypeAssetLooseFilePath, Offset(mAtlasFile, SkeletonAsset), &setAtlasFile, &defaultProtectedGetFn, &writeAtlasFile, "The loose file pointing to the .atlas file used for skinning");
     addProtectedField("SkeletonFile", TypeAssetLooseFilePath, Offset(mSkeletonFile, SkeletonAsset), &setSkeletonFile, &defaultProtectedGetFn, &writeSkeletonFile, "The loose file produced by the editor, which is fed into this asset");
-    addProtectedField("Scale", TypeF32, Offset(mScale, SkeletonAsset), &setScale, &defaultProtectedGetFn, &writeScale, "");
 }
 
 //------------------------------------------------------------------------------
@@ -193,20 +191,6 @@ void SkeletonAsset::setAtlasFile( const char* pAtlasFile )
 
 //------------------------------------------------------------------------------
 
-void SkeletonAsset::setScale( F32 fScale)
-{
-    // Ignore no change.
-    if (fScale == mScale )
-        return;
-
-    mScale = fScale;
-
-    // Scale has been set, refresh the asset based on this
-    refreshAsset();
-}
-
-//------------------------------------------------------------------------------
-
 void SkeletonAsset::copyTo(SimObject* object)
 {
     // Call to parent.
@@ -221,7 +205,6 @@ void SkeletonAsset::copyTo(SimObject* object)
     // Copy state.
     pAsset->setAtlasFile( getAtlasFile() );
     pAsset->setSkeletonFile( getSkeletonFile() );
-    pAsset->setScale( getScale() );
 }
 
 //------------------------------------------------------------------------------
@@ -329,7 +312,6 @@ void SkeletonAsset::buildSkeletonData( void )
         spSkeletonData_dispose(mSkeletonData);
     
     spSkeletonJson* json = spSkeletonJson_create(mAtlas);
-    json->scale = mScale;
     mSkeletonData = spSkeletonJson_readSkeletonDataFile(json, mSkeletonFile);
 
     if (!mSkeletonData)

+ 3 - 9
engine/source/2d/assets/SkeletonAsset.h

@@ -50,11 +50,10 @@ private:
 public:
     StringTableEntry                mSkeletonFile;
     StringTableEntry                mAtlasFile;
-    F32                           mScale;
     AssetPtr<ImageAsset>            mImageAsset;
-    spAtlas*                 mAtlas;
-    spSkeletonData*          mSkeletonData;
-    spAnimationStateData*    mStateData;
+    spAtlas*                        mAtlas;
+    spSkeletonData*                 mSkeletonData;
+    spAnimationStateData*           mStateData;
 
 public:
     SkeletonAsset();
@@ -71,9 +70,6 @@ public:
 
     void                    setAtlasFile( const char* pAtlasFile );
     inline StringTableEntry getAtlasFile( void ) const                      { return mAtlasFile; }
-
-    void                    setScale( const F32 fScale );
-    inline F32              getScale( void ) const                          { return mScale; }
     
     virtual bool            isAssetValid( void ) const;
 
@@ -100,8 +96,6 @@ protected:
     static bool writeSkeletonFile( void* obj, StringTableEntry pFieldName ) { return static_cast<SkeletonAsset*>(obj)->getSkeletonFile() != StringTable->EmptyString; }
     static bool setAtlasFile( void* obj, const char* data )                 { static_cast<SkeletonAsset*>(obj)->setAtlasFile(data); return false; }
     static bool writeAtlasFile( void* obj, StringTableEntry pFieldName )    { return static_cast<SkeletonAsset*>(obj)->getAtlasFile() != StringTable->EmptyString; }
-    static bool setScale( void* obj, const char* data )                     { static_cast<SkeletonAsset*>(obj)->setScale(dAtof(data)); return false; }
-    static bool writeScale( void* obj, StringTableEntry pFieldName )        { return static_cast<SkeletonAsset*>(obj)->getScale() != 1.0f; }
 };
 
 #endif // _SKELETON_ASSET_H_

+ 1 - 23
engine/source/2d/assets/SkeletonAsset_ScriptBinding.h

@@ -62,26 +62,4 @@ ConsoleMethodWithDocs(SkeletonAsset, getSkeletonFile, ConsoleString, 2, 2, ())
 
 //------------------------------------------------------------------------------
 
-/*! Sets the scale for the skeleton size.
-	@param scale The scale for the skeleton size.
-    @return No return value.
-*/
-ConsoleMethodWithDocs(SkeletonAsset, setScale, ConsoleVoid, 3, 3, (float scale))
-{
-    // Compilier complains that setScale can't be found. Not sure how to fix.
-    //object->setScale( argv[2] );
-}
-
-//-----------------------------------------------------------------------------
-
-/*! Gets the scale for the skeleton size.
-    @return Returns the scale for the skeleton size.
-*/
-ConsoleMethodWithDocs(SkeletonAsset, getScale, ConsoleFloat, 2, 2, ())
-{
-    return object->getScale();
-}
-
-//------------------------------------------------------------------------------
-
-ConsoleMethodGroupEndWithDocs(SkeletonAsset)
+ConsoleMethodGroupEndWithDocs(SkeletonAsset)

+ 56 - 44
engine/source/2d/sceneobject/Skeleton.cc

@@ -55,7 +55,9 @@ Skeleton::Skeleton() :      mPreTickTime( 0.0f ),
                             mState(NULL),
                             mAnimationCycle(false),
                             mAnimationFinished(true),
-                            mAnimationDuration(0.0)
+                            mAnimationDuration(0.0),
+                            mFlipX(false),
+                            mFlipY(false)
 {
     mCurrentAnimation = StringTable->insert("");
     mSkeletonScale.SetZero();
@@ -84,11 +86,13 @@ void Skeleton::initPersistFields()
     Parent::initPersistFields();
     
     addProtectedField("Asset", TypeSkeletonAssetPtr, Offset(mSkeletonAsset, Skeleton), &setSkeletonAsset, &getSkeletonAsset, &writeSkeletonAsset, "The skeleton asset ID used for the skeleton.");
-    addProtectedField("AnimationName", TypeString, Offset(mCurrentAnimation, Skeleton), &setCurrentAnimation, &getCurrentAnimation, &writeCurrentAnimation, "The animation name to play.");
+    addProtectedField("AnimationName", TypeString, Offset(mCurrentAnimation, Skeleton), &setAnimationName, &getAnimationName, &writeAnimationName, "The animation name to play.");
     addProtectedField("Skin", TypeString, Offset(mCurrentSkin, Skeleton), &setCurrentSkin, &getCurrentSkin, &writeCurrentSkin, "The skin to use.");
-    addProtectedField("RootBoneScale", TypeVector2, NULL, &setSkeletonScale, &getSkeletonScale, &writeSkeletonScale, "Scaling of the skeleton's root bone");
-    addProtectedField("RootBoneOffset", TypeVector2, NULL, &setSkeletonOffset, &getSkeletonOffset, &writeSkeletonOffset, "X/Y offset of the skeleton's root bone");
+    addProtectedField("RootBoneScale", TypeVector2, NULL, &setRootBoneScale, &getRootBoneScale, &writeRootBoneScale, "Scaling of the skeleton's root bone");
+    addProtectedField("RootBoneOffset", TypeVector2, NULL, &setRootBoneOffset, &getRootBoneOffset, &writeRootBoneOffset, "X/Y offset of the skeleton's root bone");
     addProtectedField("AnimationCycle", TypeBool, Offset(mAnimationCycle, Skeleton), &setAnimationCycle, &defaultProtectedGetFn, &writeAnimationCycle, "Whether the animation loops or not");
+    addField("FlipX", TypeBool, Offset(mFlipX, Skeleton), &writeFlipX, "");
+    addField("FlipY", TypeBool, Offset(mFlipY, Skeleton), &writeFlipY, "");
 }
 
 //-----------------------------------------------------------------------------
@@ -168,10 +172,10 @@ void Skeleton::copyTo(SimObject* object)
     
     // Copy state.
     pComposite->setSkeletonAsset( getSkeletonAsset() );
-    pComposite->setCurrentAnimation( getCurrentAnimation(), getAnimationCycle() );
+    pComposite->setAnimationName( getAnimationName(), getAnimationCycle() );
     pComposite->setCurrentSkin( getCurrentSkin() );
-    pComposite->setSkeletonScale( getSkeletonScale() );
-    pComposite->setSkeletonOffset( getSkeletonOffset() );
+    pComposite->setRootBoneScale( getRootBoneScale() );
+    pComposite->setRootBoneOffset( getRootBoneOffset() );
 }
 
 //-----------------------------------------------------------------------------
@@ -188,7 +192,7 @@ void Skeleton::sceneRender( const SceneRenderState* pSceneRenderState, const Sce
 {
     // Render.
     SpriteBatch::render( pSceneRenderState, pSceneRenderRequest, pBatchRenderer );
-
+    
 }
 
 //-----------------------------------------------------------------------------
@@ -209,20 +213,20 @@ bool Skeleton::setSkeletonAsset( const char* pSkeletonAssetId )
 
 //-----------------------------------------------------------------------------
 
-bool Skeleton::setCurrentAnimation( const char* pAnimation, const bool isLooping )
+bool Skeleton::setAnimationName( const char* pAnimation, const bool isLooping )
 {
     // Make sure an asset was loaded.
     if (mSkeletonAsset.isNull())
         return false;
-
+    
     // Set the animation.
     mCurrentAnimation = StringTable->insert(pAnimation);
-
+    
     mAnimationCycle = isLooping;
     
     // Generate composition.
     generateComposition();
-
+    
     return true;
 }
 
@@ -249,8 +253,8 @@ bool Skeleton::setMix( const char* pFromAnimation, const char* pToAnimation, flo
     }
     
     // Check to see if the "to animation" is valid
-	spAnimation* to = spSkeletonData_findAnimation(mSkeleton->data, pToAnimation);
-	
+    spAnimation* to = spSkeletonData_findAnimation(mSkeleton->data, pToAnimation);
+    
     if (!to)
     {
         Con::warnf("Skeleton::setMix() - Animation %s does not exist.", pToAnimation);
@@ -277,9 +281,9 @@ bool Skeleton::setCurrentSkin( const char* pSkin )
         Con::errorf("Skeleton::setCurrentSkin() - Skeleton Asset was null or skeleton was not built");
         return false;
     }
-
+    
     S32 result = spSkeleton_setSkinByName(mSkeleton, pSkin);
-
+    
     if (result)
     {
         spSkeleton_setSlotsToSetupPose(mSkeleton);
@@ -294,13 +298,13 @@ bool Skeleton::setCurrentSkin( const char* pSkin )
 
 //-----------------------------------------------------------------------------
 
-void Skeleton::setSkeletonScale(const Vector2& scale)
+void Skeleton::setRootBoneScale(const Vector2& scale)
 {
     mSkeletonScale = scale;
-
+    
     if (!mSkeleton)
         return;
-
+    
     if (mSkeletonScale.notZero())
     {
         spBone* rootBone = mSkeleton->root;
@@ -311,13 +315,13 @@ void Skeleton::setSkeletonScale(const Vector2& scale)
 
 //-----------------------------------------------------------------------------
 
-void Skeleton::setSkeletonOffset(const Vector2& offset)
+void Skeleton::setRootBoneOffset(const Vector2& offset)
 {
     mSkeletonOffset = offset;
-
-     if (!mSkeleton)
+    
+    if (!mSkeleton)
         return;
-
+    
     if (mSkeletonOffset.notZero())
     {
         spBone* rootBone = mSkeleton->root;
@@ -333,24 +337,24 @@ void Skeleton::generateComposition( void )
     // Clear existing visualization
     clearSprites();
     mSkeletonSprites.clear();
-
+    
     // Finish if skeleton asset isn't available.
     if ( mSkeletonAsset.isNull() )
         return;
-
-    // Generate visualization.  
+    
+    // Generate visualization.
     if ((*mSkeletonAsset).mImageAsset.isNull())
     {
         Con::warnf( "Skeleton::generateComposition() - Image asset was NULL, so nothing can be added to the composition.");
         return;
     }
-
+    
     if (!mSkeleton)
         mSkeleton = spSkeleton_create(mSkeletonAsset->mSkeletonData);
-
+    
     if (!mState)
         mState = spAnimationState_create(mSkeletonAsset->mStateData);
-
+    
     if (mCurrentAnimation != StringTable->EmptyString)
     {
         spAnimationState_setAnimationByName(mState, 0, mCurrentAnimation, mAnimationCycle);
@@ -381,7 +385,7 @@ void Skeleton::updateComposition( const F32 time )
     // Update position/orientation/state of visualization
     float delta = (time - mLastFrameTime) * mTimeScale;
     mLastFrameTime = time;
-
+    
     spSkeleton_update(mSkeleton, delta);
     
     if (!mAnimationFinished)
@@ -389,16 +393,16 @@ void Skeleton::updateComposition( const F32 time )
         spAnimationState_update(mState, delta);
         spAnimationState_apply(mState, mSkeleton);
     }
-
+    
     spSkeleton_updateWorldTransform(mSkeleton);
-
+    
     // Get the ImageAsset used by the sprites
     StringTableEntry assetId = (*mSkeletonAsset).mImageAsset.getAssetId();
-
+    
     clearSprites();
-
+    
     Vector2 vertices[4];
-
+    
     F32 vertexPositions[8];
     for (int i = 0; i < mSkeleton->slotCount; ++i)
     {
@@ -410,12 +414,17 @@ void Skeleton::updateComposition( const F32 time )
         
         spRegionAttachment* regionAttachment = (spRegionAttachment*)attachment;
         spRegionAttachment_computeWorldVertices(regionAttachment, slot->skeleton->x, slot->skeleton->y, slot->bone, vertexPositions);
-
+        
         SpriteBatchItem* pSprite = SpriteBatch::createSprite();
-		  
-        pSprite->setSrcBlendFactor(GL_ONE);
-        pSprite->setDstBlendFactor(GL_ONE_MINUS_SRC_ALPHA);
-
+        
+        pSprite->setSrcBlendFactor(mSrcBlendFactor);
+        pSprite->setDstBlendFactor(mDstBlendFactor);
+        
+        mSkeleton->r = mBlendColor.red;
+        mSkeleton->g = mBlendColor.green;
+        mSkeleton->b = mBlendColor.blue;
+        mSkeleton->a = mBlendColor.alpha;
+        
         F32 alpha = mSkeleton->a * slot->a;
         pSprite->setBlendColor(ColorF(
             mSkeleton->r * slot->r * alpha,
@@ -423,7 +432,10 @@ void Skeleton::updateComposition( const F32 time )
             mSkeleton->b * slot->b * alpha,
             alpha
         ));
-
+        
+        mSkeleton->flipX = getFlipX();
+        mSkeleton->flipY = getFlipY();
+        
         vertices[0].x = vertexPositions[VERTEX_X1];
         vertices[0].y = vertexPositions[VERTEX_Y1];
         vertices[1].x = vertexPositions[VERTEX_X4];
@@ -433,11 +445,11 @@ void Skeleton::updateComposition( const F32 time )
         vertices[3].x = vertexPositions[VERTEX_X2];
         vertices[3].y = vertexPositions[VERTEX_Y2];
         pSprite->setExplicitVertices(vertices);
-
+        
         pSprite->setImage(assetId);
         pSprite->setImageFrameByName(attachment->name);
     }
-
+    
     if (mLastFrameTime >= mTotalAnimationTime)
         mAnimationFinished = true;
     
@@ -455,4 +467,4 @@ void Skeleton::onAnimationFinished()
 {
     // Do script callback.
     Con::executef( this, 2, "onAnimationFinished", mCurrentAnimation );
-}
+}

+ 52 - 39
engine/source/2d/sceneobject/Skeleton.h

@@ -45,26 +45,29 @@ protected:
 private:
     typedef Vector<SpriteBatchItem*> typeSkeletonSpritesVector;
     typeSkeletonSpritesVector   mSkeletonSprites;
-
+    
     AssetPtr<SkeletonAsset>     mSkeletonAsset;
-    spSkeleton*          mSkeleton;
-    spAnimationState*    mState;
+    spSkeleton*                 mSkeleton;
+    spAnimationState*           mState;
     
     F32                         mPreTickTime;
-    F32                         mPostTickTime;    
+    F32                         mPostTickTime;
     F32                         mTimeScale;
     F32                         mLastFrameTime;
     F32                         mAnimationDuration;
     F32                         mTotalAnimationTime;
-
+    
     bool                        mAnimationFinished;
     bool                        mAnimationCycle;
     Vector2                     mSkeletonScale;
     Vector2                     mSkeletonOffset;
-
+    
     StringTableEntry            mCurrentAnimation;
     StringTableEntry            mCurrentSkin;
-
+    
+    bool                        mFlipX;
+    bool                        mFlipY;
+    
     
     
 public:
@@ -85,34 +88,41 @@ public:
     virtual void scenePrepareRender( const SceneRenderState* pSceneRenderState, SceneRenderQueue* pSceneRenderQueue );
     virtual void sceneRender( const SceneRenderState* pSceneRenderState, const SceneRenderRequest* pSceneRenderRequest, BatchRender* pBatchRenderer );
     
+    /// Render flipping.
+    void setFlip( const bool flipX, const bool flipY )  { mFlipX = flipX; mFlipY = flipY; }
+    void setFlipX( const bool flipX )                   { setFlip( flipX, mFlipY ); }
+    void setFlipY( const bool flipY )                   { setFlip( mFlipX, flipY ); }
+    inline bool getFlipX( void ) const                  { return mFlipX; }
+    inline bool getFlipY( void ) const                  { return mFlipY; }
+    
     bool setSkeletonAsset( const char* pSkeletonAssetId );
     inline StringTableEntry getSkeletonAsset( void ) const { return mSkeletonAsset.getAssetId(); }
     
-    inline bool setCurrentAnimation( const char* pAnimation ) { return setCurrentAnimation( pAnimation, mAnimationCycle ); }
-    bool setCurrentAnimation( const char* pAnimation, const bool isLooping = false);
-    inline StringTableEntry getCurrentAnimation( void ) const { return mCurrentAnimation; }
-
+    inline bool setAnimationName( const char* pAnimation ) { return setAnimationName( pAnimation, mAnimationCycle ); }
+    bool setAnimationName( const char* pAnimation, const bool isLooping = false);
+    inline StringTableEntry getAnimationName( void ) const { return mCurrentAnimation; }
+    
     bool setMix( const char* pFromAnimation, const char* pToAnimation, float time);
     
     bool setCurrentSkin( const char* pSkin );
     inline StringTableEntry getCurrentSkin( void ) const { return mCurrentSkin; }
-
-    void setSkeletonScale( const Vector2& scale );
-    inline void setSkeletonScale( const F32 x, const F32 y ){ setSkeletonScale( Vector2(x, y) ); }
-    inline Vector2 getSkeletonScale( void ) const { return mSkeletonScale; }
-
-    void setSkeletonOffset( const Vector2& scale );
-    inline void setSkeletonOffset( const F32 x, const F32 y ){ setSkeletonOffset( Vector2(x, y) ); }
-    inline Vector2 getSkeletonOffset( void ) const { return mSkeletonOffset; }
-
+    
+    void setRootBoneScale( const Vector2& scale );
+    inline void setRootBoneScale( const F32 x, const F32 y ){ setRootBoneScale( Vector2(x, y) ); }
+    inline Vector2 getRootBoneScale( void ) const { return mSkeletonScale; }
+    
+    void setRootBoneOffset( const Vector2& scale );
+    inline void setRootBoneOffset( const F32 x, const F32 y ){ setRootBoneOffset( Vector2(x, y) ); }
+    inline Vector2 getRootBoneOffset( void ) const { return mSkeletonOffset; }
+    
     inline F32 getAnimationDuration( void ) const { return mAnimationDuration; }
     inline bool isAnimationFinished( void ) const { return mAnimationFinished; };
-
+    
     inline void setAnimationCycle( const bool isLooping ) { mAnimationCycle = isLooping; }
     inline bool getAnimationCycle( void ) const {return mAnimationCycle; };
-
+    
     void onAnimationFinished();
-
+    
     /// Declare Console Object.
     DECLARE_CONOBJECT( Skeleton );
     
@@ -124,25 +134,28 @@ protected:
     static bool setSkeletonAsset( void* obj, const char* data )                  { static_cast<Skeleton*>(obj)->setSkeletonAsset(data); return false; }
     static const char* getSkeletonAsset(void* obj, const char* data)             { return static_cast<Skeleton*>(obj)->getSkeletonAsset(); }
     static bool writeSkeletonAsset( void* obj, StringTableEntry pFieldName )     { return static_cast<Skeleton*>(obj)->mSkeletonAsset.notNull(); }
-
-    static bool setCurrentAnimation( void* obj, const char* data )               { static_cast<Skeleton*>(obj)->setCurrentAnimation(data, static_cast<Skeleton*>(obj)->getAnimationCycle()); return false; }
-    static const char* getCurrentAnimation(void* obj, const char* data)          { return static_cast<Skeleton*>(obj)->getCurrentAnimation(); }
-    static bool writeCurrentAnimation( void*obj, StringTableEntry pAnimation )   { return static_cast<Skeleton*>(obj)->getCurrentAnimation() != StringTable->EmptyString; }
-
+    
+    static bool setAnimationName( void* obj, const char* data )                  { static_cast<Skeleton*>(obj)->setAnimationName(data, static_cast<Skeleton*>(obj)->getAnimationCycle()); return false; }
+    static const char* getAnimationName(void* obj, const char* data)             { return static_cast<Skeleton*>(obj)->getAnimationName(); }
+    static bool writeAnimationName( void*obj, StringTableEntry pAnimation )      { return static_cast<Skeleton*>(obj)->getAnimationName() != StringTable->EmptyString; }
+    
     static bool setCurrentSkin( void* obj, const char* data )                    { static_cast<Skeleton*>(obj)->setCurrentSkin(data); return false; }
     static const char* getCurrentSkin(void* obj, const char* data)               { return static_cast<Skeleton*>(obj)->getCurrentSkin(); }
     static bool writeCurrentSkin( void*obj, StringTableEntry pSkin )             { return static_cast<Skeleton*>(obj)->getCurrentSkin() != StringTable->EmptyString; }
-
-    static bool setSkeletonScale(void* obj, const char* data)                    { static_cast<Skeleton*>(obj)->setSkeletonScale(Vector2(data)); return false; }
-    static const char* getSkeletonScale(void* obj, const char* data)             { return static_cast<Skeleton*>(obj)->getSkeletonScale().scriptThis(); }
-    static bool writeSkeletonScale( void* obj, StringTableEntry pFieldName )     { return static_cast<Skeleton*>(obj)->getSkeletonScale().notZero(); }
-
-    static bool setSkeletonOffset(void* obj, const char* data)                   { static_cast<Skeleton*>(obj)->setSkeletonOffset(Vector2(data)); return false; }
-    static const char* getSkeletonOffset(void* obj, const char* data)            { return static_cast<Skeleton*>(obj)->getSkeletonOffset().scriptThis(); }
-    static bool writeSkeletonOffset( void* obj, StringTableEntry pFieldName )    { return static_cast<Skeleton*>(obj)->getSkeletonOffset().notZero(); }
-
-    static bool setAnimationCycle( void* obj, const char* data )                 { static_cast<Skeleton*>(obj)->setAnimationCycle( dAtob(data) ); return false; }    
+    
+    static bool setRootBoneScale(void* obj, const char* data)                    { static_cast<Skeleton*>(obj)->setRootBoneScale(Vector2(data)); return false; }
+    static const char* getRootBoneScale(void* obj, const char* data)             { return static_cast<Skeleton*>(obj)->getRootBoneScale().scriptThis(); }
+    static bool writeRootBoneScale( void* obj, StringTableEntry pFieldName )     { return static_cast<Skeleton*>(obj)->getRootBoneScale().notZero(); }
+    
+    static bool setRootBoneOffset(void* obj, const char* data)                   { static_cast<Skeleton*>(obj)->setRootBoneOffset(Vector2(data)); return false; }
+    static const char* getRootBoneOffset(void* obj, const char* data)            { return static_cast<Skeleton*>(obj)->getRootBoneOffset().scriptThis(); }
+    static bool writeRootBoneOffset( void* obj, StringTableEntry pFieldName )    { return static_cast<Skeleton*>(obj)->getRootBoneOffset().notZero(); }
+    
+    static bool setAnimationCycle( void* obj, const char* data )                 { static_cast<Skeleton*>(obj)->setAnimationCycle( dAtob(data) ); return false; }
     static bool writeAnimationCycle( void* obj, StringTableEntry pFieldName )    { return static_cast<Skeleton*>(obj)->getAnimationCycle() == false; }
+    
+    static bool writeFlipX( void* obj, StringTableEntry pFieldName )             { return static_cast<Skeleton*>(obj)->getFlipX() == true; }
+    static bool writeFlipY( void* obj, StringTableEntry pFieldName )             { return static_cast<Skeleton*>(obj)->getFlipY() == true; }
 };
 
-#endif // _SKELETON_H_
+#endif // _SKELETON_H_

+ 117 - 22
engine/source/2d/sceneobject/Skeleton_ScriptBinding.h

@@ -48,12 +48,12 @@ ConsoleMethodWithDocs(Skeleton, getSkeletonAsset, ConsoleString, 2, 2, ())
     @param cycle Optional bool to determine whether the animation should loop.
     @return Returns true on success."
 */
-ConsoleMethodWithDocs(Skeleton, setAnimation, ConsoleBool, 3, 4, (animationName, [cycle]))
+ConsoleMethodWithDocs(Skeleton, setAnimationName, ConsoleBool, 3, 4, (animationName, [cycle]))
 {
     // Determine looping
     bool shouldLoop = argc >= 4 ? dAtob(argv[3]) : false;
     
-    return object->setCurrentAnimation(argv[2], shouldLoop);
+    return object->setAnimationName(argv[2], shouldLoop);
 }
 
 //-----------------------------------------------------------------------------
@@ -61,9 +61,9 @@ ConsoleMethodWithDocs(Skeleton, setAnimation, ConsoleBool, 3, 4, (animationName,
 /*! Gets the name of the current animation.
     @return String containing the animation name.
 */
-ConsoleMethodWithDocs(Skeleton, getAnimation, ConsoleString, 2, 2, ())
+ConsoleMethodWithDocs(Skeleton, getAnimationName, ConsoleString, 2, 2, ())
 {
-    return object->getCurrentAnimation();
+    return object->getAnimationName();
 }
 
 //-----------------------------------------------------------------------------
@@ -96,27 +96,27 @@ ConsoleMethodWithDocs(Skeleton, getSkin, ConsoleString, 2, 2, ())
 ConsoleMethodWithDocs(Skeleton, setRootBoneScale, ConsoleVoid, 3, 4, (float scaleX, float scaleY))
 {
     F32 scaleX, scaleY;
-
+    
     const U32 elementCount = Utility::mGetStringElementCount(argv[2]);
-
+    
     // ("width height")
     if ((elementCount == 2) && (argc == 3))
     {
         scaleX = dAtof(Utility::mGetStringElement(argv[2], 0));
         scaleY = dAtof(Utility::mGetStringElement(argv[2], 1));
     }
-
+    
     // (width, [height])
     else if (elementCount == 1)
     {
         scaleX = dAtof(argv[2]);
-
+        
         if (argc > 3)
             scaleY = dAtof(argv[3]);
         else
             scaleY = scaleX;
     }
-
+    
     // Invalid
     else
     {
@@ -124,9 +124,9 @@ ConsoleMethodWithDocs(Skeleton, setRootBoneScale, ConsoleVoid, 3, 4, (float scal
         return;
     }
     
-    // Set Size.
-    object->setSkeletonScale(Vector2(scaleX, scaleY));
-}  
+    // Set Scale.
+    object->setRootBoneScale(Vector2(scaleX, scaleY));
+}
 
 //-----------------------------------------------------------------------------
 
@@ -135,7 +135,7 @@ ConsoleMethodWithDocs(Skeleton, setRootBoneScale, ConsoleVoid, 3, 4, (float scal
 */
 ConsoleMethodWithDocs(Skeleton, getRootBoneScale, ConsoleString, 2, 2, ())
 {
-    return object->getSkeletonScale().scriptThis();
+    return object->getRootBoneScale().scriptThis();
 }
 
 //-----------------------------------------------------------------------------
@@ -148,27 +148,27 @@ ConsoleMethodWithDocs(Skeleton, getRootBoneScale, ConsoleString, 2, 2, ())
 ConsoleMethodWithDocs(Skeleton, setRootBoneOffset, ConsoleVoid, 3, 4, (float x, float y))
 {
     F32 x, y;
-
+    
     const U32 elementCount = Utility::mGetStringElementCount(argv[2]);
-
+    
     // ("x y")
     if ((elementCount == 2) && (argc == 3))
     {
         x = dAtof(Utility::mGetStringElement(argv[2], 0));
         y = dAtof(Utility::mGetStringElement(argv[2], 1));
     }
-
+    
     // (x, [y])
     else if (elementCount == 1)
     {
         x = dAtof(argv[2]);
-
+        
         if (argc > 3)
             y = dAtof(argv[3]);
         else
             y = x;
     }
-
+    
     // Invalid
     else
     {
@@ -177,8 +177,8 @@ ConsoleMethodWithDocs(Skeleton, setRootBoneOffset, ConsoleVoid, 3, 4, (float x,
     }
     
     // Set Size.
-    object->setSkeletonOffset(Vector2(x, y));
-}  
+    object->setRootBoneOffset(Vector2(x, y));
+}
 
 //-----------------------------------------------------------------------------
 
@@ -187,7 +187,102 @@ ConsoleMethodWithDocs(Skeleton, setRootBoneOffset, ConsoleVoid, 3, 4, (float x,
 */
 ConsoleMethodWithDocs(Skeleton, getRootBoneOffset, ConsoleString, 2, 2, ())
 {
-    return object->getSkeletonOffset().scriptThis();
+    return object->getRootBoneOffset().scriptThis();
+}
+
+//-----------------------------------------------------------------------------
+
+/*! Sets whether the animation cycles or not.
+    @param cycle Bool to determine whether the animation should loop.
+    @return No return value.
+*/
+ConsoleMethodWithDocs(Skeleton, setAnimationCycle, ConsoleVoid, 3, 3, (bool cycle))
+{
+    object->setAnimationCycle( dAtob(argv[2] ) );
+}
+
+//-----------------------------------------------------------------------------
+
+/*! Gets whether the animation cycles or not.
+    @return Whether the animation cycles or not.
+*/
+ConsoleMethodWithDocs(Skeleton, getAnimationCycle, ConsoleBool, 2, 2, ())
+{
+    return object->getAnimationCycle();
+}
+
+//-----------------------------------------------------------------------------
+
+/*! Sets the sprite texture flipping for each axis.
+    @param flipX Whether or not to flip the texture along the x (horizontal) axis.
+    @param flipY Whether or not to flip the texture along the y (vertical) axis.
+    @return No return value.
+*/
+ConsoleMethodWithDocs(Skeleton, setFlip, ConsoleVoid, 4, 4, (bool flipX, bool flipY))
+{
+    // Set Flip.
+    object->setFlip( dAtob(argv[2]), dAtob(argv[3]) );
+}
+
+//-----------------------------------------------------------------------------
+
+/*! Gets the flip for each axis.
+    @return (bool flipX/bool flipY) Whether or not the texture is flipped along the x and y axis.
+*/
+ConsoleMethodWithDocs(Skeleton, getFlip, ConsoleString, 2, 2, ())
+{
+    // Create Returnable Buffer.
+    char* pBuffer = Con::getReturnBuffer(32);
+    
+    // Format Buffer.
+    dSprintf(pBuffer, 32, "%d %d", object->getFlipX(), object->getFlipY());
+    
+    // Return Buffer.
+    return pBuffer;
+}
+
+//-----------------------------------------------------------------------------
+
+/*! Sets whether or not the texture is flipped horizontally.
+    @param flipX Whether or not to flip the texture along the x (horizontal) axis.
+    @return No return value.
+*/
+ConsoleMethodWithDocs(Skeleton, setFlipX, ConsoleVoid, 3, 3, (bool flipX))
+{
+    // Set Flip.
+    object->setFlipX( dAtob(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+/*! Sets whether or not the texture is flipped vertically.
+    @param flipY Whether or not to flip the texture along the y (vertical) axis.
+    @return No return value.
+*/
+ConsoleMethodWithDocs(Skeleton, setFlipY, ConsoleVoid, 3, 3, (bool flipY))
+{
+    // Set Flip.
+    object->setFlipY( dAtob(argv[2]) );
+}
+
+//-----------------------------------------------------------------------------
+
+/*! Gets whether or not the texture is flipped horizontally.
+    @return (bool flipX) Whether or not the texture is flipped along the x axis.
+*/
+ConsoleMethodWithDocs(Skeleton, getFlipX, ConsoleBool, 2, 2, ())
+{
+    return object->getFlipX();
+}
+
+//-----------------------------------------------------------------------------
+
+/*! Gets whether or not the texture is flipped vertically.
+    @return (bool flipY) Whether or not the texture is flipped along the y axis.
+*/
+ConsoleMethodWithDocs(Skeleton, getFlipY, ConsoleBool, 2, 2, ())
+{
+    return object->getFlipY();
 }
 
 //-----------------------------------------------------------------------------
@@ -213,4 +308,4 @@ ConsoleMethodWithDocs(Skeleton, setMix, ConsoleBool, 5, 5, (fromAnimation, toAni
     return object->setMix(argv[2], argv[3], dAtof(argv[4]));
 }
 
-ConsoleMethodGroupEndWithDocs(Skeleton)
+ConsoleMethodGroupEndWithDocs(Skeleton)