I currently can rotate around a pivot point by first translating to the pivot point then performing the rotation and finally translating back to the origin. I do that easily enough for the shoulder in my example. However I cannot figure out how to also add in a rotation around the elbow for the forearm.
I’ve tried the following for the forearm rotation around the elbow:
- translate to shoulder, rotate, translate to origin, translate to forearm, rotate, translate to origin
- translate to shoulder, rotate, translate to forearm, rotate, translate to shoulder, translate to origin
Neither work for me. Any suggestions? I’m really stuck on this one.
I ran into a similar problem when I was doing some skeletal animation. It’s very helpful to use recursion for this. Also, structure your bones hierarchically (e.g. shoulder is a parent of forearm which is a parent of hand, etc.). By doing that you can write your code as follows:
My bone struct looked like this:
This website is a great resource for skeletal animation.