ios - Camera Rotation in SceneKit -
i have posted similar question here , different in deals eular angles.
given setup had in other post. simple board on screen, , camera looking @ it, want rotate camera. simplicity doing entire camera in code. context, per other question , answer have established board runs long on z axis, shorter on x axis, , height y axis.
adding code scene can see board running on z axis. have raised camera on y axis little better view. end goal board running longways accross camera.
scnnode *cameranode = [scnnode node]; cameranode.camera = [scncamera camera]; cameranode.camera.zfar = 200; cameranode.camera.znear = 0.1; [scene.rootnode addchildnode:cameranode]; cameranode.position = scnvector3make(0, 5, 0); cameranode.eulerangles = scnvector3make(0, 0, 0);
gives
great start. try rotate camera looking top, down on board. understanding need rotate around x-axis accomplish this. did trying following.
scnnode *cameranode = [scnnode node]; cameranode.camera = [scncamera camera]; cameranode.camera.zfar = 200; cameranode.camera.znear = 0.1; [scene.rootnode addchildnode:cameranode]; cameranode.position = scnvector3make(0, 50, 0); cameranode.eulerangles = scnvector3make(0, 0, -m_pi/2);
the ios documentation states rotation in eulars set (z, y, x). did not work, however, , gave blank screen. started experimenting , found rotation around z axis me in right direction.
scnnode *cameranode = [scnnode node]; cameranode.camera = [scncamera camera]; cameranode.camera.zfar = 200; cameranode.camera.znear = 0.1; [scene.rootnode addchildnode:cameranode]; cameranode.position = scnvector3make(0, 50, 0); cameranode.eulerangles = scnvector3make(-m_pi/2, 0, 0);
this rendered screen.
this didn't make sense went ahead , found rotating around y axis desired screen.
scnnode *cameranode = [scnnode node]; cameranode.camera = [scncamera camera]; cameranode.camera.zfar = 200; cameranode.camera.znear = 0.1; [scene.rootnode addchildnode:cameranode]; cameranode.position = scnvector3make(0, 50, 0); cameranode.eulerangles = scnvector3make(-m_pi/2, -m_pi/2, 0);
the y rotation little baffling because have expected have rotate around z axis.
while code works have similar question other post. why have rotate around z axis instead of x axis first rotation. think might not understand eular angles well.
thanks in advance
edit:
as @mnuages pointed out, documentation online states vector in (x,y,z). contrary header documentation use can seen here
it appear bug/typo in apple's code. clearing up.
[comment not fit in comment]
please note documentation states
the order of components in vector matches axes of rotation:
- pitch (the x component) rotation node’s x-axis.
- yaw (the y component) rotation node’s y-axis.
- roll (the z component) rotation node’s z-axis.
Comments
Post a Comment