Jump to content
  • Advertisement

dewey__

Member
  • Content Count

    6
  • Joined

  • Last visited

Community Reputation

106 Neutral

About dewey__

  • Rank
    Newbie
  1. I can get a transformation for a bone either in global space matrix, or global space location, rotation and scale vectors. I need to assign it to a bone which can have parents, so I need to recalculate the rotation and location (and scale) in respect to the parent bone transforms. The API I use is the Blender API and I can get the transforms of the parent bone relative to their own parent, if any.
  2. I just noticed that assigning an animation matrix to a PoseBone changes the matrix. What? <Matrix 4x4 (-0.0147, 0.0409, -0.9991, 0.3136) ( 0.0093, 0.9991, 0.0407, -0.0768) ( 0.9998, -0.0087, -0.0150, 9.2912) ( 0.0000, 0.0000, 0.0000, 1.0000)> <Matrix 4x4 (-0.0000, -0.0000, -1.0000, -0.0000) (-0.0000, 1.0000, -0.0000, -0.1500) ( 1.0000, 0.0000, -0.0000, 9.3372) ( 0.0000, 0.0000, 0.0000, 1.0000)>from file/in PoseBone
  3. If you're wondering if the problem comes from assigning the matrices in wrong order, then don't worry, that's not it. After all the Blender 2.4 version of my script works perfectly, as I've said already. And don't forget this is an example format and example importer in the archive I uploaded. And of course you can check if its in correct order by loading the anim file on the left Armature.
  4. The matrices in the files are armature space, no relative stuff. The matrices store location, rotation and scaling (usually just 1,1,1). However I want to be able to apply it to an Armature which has bone hierarchy (parenting). It's actually an old game format. So sadly I can't just change the way the animation format works. But I don't think that's necessary is it? We just need to convert matrix spaces. I tried this before, but you can see that it does something different: if pose.bones[bonename].parent: # if has parent bone parentmat = pose.bones[bonename].bone.parent.matrix_local.copy().inverted() pose.bones[bonename].matrix = frames[frame][bonenumber] * parentmat else: pose.bones[bonename].matrix = frames[frame][bonenumber] just replace the line "pose.bones[bonename].matrix = frames[frame][bonenumber]" with this.
  5. I've heard of this answer: multiply the object's (bone's) matrix by the inverse of the parent's matrix, but it doesn't quite work. I use Blender, but the question might not be API specific. I have some matrices I need to assign to PoseBones (bones used for animating). The resulting pose looks fine when there is no bone hierarchy (parenting) and messed up when there is. I've uploaded an archive with sample blend of the rigged models, test animation importer and a test animation file here: http://www.2shared.c...mple_files.html Import the animation by selecting an Armature and running the importer on "sba" file. Do this for both Armatures. This is how I assign the poses in the real (complex) importer: matrix_bases = ... # matrix from file animation_matrix = matrix_basis * pose.bones['mybone'].matrix.copy() pose.bones[bonename].matrix = animation_matrix If I go to edit mode, select all bones and press Alt+P to undo parenting, the Pose looks fine again. The API documentation says the PoseBone.matrix is in "object space", but it seems clear to me from these tests that they are relative to parent bones. Final 4x4 matrix after constraints and drivers are applied (object space)[/quote] I tried doing something like this: matrix_basis = ... # matrix from file animation_matrix = matrix_basis * (pose.bones['mybone'].matrix.copy() * pose.bones[bonename].bone.parent.matrix_local.copy().inverted()) pose.bones[bonename].matrix = animation_matrix But it looks worse. Experimented with order of operations, no luck with all. For the record, in the old 2.4 API this worked like a charm: matrix_basis = ... # matrix from file animation_matrix = armature.bones['mybone'].matrix['ARMATURESPACE'].copy() * matrix_basis pose.bones[bonename].poseMatrix = animation_matrix pose.update() Link to Blender API ref: http://www.blender.o...types.BlendData http://www.blender.o....types.PoseBone I've tried the blender forums (several times) with no answer.
  • 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!