在二维场景图中应用变换
在二维场景图中:当我在节点中执行旋转或其他变换时,我应该如何在子节点中应用这些操作?如果我对每个孩子都进行手术,可能会花费很多时间。我认为当应用程序渲染场景时,在每个节点中,全局旋转都会添加当前节点旋转。平移和比例也是如此。当图中 上升时,那些全局属性就会被减去。有更好的办法吗?
In a 2d scene graph: When I perform a transformation like a rotation or other in a node, how I should apply these operations in children nodes? If I apply the operation in each children, it can take much time. I thought when the app render the scene, in each node down the global rotation is added with the current node rotation. The same with translation and scale. When is rising in the graph, those global properties is subtracted. Is there a better way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用堆栈,并在该堆栈上推出并弹出当前转换矩阵。
这样,每个节点在绘图时都有一个全局的转换,并且在爬上树时无需“撤消”转换。
You need to use a stack on which you push and pop the current transformation matrix.
This way every node has a global transformation at drawing time, and there's no need to "undo" transformations when going up the tree.