Jump to content

Rotation and scaling inheritance of bones and objects


Trixt0r

Recommended Posts

Hi there,

first of all: You did a very very good job. The spriter editor is awesome and I really like your work.

I'm new to brashmonkey. I started last week to work a little bit with your scml format.

I'm a hobby game programmer, programming a jump and run game with game maker (now trying to move all the game logic to LibGDX) and a few months ago I wrote my own bone tool for my game, and it worked good.

But since I saw your Spriter tool I decided to work with it and it's file format. And because I don't want to reanimate my animations, made with my own bone tool, I wrote a little converter, which converts my file format to your scml file format. It works quite good if I don't convert the parenting for bones and sprites.

Now the problem: If I let a child bone or a sprite inherit scaling and rotation, Spriter breaks the scaling and rotation of my objects.

My question is: Is or will be there a way to define an attribute for an object or bone in the scml file, to do not inherit the scaling and rotation of the parent bone?

Because in the a4.1 version the scaling and rotation is inherited automatically if the file is loaded (even for bones). This would make many things easier for me.

Greetings from Switzerland :)

Link to comment
Share on other sites

I could do that, but I have very many animations to convert.

If I would parent them by hand, it would me cost too much time.

Maybe anyone could tell me how spriter calculates the x and y values for a child object or bone if they get another/new parent.

Then I could let my converter try to calculate the right values.

My idea is the following: Assume I have the absolute point of an object, which I want to parent with a bone, let's call this point oPosition.

Then I have a bone, which is going to be the parent of my object at the absolute position pPosition.

And this is how I calculate the x and y (newPosition) of the object for spriter:


Vec2 getRelPosition(Vec2 oPosition, Vec2 pPosition){
Vec2 temp = pPosition-oPosition;
float length = temp.length();
float angle = temp.angle();
return new Vec2(cos(toRadians(angle))*length,sin(toRadians(angle))*length);
}

But this doesn't work at all.

I also tried to inverse the method from here: http://www.brashmonkey.com/forum/viewtopic.php?f=2&t=1400, but didn't work.

Btw, if I don't parent the bones and objects, everything works fine for the keyframes.

But the interpolation is not the intended one, because the child bones and objects don't move relative to the parents.

Thanks for your help.

Link to comment
Share on other sites

To me, it seems like the easiest solution to your problem is to have your engine support your old format in addition to Spriter. That way you can keep using your old animations, and make new ones with Spriter. (If I understand you correctly, it seems that the difference between your system and Spriter is too big to easily convert between them.)

Link to comment
Share on other sites

Nope, there are not so many differences. The main difference is that my skeletons are final. You can't change the hirarchy/structure of the bones.

Anyway, I solved my problem. The problem was, that I made some mistakes inverting this method:

PointF rotatePoint(float px,float py, float parentAngle,float parentX, float parentY)
{
float s = sin(toRadians(parentAngle));
float c = cos(toRadians(parentAngle));
float xnew = (px * c) - (py * s);
float ynew = (px * s) + (py * c);
xnew+=parentX;
ynew+=parentY;
return PointF(xnew,ynew);
}

People, who are interested or are going to run in the same problem: Here is, how can calculate the px and py:

px = (xnew*c) + (ynew*s);
py = (ynew*c) - (xnew*s);
px = px/parent_scale_x;
py = py/parent_scale_y;

Thank you for your attention and your help!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...