获取SCNNode面临的方向 [英] Getting direction that SCNNode is facing

查看:76
本文介绍了获取SCNNode面临的方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我迷失了如何在Scenekit中处理节点空间的坐标和旋转.

I am getting lost in how nodespace coordinates and rotation are handled in scenekit.

旋转后如何获得节点朝向的方向,然后再向该方向施加力.

How do I get the direction a node is facing after rotation so I can then apply force in that direction.

我假设沿着-z轴施加到节点上的力总是会使它相对于节​​点向前移动,但是事实并非如此.

I assumed that a force along the -z axis applied to the node would always move it forward relative to the node however this is not the case.

推荐答案

负z仅是节点在其自身坐标空间(即其子级和几何体所在的坐标空间)中的面向"方向.施加力时,您正在包含节点的坐标空间中工作.

Negative z is the "facing" direction of a node only in its own coordinate space (i.e. the one its children and geometry are positioned in). When you apply a force, you're working in the coordinate space containing the node.

因此,如果要在节点的向前方向上施加力,则需要使用{0,0,-1}这样的矢量从节点的空间转换成它的父对象的空间. developer.apple.com/library/mac/documentation/SceneKit/Reference/SCNNode_Class/index.html#//apple_ref/occ/instm/SCNNode/convertPosition:toNode:"rel =" nofollow> convertPosition:toNode:

So, if you want to apply a force in a node's forward direction, you'll need to convert a vector like {0,0,-1} from the node's space to its parent's using a method like convertPosition:toNode:.

这篇关于获取SCNNode面临的方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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