SlideShare a Scribd company logo
Scene Kit
                        You’re making a scene!




Thursday, 7 March, 13
Thursday, 7 March, 13
Who am I?
                        • ambivalent coder in high school
                        • graduated with an English degree in 1996
                        • became a Mac fanatic; learned C
                        • hyped up for Rhapsody (OS X+Cocoa)
                        • back to school for Comp Sci in 2000
                        • now work as full-time iOS developer
Thursday, 7 March, 13
Motivations
                        Why am I building another 3D library?




Thursday, 7 March, 13
Thursday, 7 March, 13
Microserfs

                        •   1995

                        •   Douglas Coupland

                        •   Oop!

                        •   Virtual LEGO




Thursday, 7 March, 13

Microsoft employees leave to form a start-up in Silicon Valley. His vision for Oop! was
compelling. I wanted it, and still do. The ideas in the book burrowed into my subconscious.
And I wanted to be part of the software development world.
3D
                        • 3D scenes are interesting
                        • Some things are naturally 3-dimensional
                        • We experience a 3D world every day
                        • 3D provides a sense of realism
                        • 3D is creeping into app design through the
                          side door


Thursday, 7 March, 13

“Making a scene” means to attracts attention. That’s a good thing!
Apps: We have pseudo-3D icons, interfaces, pseudo-3D animations
let’s get 3D out in the open in a friendly way
3D is Too Hard

                        • The barrier to entry for 3D is too high.
                        • 3D math is too complicated.
                        • 3D graphics API are too complicated.
                        • Creating 3D content is too complicated.
                        • Can we make it easier?

Thursday, 7 March, 13

Vectors, transformation matrices, projective geometry. Ouch!
OpenGL state, primitives, buffers, shader programs.
I just want to stick some boxes together.
Hide Complexity
                        • Reduce or eliminate need for OpenGL
                        • Replace OpenGL state with Obj-C classes
                        • Use abstractions that feel more natural
                        • Provide necessary types and functions
                        • Take care of math drudge work
                        • Make it easier to make fun apps
Thursday, 7 March, 13

Still missing some fundamental features.
Virtual Toys
                           Not your old LEGO set




Thursday, 7 March, 13

Not about big-budget 3D games.
Example: Sim City
                        •   Build a city

                        •   Build networks:

                            •   roads

                            •   power

                        •   Build an economy

                        •   Unleash havoc



Thursday, 7 March, 13

OPTIONAL
Example: Minecraft
                        •   Explore a virtual world

                        •   Build things:

                            •   buildings

                            •   roads

                            •   railways

                            •   farms

                            •   monster traps

                            •   microprocessors !?



Thursday, 7 March, 13

OPTIONAL: Don’t waste time on this!
Beyond Games
                        • Games market is mature and saturated
                        • Interactive entertainment is bigger
                        • Games are too limiting; too constraining
                        • Toys give more freedom to explore
                        • Toys let you make a world in your image
                        • Virtual toys scale up cheaply
Thursday, 7 March, 13

Virtual toys have a lot of potential. The market could grow a lot.
Examples: Sim City, Sims, Minecraft
Toys are for experimentation and self-directed learning.
Virtual toys are not as fun as real games, but they have qualities real toys lack.
With networked software, you can
Concepts



Thursday, 7 March, 13

If you’re already a 3D developer, please
Scene Kit Concepts
                        • A scene is made of props on a virtual stage
                        • A scene is integrated into a workflow:
                         • assemble props and arrange the scene
                         • capture an image (“paint it”)
                         • update the scene
                         • capture a new image, etc.
Thursday, 7 March, 13

the stage is a conceptual container, the virtual world
in
Design Patterns
                        • Is a scene a model or a view or both?
                         • depends on your point of view
                        • could say it’s a model of a view
                         • classic MVC provides a view of a model
                         • in a simulation, there is another model
                        • scenes are require tools to build
Thursday, 7 March, 13

