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?