ceedmath & ceedgl, let's talk 3d
DESCRIPTION
Presentation of the CeedMath & CeedGL open source libraries for easier computer graphics programming on Mac & iOSTRANSCRIPT
![Page 1: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/1.jpg)
CeedMath & CeedGLLet’s talk 3D...
web: www.creaceed.comtwitter : @rsebbe
cocoaheads.be
![Page 2: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/2.jpg)
Overview• CeedMath & CeedGL are libraries for easier
computer graphics development on Mac & iOS
• BSD license
• Available on Github •https://github.com/rsebbe/CeedMath•https://github.com/rsebbe/CeedGL
![Page 3: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/3.jpg)
Overview
CeedMath Foundation
Ceed3D
Ceed3DGL Ceed3DRenderMan ...
App
GL
Cee
dGL
![Page 4: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/4.jpg)
CeedMath
![Page 5: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/5.jpg)
Why?• CG math libs are generally written in C++• C++ is cumbersome when developing in
Objective-C• Need of a pure C library• Need for both float & double data type
![Page 6: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/6.jpg)
Definition• Written in pure C• Macro-based templates, float & double• Simple types (float*)• Chain-able• C++ interoperable (polymorphic)• In C, use _f or _d suffixes• In C++, automatic based on param type
![Page 7: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/7.jpg)
Types
• vector (2D, 3D, 4D)• normal (3D) / plane (4D)• matrix (2D, 4D)• quaternion (4D)• ray• box• frustum• triangle
![Page 8: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/8.jpg)
What?
• vector: add, subtract, dot/vect product, norm, rotate, project, find angles, lerp...• matrix: add, subtract, multiply, transform,
solve, invert...• quaternion: standard operations...• ray: intersections w/ plane/triangle/box...• box: union / intersection...• frustum: perspective transform...• triangle: normal computation
![Page 9: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/9.jpg)
Xcode Project
• Universal: Mac & iOS libs
• Headers note• lib: PUBLIC_HEADERS_FOLDER_PATH = /usr/local/include/CeedMath• app: HEADER_SEARCH_PATHS = "$(DSTROOT)/usr/local/include" "$
(CONFIGURATION_BUILD_DIR)/usr/local/include"
• #include <CeedMath/C3Math.h>
![Page 10: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/10.jpg)
Demo
• Demo #1: template mechanics
• Demo #2: real world example (rounded rect)
• Demo #3: C++ templates for mouse pickingC3StreamPrimitive+Picking.mm
C3MeshGeometry+Primitives.mm
![Page 11: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/11.jpg)
Demo
![Page 12: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/12.jpg)
Demo’s
![Page 13: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/13.jpg)
CeedGL
![Page 14: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/14.jpg)
Why?• OpenGL is a C API, most GL objects are int’s• Error prone, all function take int’s• Complex APIs, many functions• Not practical within Objective-C• Intimidating, hard to start
• Higher level abstractions exist (scene graphs), but what if you only need standard OpenGL?
![Page 15: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/15.jpg)
Old vs. Modern OpenGL
define camera position, define object position, choose a predefined illumination model, place the lights, draw some
triangles, change position, draw some other...
set vertices, indices, shading program & params, then draw
OpenGL 1.x, 2.x OpenGL ES 1.x
OpenGL >= 3.1 OpenGL ES 2.x + WebGL
![Page 16: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/16.jpg)
OpenGL• Modern OpenGL programming is hard.
Especially the first time...• It’s a functional C API• Most “objects” are represented by handles (int)• Modern GL has removed many concepts• Light, shading, transforms
• For the good, the old pipeline was limiting, and a hurdle for card makers• It is now more in sync w/ hardware capabilities
![Page 17: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/17.jpg)
CeedGL• CeedGL does not define new concepts• But it helps in setting up and managing your
OpenGL objects• Thin Objective-C Wrapper
![Page 18: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/18.jpg)
CeedGLGLObject
GLBuffer GLTexture
GLFramebuffer GLRenderbuffer
GLShader GLProgram
GLDrawCommand
GLValue
![Page 19: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/19.jpg)
Draw (1/2)• Vertex Shader• 1 execution per vertex• inputs: uniform, attribute• output: varying
• Fragment Shader• 1 execution per output
pixel• input: uniform, varying• output: fragment color
![Page 20: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/20.jpg)
Draw (2/2)
GLBuffer
GLTexture
GLFramebuffer
GLRenderbuffer
GLShader
GLProgram
GLDrawCommand
GLValue
GLShader
vf
GLBuffer
GLValue
GLTexture
uaait
![Page 21: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/21.jpg)
Demo’s
![Page 22: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/22.jpg)
GLKit?• GLKit’s Math• NEON optimized• Currently iOS5 only, definitely Apple only• Has an overlap with CeedMath
• GLKit’s GL• Forces a GL coding style• Provides easier starting point• Mostly complementary to CeedGL
• Permissive, forkable open source make sense in such projects
![Page 23: CeedMath & CeedGL, Let's talk 3D](https://reader034.vdocuments.net/reader034/viewer/2022051411/546fd60cb4af9faa0b8b4607/html5/thumbnails/23.jpg)
Happy 3D coding !
web: www.creaceed.comtwitter : @rsebbe
cocoaheads.be