SCNNode枢轴更改节点位置是否正常? [英] Is it normal for an SCNNode pivot to change the nodes position?

查看:79
本文介绍了SCNNode枢轴更改节点位置是否正常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过将块的枢轴点设置为任意角来旋转它,但是似乎设置枢轴点实际上是在重新定位节点,从而使该点精确地位于其位置...

I'm trying to rotate a block by setting its pivot point to any of the corners, but it seems as though setting the pivot point actually repositions the node, keeping the point exactly where it was...

例如

SCNBox *box = [SCNBox boxWithWidth:1 height:2 length:1 chamferRadius:0];
SCNNode *node = [SCNNode nodeWithGeometry:box];

node.position = SCNVector3Make(0, 0, 0);
[self.scene.rootNode addChildNode:node];

node.pivot = SCNMatrix4MakeTranslation(0.5, -1, 0.5);

[node runAction:[SCNAction rotateByAngle:GLKMathDegreesToRadians(90) 
                              aroundAxis:SCNVector3Make(0, 0, 1) 
                                duration:2]];

在node.position为0,0,0且箱形为1,2,1,1的情况下,我会想到此块位于地板上方1个单位...如果您不这样做,它会这样做设置枢轴.

With a node.position of 0,0,0 and a box geometry of 1, 2, 1, I would have imagined this block to be sitting 1 unit above the floor... which it does if you don't set the pivot.

真正的问题是,如何在不影响该节点位置的情况下设置该节点的枢轴位置,因此,例如,如果我按了向右键,它将在z轴上绕最右下点旋转,如果我按向左键,它将绕最左下点旋转,上下方向相同,但在x轴上.

The real question is, how would you set the pivot position of this node, without it affecting it's position, so if I for example pushed the right key, it would pivot on the z-axis around the bottom right most point, and if I pushed the left key, it would pivot around the bottom left most point, and same for up and down but on the x-axis.

推荐答案

SCNNode pivot 属性类似于的 anchorPoint CALayer (请参见

the pivot property of an SCNNode is similar to the anchorPoint of a CALayer (see Anchor Points Affect Geometric Manipulations). If you want a change to the pivot property not to have any visual effect, you'll also have to change its transform (or position) property.

这篇关于SCNNode枢轴更改节点位置是否正常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