asahi Posted March 15, 2015 Report Share Posted March 15, 2015 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: But what I got in my game is something like: 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: Get the Matrix of each bone by reading scml data. following code is related to bone matrix calculation. 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;} 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? DarrenOl, DalilaTuP, Ddyrinsyk and 5 others 8 Quote Link to comment Share on other sites More sharing options...
lucid Posted April 7, 2015 Report Share Posted April 7, 2015 Are you applying scale before rotation? Quote Link to comment Share on other sites More sharing options...
asahi Posted April 7, 2015 Author Report Share Posted April 7, 2015 Are you applying scale before rotation? Thank for the attention lucid. :) Yes, I am applying scale first. the sequence is scale->rotation->transform. I have tried to apply rotation first, the result get worse... Quote Link to comment Share on other sites More sharing options...
lucid Posted April 11, 2015 Report Share Posted April 11, 2015 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. Quote Link to comment Share on other sites More sharing options...
asahi Posted April 12, 2015 Author Report Share Posted April 12, 2015 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. Quote Link to comment Share on other sites More sharing options...
lucid Posted April 13, 2015 Report Share Posted April 13, 2015 Thanks @asahi, Could you also do a video of the second animation? (idle_000) Quote Link to comment Share on other sites More sharing options...
asahi Posted April 14, 2015 Author Report Share Posted April 14, 2015 Thanks @asahi, Could you also do a video of the second animation? (idle_000) Here it is. https://github.com/PanXu86/publicfiles/blob/master/skeleton2.mp4 Quote Link to comment Share on other sites More sharing options...
lucid Posted May 4, 2015 Report Share Posted May 4, 2015 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 RunnerPack 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.