SceneKit Orbital Transformations

北慕城南 提交于 2019-12-12 07:38:51

问题


So having started with SceneKit all has gone well so far until I stumbled upon transformations, thinking that it would be like CA3d* transformations on layers.

However it seems I quite wrong and transformation work quite differently with regards to how the Z-axis works.

For example I am trying to accomplish a 3d orbital style movement, similar to a carousel look. This piece of CA3D code works brilliantly to do that:

var trans = CATransform3DIdentity
trans = CATransform3DRotate(trans, deg * (Float(M_PI)/180), 1, 1, 0)
trans = CATransform3DTranslate(trans, 0, 0, 100)
layer.transform = trans

If applied to multiple objects with different "deg" values, you get a nice circular 3d orbit look.

The same with SceneKit produces different result:

var trans = SCNMatrix4Identity
trans = SCNMatrix4Rotate(trans,Float(angleTemp*(M_PI/180)), 1, 1, 0)
trans = SCNMatrix4Translate(trans, 0, 0, 100)
node.transform = transform

What happens actually is after the rotation the Z-value axis changes and translates based on the rotation applied in CAT3D + layers, however on SceneKit the Z-axis is always constant so the translation just moves them all together, so you just get a squashed look.

So I understand that this is working in true 3d space but now it seems I am having to work with Sphereical and Ellipse mathematics to do the same.

So anyone can offer me tips how to do what I am trying to do? I am now experimenting with spherical maths and using SCNMatrix4Translate but I haven't quite got the maths right yet.

I think what I need is formulas to calculate xyz for an Ellipse, I am after something very similar to this:

http://en.wikipedia.org/wiki/Ellipse#mediaviewer/File:Conicas1.PNG

That kind of orbit can be achieved using the CAT3D snippet above on layers.

So long story short, I need to get an orbital layout like the above picture and need some help on it with SceneKit and/or geometry maths. All the object should rotate around a centre origin like an orbit

来源:https://stackoverflow.com/questions/24556391/scenekit-orbital-transformations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!