翻转osx SceneKit中的y轴

时间:2014-05-10 13:01:59

标签: macos scenekit

我在OSX上使用SceneKit。

是否可以在SceneKit中翻转y轴。

我希望y轴上升而不是正面?

更新,这是我的代码,我已经尝试过-1 y轴,但是盒子仍然在右上角...

- (void)awakeFromNib
{
SCNScene *scene = [SCNScene scene];
self.scene = scene;

scene.rootNode.scale = SCNVector3Make(1, -1, 1);

self.allowsCameraControl = YES;
self.jitteringEnabled = YES;

defaultNode = [SCNNode node];
actorsNode = [SCNNode node];

// A 3D camera
cameraNode3D = [SCNNode node];
cameraNode3D.camera = [SCNCamera camera];
cameraNode3D.position = SCNVector3Make(0, 10, 400);
cameraNode3D.camera.zFar = 3500.0;
cameraNode3D.camera.yFov = 35.0;
cameraNode3D.transform = CATransform3DTranslate(cameraNode3D.transform, 0, 0, 50.0);

//A 2D camera
cameraNode2D = [SCNNode node];
cameraNode2D.camera = [SCNCamera camera];
[cameraNode2D.camera setUsesOrthographicProjection:YES];
cameraNode2D.scale = SCNVector3Make(200, 200, 10);
cameraNode2D.camera.zFar = 1500.0;
cameraNode2D.transform = CATransform3DTranslate(cameraNode2D.transform, 0, 0, 50.0);


[scene.rootNode addChildNode:cameraNode2D];


SCNLight *ambient = [SCNLight light];
ambient.type = SCNLightTypeAmbient;
ambient.color = [NSColor colorWithDeviceWhite:1.0 alpha:1.0];
SCNNode *ambientNode = [SCNNode node];
ambientNode.light = ambient;
[defaultNode addChildNode:ambientNode];


axisNode = [SCNNode node];

SCNCylinder *xAxis = [SCNCylinder cylinderWithRadius:0.5 height:3500];
xAxis.firstMaterial.diffuse.contents = [NSColor redColor];
xAxis.firstMaterial.ambient.contents = [NSColor redColor];
SCNNode *xNode = [SCNNode nodeWithGeometry:xAxis];
[axisNode addChildNode:xNode];

SCNCylinder *yAxis = [SCNCylinder cylinderWithRadius:0.5 height:3500];
yAxis.firstMaterial.ambient.contents = [NSColor greenColor];
SCNNode *yNode = [SCNNode nodeWithGeometry:yAxis];
yNode.transform = CATransform3DRotate(yNode.transform, radians(90.0), 0, 0, 1.0);
[axisNode addChildNode:yNode];

SCNCylinder *zAxis = [SCNCylinder cylinderWithRadius:0.5 height:3500];
zAxis.firstMaterial.ambient.contents = [NSColor blueColor];
SCNNode *zNode = [SCNNode nodeWithGeometry:zAxis];
zNode.transform = CATransform3DRotate(zNode.transform, radians(90.0), 1.0, 0, 0);
[axisNode addChildNode:zNode];


SCNPlane *plane = [SCNPlane planeWithWidth:100.0 height:100.0];

plane.firstMaterial.ambient.contents = [NSColor redColor];
plane.firstMaterial.doubleSided = TRUE;
SCNNode *pNode = [SCNNode nodeWithGeometry:plane];
pNode.position = SCNVector3Make(100, 100, 0);
[actorsNode addChildNode:pNode];

//Add the axis node
[defaultNode addChildNode:axisNode];

[scene.rootNode addChildNode:defaultNode];
[scene.rootNode addChildNode:actorsNode];

}

0 个答案:

没有答案