Jump to content

Need help on bone twisted issue.


asahi

Recommended Posts

Hi, 

 
 
Recently I have tried to integrate Spriter to my game by rendering it by myself.
Before doing anything further I tried to render all the bone correctly.
 
Here is the Grey Guy's bone looks like in Spriter:
Image.png?raw=true
But what I got in my game is something like:
Image1.png?raw=true
 
There is a serious twist in the result I got, and I am not sure what goes wrong, seem it is related to non-uniform scale we have in greyguy skeleton.
 
 
What I have done basically can be break done into following step:
  1. Get the Matrix of each bone by reading scml data. following code is related to bone matrix calculation.
    1. void Transform::ToMatrix( glm::mat4& mat ) const{     glm::mat4 scale(1.0f);     scale = glm::scale(scale, m_scale);     glm::mat4 rot = glm::toMat4(m_rot);     glm::mat4 trans = glm::translate(glm::mat4(1.0f), m_trans);     Matrix::Multiply(scale, rot, mat);     Matrix::Multiply(mat, trans, mat);}void Matrix::Multiply( const glm::mat4& mat1, const glm::mat4& mat2, glm::mat4& output ){     output = mat2 * mat1;}
  2. Get the bone join coordinate by I am just doing (0.0, 0.0, 0.0, 1.0) * localMat * ParentMat1 * ..... ParentMatN
 
Can you guys give me some lead about how could I fix this issue?

 

Link to comment
Share on other sites

  • 4 weeks later...

hello @asahi, if you don't mind, could you please do a screen-capture of what it looks like trying to animate each of the animations in this file: http://tinyurl.com/asahispritertest

 

If  you can't, or if it would be easier, taking a screenshot at 4 points on each animation: 0 milliseconds, 1000 milliseconds, 2000 milliseconds, and 3000 milliseconds should suffice.

 

This file has no images, just bones.

 

This might help me figure out what's happening.

Link to comment
Share on other sites

hello @asahi, if you don't mind, could you please do a screen-capture of what it looks like trying to animate each of the animations in this file: http://tinyurl.com/asahispritertest

 

If  you can't, or if it would be easier, taking a screenshot at 4 points on each animation: 0 milliseconds, 1000 milliseconds, 2000 milliseconds, and 3000 milliseconds should suffice.

 

This file has no images, just bones.

 

This might help me figure out what's happening.

I have uploaded a video of the skeleton you give to me at:

https://github.com/PanXu86/publicfiles/blob/master/skeleton.mp4

(the horizontal line you can see in the video is just about the unused bone in the scml.

 

And I also get all the bone position for 1st frame(0 ms) of the animation at here:

Player_pelvis   (5,40,0)
Player_pelvis   (3.97112,77.0397,0)
Player_chest   (4,81,0)
Player_chest   (4.5867,130.044,0)
Player_head   (5.68297,133.053,0)
Player_head   (50.97,267.108,0)
Player_back_arm   (31.4025,125.2,0)
Player_back_arm   (60.791,91.8076,0)
Player_back_forarm   (63.6757,90.5715,0)
Player_back_forarm   (64.298,67.2632,0)
Player_back_hand   (65.168,65.2072,0)
Player_back_hand   (52.2438,34.2198,0)
Player_front_thigh   (0,0,0)
Player_front_thigh   (200,0,0)
.... for unused bone.
Link to comment
Share on other sites

  • 3 weeks later...

Hi @asahi. sorry it took so long to get back to you.

 

In order to allow Spriter to work on the most possible engines, for now Spriter only supports rigid transformations.

so for child bones, you would apply

the transforms named 'parent' below are the parent's final values after applying their own parent

the transforms named 'child' are the value before applying the parent transform (the same as they are in the file)

scaleX=parentScaleX * childScaleX scaleY=parentScaleY * childScaleY angle=parentAngle + child angle, x=(parentScaleX * childX) rotated around parentPositiony=(parentScaleY * childY) rotated around parentPosition
rigidtransforms.png
transforms.png
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...