Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

111 Neutral

About yanjobin2641

  • Rank
  1. yanjobin2641

    3D vertex skinning

    I got it working with a single bone affecting all vertices of a cube by 1. (!!) I followed the whole process again starting from reading matrices in the collada file, and I realised there was something inversed in the translation part of the matrices. When building my matrices from a string (EX : 1 0 0 0 0 -1 5.88609e-8 0 0 -5.88609e-8 -1 0 0 0 0 1), the Y and Z translations were switched together. Thank you very much Eklipse your reply made me understand a lot of things that I thought I understood before. It is now much clearer how the matrices work together.
  2. yanjobin2641

    3D vertex skinning

    You confused me a bit there. I am not actually sure what the bone space and world space. The vertices I load from the collada file are in local space (I think). Does that mean I can apply the inverse of the bone transform direcly to the vertices to put them into bone space. From there, I apply the new bone transform (im assuming there is only one bone here.) and ti would put them back into 'local space'.   Also, do you know what the bind shape matrix is for ? I read everywhere that you have to multiply the vertex with this bind shape matrix, and I am unsure what it is exacly for   EDIT Now I think I understand a bit better. You need to apply the inverse of the bind pose in order to pring the vertex back to "0" then aply the current transformation matrix. Am I right ? I can read an inverse bind matrix from the COLLADA, but shouldnt it be the same as if I take the absolute transform matrix of a joint in its bind pose and inverse it ? Because it isnt right now. I currently have only one bone in my model, and here is the data I read from the COLLADA file :   bone transformation matrix : 1.0    0.0                0.0                 0.0 0.0    7.54979E-8  1.0                  0.0 0.0    -1.0               7.54979E-8   0.0 0.0    0.0                0.0                 1.0   This is the manually inverted bone transformation matrix, not the one I read from the file: 1.0     -0.0                 0.0                 -0.0 -0.0    7.54979E-8    -1.0                  0.0 0.0     1.0                   7.54979E-8   -0.0 -0.0    0.0                  -0.0                 1.0   Wich is not the same as the corresponding inverse bind shape matrix, read from file: 1.0                      0.0                 0.0                    0.0 0.0                      0.0                 -1.0                   0.0 0.0                      1.0                 0.0                    0.0 -0.005478084     -0.5606597   -0.002059936   1.0   Should I ignore the inverted bind pose matrix read from the file and just create mine by inverting the absolute transform of the bone when loading it ?
  3. yanjobin2641

    3D vertex skinning

      Thank you for the reply.   First of all, if I render my model without applying any skinning transforms, it looks exacly how it should look like. I am not exacly sure but I am guessing that they are in world space, since they are draw a the right place.   In the file, the bones are relative to their parent bone. So the matrix I read is the local matrix, relative to its parent. To create the world matrix or a joint I take the parent world matrix and I multiply it by its local transform. I already start from the root bone, and move down the hierarchy. As for the root bone, its local transform becomes the world transform.   I have thought about trying to draw my skeleton to see if there is a problem, but I am still not an expert with openGL drawing stuff, but I will work on that.   Other than that, I have just no idea what else to try. I have switch matrices around to see the result, but nothing is as close as what I currently get.
  4. yanjobin2641

    3D vertex skinning

    Sorry I hit the post button before finishing my post =/. Editing it right now ! :P
  5. Hi, over the past week, I have been struggling alot with 3D vertex skinning. I use blender to create my model, to rig them and I expert the mesh and its armature in COLLADA file (.dae). Btw, I am using java with lwjgl, wich uses mostly opengl.   However, I am having trouble trying to get my mesh into its bind pose in my game engine. Here is what I have :   In the <library_visual_scenes> node of the collada file, I can read the whole bone hierarchy, and get the local matrix of each joint: <node id="Bone" name="Bone" sid="Bone" type="JOINT"> <matrix sid="transform">1 0 0 0 0 7.54979e-8 -1 0 0 1 7.54979e-8 0 0 0 0 1</matrix> Then, in the <library_controllers> node, I firstly read the bind shape matrix: <skin source="#Cube-mesh"> <bind_shape_matrix>1 -2.22045e-16 0 2.32831e-10 0 1 1.19249e-8 1.19249e-8 0 -1.19249e-8 0.9999999 0.9999999 0 0 0 1 </bind_shape_matrix> In the same node, I also read all the inverse bind matrix aswell as all the weights associated to vertex.   I have verified all the datas after loading them to see if they get loaded correctly, so the problem should not be in loading datas, unless there is something I don't know about collada matrices.   After loading the collada file, I calculate the world matrices of each joint by multiplying its local matrix with its aprent's world matrix. For the root joint, the local matrix becomes the world matrix.   The vertex shader is where I calculate the final vertex position. Here is how I proceed (For some reason I cannot post code anymore) : vec4 actualPosition = vec4(position, 1.0); vec4 weightedPos = (((actualPosition * bindShapeMatrix) * boneTransforms[boneIDs.x]) * boneWeights.x) + (((actualPosition * bindShapeMatrix) * boneTransforms[boneIDs.y]) * boneWeights.y) + (((actualPosition * bindShapeMatrix) * boneTransforms[boneIDs.z]) * boneWeights.z) + (((actualPosition * bindShapeMatrix) * boneTransforms[boneIDs.w]) * boneWeights.w); actualPosition += weightedPos;   The bindShapeMatrix was taken from the collada file. It's the same for every vertex. The boneIDs are indices to get the skinningMatrix from boneTransfroms The boneWeights are weights that the corresponding boneID affect the current vetex. (total of 1.0, for all 4) The boneTransforms array contains all the joints skinning matrices(I think thats how they call it)   To get the skinning matrix of a joint, I multiply its inverse bind matric with its world matrix :   Matrix4f skinningMatrix = new Matrix4f(); Matrix4f.mul(invBindShapeMatrix, worldMatrix, skinningMatrix);   But sadly, this doesnt give me the right results. On the left you can see an image of what it should look like in its bind pose, taken from blender. On the right, there is 2 images of different views of what it actually look like in my game engine,    http://www.cjoint.com/15jv/EAqtjo1KdhU.htm   As you can see, it is pretty close but something is definetly wrong.   For testing purpose, I have break it down to a simple cube with 2 bones. Bottom bone being the root bone, affecting the bottom 4 vertices of the cube, and the top bone affecting the other 4 top vertices. And I get the same results, some vertices (not all) are not at their position.   http://www.cjoint.com/15jv/EAqult0S5fE.htm   From this example, I definitely think something is wrong with the root bone, or something is wrong with the weights, because vertices affected by the top bones (4 top vetices) are in their correct position.   I am currently trying on paper to do all the matrix muliplications by myself to see if I get the same results. After doing the calculations in the shader, the vertex position should not change, so I am trying to see whats wrong. The down part of glsl is that I cannot put breakpoints or print stuff in the console to debug, so it makes things harder.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!