OPTIONAL
Camera

                        • point of view
                         • field of view, etc.
                        • “style” of the image
                         • fill style, blur, etc.
                        • delegates drawing

Thursday, 7 March, 13

POV: orientation, depth of field, field of view, dimensions, aspect ratio, focus point
Scene Hierarchy

                        • Arrangement
                         • Stage > Partition > Group > Prop
                        • Construction
                         • Prop > Prototype > Mesh > Polygon >
                            Point > Tuple



Thursday, 7 March, 13
Prop

                        •   a “physical” object

                        •   instance of prototype

                        •   make many copies that
                            share the same
                            geometry data




Thursday, 7 March, 13
Prototype

                        •   Collection of meshes

                        •   meshes can be shared

                        •   each mesh can have a
                            customized appearance
                            that is unique to that
                            prototype




Thursday, 7 March, 13

Transform is used to position the mesh in the prototype’s local coordinate space.
I didn’t make this model!
Mesh


                        •   Collection of polygons




Thursday, 7 March, 13
Polygon


                        •   Closed, flat shape

                        •   Composed of points




Thursday, 7 March, 13
Point
                        •   Fundamental geometric
                            concept

                        •   Collection of tuples

                            •   location

                            •   orientation (normal)

                            •   colour

                            •   texture coordinates


Thursday, 7 March, 13

A tuple is a 3-element vector interpreted as a spatial co-ordinate (cartesian space, colour
space, texture space).
Textures may only need 1 or 2 elements. This picture doesn’t tell you much.
Classes and Interfaces
                          Object model, data types, and functions




Thursday, 7 March, 13

Here I’ll begin to review the concepts in reverse order
Base Types
                        • Structures
                         • point, matrix, size, region, triangle ++
                        • vector types often union’ed with an array
                          (e.g.: volume for size)
                        • some have integer and float variations
                        • string transformation functions
Thursday, 7 March, 13

a volume is a union of a size and an array of elements
add picture of code defining Volume and Size types
typedef struct {                typedef struct {
                ! CGFloat x;                    ! NSUInteger w;
                ! CGFloat y;                    ! NSUInteger h;
                ! CGFloat z;                    ! NSUInteger d;
                } BAPointf;                     } BASizei;

                typedef BAPointf BARotation3;   typedef struct {
                                                ! CGFloat w;
                typedef union {                 ! CGFloat h;
                ! BAPointi p;                   ! CGFloat d;
                ! NSInteger i[3];               } BASizef;
                } BALocationi;
                                                typedef union {
                typedef union {                 ! BASizei s;
                ! BAPoint4f p;                  ! NSUInteger i[3];
                ! CGFloat i[4];                 } BAVolumei;
                } BALocationf;
                                                typedef union {
                typedef union {                 ! BASizef s;
                ! BARotation3 r;                ! CGFloat i[3];
                ! CGFloat i[3];                 } BAVolumef;
                } BAOrientationf;




Thursday, 7 March, 13
Utilities
                        • Functions for operating on structures
                        • Imitates functions from NSGeometry.h
                        • Simple operations like creation, midpoints
                        • Complex stuff like matrix math
                        • NSColor to struct transformation
                        • useful drawing functions for debugging
Thursday, 7 March, 13
Managed Object Model
                        Custom NSManagedObject subclasses




Thursday, 7 March, 13
Model: Geometry
Thursday, 7 March, 13
Model: Composition
Thursday, 7 March, 13
Geometric Entities

                        • Point, Prototype and Mesh
                        • support construction from element arrays
                        • along with Group, support flattening back
                          to element arrays




Thursday, 7 March, 13
Mesh

                        • Represent complex geometric shapes
                        • As part of a prototype, support:
                         • appearance properties
                         • spatial transformation
                        • library of simple shapes provided

Thursday, 7 March, 13
Composites

                        • Mesh, Prototype, Prop and Group
                        • can be identified and loaded by name
                        • organization and re-use
                        • have bounding boxes and intersection tests

