Jump to content

Problems with scaling


Jan

Recommended Posts

Hello,

I've written a spriter importer for my own render engine. Everything is working as expected up the point when bones are scaled in spriter. Then my displayed characters are distorded badly.

I think I just didn't understand how scale is applied in spriter and unfortunately things are still not getting clear to me even after thinking about it and reducing setups to a minimum.

So my basic questions are: Which role is playing scale in the whole transformation setup and in which order is it applied?

Here are some points that confuse me:

The scml documentation says for scale: "ratio of (original) image width/height". When I change the scale in spriter all other connected bones are moving to. So obviously scale is also applied to the bone transformation and is not only applied as a factor to the image size. Is the documentation outdated at this point or did I misunderstand the documentation?

In a very basic setup when I connect one sprite to a bone the sprite is rotated by 270°. That is right because the bone base position points down the positive x-axis. So the sprite must be rotated in it's local space by 270°. When the bone is scaled before the sprite is attached to it, the newly attached sprite gets a scale factor which compensates the bone scaling so that the sprite is displayed in its original size. In this setup the sprite gets a scale factor also for the x axis although it is rotated by 270°. I would have expected that it is scaled in y. As far as I can understand this scaling in x makes only sense if it is applied after rotation. This seems unusual to me and changing the transformation order (first rotate, then scale) only solves issues in certain situations.

Thank you very much for your help!

Kind regards,

Jan

Link to comment
Share on other sites

Hello Jan,

Spriter is designed to work even on engines using separate sprites for each object, where only scale and angle are applied on an individual basis. This might help to explain:

transforms.png

So, the if the first bone is 1.5 x scaled, then rotated. Any child bone or sprite, will be 1.5 x scaled*their own x scale, then rotated, and any child of that bone, will be the result that multiplied x scale times it's own, etc.

Please let me know if that answers your question, if not I can give a more detailed answer.

Link to comment
Share on other sites

Hello lucid,

thank you very much for the quick reply.

When I got you right my assumed order of transformation is wrong. Just to clearify, I thought a sprite's transformation would be calculated like this:

M_sprite = M_parent_t * M_parent_r * M_parent_s * M_t * M_r * M_s (Last transform applied first.)

But scaling must be calculated independently. So the correct way would be:

M_overall_scale = M_parent_s * M_s

M_sprite = M_parent_t * M_parent_r * M_t * M_r * M_overall_scale

Did I get you right?

Unfortunately I didn't have the possibility to test this but I will do that as soon as possible.

Jan

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...