Re: Scene Kit
Re: Scene Kit
- Subject: Re: Scene Kit
- From: Daniel Vollmer <email@hidden>
- Date: Sun, 21 Oct 2012 11:38:10 +0200
Hi,
On 21 Oct 2012, at 00:44, Thomas Cunningham <email@hidden> wrote:
>
>>> How (as in by which amounts) are you modifying the properties to arrive at those mixed results? Why are they not what you want? What do you actually want?
>
> I want to know what properties I should be adjusting to simulate a zoom in and a zoom out.
No, you already *know* what you should adjust to zoom in and out, because as you say below, it works the first time.
> Using the Scene Kit Fun project, I place this code in the mousedown event, distance is an ivar that is set to 45.
>
> self->distance = self->distance - 5.0;
> camera.xFov = distance; // degrees
> camera.yFov = distance;
> [self setNeedsDisplay:YES]; // just in case it needs refreshing
>
> On the first click it zooms in fine, subsequent clicks are ignored, no zoom in, values are correctly reflected in the log.
The basic principle works absolutely fine here (although I had to hunt down to the non-Apple example code you were referring to).
I think your problem lies elsewhere, probably not setting the properties on the right object. What is camera in your snippet above? In the example I had, it was only a local variable declared in awakeFromNib:.
Here are my changes from SceneKitFun - HitTest:
--- /Users/maven/Downloads/SceneKitFun-1/SceneKitFun Hit Testing/SceneKitFun/MCPSceneView.h 2012-08-17 19:32:50.000000000 +0200
+++ /Users/maven/Downloads/SceneKitFun/SceneKitFun Hit Testing/SceneKitFun/MCPSceneView.h 2012-10-21 11:25:00.000000000 +0200
@@ -9,4 +9,6 @@
#import <Cocoa/Cocoa.h>
#import <SceneKit/SceneKit.h>
@interface MCPSceneView : SCNView
+@property double distance;
+@property SCNCamera *camera;
@end
--- /Users/maven/Downloads/SceneKitFun-1/SceneKitFun Hit Testing/SceneKitFun/MCPSceneView.m 2012-08-18 16:40:52.000000000 +0200
+++ /Users/maven/Downloads/SceneKitFun/SceneKitFun Hit Testing/SceneKitFun/MCPSceneView.m 2012-10-21 11:34:44.000000000 +0200
@@ -13,6 +13,7 @@
@implementation MCPSceneView
-(void)awakeFromNib
{
+ self.distance = 45.0;
self.backgroundColor = [NSColor grayColor];
// Create an empty scene
@@ -20,11 +21,11 @@
self.scene = scene;
// Create a camera
- SCNCamera *camera = [SCNCamera camera];
- camera.xFov = 45; // Degrees, not radians
- camera.yFov = 45;
+ self.camera = [SCNCamera camera];
+ self.camera.xFov = 45; // Degrees, not radians
+ self.camera.yFov = 45;
SCNNode *cameraNode = [SCNNode node];
- cameraNode.camera = camera;
+ cameraNode.camera = self.camera;
cameraNode.position = SCNVector3Make(0, 0, 30);
[scene.rootNode addChildNode:cameraNode];
@@ -107,6 +108,10 @@
highlightAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[material.emission addAnimation:highlightAnimation forKey:@"highlight"];
+
+ self.distance = self.distance - 5.0;
+ self.camera.xFov = self.distance; // degrees
+ self.camera.yFov = self.distance;
}
[super mouseDown:event];
Daniel.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >Re: Scene Kit (From: Thomas Cunningham <email@hidden>) |