人类的 opengl 旋转
目前,我可以通过首先平移到枢轴点然后执行旋转最后平移回原点来围绕枢轴点旋转。在我的例子中,我很容易就肩部做到这一点。然而,我不知道如何为前臂添加围绕肘部的旋转。
我已经尝试过以下方法来实现前臂绕肘部的旋转:
- 平移到肩部、旋转、平移到原点、平移到前臂、旋转、平移到原点
- 、平移到肩部、旋转、平移到前臂、旋转、平移到肩部、平移to origin
都不适合我。有什么建议吗?我真的被这个问题困住了。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在做一些骨骼动画时遇到了类似的问题。为此使用递归非常有帮助。另外,按层次结构构建骨骼(例如,肩膀是前臂的父级,前臂是手的父级,等等)。通过这样做,您可以编写代码如下:
我的骨骼结构如下所示:
这个 网站< /a> 是骨骼动画的重要资源。
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.
第二种方法应该有效。
我真的不知道你的人体模型。一些类似的任务是
我参加的计算机视觉课程的第一个作业。
一个有用的事情是使用场景图来构建共享共同点的部件
局部坐标系。
然后你就可以遍历它并正确旋转。
有用的不是翻译而是使用
glPushMatrix() 和 glPopMatrix()
通过这种方式,您可以在局部坐标系中思考并影响所有其他元素。
The second approach should work.
I don't really know your model for the human body. Some similar task was
a first assignment in a computer vision course I took.
A helpful thing is to use a scene-graph to build parts that share a common
local coordinate system.
Then you can traverse it and rotate correctly.
It is helpful not to translate but to use
glPushMatrix() and glPopMatrix()
In this way you can think in a local coordinate system and affect all other elements.