Thursday, 7 March, 13
Other
                        • BAScene class does some high-level work
                         • manages object model and context
                        • BASceneView: custom OpenGL view
                        • BACameraSetup: view to control camera
                        • BAResourceStorage: caches GL data
                        • BATexture: handles GL texture stuff
Thursday, 7 March, 13

BATexture has an equivalent in GLKit, but Scene Kit is compatible back to 10.5
Alternatives
                        • Quartz Composer
                        • if you don’t want or need Objective-C:
                         • Ogre3D, Irrlicht, Unity, Unreal
                        • for iOS (could be ported to Mac OS X):
                         • iSGL3D - developer has abandoned
                         • Cocos3d (based on Cocos2d) - young
Thursday, 7 March, 13

Quartz Composer really has a different design and usage model. I’ve never really used it.
There is no open-source development targeting 3D on Mac OS X.
Should not need to use C++ or some bizarre C library to have fun with 3D programming.
The commercial stuff is good if you want to do polished-looking 3D games.
Caveats
                        • Missing a lot of things
                        • Work progressing slowly
                         • I’m lazy and life is full of distractions
                        • Not available, not even open source
                         • When it’s sufficient, I’ll share SDK
                         • release source code at some point
Thursday, 7 March, 13

Needs support for creating texture mapping; animations; and shaders.
If you want to try it, just ask me for it.
Contact me


                        • bgulanowski@gmail.com



Thursday, 7 March, 13
Thank You




                        Time for demos and sample code


Thursday, 7 March, 13

More Related Content

PDF
Freetoolsforanimation m
PPTX
Computational Thinking - 101
PDF
7วิชาสามัญ ภาษาอังกฤษ + เฉลย
PPT
4th Period World History 3/6/2009
PPTX
Chris bosh cell
PDF
키즈노트 안내
Freetoolsforanimation m
Computational Thinking - 101
7วิชาสามัญ ภาษาอังกฤษ + เฉลย
4th Period World History 3/6/2009
Chris bosh cell
키즈노트 안내

Similar to Intro to BAScene framework for Mac (12)

PDF
Designing Puppet: Roles/Profiles Pattern
PDF
Vim's Meetup Cinema
PDF
Getting started in mobile games
PPTX
Super Gun Kids: The Making Of by Iain Lobb
PDF
IGDATC This Indie Life: Lessons From the Front by Kris Szafranski
PDF
Data Viz Barcamp, Amsterdam
PDF
Been there done that
PDF
Judy Perry- MIT Scheller Teacher, Education Program Lab
PDF
Launching Mixer: What Worked, What didn't
PDF
Pregel: A System for Large-Scale Graph Processing
ZIP
Avoiding common Accessibility mistakes
PDF
jQuery Mobile, Backbone.js, and ASP.NET MVC
Designing Puppet: Roles/Profiles Pattern
Vim's Meetup Cinema
Getting started in mobile games
Super Gun Kids: The Making Of by Iain Lobb
IGDATC This Indie Life: Lessons From the Front by Kris Szafranski
Data Viz Barcamp, Amsterdam
Been there done that
Judy Perry- MIT Scheller Teacher, Education Program Lab
Launching Mixer: What Worked, What didn't
Pregel: A System for Large-Scale Graph Processing
Avoiding common Accessibility mistakes
jQuery Mobile, Backbone.js, and ASP.NET MVC
Ad

