Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Loius · Mar 27, 2013 at 08:40 AM · animationbone

I need a point midway between two bones' rest positions

I can't get matrices to work in my head. There should be a simple multiplication to get this, but my feeble attempts result in seemingly random placement of the 'midpoint'.

I have an animated character (its bones are not in their rest position), and I need to get a point 'along a bone' - specifically, the point is directly on the line between two bone transforms.

Getting that point in the animation space or world space is easy, but I need to get it in the armature's 'rest space', working back from the animation space somehow. SkinnedMeshRenderer.bindposes seems to be related, but I'm at a loss. Any math gurus able to expand on this?

 bones : List.<Transform> = new List.<Transform>( smr.bones ); // copy bones into a list for IndexOf
 
 // find point between bone #index and #index2:
 var ray : Ray;
 ray.origin = bones[index].position;
 ray.direction = bones[index2].position-ray.origin;
 
 centerInWorldSpace = ray.origin + ray.direction * desiredLength; // works!
 
 ray.origin = smr.bindposes[index] * bones[index].position; // doesn't land on the bone line
 // or is that right, and the complex logic i haven't copied here is getting the wrong index? i don't even know where to look.
 
 centerInAnimationSpace = ray.origin + ray.direction * desiredlength; // would work if the ray was built correctly

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by whydoidoit · Mar 27, 2013 at 09:27 AM

Well the bindpose converts the position of the bone relative to the parent (root) of the mesh in local coordinates. So don't you need to do:

 ray.origin = (smr.bindposes[index] * (bones[index].position - meshHolder.position))+meshHolder.position;
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image whydoidoit · Mar 27, 2013 at 09:45 AM 0
Share

Sorry - think I'm being thick their - now I think it's actually the parent it's offseting from so it would be:

 ray.origin = (smr.bindposes[index] * (bones[index].localPosition))+meshHolder.position;
avatar image Loius · Mar 27, 2013 at 11:13 AM 0
Share

Got me pointed in the right direction! From your snippet I managed to get the bones to clump together in a reasonable pattern, but it's clear (now, to me) that the bindpose relies on the parent bone and not just the mesh itself.

It seems like I need to reset the bind poses of each bone in order to reconstruct the original bone structure.

So, uh. Can I set a transform's data from the bindpose matrix with a function? I'd hardly trust me to write that, I am horrendous with mathematics.

Resetting localPosition and localRotation of each bone using bindpose somehow should snap the skeleton to its default pose, then I can just store the bone relationships and restore the pose it WAS in.

Argh, it might be better to write a helper component to just store this stuff on Start... it's late, I'll wonder more when I wake up.

avatar image Loius · Mar 28, 2013 at 08:00 AM 0
Share

I am an utter failure at applied math, so I made a purely logical solution ins$$anonymous$$d :S

Now I've just got a helper component sitting on objects that might want this functionality - it has to be set up in edit mode, but as it turns out, I want to exclude helper bones anyway so it's kind of a good thing.

Answer marked as accepted because someone who knows what mathwords mean can certainly make it work from there.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Animate Bones, or Geometry? 1 Answer

Anima2d: How to use a single sprite for two paws? 0 Answers

Can I make animations snap to a frame? 1 Answer

How can I animate a single model with two skinned meshes? 1 Answer

Blender animation problem with armature 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges