BMW_Skeleton version 2.0
Hi all,
AGKs Spine implementation has been broken since Spine changed the way attachments work in 3.8. Animations no longer load at all.
Because TGC have stated they won't work on Spine in AppGameKit any more, I've reworked my BMW skeleton system and removed all of AGK's Skeleton2D commands.
Basically this lib loads in the Spine JSON, creates Tweenchains for every bone and slot and plays them using BMW_Update(skeletonID)
This WIP API supports both 3.7 and below, and 3.8 and above Spine skeletons. The command list has been expanded to cover AGKs functionality.
Done
Load a json skeleton once, subsequent skeletons with the same path will use the same data.
Generate sprites from a Spine image atlas and attach them to bones.
Image use is tracked internally to prevent loading the same image multiple times.
Scale bones - now you can scale in addition to rotate and translate.
Skins - animate skin alpha and colours in Spine see the results in your AppGameKit app
Events - add an Event Key in Spine to trigger a sound effect or particle in AGK.
Shaders - apply shaders to your skeleton!
Curve data - it detects whether an animation curve is present and applies TweenSmooth1() if so, TweenLinear() if not.
To Do (eventually):
Support for multiple image files and atlases
Meshes
REQUEST FOR HELP
The one thing this implementation lacks is interpolation between animations over time, and I've not sure how to implement that.
I've had a look at the AppGameKit Tier 2 source code for Spine here:
https://github.com/TheGameCreators/AGKTier2/blob/master/common/Source/Skeleton2D.cpp
..but I don't know the right approach to blend between anims. I'm pretty sure I need to store the Previous values and interpolate to the new over time, but I don't want to create temporary tweens on the fly.
Can anyone help?
May 6th 2020
- Split all source files out again - one file was too difficult to manage.
- Added my LIB_Basics.agc library for 2d camera control (pan/zoom/grids)
This lib is based on Baxslash's very cool Adaptable Spine Character code:
https://forum.thegamecreators.com/thread/218190
and uses Madbits deeply awesome json api:
https://forum.thegamecreators.com/thread/218297
Command List:
//BMW_update.agc
// void = BMW_UpdateSkel(int skeleton ID)
// void = BMW_CheckLooping(int skeleton ID)
// void = BMW_DrawSpineBone(int skeleton ID, string boneName1, string boneName2, string boneColorHex)
// void = BMW_DebugSkeleton(int skeleton ID)
// BMWskel_build.agc
// void = BMW_InitAnimationTweens(int skeleton id)
// string = BMW_SkelNewGuid()
// int = BMW_AddSkeleton(string JsonPath, string Atlas Image Path, string animation name, float scale)
// int = BMW_LoadSkeleton(string JsonPath, string Atlas Image Path)
// void = BMW_SetSkelBoneImage(int skeleton id, string bone name, float bone angle offset, integer attachment offset X, integer attachment offset Y, float scale, int atlas offset X, int atlas offset Y, int atlas image width, int atlas image height)
// void = BMW_SpineAtlasReader(int spine data index, string Atlas Path)
// void = BMW_CloneSkel(int skeleton to clone, int new skeleton index)
// void = BMW_DeleteSkel(int skeleton to clone)
// void = BMW_PrepAtlasImage(string Atlas Image Path)
// int = BMW_MaintainSkelList(i as integer, sPath$, guid$)
// BMWskel_commands.agc
// void = BMW_playSkeletonAnimation(int skeleton ID, string sAnim , float fTime, int bLoop )
// void = BMW_stopSkeletonAnimation(int skeleton ID)
// int = BMW_GetSkeletonExists(string searchID)
// float = BMW_GetSkeletonCurrentTime(int skeleton ID)
// float = BMW_GetSkeletonCurrentAnimationTotalTime(int skeleton ID)
// void = BMW_SetSkeletonPosition(int skeleton ID, float x#, float y#)
// void = BMW_SetSkeletonAngle(int skeleton ID, float ang#)
// int = BMW_GetSkeletonPositionX(int skeleton ID)
// int = BMW_GetSkeletonPositionY(int skeleton ID)
// string = BMW_GetSkeletonCurrentAnimationName(int skeleton ID)
// int = BMW_GetSkeletonCurrentAnimationFinished(int skeleton ID)
// int = BMW_GetSkeletonBoneIDByName(int skeleton ID, string sSearch$)
// float = BMW_GetSkeletonBoneCurrX(int skeleton ID, int bone ID)
// float = BMW_GetSkeletonBoneCurrY(int skeleton ID, int bone ID)
// float = BMW_GetSkeletonBoneCurrAngle(int skeleton ID, int bone ID)
// int = BMW_GetSkeletonAnimationCount(int skeleton ID)
// int = BMW_GetSkeletonAnimationExists(int skeleton ID, string sSearch$)
// int = BMW_GetSkeletonIsPlaying(int skeleton ID)
// int = BMW_GetSkeletonIndex(guid$ as string)
// void = BMW_SetSkeletonScale(int skeleton ID , float fScale#)
// float = BMW_getSkeletonScale(int skeleton ID )
// void = BMW_SetSkeletonDepth(int skeleton ID , int iDepth )
// void = BMW_FixSkeletonToScreen(int skeleton ID, int bFix )
// void = BMW_applyShaderEffect(int skeleton ID , int iShader ID , fDuration as float)
// void = BMW_updateShaderEffect(int skeleton ID )
// void = BMW_SetSkeletonShader(int skeleton ID ,int Shader ID )
// void = BMW_SetSkeletonSlotShader(int skeleton ID ,int slot id ,int Shader ID)
// void = BMW_SetSkeletonVisible(int skeleton ID ,int bVis )
// void = BMW_skeletonFlip(int skeleton ID ,int iDirection )
// float = BMW_WrapValue(float angle)
// void = BMW_CheckEvents(int skeleton id)
// void = BMW_ResetEvents(int int skeleton id), int animation ID)
// BMWskel_tweens_build.agc
// void = BMW_BuildTweens_translate(int skeleton id)
// void = BMW_BuildTweens_rotate(int skeleton id)
// void = BMW_BuildTweens_scale(int skeleton id)
// void = BMW_BuildTweens_color(int skeleton id)
// void = BMW_DriveSkeletonTweens(int skeleton id)
// BMWskel_tweens_resolve.agc
// void = BMW_StartTweens(int skeleton id, int animation index)
// void = BMW_StopTweens(int skeleton id)
// void = BMW_ResolveBoneTweens(int spine data index)
// void = BMW_ResolveSlotTweens(int skeleton id)
// BMWskel_spine_data.agc
// int = BMW_GetSpineData(string Json Path)
// void = BMW_BindSpineDATASkinsToBones(int spine data index)
// void = BMW_GetSpineData_animations(int json doc, int spine data index)
// void = BMW_GetSpineData_bones(int json doc, int spine data index)
// void = BMW_GetSpineData_slots(int json doc, int spine data index)
// void = BMW_getSpineData_3_7_skins(int json doc, int spine data index)
// void = BMW_getSpineData_3_8_skins(int json doc, int spine data index)