Intro to BAScene framework for Mac

  • 1. Scene Kit You’re making a scene! Thursday, 7 March, 13
  • 3. Who am I? • ambivalent coder in high school • graduated with an English degree in 1996 • became a Mac fanatic; learned C • hyped up for Rhapsody (OS X+Cocoa) • back to school for Comp Sci in 2000 • now work as full-time iOS developer Thursday, 7 March, 13
  • 4. Motivations Why am I building another 3D library? Thursday, 7 March, 13
  • 6. Microserfs • 1995 • Douglas Coupland • Oop! • Virtual LEGO Thursday, 7 March, 13 Microsoft employees leave to form a start-up in Silicon Valley. His vision for Oop! was compelling. I wanted it, and still do. The ideas in the book burrowed into my subconscious. And I wanted to be part of the software development world.
  • 7. 3D • 3D scenes are interesting • Some things are naturally 3-dimensional • We experience a 3D world every day • 3D provides a sense of realism • 3D is creeping into app design through the side door Thursday, 7 March, 13 “Making a scene” means to attracts attention. That’s a good thing! Apps: We have pseudo-3D icons, interfaces, pseudo-3D animations let’s get 3D out in the open in a friendly way
  • 8. 3D is Too Hard • The barrier to entry for 3D is too high. • 3D math is too complicated. • 3D graphics API are too complicated. • Creating 3D content is too complicated. • Can we make it easier? Thursday, 7 March, 13 Vectors, transformation matrices, projective geometry. Ouch! OpenGL state, primitives, buffers, shader programs. I just want to stick some boxes together.
  • 9. Hide Complexity • Reduce or eliminate need for OpenGL • Replace OpenGL state with Obj-C classes • Use abstractions that feel more natural • Provide necessary types and functions • Take care of math drudge work • Make it easier to make fun apps Thursday, 7 March, 13 Still missing some fundamental features.
  • 10. Virtual Toys Not your old LEGO set Thursday, 7 March, 13 Not about big-budget 3D games.
  • 11. Example: Sim City • Build a city • Build networks: • roads • power • Build an economy • Unleash havoc Thursday, 7 March, 13 OPTIONAL
  • 12. Example: Minecraft • Explore a virtual world • Build things: • buildings • roads • railways • farms • monster traps • microprocessors !? Thursday, 7 March, 13 OPTIONAL: Don’t waste time on this!
  • 13. Beyond Games • Games market is mature and saturated • Interactive entertainment is bigger • Games are too limiting; too constraining • Toys give more freedom to explore • Toys let you make a world in your image • Virtual toys scale up cheaply Thursday, 7 March, 13 Virtual toys have a lot of potential. The market could grow a lot. Examples: Sim City, Sims, Minecraft Toys are for experimentation and self-directed learning. Virtual toys are not as fun as real games, but they have qualities real toys lack. With networked software, you can
  • 14. Concepts Thursday, 7 March, 13 If you’re already a 3D developer, please
  • 15. Scene Kit Concepts • A scene is made of props on a virtual stage • A scene is integrated into a workflow: • assemble props and arrange the scene • capture an image (“paint it”) • update the scene • capture a new image, etc. Thursday, 7 March, 13 the stage is a conceptual container, the virtual world in
  • 16. Design Patterns • Is a scene a model or a view or both? • depends on your point of view • could say it’s a model of a view • classic MVC provides a view of a model • in a simulation, there is another model • scenes are require tools to build Thursday, 7 March, 13 OPTIONAL
  • 17. Camera • point of view • field of view, etc. • “style” of the image • fill style, blur, etc. • delegates drawing Thursday, 7 March, 13 POV: orientation, depth of field, field of view, dimensions, aspect ratio, focus point
  • 18. Scene Hierarchy • Arrangement • Stage > Partition > Group > Prop • Construction • Prop > Prototype > Mesh > Polygon > Point > Tuple Thursday, 7 March, 13
  • 19. Prop • a “physical” object • instance of prototype • make many copies that share the same geometry data Thursday, 7 March, 13
  • 20. Prototype • Collection of meshes • meshes can be shared • each mesh can have a customized appearance that is unique to that prototype Thursday, 7 March, 13 Transform is used to position the mesh in the prototype’s local coordinate space. I didn’t make this model!
  • 21. Mesh • Collection of polygons Thursday, 7 March, 13
  • 22. Polygon • Closed, flat shape • Composed of points Thursday, 7 March, 13
  • 23. Point • Fundamental geometric concept • Collection of tuples • location • orientation (normal) • colour • texture coordinates Thursday, 7 March, 13 A tuple is a 3-element vector interpreted as a spatial co-ordinate (cartesian space, colour space, texture space). Textures may only need 1 or 2 elements. This picture doesn’t tell you much.
  • 24. Classes and Interfaces Object model, data types, and functions Thursday, 7 March, 13 Here I’ll begin to review the concepts in reverse order
  • 25. Base Types • Structures • point, matrix, size, region, triangle ++ • vector types often union’ed with an array (e.g.: volume for size) • some have integer and float variations • string transformation functions Thursday, 7 March, 13 a volume is a union of a size and an array of elements add picture of code defining Volume and Size types
  • 26. typedef struct { typedef struct { ! CGFloat x; ! NSUInteger w; ! CGFloat y; ! NSUInteger h; ! CGFloat z; ! NSUInteger d; } BAPointf; } BASizei; typedef BAPointf BARotation3; typedef struct { ! CGFloat w; typedef union { ! CGFloat h; ! BAPointi p; ! CGFloat d; ! NSInteger i[3]; } BASizef; } BALocationi; typedef union { typedef union { ! BASizei s; ! BAPoint4f p; ! NSUInteger i[3]; ! CGFloat i[4]; } BAVolumei; } BALocationf; typedef union { typedef union { ! BASizef s; ! BARotation3 r; ! CGFloat i[3]; ! CGFloat i[3]; } BAVolumef; } BAOrientationf; Thursday, 7 March, 13
  • 27. Utilities • Functions for operating on structures • Imitates functions from NSGeometry.h • Simple operations like creation, midpoints • Complex stuff like matrix math • NSColor to struct transformation • useful drawing functions for debugging Thursday, 7 March, 13
  • 28. Managed Object Model Custom NSManagedObject subclasses Thursday, 7 March, 13
  • 31. Geometric Entities • Point, Prototype and Mesh • support construction from element arrays • along with Group, support flattening back to element arrays Thursday, 7 March, 13
  • 32. Mesh • Represent complex geometric shapes • As part of a prototype, support: • appearance properties • spatial transformation • library of simple shapes provided Thursday, 7 March, 13
  • 33. Composites • Mesh, Prototype, Prop and Group • can be identified and loaded by name • organization and re-use • have bounding boxes and intersection tests Thursday, 7 March, 13
  • 34. Other • BAScene class does some high-level work • manages object model and context • BASceneView: custom OpenGL view • BACameraSetup: view to control camera • BAResourceStorage: caches GL data • BATexture: handles GL texture stuff Thursday, 7 March, 13 BATexture has an equivalent in GLKit, but Scene Kit is compatible back to 10.5
  • 35. Alternatives • Quartz Composer • if you don’t want or need Objective-C: • Ogre3D, Irrlicht, Unity, Unreal • for iOS (could be ported to Mac OS X): • iSGL3D - developer has abandoned • Cocos3d (based on Cocos2d) - young Thursday, 7 March, 13 Quartz Composer really has a different design and usage model. I’ve never really used it. There is no open-source development targeting 3D on Mac OS X. Should not need to use C++ or some bizarre C library to have fun with 3D programming. The commercial stuff is good if you want to do polished-looking 3D games.
  • 36. Caveats • Missing a lot of things • Work progressing slowly • I’m lazy and life is full of distractions • Not available, not even open source • When it’s sufficient, I’ll share SDK • release source code at some point Thursday, 7 March, 13 Needs support for creating texture mapping; animations; and shaders. If you want to try it, just ask me for it.
  • 37. Contact me • bgulanowski@gmail.com Thursday, 7 March, 13
  • 38. Thank You Time for demos and sample code Thursday, 7 March, 13