I use a hierarchy of joints to create the skeleton, and their coordinates are stored as local (relative to the root bone), So now to flip the skeleton, I simply multiply the X value by -1, and the angle of the bone by -1, That seems to flip the skeleton properly, BUT When there are sprites on each bone I ran into some inconsistencies with the way the sprites looked when flipped(Some things not lining up properly and some things have different looking angles), Here is the code(although I'm fairly sure it wont really help much to show it):
double DrawSkeleton(double Id, double aId, double x, double y, double Xscale)
{
double sId = FindSkeletonById(Id);
if (sId == -1) return 0.0;
int i;
for(int b = 0; b < SkeletonClasses[(int) sId]->BoneDepths.size() ; b++)
{
i = SkeletonClasses[(int) sId]->BoneDepths;
if (gm::sprite_exists(SkeletonClasses[(int) sId]->BoneSprite) && SkeletonClasses[(int) sId]->BoneSprite > 0)
{
gm::draw_sprite_ext( SkeletonClasses[(int) sId]->BoneSprite, 0, x + ( SkeletonClasses[(int) sId]->BoneX) * Xscale, y + SkeletonClasses[(int) sId]->BoneY, Xscale, 1, ( (SkeletonClasses[(int) sId]->BoneAngle) + SkeletonClasses[(int) sId]->BoneSpriteAngle ) * Xscale, gm::c_white, 1);
}
}
return 0.0;
}
If you aren't familiar with this game maker function it's as follows :
draw_sprite_ext( SpriteIndex, SubImage, x, y, Xscale, Yscale, Angle, Color, Alpha);
I'm not sure, but I have a hunch it could possibly be the sprite origins causing the issues I'm having.
Now note the skeleton itself looks just fine when flipped, its just the flipping of the sprites that cause issues.
Some screenshots of the issue:
So I was wondering if any of you could help me out with this issue? Could this possibly be an issue with the origin points of the sprites?
I've tested with 'dummy' sprites and gave them random origins, and they flipped fine.. I'm puzzled by this.
If you need any more info please let me know.(like the sprite origins or original sprite orientation, etc..).
Also, I managed to get the sprites to look better, by flipping along the Y axis, then adding 180 to the sprite angle, That made things look more like they should, but still some inconsistencies.