Accelerometer and OpenGL
-
Upload
john-wilker -
Category
Technology
-
view
3.589 -
download
3
description
Transcript of Accelerometer and OpenGL
![Page 1: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/1.jpg)
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/
![Page 2: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/2.jpg)
Introduction to Accelerometers and OpenGL ES on the iPhone
● OpenGL ES● Accelerometer● More OpenGL
![Page 3: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/3.jpg)
OpenGL ES 1.1 - Open Graphics Library for Embedded Systems
![Page 4: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/4.jpg)
OpenGL
Source:http://www.cs.unc.edu/~walk/pap//fig1.gif
![Page 5: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/5.jpg)
OpenGL (continued)
● Platform independent● Input
● Points, Lines, Polygons● Transforms● Textures● Transparency● Lighting
![Page 6: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/6.jpg)
OpenGL Pipeline
Source: Apple
![Page 7: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/7.jpg)
Code: Hello World
![Page 8: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/8.jpg)
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– Less Overhead
● 3D
Source: Apple
![Page 9: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/9.jpg)
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/iPhone/Conceptual/iPhoneOSProgrammingGuide/GraphicsandDrawing/chapter_6_section_5.html#//apple_ref/doc/uid/TP40007072-CH10-SW18
![Page 10: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/10.jpg)
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.
![Page 11: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/11.jpg)
Questions?
![Page 12: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/12.jpg)
Accelerometer
![Page 13: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/13.jpg)
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)
![Page 14: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/14.jpg)
Basic Tasks: Signal Processing
● Isolating Large Movements● Low-Pass Filter:
xn = x
n-1/2 + x/2
● Isolating Small Movements● High-Pass Filter:
xn = x - x
n-1
Sournce: http://jp.physoc.org/content/vol550/issue3/fulltext/873/Figures/HiRes/873-F2.gif
![Page 15: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/15.jpg)
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
![Page 16: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/16.jpg)
Basic Tasks: Simple Gestures
● SwipePositive-Negative Spike
● ShakeOscillating Wave
● Rotations2-Axis Change
![Page 17: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/17.jpg)
Classes
UIAccelerometer
Methods+ sharedAccelerometer
PropertiesupdateIntervaldelegate
MyClass <UIAccelerationDelegate>
Methods- (void) accelerometer:(UIAccelerometer*) accelerometer
didAccelerate:(UIAcceleration*) acceleration
UIAcceleration
PropertiesUIAccelerationValue xUIAccelerationValue yUIAccelerationValue z NSTimeInterval timestamp
MyOtherClass
![Page 18: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/18.jpg)
Code: Hello World (continued)
![Page 19: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/19.jpg)
Questions?
![Page 20: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/20.jpg)
More Open GL
![Page 21: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/21.jpg)
Apple Sample Code
● Accelerometer Graph● Crash Landing● GLGravity● GLPaint● GLSprite● Touchfighter II
![Page 22: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/22.jpg)
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-recognition.html● http://ifiddling.blogspot.com/2009/01/dummy2.html
![Page 23: Accelerometer and OpenGL](https://reader034.fdocuments.in/reader034/viewer/2022052209/5550c3feb4c905ff618b5541/html5/thumbnails/23.jpg)
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