Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // NoctuaryTestView.m
- // Noctuary
- //
- // Created by Dylan Lukes on 2/20/12.
- // Copyright (c) 2012 Dylan Lukes. All rights reserved.
- //
- #import "NoctuaryTestView.h"
- #import <SceneKit/SceneKit.h>
- @implementation NoctuaryTestView
- - (id)initWithFrame:(NSRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- NSArray *sources = @[
- [SCNGeometrySource geometrySourceWithVertices: (SCNVector3[]){
- {.x = 0.0f, .y = 1.0f, .z = 0.0f},
- {.x = -1.0f, .y = -1.0f, .z = 0.0f},
- {.x = 1.0f, .y = -1.0f, .z = 0.0f}
- } count:3]
- ];
- NSArray *elements = @[
- [SCNGeometryElement geometryElementWithData:[NSData dataWithBytes:(short[]){0, 1, 2} length:sizeof(short[3])]
- primitiveType:SCNGeometryPrimitiveTypeTriangles
- primitiveCount:1
- bytesPerIndex:sizeof(short)]
- ];
- SCNGeometry *geo = [SCNGeometry geometryWithSources:sources elements:elements];
- SCNNode *node = [SCNNode nodeWithGeometry:geo];
- SCNScene *scene = [SCNScene scene];
- [scene.rootNode addChildNode:node];
- SCNLayer *layer = [SCNLayer layer];
- layer.scene = scene;
- self.layer = layer;
- self.wantsLayer = YES;
- }
- return self;
- }
- - (void)drawRect:(NSRect)dirtyRect
- {
- // Drawing code here.
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement