Introduction To Animation and OpenGL On The Android SDK Paper
Introduction To Animation and OpenGL On The Android SDK Paper
In Android
Satya Komatineni
Active Intellect, Inc.
(http://www.satyakomatineni.com)
How does it
Marketing work? Advanced
(Essentials)
• Frame Animation
• List Animation
• View Animation
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="6dip"
android:paddingRight="6dip"
android:paddingBottom="3dip">
<EditText android:id="@+id/title"
android:maxLines="1"
android:layout_marginTop="2dip"
android:layout_width="wrap_content"
android:ems="25"
android:layout_height="wrap_content"
android:autoText="true"
android:capitalize="sentences"
android:scrollHorizontally="true" />
<Button android:id="@+id/ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="@string/button_ok" />
</LinearLayout>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.notepad"
>
<application android:icon="@drawable/app_notes"
android:label="@string/app_name"
>
<provider android:name="NotePadProvider"
android:authorities="com.google.provider.NotePad"
/>
<activity android:name="NoteEditor"
android:theme="@android:style/Theme.Light"
android:label="@string/title_note"
>
• Opengl • Java.*
• App • Javax.*
• Content • Os
• Preference • Junit.*
• Content.pm • Org.apache.http.*
• Content.res • Provider
• Sax • Org.json
• Database • Org.xml.*
• Database.sqlite • Telephony
• Graphics • Telephony.gsm
• Graphics.drawable • Text
• Graphics.drawable.shapes • Text.method
• Hardware • Text.style
• Location • Text.util
• Media • View
• Net • View.animation
• Net.http • Webkit
• Net.wifi • Widget
• Com.google.android.maps
AnimationDrawable frameAnimation =
(AnimationDrawable) imgView.getBackground();
frameAnimation.running() ?
frameAnimation.stop():
frameAnimation.start();
}
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="30%"
android:animationOrder="reverse"
android:animation="@anim/alpha_translate" />
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<translate android:fromYDelta="-100%"
android:toYDelta="0"
android:duration="500" />
<alpha android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="500" />
</set>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromDegrees="0.0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="500" />
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<scale
android:fromXScale="1” android:toXScale="1"
android:fromYScale="0.1” android:toYScale="1.0"
android:duration="500” android:pivotX="50%"
android:pivotY="50%” android:startOffset="100" />
</set>
7/22/2009 Satya Komatineni (http://www.satyakomatineni.com) 22
Interpolators: Definition and Java code
<accelerateInterpolator
xmlns:android="http://schemas.android.com/apk/res/android"
factor="1" />
AccelerateDecelerateInterpolator
AccelerateInterpolator
CycleInterpolator
DecelerateInterpolator
LinearInterpolator
View someView;
someView.startAnimation(new ViewAnimation());
matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
camera.restore();
}
glVertexPointer
glDrawElements
gluLookAt
glFrustum
glViewPort
glTexturePointer
GL_TRIANGLE_STRIP
GL_POINTS
GL_LINE_STRIP
GL_LINES
GL_LINE_LOOP
GL_TRIANGLES
GL_TRIANGLE_FAN
float[] coords = {
-0.5f, -0.5f, 0, // (x1,y1,z1)
0.5f, -0.5f, 0,
0.0f, 0.5f, 0 };
glFrustum
gluLookAt
glViewPort
//Look at the screen (origin) from 5 units away from the front of the screen
GLU.gluLookAt(gl, 0,0,5, 0,0,0, 0,1,0);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mTestHarness = new GLSurfaceView(this);
mTestHarness.setEGLConfigChooser(false);
mTestHarness.setRenderer(new SimpleTriangleRenderer(this));
mTestHarness.setRenderMode(
GLSurfaceView.RENDERMODE_WHEN_DIRTY);
setContentView(mTestHarness);
}
Use
Renderer
GLSurfaceView
(Interface)
Specialize
Abstract
Renderer
(Interface)
Specialize
General
Triangle Rectangle Polygon
Renderer Renderer Renderer
gl.glColor4f(1.0f, 0, 0, 0.5f);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mFVertexBuffer);
gl.glDrawElements(GL10.GL_TRIANGLES, this.numOfIndecies,
GL10.GL_UNSIGNED_SHORT, mIndexBuffer);
gl.glColor4f(1.0f, 0, 0, 0.5f);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mFVertexBuffer);
gl.glDrawElements(GL10.GL_TRIANGLES, this.numOfIndecies,
GL10.GL_UNSIGNED_SHORT, mIndexBuffer);
(1,1)
(0,0)
Object
bitmap
(1,1)
(0,0)
Specialize
Use
Renderer
GLSurfaceView
(Interface)
Abstract
Renderer
(Interface)
Specialize
Abstract
TextureRenderer
(Interface)
Textured
Polygon
Renderer
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,
GL10.GL_CLAMP_TO_EDGE);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,
GL10.GL_CLAMP_TO_EDGE);
gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE,
GL10.GL_REPLACE);
7/22/2009 Satya Komatineni (http://www.satyakomatineni.com) 52
Setup Your Texture in OnSurfaceCreated
InputStream is = mContext.getResources()
.openRawResource(this.mImageResourceId);
Bitmap bitmap;
try {
bitmap = BitmapFactory.decodeStream(is);
} finally {
try {
is.close();
} catch(IOException e) {
// Ignore.
}
}
gl.glEnable(GL10.GL_TEXTURE_2D);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mFVertexBuffer);
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mFTextureBuffer);
glDrawElements(….);
gl.glEnable(GL10.GL_TEXTURE_2D);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mFVertexBuffer);
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mFTextureBuffer);
gl.glPushMatrix();
gl.glScalef(0.5f, 0.5f, 1.0f);
gl.glTranslatef(0.5f,0, 0);
gl.glDrawElements(GL10.GL_TRIANGLES, this.numOfIndecies,
GL10.GL_UNSIGNED_SHORT, mIndexBuffer);
gl.glPopMatrix();gl.glPushMatrix();
gl.glScalef(0.5f, 0.5f, 1.0f); gl.glTranslatef(-0.5f,0, 0);
gl.glDrawElements(GL10.GL_TRIANGLES, this.numOfIndecies,
GL10.GL_UNSIGNED_SHORT, mIndexBuffer);
gl.glPopMatrix();
This following book Pro Android talks about Android and also some of the content
covered here.
http://www.satyakomatineni.com/akc/display?
url=DisplayNoteIMPURL&reportId=3186&ownerUserId=satya
My Notes on OpenGL
http://www.knowledgefolders.com/akc/display?
url=NotesIMPTitlesURL&ownerUserId=satya&folderName=OpenGL&order_by_form
at=news