Upload
rsebbe
View
4.185
Download
1
Tags:
Embed Size (px)
DESCRIPTION
Blitz T
Citation preview
Designing an Objective-C Framework about 3D
(to Rule Them All)
Raphael SebbeTwitter: @rsebbe
We all Enjoy Cocoa
Because it’s Smart & Elegant
Developers are UsersKeep that in mind when designing a framework
The Wonderful World of 3D
OpenGLDirect X
Ogre Quesa
OSG
OpenSG
VL
Pixar’s PRMan
3DelightPixie
Aqsis
POV
LuxRenderMental Ray
DotCLucille
3DKit
What
• A framework for building 3D apps / games, for Mac & iOS
• Common foundation for 3D
• Specialized to talk to various libs / tools
• Good Cocoa citizen
Conceptualizing (a bit)
• Computer Graphics Math
• 3D Data Representation(s)
• Object Graph(s)
• Rendering InterfacesCeedMath Foundation
Ceed3D
Ceed3DGL Ceed3DRenderMan ...
App
GL
Focus on Frameworks
C3ProceduralObject
C3Object
C3Node
C3GeometricObject
C3Sphere
C3Mesh
...
... C3Buffer
C3Light
C3Camera
C3Material
C3Geometry
C3ParametricGeometry
C3MeshGeometry
C3RendererC3Scene
C3StreamGeometry
C3SubdivisionGeometry
C3RenderManRenderer
C3PixarRenderer
C3AqsisRenderer
C3GLRenderer C3GLView
Objects Talk Together
Sphere A
1.7Value
Radius
TransformCube B
Parent Transform
TransformCube C
Size
Style Group 1 Style Group 2
Objects Talk Together
Sphere A
1.7Value
Radius
TransformCube B
Parent Transform
TransformCube C
Size
Coping with Diversity
• Objective-C is high level
• Sometimes, subclassing is your enemy
• And then, categories are your friend
• Renderer interface & file read/write’s as categories of existing classes
Ceed3DRenderMan.framework
Ceed3D.framework
Ceed3DGL.framework
Category Use
+GL
C3Sphere
+RenderMan
+POV
+GL
C3Mesh
+RenderMan
+Obj
+3ds
+Collada
+ ...
Focus on OpenGL• Modern OpenGL only (no legacy calls)
• Support for OpenGL ES
• Sophisticated Shader Definition
Focus on OpenGL• Modern OpenGL only (no legacy calls)
• Support for OpenGL ES
• Sophisticated Shader Definition
CeedMath
Ceed3D
Ceed3DGL
Cee
dGL
GL
• Thin Objective-C layer for OpenGL
• Encapsulates GL objects (texture, buffer, framebuffer, program, shader...)
• Defines Draw Commands
Cocoa Interactions
• KVO / KVC: easy access to object inputs/outputs
• Core Image: CIImage used as textures, CIFilter as post process filters on rendered image
• Quartz: NSBezierPath used as geometry source, incl. glyphs
• Quartz Composer: Ceed3D should be able to render as a QCPlugin, QC outputs usable as Ceed3D textures
• Grand Central Dispatch: Parallelism for computations
• OpenCL: Geometry filters
Examples! sphere = [C3Sphere sphere];! sphere.radius = 0.15;! sphere.translation.z = 0.3;!! C3GenericMaterial *material = [C3GenericMaterial genericMaterial];! material.diffuseColor = [C3Color redColor];! material.environmentImage = [C3Image imageWithContentsOfFile:! ! [[NSBundle mainBundle] pathForResource:@"skydome_1024" ofType:@"jpg"]];! sphere.defaultMaterial = material;!! [scene addNode:sphere];
!! NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:rect ! ! xRadius:0.1 yRadius:0.1];! [path appendBezierPath:[[NSBezierPath bezierPathWithOvalInRect:! ! NSInsetRect(rect, 0.15, 0.15)] bezierPathByReversingPath]];!! id options = [NSDictionary dictionaryWithObjectsAndKeys:C3DOUBLE(0.02), ! ! kC3MeshOptionAdaptiveSubdivisionDistance, nil];!! C3MeshGeometry *geom = [C3MeshGeometry meshGeometryWithBezierPath:path ! ! options:options];! C3Mesh *mesh = [C3Mesh mesh]; [mesh insertObject:geom inGeometriesAtIndex:0];! [scene addNode:mesh];
Examples! glRenderer = [C3GLRenderer new];! glRenderer.scene = scene;!! glView.viewer.camera = camera;! glRenderer.viewers = [NSArray arrayWithObject:glView.viewer];
! pixarRenderer = [C3PixarRenderer new]; ! pixarRenderer.outputDirectoryPath = @"~/Render/Ceed3D-pixar";! pixarRenderer.scene = scene;
! aqsisRenderer = [C3AqsisRenderer new];! aqsisRenderer.outputDirectoryPath = @"~/Render/Ceed3D-aqsis";! aqsisRenderer.scene = scene;
// ....
[glRenderer render];
Demo
Demo
mesh = [C3Mesh meshWithAttributedString:@"" options:nil];
Availability
• Work in progress
• Low-level, stable parts will be released as open source soon
• We want to release more later...
• Stay tuned!
Thank you!
Raphael SebbeTwitter: @rsebbe