Advertisement
Guest User

Untitled

a guest
Jul 21st, 2012
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. //
  2. // NoctuaryTestView.m
  3. // Noctuary
  4. //
  5. // Created by Dylan Lukes on 2/20/12.
  6. // Copyright (c) 2012 Dylan Lukes. All rights reserved.
  7. //
  8.  
  9. #import "NoctuaryTestView.h"
  10. #import <SceneKit/SceneKit.h>
  11.  
  12. @implementation NoctuaryTestView
  13.  
  14. - (id)initWithFrame:(NSRect)frame
  15. {
  16. self = [super initWithFrame:frame];
  17. if (self) {
  18. NSArray *sources = @[
  19. [SCNGeometrySource geometrySourceWithVertices: (SCNVector3[]){
  20. {.x = 0.0f, .y = 1.0f, .z = 0.0f},
  21. {.x = -1.0f, .y = -1.0f, .z = 0.0f},
  22. {.x = 1.0f, .y = -1.0f, .z = 0.0f}
  23. } count:3]
  24. ];
  25.  
  26. NSArray *elements = @[
  27. [SCNGeometryElement geometryElementWithData:[NSData dataWithBytes:(short[]){0, 1, 2} length:sizeof(short[3])]
  28. primitiveType:SCNGeometryPrimitiveTypeTriangles
  29. primitiveCount:1
  30. bytesPerIndex:sizeof(short)]
  31. ];
  32.  
  33. SCNGeometry *geo = [SCNGeometry geometryWithSources:sources elements:elements];
  34.  
  35. SCNNode *node = [SCNNode nodeWithGeometry:geo];
  36.  
  37. SCNScene *scene = [SCNScene scene];
  38. [scene.rootNode addChildNode:node];
  39.  
  40. SCNLayer *layer = [SCNLayer layer];
  41. layer.scene = scene;
  42.  
  43. self.layer = layer;
  44. self.wantsLayer = YES;
  45. }
  46.  
  47. return self;
  48. }
  49.  
  50. - (void)drawRect:(NSRect)dirtyRect
  51. {
  52. // Drawing code here.
  53. }
  54.  
  55. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement