Accelerometer and OpenGL

3,641
-1

Published on

Jon liang stepped in to pinch hit on two sessions that the presenters had to miss. OpenGL and Acceleromter. Hit it out of the park. Non Game App Dev Track. 360|iDev San Jose 09

Published in: Technology, Art & Photos
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,641
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
80
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

Accelerometer and OpenGL

  1. 1. Introduction to Accelerometers and OpenGL ES on the iPhone Jon Liang ● Mobility Lead – Mobclix ● http://www.mobclix.com ● Jeff LaMarche ● Author - Beginning iPhone Development: Exploring ● the iPhone SDK http://iphonedevelopment.blogspot.com/ ●
  2. 2. Introduction to Accelerometers and OpenGL ES on the iPhone OpenGL ES ● Accelerometer ● More OpenGL ●
  3. 3. OpenGL ES 1.1 - Open Graphics Library for Embedded Systems
  4. 4. OpenGL Source:http://www.cs.unc.edu/~walk/pap//fig1.gif
  5. 5. OpenGL (continued) Platform independent ● Input ● Points, Lines, Polygons ● Transforms ● Textures ● Transparency ● Lighting ●
  6. 6. OpenGL Pipeline Source: Apple
  7. 7. Code: Hello World
  8. 8. Quartz 2D vs. OpenGL for 2D Quartz 2D ● Higher Level API ● Compatible with – CoreAnimation Easier to Display Text – Inverted y-axis ● OpenGL ● Low Level API ● More Control – Source: Apple Less Overhead – 3D ●
  9. 9. iPhone Limitations 24 MB of Memory for textures and surfaces. ● The maximum texture size is 1024 x 1024. ● 2D texture targets are supported; other texture ● targets are not. Stencil buffers aren’t available. ● More Info: ● http://developer.apple.com/iphone/library/documentation/i – Phone/Conceptual/iPhoneOSProgrammingGuide/Graphi csandDrawing/chapter_6_section_5.html#//apple_ref/doc /uid/TP40007072-CH10-SW18
  10. 10. Open GL → OpenGL ES Removed glBegin() and glEnd() ● Use glDrawArrays() or glDrawElements() ● Added Fixed Point data types ● Embedded systems often don't have FPU's. ● Removed convenience functions ● More lightweight implementation. ●
  11. 11. Questions?
  12. 12. Accelerometer
  13. 13. Accelerometer Hardware ● 3-Axis MEMS Accelerometer ● Part Number: LIS302DL – Max Sample Rate: 400 Hz – Max Acceleration: ± 8g – No Gyroscope ● Implications ● No Direct Angular Acceleration Data ● Zeroed at Free Fall ● Limited Amplitude (± 4g per axis) ●
  14. 14. Basic Tasks: Signal Processing Isolating Large Movements ● Low-Pass Filter: ● xn = xn-1/2 + x/2 Isolating Small Movements ● High-Pass Filter: ● xn = x - xn-1 Sournce: http://jp.physoc.org/content/vol550/issue3/fulltext/873/Figures/HiRes/873-F2.gif
  15. 15. Basic Tasks: Ground Angle 2 Dimensions: ● Θ = atan(y/x) Axis-Plane: ● Θ = atan(z/sqrt(x2+y2)) Source: http://www.forestgumpsays.com/wp-content/uploads/2008/03/3iphoneaxes.jpg
  16. 16. Basic Tasks: Simple Gestures Swipe ● Positive-Negative Spike Shake ● Oscillating Wave Rotations ● 2-Axis Change
  17. 17. Classes UIAccelerometer UIAcceleration Methods Properties + sharedAccelerometer UIAccelerationValue x Properties UIAccelerationValue y updateInterval UIAccelerationValue z delegate NSTimeInterval timestamp MyClass <UIAccelerationDelegate> Methods - (void) accelerometer:(UIAccelerometer*) accelerometer didAccelerate:(UIAcceleration*) acceleration MyOtherClass
  18. 18. Code: Hello World (continued)
  19. 19. Questions?
  20. 20. More Open GL
  21. 21. Apple Sample Code Accelerometer Graph ● Crash Landing ● GLGravity ● GLPaint ● GLSprite ● Touchfighter II ●
  22. 22. Additional Resources Open GL ● http://www.khronos.org/opengles/sdk/1.1/docs/man/ ● http://www.glprogramming.com/red/ ● Accelerometer ● www.st.com/stonline/products/literature/ds/12726.p ● df http://squallchua.blogspot.com/2008/12/wiimote-gesture ● http://ifiddling.blogspot.com/2009/01/dummy2.html ●
  23. 23. Additional Resources (continued) Collision Models ● http://www.metanetsoftware.com/technique/tutorialA ● .html http://www.metanetsoftware.com/technique/tutorialB ● .html http://www.euclideanspace.com/physics/dynamics/c ● ollision/index.htm
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×