Random Maze

ESText.java - Source Code - Random Maze - Project Pilihan

===

ESText.java

// This is a OpenGL ES 1.0 dynamic font rendering system. It loads actual font // files, generates a font map (texture) from them, and allows rendering of // text strings. // // NOTE: the rendering portions of this class uses a sprite batcher in order // provide decent speed rendering. Also, rendering assumes a BOTTOM-LEFT // origin, and the (x,y) positions are relative to that, as well as the // bottom-left of the string to render.

package com.fractalbackground;

import javax.microedition.khronos.opengles.GL10;

import android.content.res.AssetManager; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Typeface; import android.opengl.GLUtils;

public class ESText {

//--Constants--// public final static int CHAR_START = 32;

// First Character (ASCII Code) public final static int CHAR_END = 126; // Last Character (ASCII Code) public final static int CHAR_CNT = ( ( ( CHAR_END - CHAR_START ) + 1 ) + 1 ); // Character Count (Including Character to use for Unknown)

public final static int CHAR_NONE = 32; // Character to Use for Unknown (ASCII Code) public final static int CHAR_UNKNOWN = ( CHAR_CNT - 1 ); // Index of the Unknown Character

public final static int FONT_SIZE_MIN = 6; // Minumum Font Size (Pixels)

public final static int FONT_SIZE_MAX = 180; // Maximum Font Size (Pixels)

public final static int CHAR_BATCH_SIZE = 100; // Number of Characters to Render Per Batch

//--Members--// GL10 gl;

// GL10 Instance AssetManager assets; // Asset Manager SpriteBatch batch; // Batch Renderer

int fontPadX, fontPadY;

// Font Padding (Pixels; On Each Side, ie. Doubled on Both X+Y Axis)

float fontHeight; // Font Height (Actual; Pixels) float fontAscent; // Font Ascent (Above Baseline; Pixels) float fontDescent; // Font Descent (Below Baseline; Pixels)

int textureId; // Font Texture ID [NOTE: Public for Testing Purposes Only!]

int textureSize; // Texture Size for Font (Square) [NOTE: Public for Testing Purposes Only!]

TextureRegion textureRgn; // Full Texture Region

float charWidthMax; // Character Width (Maximum; Pixels) float charHeight; // Character Height (Maximum; Pixels) final float[] charWidths; // Width of Each Character (Actual; Pixels) TextureRegion[] charRgn; // Region of Each Character (Texture Coordinates) int cellWidth, cellHeight; // Character Cell Width/Height int rowCnt, colCnt; // Number of Rows/Columns

float scaleX, scaleY; // Font Scale (X,Y Axis) float spaceX; // Additional (X,Y Axis) Spacing (Unscaled)

//--Constructor--// // D: save GL instance + asset manager, create

arrays, and initialize the members // A: gl - OpenGL ES 10 Instance public ESText(GL10 gl, AssetManager assets) {

this.gl = gl; // Save the GL10 Instance this.assets = assets; // Save the Asset Manager Instance

batch = new SpriteBatch( gl, CHAR_BATCH_SIZE ); // Create Sprite Batch (with Defined Size)

charWidths = new float[CHAR_CNT]; // Create the Array of Character Widths charRgn = new TextureRegion[CHAR_CNT]; // Create the Array of Character Regions

// initialize remaining members fontPadX = 0; fontPadY = 0; // initialize remaining members fontPadX = 0; fontPadY = 0;

textureId = -1; textureSize = 0;

charWidthMax = 0; charHeight = 0;

cellWidth = 0; cellHeight = 0; rowCnt = 0; colCnt = 0;

scaleX = 1.0f; // Default Scale = 1 (Unscaled) scaleY = 1.0f; // Default Scale = 1 (Unscaled) spaceX = 0.0f; }

//--Load Font--// // description // this will load the specified font file,

create a texture for the defined // character range, and setup all required values used to render with it. // arguments: // file - Filename of the font (.ttf, .otf) to

use. In 'Assets' folder. // size - Requested pixel size of font (height) // padX, padY - Extra padding per character

(X+Y Axis); to prevent overlapping characters.

public boolean load(String file, int size, int padX, int padY) {

// setup requested values fontPadX = padX;

// Set Requested X Axis Padding fontPadY = padY; // Set Requested Y Axis Padding

// load the font and setup paint instance for drawing Typeface tf = Typeface.createFromAsset( assets, file ); // Create the Typeface from Font File Paint paint = new Paint(); // Create Android Paint Instance paint.setAntiAlias( true ); // Enable Anti Alias paint.setTextSize( size ); // Set Text Size paint.setColor( 0xffffffff ); // Set ARGB (White, Opaque) paint.setTypeface( tf ); // Set Typeface

// get font metrics Paint.FontMetrics fm = paint.getFontMetrics();

// Get Font Metrics

fontHeight = (float)Math.ceil( Math.abs( fm.bottom ) + Math.abs( fm.top ) ); // Calculate Font Height

fontAscent = (float)Math.ceil( Math.abs( fm.ascent ) ); // Save Font Ascent

fontDescent = (float)Math.ceil( Math.abs( fm.descent ) ); // Save Font Descent

// determine the width of each character (including unknown character) // also determine the maximum character width char[] s = new char[2];

// Create Character Array charWidthMax = charHeight = 0; // Reset Character Width/Height Maximums float[] w = new float[2]; // Working Width Value int cnt = 0; // Array Counter for ( char c = CHAR_START; c <= CHAR_END; c++ ) { // FOR Each Character s[0] = c; // Set Character

paint.getTextWidths( s, 0, 1, w ); // Get Character Bounds charWidths[cnt] = w[0]; // Get Width

if ( charWidths[cnt] > charWidthMax ) // IF Width Larger Than Max Width

charWidthMax = charWidths[cnt];

// Save New Max Width cnt++; // Advance Array Counter } s[0] = CHAR_NONE;

// Set Unknown Character paint.getTextWidths( s, 0, 1, w ); // Get Character Bounds charWidths[cnt] = w[0]; // Get Width if ( charWidths[cnt] > charWidthMax ) // IF Width Larger Than Max Width charWidthMax = charWidths[cnt]; // Save New Max Width cnt++; // Advance Array Counter

// set character height to font height charHeight = fontHeight;

// Set Character Height

// find the maximum size, validate, and setup cell sizes cellWidth = (int)charWidthMax + ( 2 * fontPadX ); // Set Cell Width cellHeight = (int)charHeight + ( 2 * fontPadY

); // Set Cell Height int maxSize = cellWidth > cellHeight ? cellWidth : cellHeight; // Save Max Size (Width/Height)

if ( maxSize < FONT_SIZE_MIN || maxSize > FONT_SIZE_MAX ) // IF Maximum Size Outside Valid Bounds

return false; // Return Error

// set texture size based on max font size (width or height) // NOTE: these values are fixed, based on the defined characters. when // changing start/end characters (CHAR_START/CHAR_END) this will need adjustment too! if ( maxSize <= 24 ) // IF Max Size is 18 or Less textureSize = 256; // Set 256 Texture Size else if ( maxSize <= 40 ) // ELSE IF Max Size is 40 or Less textureSize = 512; // Set 512 Texture Size else if ( maxSize <= 80 ) // ELSE IF Max Size is 80 or Less textureSize = 1024; // Set 1024 Texture Size else // ELSE IF Max Size is Larger Than 80 (and Less than FONT_SIZE_MAX)

textureSize = 2048; // Set 2048 Texture Size

// create an empty bitmap (alpha only) Bitmap bitmap = Bitmap.createBitmap(

textureSize, textureSize, Bitmap.Config.ALPHA_8 ); // Create Bitmap

Canvas canvas = new Canvas( bitmap ); // Create Canvas for Rendering to Bitmap bitmap.eraseColor( 0x00000000 ); // Set Transparent Background (ARGB)

// calculate rows/columns // NOTE: while not required for anything, these

may be useful to have :) colCnt = textureSize / cellWidth; // Calculate Number of Columns

rowCnt = (int)Math.ceil( (float)CHAR_CNT / (float)colCnt ); // Calculate Number of Rows

// render each of the characters to the canvas (ie. build the font map) float x = fontPadX; // Set Start Position (X) float y = ( cellHeight - 1 ) - fontDescent - fontPadY; // Set Start Position (Y) for ( char c = CHAR_START; c <= CHAR_END; c++ ) { // FOR Each Character // render each of the characters to the canvas (ie. build the font map) float x = fontPadX; // Set Start Position (X) float y = ( cellHeight - 1 ) - fontDescent - fontPadY; // Set Start Position (Y) for ( char c = CHAR_START; c <= CHAR_END; c++ ) { // FOR Each Character

if ( ( x + cellWidth - fontPadX ) > textureSize ) { // IF End of Line Reached x = fontPadX; // Set X for New Row y += cellHeight; // Move Down a Row } } s[0] = CHAR_NONE;

// Set Character to Use for NONE

canvas.drawText( s, 0, 1, x, y, paint ); // Draw Character

// generate a new texture int[] textureIds = new int[1];

// Array to Get Texture Id gl.glGenTextures( 1, textureIds, 0 ); // Generate New Texture textureId = textureIds[0]; // Save Texture Id

// setup filters for texture gl.glBindTexture( GL10.GL_TEXTURE_2D, textureId

); // Bind Texture gl.glTexParameterf( GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST ); // Set Minification Filter

gl.glTexParameterf( GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR ); // Set Magnification Filter

gl.glTexParameterf( GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE ); // Set U Wrapping

gl.glTexParameterf( GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE ); // Set V Wrapping

// load the generated bitmap onto the texture GLUtils.texImage2D( GL10.GL_TEXTURE_2D, 0,

bitmap, 0 ); // Load Bitmap to Texture

gl.glBindTexture( GL10.GL_TEXTURE_2D, 0 ); // Unbind Texture

// release the bitmap bitmap.recycle();

// Release the Bitmap

// setup the array of character texture regions x = 0;

// Initialize X y = 0; // Initialize Y

for ( int c = 0; c < CHAR_CNT; c++ ) {

// FOR Each Character (On Texture) charRgn[c] = new TextureRegion( textureSize, textureSize, x, y, cellWidth-1, cellHeight-1 ); // Create Region for Character

x += cellWidth; // Move to Next Char (Cell)

if ( x + cellWidth > textureSize ) {

x = 0; // Reset X Position to Start y += cellHeight; // Move to Next Row (Cell) } }

// create full texture region textureRgn = new TextureRegion( textureSize,

textureSize, 0, 0, textureSize, textureSize ); // Create Full Texture Region

// return success return true;

// Return Success }

//--Begin/End Text Drawing--// // D: call these methods before/after

(respectively all draw() calls using a text instance // NOTE: color is set on a per-batch basis, and fonts should be 8-bit alpha only!!! // A: red, green, blue - RGB values for font (default = 1.0) // alpha - optional alpha value for font (default = 1.0) // R: [none] public void begin() {

begin( 1.0f, 1.0f, 1.0f, 1.0f ); // Begin with White Opaque } public void begin(float alpha) {

begin( 1.0f, 1.0f, 1.0f, alpha ); // Begin with White (Explicit Alpha) } public void begin(float red, float green, float

blue, float alpha) {

gl.glColor4f( red, green, blue, alpha ); // Set Color+Alpha gl.glBindTexture( GL10.GL_TEXTURE_2D, textureId ); // Bind the Texture batch.beginBatch(); // Begin Batch } public void end() {

batch.endBatch(); // End Batch

gl.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); // Restore Default Color/Alpha }

//--Draw Text--//

// D: draw text at the specified x,y position // A: text - the string to draw // x, y - the x,y position to draw text at

(bottom left of text; including descent) // R: [none] public void draw(String text, float x, float y) {

float chrHeight = cellHeight * scaleY; // Calculate Scaled Character Height float chrWidth = cellWidth * scaleX; // Calculate Scaled Character Width int len = text.length(); // Get String Length x += ( chrWidth / 2.0f ) - ( fontPadX * scaleX ); // Adjust Start X y += ( chrHeight / 2.0f ) - ( fontPadY * scaleY ); // Adjust Start Y for ( int i = 0; i < len; i++ ) { // FOR Each Character in String int c = (int)text.charAt( i ) - CHAR_START; // Calculate Character Index (Offset by First Char in Font)

if ( c < 0 || c >= CHAR_CNT ) // IF Character Not In Font

c = CHAR_UNKNOWN; // Set to Unknown Character Index batch.drawSprite( x, y, chrWidth, chrHeight, charRgn[c] ); // Draw the Character x += ( charWidths[c] + spaceX ) * scaleX; // Advance X Position by Scaled Character Width } }

//--Draw Text Centered--// // D: draw text CENTERED at the specified x,y

position // A: text - the string to draw // x, y - the x,y position to draw text at

(bottom left of text)

// R: the total width of the text that was drawn public float drawC(String text, float x, float y)

{ float len = getLength( text ); // Get Text Length draw( text, x - ( len / 2.0f ), y - ( getCharHeight() / 2.0f ) ); // Draw Text Centered return len; // Return Length } public float drawCX(String text, float x, float y)

{ float len = getLength( text ); // Get Text Length draw( text, x - ( len / 2.0f ), y ); // Draw Text Centered (X-Axis Only) return len; // Return Length } public void drawCY(String text, float x, float y) { float len = getLength( text ); // Get Text Length draw( text, x - ( len / 2.0f ), y ); // Draw Text Centered (X-Axis Only) return len; // Return Length } public void drawCY(String text, float x, float y)

//--Set Scale--// // D: set the scaling to use for the font // A: scale - uniform scale for both x and y axis

scaling // sx, sy - separate x and y axis scaling factors // R: [none] public void setScale(float scale) {

scaleX = scaleY = scale; // Set Uniform Scale } public void setScale(float sx, float sy) {

scaleX = sx; // Set X Scale scaleY = sy; // Set Y Scale }

//--Get Scale--// // D: get the current scaling used for the font // A: [none] // R: the x/y scale currently used for scale public float getScaleX() {

return scaleX; // Return X Scale } public float getScaleY() {

return scaleY; // Return Y Scale }

//--Set Space--// // D: set the spacing (unscaled; ie. pixel size)

to use for the font // A: space - space for x axis spacing // R: [none] public void setSpace(float space) {

spaceX = space; // Set Space }

//--Get Space--// // D: get the current spacing used for the font // A: [none] // R: the x/y space currently used for scale public float getSpace() {

return spaceX; // Return X Space }

//--Get Length of a String--// // D: return the length of the specified string if

rendered using current settings // A: text - the string to get length for // R: the length of the specified string (pixels) rendered using current settings // A: text - the string to get length for // R: the length of the specified string (pixels)

len += ( charWidths[c] * scaleX ); // Add Scaled Character Width to Total Length } len += ( strLen > 1 ? ( ( strLen - 1 ) * spaceX

) * scaleX : 0 ); // Add Space Length return len; // Return Total Length }

//--Get Width/Height of Character--// // D: return the scaled width/height of a

character, or max character width // NOTE: since all characters are the same height, no character index is required! // NOTE: excludes spacing!! // A: chr - the character to get width for // R: the requested character size (scaled) public float getCharWidth(char chr) {

int c = chr - CHAR_START; // Calculate Character Index (Offset by First Char in Font)

return ( charWidths[c] * scaleX ); // Return Scaled Character Width } public float getCharWidthMax() {

return ( charWidthMax * scaleX ); // Return Scaled Max Character Width } public float getCharHeight() {

return ( charHeight * scaleY ); // Return Scaled Character Height }

//--Get Font Metrics--// // D: return the specified (scaled) font metric // A: [none] // R: the requested font metric (scaled) public float getAscent() {

return ( fontAscent * scaleY ); // Return Font Ascent } public float getDescent() {

return ( fontDescent * scaleY ); // Return Font Descent } public float getHeight() {

return ( fontHeight * scaleY ); // Return Font Height (Actual) }

//--Draw Font Texture--// // D: draw the entire font texture (NOTE: for

testing purposes only) // A: width, height - the width and height of the area to draw to. this is used // to draw the texture to the top-left corner. public void drawTexture(int width, int height) {

batch.beginBatch( textureId ); // Begin Batch (Bind Texture) batch.drawSprite( textureSize / 2, height - ( textureSize / 2 ), textureSize, textureSize, textureRgn ); // Draw

batch.endBatch(); // End Batch }

MainActivity.java

package com.fractalbackground;

import android.opengl.GLSurfaceView; import android.os.Bundle; import android.app.Activity; import android.content.pm.ActivityInfo; //import android.graphics.PixelFormat; import android.view.Menu; import android.view.Window; import android.view.WindowManager;

public class MainActivity extends Activity {

/** The OpenGL view */ private GLSurfaceView glSurfaceView;

@Override protected void onCreate(Bundle

savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.activity_main);

// requesting to turn the title OFF

requestWindowFeature(Window.FEATURE_NO_TITLE); // making it full screen

getWindow().setFlags(WindowManager.LayoutParams.F LAG_FULLSCREEN,

WindowManager.LayoutParams.FLAG_FULLSCREEN);

// Initiate the Open GL view and // create an instance with this activity glSurfaceView = new ESSurfaceView(this);

//glSurfaceView.setEGLConfigChooser(8, 8, 8, 8,

//glSurfaceView.getHolder().setFormat(PixelFormat.TRA NSLUCENT);

//glSurfaceView.setBackgroundResource(R.drawable.spla sh);

// glSurfaceView.setZOrderMediaOverlay(true);

//glSurfaceView.setZOrderOnTop(true);

//glSurfaceView.getHolder().setFormat(PixelFormat.TRA NSLUCENT);

//glSurfaceView.setBackgroundResource(R.drawable.spla sh);

// glSurfaceView.setZOrderOnTop(true);

// set our renderer to be the main renderer with // the current activity context //glSurfaceView.setRenderer(new ESRender()); setContentView(glSurfaceView);

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATI ON_LANDSCAPE);

/** * Remember to resume the glSurface */

@Override protected void onResume() {

super.onResume(); //Music.play(this, R.raw.song); glSurfaceView.onResume();

/** * Also pause the glSurface */

@Override protected void onPause() {

super.onPause(); //Music.stop(this); //Music.pauseSong(this); glSurfaceView.onPause();

@Override public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; }

MathHelper.java

package com.fractalbackground;

public class MathHelper

public static float angle_of_vector(float x, float y) { double angle = Math.atan(x / y) * 180 / Math.PI; angle = y > 0 ? 90 + angle : 270 + angle; return 270f - (float) angle;

Maths.java

package com.fractalbackground;

/** * @author Jim Cornmell re-edit by XTech * */

public final class Maths {

/** 180 in radians. */ public static final double ONE_EIGHTY_DEGREES =

Math.PI;

/** 360 in radians. */ public static final double THREE_SIXTY_DEGREES =

ONE_EIGHTY_DEGREES * 2;

/** 120 in radians. */ public static final double ONE_TWENTY_DEGREES =

THREE_SIXTY_DEGREES / 3;

/** 90 degrees, North pole. */ public static final double NINETY_DEGREES = Math.PI

/** Used by power. */ private static final long POWER_CLAMP =

0x00000000ffffffffL;

/** * Constructor, although not used at the moment. */

private Maths() { }

/** * Quick integer power function. * * @param base * number to raise. * @param raise * to this power. * @return base ^ raise. */

public static int power(final int base, final int raise) { int p = 1; long b = raise & POWER_CLAMP; // bits in b correspond to values of powerN // so start with p=1, and for each set bit in b,

multiply corresponding // table entry long powerN = base;

while (b != 0) { if ((b & 1) != 0) { p *= powerN; }

b >>>= 1; powerN = powerN * powerN; }

return p; }

Music.java Music.java

import android.content.Context; import android.media.MediaPlayer;

public class Music { private static MediaPlayer mp = null; private static MediaPlayer mpOnce = null;

/** Stop old song and start new one */ public static void playOnce(Context context, int

resource) { //stop(context); mpOnce = MediaPlayer.create(context,

resource); mpOnce.setLooping(false); mpOnce.start();

public static void play(Context context, int resource) { stop(context); mp = MediaPlayer.create(context,

resource); mp.setLooping(true); mp.start();

/** Stop the music */ public static void stop(Context context) {

if (mp != null) { mp.stop(); mp.release(); mp = null;

public static void pauseSong(Context context) { if (mp != null) { mp.pause(); //mp.start(); //mp.play(this, resource); //mp.release(); //mp = null;

public static void stopOnce(Context context) { if (mpOnce != null) {

mpOnce.stop(); mpOnce.release(); mpOnce = null;

MyComplex.java

package com.fractalbackground;

* Compilation: javac Complex.java * Execution: java Complex * * Data type for complex numbers. * * The data type is "immutable" so once you create

and initialize

* a Complex object, you cannot change it. The "final" keyword

* when declaring re and im enforces this rule, making it a

* compile-time error to change the .re or .im fields after * they've been initialized. * * % java Complex * a = 5.0 + 6.0i * b = -3.0 + 4.0i * Re(a) = 5.0 * Im(a) = 6.0 * b + a = 2.0 + 10.0i * a - b = 8.0 + 2.0i * a * b = -39.0 + 2.0i * b * a = -39.0 + 2.0i * a / b = 0.36 - 1.52i * (a / b) * b = 5.0 + 6.0i * conj(a) = 5.0 - 6.0i * |a| = 7.810249675906654 * tan(a) = -6.685231390246571E-6 +

1.0000103108981198i *

public class MyComplex {

private final double re; // the real part private final double im; // the imaginary part

// create a new object with the given real and imaginary parts

public MyComplex(double real, double imag) {

re = real; im = imag;

// return a string representation of the invoking Complex object public String toString() { if (im == 0) return re + ""; // return a string representation of the invoking Complex object public String toString() { if (im == 0) return re + "";

// return abs/modulus/magnitude and angle/phase/argument

public double abs() { return Math.hypot(re, im); } // Math.sqrt(re*re + im*im)

public double phase() { return Math.atan2(im, re); } // between -pi and pi

// return a new Complex object whose value is (this + b) public MyComplex plus(MyComplex b) { MyComplex a = this; // invoking object double real = a.re + b.re; double imag = a.im + b.im; return new MyComplex(real, imag);

// return a new Complex object whose value is (this - b) public MyComplex minus(MyComplex b) { MyComplex a = this; double real = a.re - b.re; double imag = a.im - b.im; return new MyComplex(real, imag);

// return a new Complex object whose value is (this * b) public MyComplex times(MyComplex b) { MyComplex a = this; double real = a.re * b.re - a.im * b.im; double imag = a.re * b.im + a.im * b.re; return new MyComplex(real, imag);

// scalar multiplication // return a new object whose value is (this *

alpha) public MyComplex times(double alpha) { return new MyComplex(alpha * re, alpha * im); }

// return a new Complex object whose value is the conjugate of this public MyComplex conjugate() { return new MyComplex(re, -im); }

// negation public MyComplex negation() { return new

MyComplex(-re, -im); }

// return a new Complex object whose value is the reciprocal of this public MyComplex reciprocal() { double scale = re*re + im*im; return new MyComplex(re / scale, -im /

scale); }

// return the real or imaginary part public double re() { return re; } public double im() { return im; }

// return a / b public MyComplex divides(MyComplex b) {

MyComplex a = this; return a.times(b.reciprocal());

// return a new Complex object whose value is the complex exponential of this public MyComplex exp() { return new MyComplex(Math.exp(re) * Math.cos(im), Math.exp(re) * Math.sin(im)); }

// return a new Complex object whose value is the complex sine of this public MyComplex sin() { return new MyComplex(Math.sin(re) * Math.cosh(im), Math.cos(re) * Math.sinh(im)); }

// return a new Complex object whose value is the complex cosine of this public MyComplex cos() { return new MyComplex(Math.cos(re) * Math.cosh(im), -Math.sin(re) * Math.sinh(im)); }

// return a new Complex object whose value is the complex tangent of this public MyComplex tan() { return sin().divides(cos()); }

// return a new complex^degree /*public MyComplex pow(MyComplex a, double

degree) {

// count root from abs a double root_abs_a =

Math.pow(a.abs(),1/degree);

// hitung besar sudut teta double teta = Math.atan2(a.im(), a.re());

double real = root_abs_a*Math.cos(teta/degree); double imag = double real = root_abs_a*Math.cos(teta/degree); double imag =

public MyComplex pow(double degree, int type) {

// count root from abs double root_abs = Math.pow(abs(),degree); double teta = Math.atan2(im,re); if(type==1){

// hitung besar sudut teta teta = Math.atan2(re,im); }else{ teta = Math.atan2(im,re); }

double real = root_abs*Math.cos(teta/(1/degree)); double imag = root_abs*Math.sin(teta/(1/degree)); return new MyComplex(real, imag);

// a static version of plus public static MyComplex plus(MyComplex a,

MyComplex b) { double real = a.re + b.re; double imag = a.im + b.im; MyComplex sum = new MyComplex(real, imag); return sum;

// sample client for testing public static void main(String[] args) {

MyComplex a = new MyComplex(5.0, 6.0); MyComplex b = new MyComplex(-3.0, 4.0);

System.out.println("a = " + a); System.out.println("b = " + b); System.out.println("Re(a) = " +

a.re());

System.out.println("Im(a) = " + a.im());

System.out.println("b + a = " + b.plus(a));

System.out.println("a - b = " + a.minus(b));

System.out.println("a * b = " + a.times(b));

System.out.println("b * a = " + b.times(a));

System.out.println("a / b = " + a.divides(b));

System.out.println("(a / b) * b = " + a.divides(b).times(b));

System.out.println("conj(a) = " + a.conjugate()); System.out.println("|a| = " + a.abs()); System.out.println("tan(a) = " + a.tan()); }

MySphere.java

package com.fractalbackground;

import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.util.ArrayList; import java.util.List;

import javax.microedition.khronos.opengles.GL10;

import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; import android.opengl.GLES20; import android.opengl.GLUtils;

/** * Render a sphere. * * @author Jim Cornmell re-edit by XTech * @since July 2013 */

public class MySphere { /** Maximum allowed depth. */ private static final int MAXIMUM_ALLOWED_DEPTH = 5;

/** Used in vertex strip calculations, related to properties of a icosahedron. */ private static final int VERTEX_MAGIC_NUMBER = 5;

/** Each vertex is a 2D coordinate. */ private static final int NUM_FLOATS_PER_VERTEX = 3;

/** Each texture is a 2D coordinate. */ private static final int NUM_FLOATS_PER_TEXTURE =

/** Each vertex is made up of 3 points, x, y, z. */ private static final int

AMOUNT_OF_NUMBERS_PER_VERTEX_POINT = 3;

/** Each texture point is made up of 2 points, x, y (in reference to the texture being a 2D image). */ private static final int AMOUNT_OF_NUMBERS_PER_TEXTURE_POINT = 2;

/** Buffer holding the vertices. */ private final List<FloatBuffer> mVertexBuffer = new

ArrayList<FloatBuffer>();

/** The vertices for the sphere. */ private final List<float[]> mVertices = new

ArrayList<float[]>();

/** Buffer holding the texture coordinates. */ private final List<FloatBuffer> mTextureBuffer =

new ArrayList<FloatBuffer>();

/** Mapping texture coordinates for the vertices. */ private final List<float[]> mTexture = new ArrayList<float[]>();

/** The texture pointer. */ private final int[] mTextures = new int[1];

/** Total number of strips for the given depth. */ private final int mTotalNumStrips;

private int[] imageFileIDs = { // Image file IDs

R.drawable.nature, R.drawable.mule, R.drawable.earth, R.drawable.basketballcolor,

R.drawable.soccerballadidas };

/** * Sphere constructor. * @param depth integer representing the split of

the sphere. * @param radius The spheres radius. */

public MySphere(final int depth, final float radius) { // Clamp depth to the range 1 to MAXIMUM_ALLOWED_DEPTH; final int d = Math.max(1, Math.min(MAXIMUM_ALLOWED_DEPTH, depth));

// Calculate basic values for the sphere. this.mTotalNumStrips = Maths.power(2, d - 1) *

VERTEX_MAGIC_NUMBER; final int numVerticesPerStrip = Maths.power(2, d) * 3; final double altitudeStepAngle = Maths.ONE_TWENTY_DEGREES / Maths.power(2, d); final double azimuthStepAngle = Maths.THREE_SIXTY_DEGREES / this.mTotalNumStrips; VERTEX_MAGIC_NUMBER; final int numVerticesPerStrip = Maths.power(2, d) * 3; final double altitudeStepAngle = Maths.ONE_TWENTY_DEGREES / Maths.power(2, d); final double azimuthStepAngle = Maths.THREE_SIXTY_DEGREES / this.mTotalNumStrips;

for (int stripNum = 0; stripNum < this.mTotalNumStrips; stripNum++) { // Setup arrays to hold the points for this strip. final float[] vertices = new float[numVerticesPerStrip * NUM_FLOATS_PER_VERTEX]; // NOPMD

final float[] texturePoints = new float[numVerticesPerStrip * NUM_FLOATS_PER_TEXTURE]; // NOPMD

int vertexPos = 0; int texturePos = 0;

// Calculate position of the first vertex in this strip. altitude = Maths.NINETY_DEGREES; azimuth = stripNum * azimuthStepAngle;

// Draw the rest of this strip. for (int vertexNum = 0; vertexNum <

numVerticesPerStrip; vertexNum += 2) { // First point - Vertex. y = radius * Math.sin(altitude);

h = radius * Math.cos(altitude); z = h * Math.sin(azimuth); x = h * Math.cos(azimuth); vertices[vertexPos++] = (float) x; vertices[vertexPos++] = (float) y; vertices[vertexPos++] = (float) z;

// First point - Texture. texturePoints[texturePos++] = (float) (1 -

azimuth / Maths.THREE_SIXTY_DEGREES); texturePoints[texturePos++] = (float) (1 - (altitude + Maths.NINETY_DEGREES) / Maths.ONE_EIGHTY_DEGREES);

// Second point - Vertex. altitude -= altitudeStepAngle; azimuth -= azimuthStepAngle / 2.0; y = radius * Math.sin(altitude);

h = radius * Math.cos(altitude); z = h * Math.sin(azimuth); x = h * Math.cos(azimuth); vertices[vertexPos++] = (float) x; vertices[vertexPos++] = (float) y; vertices[vertexPos++] = (float) z;

// Second point - Texture. texturePoints[texturePos++] = (float) (1 -

azimuth / Maths.THREE_SIXTY_DEGREES); texturePoints[texturePos++] = (float) (1 - (altitude + Maths.NINETY_DEGREES) / Maths.ONE_EIGHTY_DEGREES);

azimuth += azimuthStepAngle; } azimuth += azimuthStepAngle; }

ByteBuffer byteBuffer = ByteBuffer.allocateDirect(numVerticesPerStrip * NUM_FLOATS_PER_VERTEX * Float.SIZE);

byteBuffer.order(ByteOrder.nativeOrder()); FloatBuffer fb = byteBuffer.asFloatBuffer(); fb.put(this.mVertices.get(stripNum)); fb.position(0); this.mVertexBuffer.add(fb);

// Setup texture. byteBuffer =

ByteBuffer.allocateDirect(numVerticesPerStrip * NUM_FLOATS_PER_TEXTURE * Float.SIZE);

byteBuffer.order(ByteOrder.nativeOrder());

fb = byteBuffer.asFloatBuffer(); fb.put(this.mTexture.get(stripNum)); fb.position(0); this.mTextureBuffer.add(fb);

/** * Load the texture for the square. * * @param gl Handle. * @param context Handle. * @param texture Texture map for the sphere. */

public void loadGLTexture(final GL10 gl, final Context context, final int index_Texture) {

//public void loadGLTexture(final GL10 gl, final Context context, final int texture) { // final Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), texture);

final Bitmap bitmap = BitmapFactory.decodeStream(context.getResources()

.openRawResource(imageFileIDs[index_Texture]));

// flip method, untuk membalik texture yang kurang sesuai Matrix flip = new Matrix(); flip.postScale(-1f, 1f); final Bitmap bmp = Bitmap.createBitmap(bitmap, 0,

0, bitmap.getWidth(), bitmap.getHeight(), flip, true);

// Generate one texture pointer, and bind it to the texture array. gl.glGenTextures(1, this.mTextures, 0); gl.glBindTexture(GL10.GL_TEXTURE_2D,

this.mTextures[0]);

// Create nearest filtered texture. //gl.glTexParameterf(GL10.GL_TEXTURE_2D,

GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST); //gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);

//The min filters provided by opengl are

//gl.glTexParameterf(GLES20.GL_LINEAR_MIPMAP_LINEAR, GLES20.GL_NEAREST_MIPMAP_NEAREST, GLES20.GL_LINEAR);

//The texture seems to be rendering for the following line of code // to enable textue where texture not showing on some device android mobile

GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);

// Use Android GLUtils to specify a two- dimensional texture image from our bitmap. //GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);

GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bmp,

// Tidy up. //bitmap.recycle(); bmp.recycle();

/** * The draw method for the square with the GL context. * * @param gl Graphics handle. */

public void draw(final GL10 gl) { //menempelkan tekstur ke objek gl.glEnable(GL10.GL_TEXTURE_2D);

// bind the previously generated texture. gl.glBindTexture(GL10.GL_TEXTURE_2D,

this.mTextures[0]);

// Point to our buffers. gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glEnableClientState(GL10.GL_NORMAL_ARRAY);

gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

// Set the face rotation, clockwise in this case. gl.glFrontFace(GL10.GL_CCW);

// Point to our vertex buffer. for (int i = 0; i < this.mTotalNumStrips; i++) {

gl.glVertexPointer(AMOUNT_OF_NUMBERS_PER_VERTEX_POINT , GL10.GL_FLOAT, 0, this.mVertexBuffer.get(i)); gl.glVertexPointer(AMOUNT_OF_NUMBERS_PER_VERTEX_POINT , GL10.GL_FLOAT, 0, this.mVertexBuffer.get(i));

gl.glTexCoordPointer(AMOUNT_OF_NUMBERS_PER_TEXTURE_PO INT, GL10.GL_FLOAT, 0, this.mTextureBuffer.get(i));

// Draw the vertices as triangle strip. gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0,

this.mVertices.get(i).length / AMOUNT_OF_NUMBERS_PER_VERTEX_POINT);

// Disable the client state before leaving. gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); gl.glDisableClientState(GL10.GL_NORMAL_ARRAY); gl.glDisable( GL10.GL_TEXTURE_2D );

// Disable Texture Mapping }

ObjectArena.java

package com.fractalbackground;

import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; import javax.microedition.khronos.opengles.GL10;

public class ObjectArena { private float vertices[] = { -0.5f, -0.5f, 0.0f,

// V1 - first vertex (x,y,z) -0.5f, 0.5f, 0.0f,

V2 0.5f, 0.5f, 0.0f,

V3 0.5f, -0.5f, 0.0f,

// V4 -0.5f, -0.5f, 0.0f

V5 };

private float vertices_color[] = { 1.0f, 0.0f, 0.0f, 1.0f,

CV1 - first color (red,green,blue) 0.0f, 1.0f, 0.0f, 1.0f,

// CV2 0.0f, 0.0f, 1.0f, 1.0f,

// CV3 0.0f, 1.0f, 0.0f, 1.0f,

// CV4 1.0f, 0.0f, 0.0f, 1.0f // CV5 };

public ObjectArena() {

// Point to our vertex buffer, return buffer holding the vertices public static FloatBuffer makeFloatBuffer(float[] arr){ ByteBuffer bb = ByteBuffer.allocateDirect(arr.length * 4); bb.order(ByteOrder.nativeOrder()); FloatBuffer fb = bb.asFloatBuffer(); fb.put(arr); fb.position(0); return fb;

/** The draw method for the primitive object with the GL context */ public void draw_kotak(GL10 gl) {

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// Point to our vertex buffer gl.glVertexPointer(3, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices));

// Draw the vertices as square

gl.glColorPointer(4, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_color)); gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 3);

gl.glColorPointer(4, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_color)); gl.glDrawArrays(GL10.GL_TRIANGLES, 2, 3);

//Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

ObjectBall.java

package com.fractalbackground;

import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer;

import javax.microedition.khronos.opengles.GL10;

import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.opengl.GLES20; import android.opengl.GLUtils;

public class ObjectBall {

private float textCoord_Triagle[]={ 1.0f, 1.0f, 0.0f,

V3 0.0f, 1.0f, 0.0f,

V2 0.5f, 0.0f, 0.0f,

// V1 - first vertex (x,y,z) };

private int[] imageFileIDs = { // Image file IDs R.drawable.nature, R.drawable.mule, R.drawable.joystick, R.drawable.joystick_bg,

R.drawable.meow};

private float vertices_circle[]={0.0f,0.0f,0.0f}; private float

vertices_circle_color[]={0.0f,0.0f,0.0f,0.5f}; private float textCoord[]; private float vertices_circle1[];

int[] textures_indek = new int[1]; int[] textures_indek = new int[1];

public ObjectBall() {

// ============ start to generate stetch texture coordinat ========================== //Inisialisasi jari_jari=0.5f;

// Titik Pusat

a = 0.5f; b = 0.5f ; //x=a+jari_jari; y=b; teta = 0;

// generate stretch texture coordinat teta=0; textCoord = new float[batas_sudut * 3]; for (int ii = 0; ii < batas_sudut * 3; ii

+= 3) { // membentuk textCoord textCoord[ii] =

(jari_jari*((float) Math.cos(-teta)))+a; textCoord[ii + 1] = (jari_jari*((float) Math.sin(-teta)))+b; textCoord[ii + 2] = 0.0f;

teta += Math.PI / 90;

// ============ start to generate vertices to circle (Cara 1) ==========================

//Inisialisasi jari_jari=50.0f;

// Titik Pusat

a = 50.0f; b = 50.0f ;

vertices_circle1 = new float[batas_sudut * 3]; for (int ii = 0; ii < batas_sudut * 3; ii += 3) { // membentuk vertices_circle1 vertices_circle1[ii] =

(jari_jari*((float) Math.cos(teta)))+a; vertices_circle1[ii + 1] = (jari_jari*((float) Math.sin(teta)))+b; vertices_circle1[ii + 2] = 0.0f;

teta += Math.PI / 90;

// ============ start to generate vertices to circle (Cara 2) ==========================

//Inisialisasi jari_jari=50.0f;

// Titik Pusat

a = 50.0f; b = 50.0f ; x=a+jari_jari; y=b;

loop=0; loop_color=0; vertices_circle=new

float[(int)(3*batas_sudut/step)*3]; vertices_circle_color=new float[(int)(3*batas_sudut/step)*4]; for(teta=0;teta<=2*batas_sudut;teta+=step){ vertices_circle[loop] = (float) ((x- a)*Math.cos((teta/180)*(22/7)) - ((y- b)*Math.sin((teta/180)*(22/7))) + a);

vertices_circle[loop+1] = (float) ((x- a)*Math.sin((teta/180)*(22/7)) - ((y- b)*Math.cos((teta/180)*(22/7))) + b);

vertices_circle[loop+2]=0; loop+=3;

//mengenerate warna untuk setiap vertex

//vertices_circle_color[loop_color]=(float) ((x- a)*Math.cos((teta/180)*(22/7)) - ((y- b)*Math.sin((teta/180)*(22/7))) + a);

//vertices_circle_color[loop_color+1]=(float) ((x-a)*Math.sin((teta/180)*(22/7)) - ((y- b)*Math.cos((teta/180)*(22/7))) + b);

vertices_circle_color[loop_color]=(float) (Math.cos((teta/180)*(22/7)) );

vertices_circle_color[loop_color+1]=(float) (Math.sin((teta/180)*(22/7)));

vertices_circle_color[loop_color+2]=0.5f; vertices_circle_color[loop_color+3]=0.5f; loop_color+=4; }

// ============= end for generate vertices to circle ====================

// Point to our vertex buffer, return buffer holding the vertices public static FloatBuffer makeFloatBuffer(float[] arr){

ByteBuffer bb = ByteBuffer.allocateDirect(arr.length * 4); bb.order(ByteOrder.nativeOrder()); FloatBuffer fb = bb.asFloatBuffer(); fb.put(arr); fb.position(0); return fb;

// Setup index-array buffer. Indices in byte. public static ByteBuffer makeByteBuffer(byte[]

arr){ ByteBuffer bb = ByteBuffer.allocateDirect(arr.length); bb.put(arr); bb.position(0); return bb;

/** The draw method for the primitive object with the GL context */ public void draw_circle(GL10 gl) {

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour for the object circle //gl.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);

//create VBO from buffer with

glBufferData()

gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_circle));

//memetakan warna untuk setiap vertex gl.glColorPointer(4, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices_circle_color));

//draw circle as filled shape //gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 1,

(int) ((int) 2*batas_sudut/step));

//draw circle contours //gl.glDrawArrays(GL10.GL_LINES, 1, (int)

((int) 2*batas_sudut/step)); // membuat garis putus- putus pada tepi lingkaran

//gl.glDrawArrays(GL10.GL_LINES, 1, (int) ((int) 2*batas_sudut/step)); gl.glDrawArrays(GL10.GL_LINE_STRIP, 1, (int) ((int) 2*batas_sudut/step)); //gl.glDrawArrays(GL10.GL_POINTS, 1, (int) ((int) 2*batas_sudut/step));

//Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

public void draw_circle_color(GL10 gl) {

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

//gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour edge for the object circle //gl.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);

//create VBO from buffer with

glBufferData()

gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_circle1));

//memetakan warna untuk setiap vertex //gl.glColorPointer(4, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices_circle_color));

//menempelkan tekstur ke objek gl.glEnable(GL10.GL_TEXTURE_2D);

gl.glEnable(GL10.GL_BLEND); gl.glBlendFunc(GL10.GL_SRC_ALPHA,

GL10.GL_ONE_MINUS_SRC_ALPHA);

gl.glBindTexture(GL10.GL_TEXTURE_2D, textures_indek[0]); // 4 //gl.glTexCoordPointer(3, GL10.GL_FLOAT,

1, makeFloatBuffer(vertices_circle)); // 5 gl.glTexCoordPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(textCoord)); // 5

gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRA Y);

//GL11ExtensionPack gl_ = (GL11ExtensionPack) gl; //GL11 gl11 = (GL11) gl; //gl.glBindTexture(GL10.GL_TEXTURE_2D,

textures_indek[0]);

// Set the face rotation //gl.glFrontFace(GL10.GL_CW);

//draw circle as filled shape //gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0,

(int) ((int) 2*batas_sudut/step)); //gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0, (int) ((int) 2*batas_sudut/step)); gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0, batas_sudut); //gl.glDrawArrays(GL10.GL_LINE_STRIP, 0,

(int) ((int) 2*batas_sudut/step)); //gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 1, 120);

//Log.i("Nilai 2*batas_sudut/step : ", ""+2*batas_sudut/step);

//gl.glDrawArrays(GL10.GL_LINE_STRIP, 1, (int) ((int) 2*batas_sudut/step)); //gl.glDrawElements(GL10.GL_TRIANGLES, (int) ((int) 2*batas_sudut/step), // GL10.GL_UNSIGNED_SHORT, makeFloatBuffer(vertices_circle));

//draw circle contours //gl.glDrawArrays(GL10.GL_LINES, 1, (int)

((int) 2*batas_sudut/step)); // membuat garis putus- putus pada tepi lingkaran

//gl.glDrawArrays(GL10.GL_LINE_STRIP, 1, (int) ((int) 2*batas_sudut/step)); //gl.glDrawArrays(GL10.GL_POINTS, 1, (int) ((int) 2*batas_sudut/step));

//Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

//gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

gl.glDisable( GL10.GL_BLEND );

// Disable Alpha Blend

gl.glDisable( GL10.GL_TEXTURE_2D ); // Disable Texture Mapping }

public void draw_circle_color(GL10 gl,float red_in, float green_in,float blue_in, float alpha_in) {

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

//gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour edge for the object circle gl.glColor4f(red_in, green_in, blue_in, 0.33f); //gl.glColor4f(red_in, green_in, blue_in, alpha_in);

//create VBO from buffer with

glBufferData() gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_circle1));

//memetakan warna untuk setiap vertex //gl.glColorPointer(4, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices_circle_color));

//menempelkan tekstur ke objek //gl.glEnable(GL10.GL_TEXTURE_2D);

//gl.glEnable(GL10.GL_BLEND); //gl.glBlendFunc(GL10.GL_SRC_ALPHA,

GL10.GL_ONE_MINUS_SRC_ALPHA);

//gl.glBindTexture(GL10.GL_TEXTURE_2D, textures_indek[0]); // 4 //gl.glTexCoordPointer(3, GL10.GL_FLOAT,

1, makeFloatBuffer(vertices_circle)); // 5 //gl.glTexCoordPointer(3, GL10.GL_FLOAT,

0, makeFloatBuffer(textCoord)); // 5

//gl.glEnableClientState(GL10.GL_TEXTURE_COORD_AR RAY);

//GL11ExtensionPack gl_ = (GL11ExtensionPack) gl; //GL11 gl11 = (GL11) gl; //gl.glBindTexture(GL10.GL_TEXTURE_2D,

textures_indek[0]);

// Set the face rotation //gl.glFrontFace(GL10.GL_CW);

gl.glEnable(GL10.GL_BLEND); gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

//draw circle as filled shape //gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0,

(int) ((int) 2*batas_sudut/step));

gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0, batas_sudut); //gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0, (int) ((int) 2*batas_sudut/step)); //gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0, batas_sudut); //gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, (int) ((int) 2*batas_sudut/step)); //gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 1, 120);

//Log.i("Nilai 2*batas_sudut/step : ", ""+2*batas_sudut/step);

//gl.glDrawArrays(GL10.GL_LINE_STRIP, 1, (int) ((int) 2*batas_sudut/step)); //gl.glDrawElements(GL10.GL_TRIANGLES, (int) ((int) 2*batas_sudut/step), // GL10.GL_UNSIGNED_SHORT, makeFloatBuffer(vertices_circle));

//draw circle contours

//gl.glDrawArrays(GL10.GL_LINES, 1, (int) ((int) 2*batas_sudut/step)); // membuat garis putus- putus pada tepi lingkaran

//gl.glDrawArrays(GL10.GL_LINE_STRIP, 1, (int) ((int) 2*batas_sudut/step)); //gl.glDrawArrays(GL10.GL_POINTS, 1, (int) ((int) 2*batas_sudut/step));

//Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

//gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

gl.glDisable( GL10.GL_BLEND );

// Disable Alpha Blend

//gl.glDisable( GL10.GL_TEXTURE_2D ); // Disable Texture Mapping }

public void draw_segitiga(GL10 gl) { gl.glFrontFace(GL10.GL_CCW); // Front face in counter-clockwise

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

//gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour for the triangle //gl.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);

gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(new float [] {

1.0f, 1.0f, 0.0f, // V3 0.0f, 1.0f, 0.0f, // V2 0.5f, 0.0f, 0.0f,

// V1 - first vertex (x,y,z) }));

// Draw the vertices as triangle //gl.glColorPointer(4, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices_color));

//menempelkan tekstur ke objek //gl.glEnable(GL10.GL_TEXTURE_2D);

gl.glEnable(GL10.GL_BLEND); gl.glBlendFunc(GL10.GL_SRC_ALPHA,

GL10.GL_ONE_MINUS_SRC_ALPHA);

//gl.glEnableClientState(GL10.GL_TEXTURE_COORD_AR RAY); //gl.glEnableClientState(GL10.GL_TEXTURE_COORD_AR RAY);

//Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

//gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

gl.glDisable( GL10.GL_BLEND );

// Disable Alpha Blend

public void draw_segitiga_texture(GL10 gl) {

gl.glFrontFace(GL10.GL_CCW); // Front face in counter-clockwise

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

//gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour for the triangle (menghilangkan effect dari warna objek sebelumnya) gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(new float [] { 1.0f, 1.0f, 0.0f, // V3 0.0f, 1.0f, 0.0f, // V2 0.5f, 0.0f, 0.0f,

// V1 - first vertex (x,y,z) }));

// Draw the vertices as triangle //gl.glColorPointer(4, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices_color));

//menempelkan tekstur ke objek gl.glEnable(GL10.GL_TEXTURE_2D);

gl.glEnable(GL10.GL_BLEND); gl.glBlendFunc(GL10.GL_SRC_ALPHA,

GL10.GL_ONE_MINUS_SRC_ALPHA);

gl.glBindTexture(GL10.GL_TEXTURE_2D, textures_indek[0]); // gl.glTexCoordPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(textCoord_Triagle)); //

gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRA Y);

gl.glDrawArrays(GLES20.GL_TRIANGLE_STRIP,

//Disable the client state before leaving //Disable the client state before leaving

//gl.glDisableClientState(GL10.GL_COLOR_ARRAY); gl.glDisable( GL10.GL_BLEND ); // Disable Alpha Blend

gl.glDisable( GL10.GL_TEXTURE_2D ); // Disable Texture Mapping

public void loadBallTexture(GL10 gl, Context context) { // Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), // resource);

Bitmap bitmap = BitmapFactory.decodeStream(context.getResources()

.openRawResource(R.drawable.nature));

gl.glGenTextures(1, textures_indek, 0); gl.glBindTexture(GL10.GL_TEXTURE_2D,

textures_indek[0]);

/*gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); */

//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 );

// ori :

//gl.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);

//gl.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);

// edit

GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);

//gl.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_REPEAT );

//gl.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_REPEAT );

///gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, //GL10.GL_NEAREST); //gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, //GL10.GL_LINEAR);

GLUtils.texImage2D(GLES20.GL_TEXTURE_2D,

0, bitmap, 0);

bitmap.recycle(); }

public void loadBallTexture(GL10 gl, Context context,int index_Texture) { // Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), // resource);

/*Bitmap bitmap = BitmapFactory.decodeStream(context.getResources()

.openRawResource(R.drawable.nature));*/

Bitmap bitmap = BitmapFactory.decodeStream(context.getResources()

.openRawResource(imageFileIDs[index_Texture]));

gl.glGenTextures(1, textures_indek, 0); gl.glBindTexture(GL10.GL_TEXTURE_2D,

textures_indek[0]);

/*gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); */

//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 );

//ori :

//gl.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);

//gl.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);

//edit :

GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);

//gl.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_REPEAT );

//gl.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_REPEAT );

///gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, //GL10.GL_NEAREST); //gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, //GL10.GL_LINEAR);

GLUtils.texImage2D(GLES20.GL_TEXTURE_2D,

0, bitmap, 0);

bitmap.recycle(); }

ObjModel.java

package com.fractalbackground;

import android.content.Context; //import android.content.res.AssetManager; import android.graphics.Bitmap; //import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.opengl.GLUtils; import android.util.Log; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.FloatBuffer; import java.util.ArrayList; import java.util.StringTokenizer; import javax.microedition.khronos.opengles.GL10;

public class ObjModel {

public void bindTextures(Context context, GL10 gl) { Bitmap bitmap;

try { InputStream is =

context.getAssets().open("textures/"+mTextureName); context.getAssets().open("textures/"+mTextureName);

Log.v("ObjModel", "err loading bitmap!"); } } catch (java.io.IOException e) { Log.v("ObjModel", "err loading tex: "+e.toString()); return; }

mTextures = new int[1]; gl.glGenTextures(1, mTextures, 0); gl.glBindTexture(GL10.GL_TEXTURE_2D,

mTextures[0]);

gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);

gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);

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); GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);

Log.v("ObjModel", "loaded texture: "+mTextureName+" = "+mTextures[0]);

bitmap.recycle(); }

public void draw(GL10 gl) {

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

for (Model model : mModels) {

gl.glVertexPointer(3, GL10.GL_FLOAT, 0, model.v); if (model.vt != null && mTextures != null) { gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextures[0]);

gl.glTexCoordPointer(2,

GL10.GL_FLOAT, 0, model.vt); } if (model.vn != null) {

gl.glNormalPointer(GL10.GL_FLOAT, 0, model.vn); } gl.glDrawArrays(GL10.GL_TRIANGLES, 0,

model.v_size); model.v_size);

gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

public static ObjModel loadFromStream(InputStream is, String texture_name) throws IOException { ObjModel obj = ObjLoader.loadFromStream(is); obj.mTextureName = texture_name; return obj;

/* private */

private Model mModels[]; private int mTextures[]; private String mTextureName;

private static class ObjLoader {

public static ObjModel loadFromStream(InputStream is) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(is));

ObjModel obj = new ObjModel(); ArrayList<Point3> v = new

ArrayList<Point3>(); ArrayList<Point3> vt = new ArrayList<Point3>(); ArrayList<Point3> vn = new ArrayList<Point3>(); ArrayList<Face> f = new ArrayList<Face>();

ArrayList<Model> o = new ArrayList<Model>();

boolean o_pending=false;

while(reader.ready()) {

String line = reader.readLine(); if (line == null)

break;

StringTokenizer tok = new StringTokenizer(line); String cmd = tok.nextToken();

if (cmd.equals("o")) { if (o_pending) {

Model model = new Model(); model.fill(f, vt.size() > 0, Model model = new Model(); model.fill(f, vt.size() > 0,

o_pending=true; } } else if (cmd.equals("v")) {

v.add(read_point(tok)); } else if (cmd.equals("vn")) {

vn.add(read_point(tok)); } else if (cmd.equals("vt")) {

vt.add(read_point(tok)); } else if (cmd.equals("f")) {

if (tok.countTokens() != 3) throw new UnsupportedOperationException("Only triangles supported");

Face face = new Face(3); while (tok.hasMoreTokens()) {

StringTokenizer face_tok = new StringTokenizer(tok.nextToken(), "/");

int v_idx = -1; int vt_idx = -1; int vn_idx = -1; v_idx =

Integer.parseInt(face_tok.nextToken()); if (face_tok.hasMoreTokens()) vt_idx = Integer.parseInt(face_tok.nextToken()); if (face_tok.hasMoreTokens()) vn_idx = Integer.parseInt(face_tok.nextToken());

//Log.v("objmodel", "face: "+v_idx+"/"+vt_idx+"/"+vn_idx);

face.addVertex( v.get(v_idx-1), vt_idx == -1 ? null :

vt.get(vt_idx-1), vn_idx == -1 ? null : vn.get(vn_idx-1)

} f.add(face);

} /* else if (cmd.equals("usemtl")) {

// lets not bother parsing material file

// just use the name as an asset path obj.mTextureName = tok.nextToken(); } */

if (o_pending) { Model model = new Model(); model.fill(f, vt.size() > 0,

vn.size() > 0); o.add(model); }

obj.mModels = new Model[o.size()]; o.toArray(obj.mModels);

return obj; }

private static Point3 read_point(StringTokenizer tok) { Point3 ret = new Point3(); if (tok.hasMoreTokens()) {

ret.x = Float.parseFloat(tok.nextToken()); if (tok.hasMoreTokens()) { ret.y = Float.parseFloat(tok.nextToken()); if (tok.hasMoreTokens()) {

ret.z =

Float.parseFloat(tok.nextToken()); } } } return ret;

private static class Face {

Point3 v[]; Point3 vt[]; Point3 vn[]; int size; int count;

public Face(int size) {

this.size = size; this.count = 0; this.v = new Point3[size]; this.vt = new Point3[size]; this.vn = new Point3[size];

} public boolean addVertex(Point3 v, Point3 vt,

Point3 vn) { if (count >= size) return false; this.v[count] = v; this.vt[count] = vt; this.vn[count] = vn; count++; return true;

public void pushOnto(FloatBuffer v_buffer, FloatBuffer vt_buffer, FloatBuffer vn_buffer) { int i; for (i=0; i<size; i++) {

v_buffer.put(v[i].x);

v_buffer.put(v[i].y); v_buffer.put(v[i].z);

if (vt_buffer != null && vt[i] != null) { vt_buffer.put(vt[i].x); vt_buffer.put(vt[i].y); }

if (vn_buffer != null && vn[i] != null) { vn_buffer.put(vn[i].x); vn_buffer.put(vn[i].y); vn_buffer.put(vn[i].z); } } } }

private static class Model {

public FloatBuffer v; public FloatBuffer vt; public FloatBuffer vn; public int v_size;

public void fill(ArrayList<Face> faces, boolean has_tex, boolean has_normals) { int f_len = faces.size();

this.v_size = f_len * 3; this.v =

FloatBuffer.allocate(this.v_size*3);

if (has_tex) this.vt = FloatBuffer.allocate(this.v_size*2); if (has_normals) this.vn = FloatBuffer.allocate(this.v_size*3); if (has_tex) this.vt = FloatBuffer.allocate(this.v_size*2); if (has_normals) this.vn = FloatBuffer.allocate(this.v_size*3);

Face face = faces.get(i); face.pushOnto(this.v, this.vt,

this.vn); }

this.v.rewind(); if (this.vt != null)

this.vt.rewind(); if (this.vn != null)

this.vn.rewind();

Point3.java

package com.fractalbackground;

public class Point3 extends Object {

public float x; public float y; public float z;

public Point3() {

x = 0.0f; y = 0.0f; z = 0.0f;

} public Point3(float x, float y, float z) {

set(x,y,z); } public Point3(Point3 src) {

set(src.x, src.y, src.z); }

public final boolean equals(float x, float y, float z) { return ((this.x == x) && (this.y == y) && (this.z == z)); }

public void set(float x, float y, float z)

{ this.x = x; this.y = y; this.z = z;

public void minmax(float minx, float miny, float minz, float maxx, float maxy, float maxz) { this.x = Math.min(Math.max(this.x, minx), maxx); this.y = Math.min(Math.max(this.y, miny), maxy); this.z = Math.min(Math.max(this.z, minz), maxz); }

@Override public boolean equals(Object o) {

if (this == o) return true;

if (!(o instanceof Point3)) return false;

Point3 obj = (Point3)o; return this.equals(obj.x, obj.y, obj.z);

} @Override public String toString() {

return "("+x+","+y+","+z+")"; } @Override public int hashCode() { throw new

UnsupportedOperationException(); } }

PrimitivesObject.java

package com.fractalbackground;

import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; //import java.util.Random;

import javax.microedition.khronos.opengles.GL10;

import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.opengl.GLES20; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.opengl.GLES20;

public class PrimitivesObject {

//MyComplex mycomplex_k;

//MyComplex c = new MyComplex(0.109, 0.603); int width = 100, height = 100; //private int its_loop =0; //private float r_julia_m =0.f; boolean doJuliaSet = true; int idx_vertex = 0; int idx_vertex_color = 0;

private float verticesbackground[] = { 0.0f, 0.0f, 0.0f,

// V1 - bottom left 0.0f, 1.0f, 0.0f,

// V2 - top left 1.0f, 0.0f, 0.0f,

// V3 - bottom right 1.0f, 1.0f, 0.0f // V4 - top right };

//private FloatBuffer textureBuffer; // buffer holding the texture coordinates private float texturebackground[] = {

// Mapping coordinates for the vertices 0.0f, 1.0f, 0.0f,

// top left

(V2) 0.0f, 0.0f, 0.0f,

// bottom left (V1) 1.0f, 1.0f,

0.0f, // top right

(V4)

// bottom right (V3) };

1.0f, 0.0f, 0.0f

private int[] imageFileIDs = { // Image file IDs R.drawable.nature, R.drawable.mule, R.drawable.joystick, R.drawable.joystick_bg,

R.drawable.meow,R.drawable.earth,R.drawable.groun d};

private int[] imageFileIDs2 = { // Image file IDs R.drawable.bird1, R.drawable.bird2, R.drawable.bird3, R.drawable.bird4, R.drawable.bird5, R.drawable.bird6, R.drawable.bird7, R.drawable.bird8};

private float vertices[] = { -0.5f, -0.5f, 0.0f,

// V1 - first vertex

// (x,y,z) -0.5f, 0.5f, 0.0f, // V2 0.5f, 0.5f, 0.0f, // V3 0.5f, -0.5f, 0.0f, // V4 -0.5f, -0.5f, 0.0f // V5

private float textCoord_Triagle[]={ 1.0f, 1.0f, 0.0f,

V3 0.0f, 1.0f, 0.0f,

V2 0.5f, 0.0f, 0.0f,

// V1 - first vertex (x,y,z) };

int[] textures_indek = new int[1];

private float[] vertices_quad = { // Vertices for the square -1.0f, -1.0f, 0.0f, // 0. left-bottom 1.0f, -1.0f, 0.0f, // 1. right- bottom -1.0f, 1.0f, 0.0f, // 2. left-top 1.0f, 1.0f, 0.0f // 3. right-top

private float vertices_color[] = { 1.0f, 0.0f, 0.0f, 1.0f, // CV1 - first

// color

// (red,green,blue) 0.0f, 1.0f, 0.0f, 1.0f, // CV2 0.0f, 0.0f, 1.0f, 1.0f, // CV3 0.0f, 1.0f, 0.0f, 1.0f, // CV4 1.0f, 0.0f, 0.0f, 1.0f // CV5

//private float vertices_horizontal[] = { 0.0f, 0.0f, 0.0f };

private float vertices_horiverti[] = { 0.0f, 0.0f, 0.0f }; private float vertices_labirin_player[] = { 0.0f, 0.0f, 0.0f }; private float vertices_circle[] = { 0.0f, 0.0f, 0.0f }; private float vertices_circle_color[] = { 0.0f, 0.0f, 0.0f, 0.5f };

private float vertices_line[] = { 0.0f, 0.0f, 0.0f };

private float vertices_line_color[] = { 0.0f, 0.0f, 0.0f, 1.0f }; private float private float vertices_line_color[] = { 0.0f, 0.0f, 0.0f, 1.0f }; private float

private float vertices_fractal_julia[]={0.0f, 0.0f, 0.0f}; private float vertices_color_fractal_julia[]={0.0f, 0.0f, 0.0f, 0.0f};

private float vertices_fractal_julia_m[]={0.0f, 0.0f, 0.0f}; private float vertices_color_fractal_julia_m[]={0.0f, 0.0f, 0.0f, 0.0f};

private int batas_sudut = 360; float jari_jari; float a, b; float x, y; float step = 3.0f, step_line = 0.2f; float x1, y1; float x2, y2; private int loop, loop_color, loop_line,

loop_line_color;

float WidthObject=0.08f; int numberRow=10,numberCol=10; int positionRow; int positionCol; int positionRow_end; int positionCol_end; int Navigate; int draw=1; float x_player=0; // posisi start float y_player=0; float x_player_end=0; // posisi end float y_player_end=0;

// menyimpan inisialisasi array untuk labirin int hori[][] = new

int[2*numberRow*numberCol][2*numberRow*numberCol]; int verti[][] = new int[2*numberRow*numberCol][2*numberRow*numberCol]; private int maze[][] = new int[2*numberRow*numberCol][2*numberRow*numberCol];

public PrimitivesObject() {

//this.mycomplex = new MyComplex(WidthObject, WidthObject);

// ============ start to generate vertices to circle

// ========================== // Inisialisasi // ========================== // Inisialisasi

// Titik Pusat

a = 0.0f;

b = 0.0f; x = a + jari_jari; y = b;

loop = 3; loop_color = 4; vertices_circle = new float[(int) (3 *

batas_sudut / step) * 3]; vertices_circle_color = new float[(int) (3 * batas_sudut / step) * 4]; for (float teta = 0; teta <= 2 * batas_sudut; teta += step) { vertices_circle[loop] = (float) ((x - a) * Math.cos((teta / 180) * (22 / 7)) - ((y - b) * Math.sin((teta / 180) * (22 / 7))) + a); vertices_circle[loop + 1] = (float) ((x - a) * Math.sin((teta / 180) * (22 / 7)) - ((y - b) * Math.cos((teta / 180) * (22 / 7))) + b); vertices_circle[loop + 2] = 0; loop += 3;

// mengenerate warna untuk setiap vertex vertices_circle_color[loop_color] = (float) ((x - a) * Math.cos((teta / 180) * (22 / 7)) - ((y - b) * Math.sin((teta / 180) * (22 / 7))) + a); vertices_circle_color[loop_color + 1] = (float) ((x - a) * Math.sin((teta / 180) * (22 / 7)) - ((y - b) * Math.cos((teta / 180) * (22 / 7))) + b); vertices_circle_color[loop_color + 2] = 0.5f; vertices_circle_color[loop_color + 3] = 0.5f;

loop_color += 4;

} // ============= end for generate

vertices to circle // ====================

// ============ start to generate vertices to line

// ========================== x1 = -1.0f; // ========================== x1 = -1.0f;

loop_line = 3; loop_line_color = 4; vertices_line = new float[(int) (2 * (x2

- x1) / step_line) * 3]; vertices_line_color = new float[(int) (2 * (x2 - x1) / step_line) * 4];

float m = (y2 - y1) / (x2 - x1); for (x = x1; x <= x2; x += step_line) {

vertices_line[loop_line] = (float) (x); vertices_line[loop_line + 1] = (float) (m * (x - x1) + y1); vertices_line[loop_line + 2] = 0; loop_line += 3;

// mengenerate warna untuk setiap vertex

vertices_line_color[loop_line_color] = (float) (0.5 * x);

vertices_line_color[loop_line_color + 1] = (float) (0.5 * m * (x - x1) + y1);

vertices_line_color[loop_line_color + 2] = 1.0f;

vertices_line_color[loop_line_color + 3] = 1.0f; loop_line_color += 4; } // ============= end for generate

vertices to line ====================

int i, j; vertices_horiverti = new

float[2*numberRow*numberCol*6];

vertices_labirin_player = new

float[2*3*3]; // start generate jaring-jaring labirin

////////////////////////////////////////// generateMaze();

//Log.v("ii Test get numberRow : ", "" + numberRow); //Log.v("ii Test get numberCol : ", "" + numberCol);

//line horizontal int loop_vertices_horiverti=0; float y = (WidthObject * numberRow); for(i = 0; i < numberRow+1; i++)

{ for(j = 0; j < numberCol; j++){ if (hori[i][j] == 1) {

// menampung vertex yang terbentuk

vertices_horiverti[loop_vertices_horiverti]=j*WidthOb ject;

vertices_horiverti[loop_vertices_horiverti+1]=y;

vertices_horiverti[loop_vertices_horiverti+2]=0;

vertices_horiverti[loop_vertices_horiverti+3]=j*Width Object + WidthObject;

vertices_horiverti[loop_vertices_horiverti+4]=y;

vertices_horiverti[loop_vertices_horiverti+5]=0;

loop_vertices_horiverti+=6;

} y -= WidthObject;

//line vertical float x = 0; for(j = 0; j < numberCol+1; j++) {

for(i = 0; i < numberRow; i++){ if (verti[i][j] == 1){ // menampung vertex yang terbentuk

vertices_horiverti[loop_vertices_horiverti]=x;

vertices_horiverti[loop_vertices_horiverti+1]=(number Row-i)*WidthObject;

vertices_horiverti[loop_vertices_horiverti+2]=0;

vertices_horiverti[loop_vertices_horiverti+3]=x;

vertices_horiverti[loop_vertices_horiverti+4]=(number Row-i)*WidthObject-WidthObject;

vertices_horiverti[loop_vertices_horiverti+5]=0;

loop_vertices_horiverti+=6; } } x += WidthObject;

//triagle //triagle

vertices_labirin_player[3]=(positionCol * WidthObject) + (WidthObject/4); vertices_labirin_player[4]=(numberRow - positionRow - 1)*WidthObject + (WidthObject / 4); vertices_labirin_player[5]=0;

vertices_labirin_player[6]=(positionCol * WidthObject) + (WidthObject*3/4); vertices_labirin_player[7]=(numberRow - positionRow - 1)*WidthObject + (WidthObject / 4); vertices_labirin_player[8]=0;

x = (positionCol * WidthObject) + (WidthObject/2); y = (numberRow - positionRow - 1)*WidthObject + (WidthObject / 2); this.x_player=x; this.y_player=y;

this.x_player_end=(positionCol_end * WidthObject) - (WidthObject/2);; this.y_player_end=(numberRow- positionRow_end - 1)*WidthObject + (WidthObject / 2);;

Log.v("Test get x_player : ", "" + x); Log.v("Test get y_player : ", "" + y);

Log.v("Test get x_player_end : ", "" + x_player_end); Log.v("Test get y_player_end : ", "" + y_player_end);

// ============ start to generate vertices to fractal mandelbrot /* int k; float x0,y0,xn,yn,xn1,yn1,c1,c2,thrd;

x0=-2f; y0=-2f; c1=-2f; c2=-2f;

// start counter length array int up_bound_1=479; int up_bound_2=639; int up_bound_3=1024; up_bound_1=479; up_bound_2=639; up_bound_3=1024; int length_fractal_mandelbrot=0; int step_=9; for(i=0;i<up_bound_1;i+= step_){ // start counter length array int up_bound_1=479; int up_bound_2=639; int up_bound_3=1024; up_bound_1=479; up_bound_2=639; up_bound_3=1024; int length_fractal_mandelbrot=0; int step_=9; for(i=0;i<up_bound_1;i+= step_){

yn = y0 + ( i * 0.00833f ); // moving from pixel to pixel vertically..

c1=-2+(j*0.00625f); // incrementing the value of C1 c2=-2+(i*0.00833f); // incrementing the value of C2

for(k=0;k<up_bound_3;k+=step_){

xn1=(xn*xn)-(yn*yn)+c1; // finding the value of next X

yn1=(2*xn*yn)+c2; // finding the value of next Y

thrd=(xn1*xn1)+(yn1*yn1); // Checking the absolute value of X+Y if( thrd >= 64.0f ){

//if( thrd >= 32.0f && thrd <= 150.0f ){

length_fractal_mandelbrot += 1;

k=up_bound_3; } xn=xn1; yn=yn1;

length_fractal_mandelbrot += 1;

} // end counter length array Log.v("Test get

length_fractal_mandelbrot : ", "" + length_fractal_mandelbrot);

Log.v("Test get

length_fractal_mandelbrot*3 : ", "" + length_fractal_mandelbrot*3);

Log.v("Test get

length_fractal_mandelbrot*4 : ", "" + length_fractal_mandelbrot*4);

x0=-2f; y0=-2f; c1=-2f; c2=-2f; int loop_fractal_mandelbrot=0; int

loop_color_fractal_mandelbrot=0; vertices_fractal_mandelbrot=new loop_color_fractal_mandelbrot=0; vertices_fractal_mandelbrot=new

vertices_color_fractal_mandelbrot=new float[(length_fractal_mandelbrot) * 4];

for(i=0;i<up_bound_1;i+=step_){

for(j=0;j<up_bound_2;j+=step_){ xn = x0 + ( j * 0.00625f ); // moving from pixel to pixel horizontally..

yn = y0 + ( i * 0.00833f ); // moving from pixel to pixel vertically..

c1=- 2.0f+(j*0.00625f); // incrementing the value of C1 c2=- 2.0f+(i*0.00833f); // incrementing the value of C2

for(k=0;k<up_bound_3;k+=step_){

xn1=(xn*xn)-(yn*yn)+c1; // finding the value of next X

yn1=(2.0f*xn*yn)+c2; // finding the value of next Y

thrd=(xn1*xn1)+(yn1*yn1); // Checking the absolute value of X+Y if( thrd >= 64.0f ){

//if( thrd >= 32.0f && thrd <= 150.0f ){

//glColor3f(1.0, 0.0, 0.0);

//glVertex2f(xn,yn);

vertices_fractal_mandelbrot[loop_fractal_mandelbr ot] = xn;

vertices_fractal_mandelbrot[loop_fractal_mandelbr ot + 1] = yn;

vertices_fractal_mandelbrot[loop_fractal_mandelbr ot + 2] = 0;

loop_fractal_mandelbrot += 3;

// mengenerate warna untuk setiap vertex

vertices_color_fractal_mandelbrot[loop_color_frac tal_mandelbrot] = 1.0f*yn; vertices_color_fractal_mandelbrot[loop_color_frac tal_mandelbrot] = 1.0f*yn;

vertices_color_fractal_mandelbrot[loop_color_frac tal_mandelbrot + 2] = 0.5f;

vertices_color_fractal_mandelbrot[loop_color_frac tal_mandelbrot + 3] = 1.0f;

loop_color_fractal_mandelbrot += 4;

k=up_bound_3; }

xn=xn1; yn=yn1;

//glColor3f(0,1,0);

//glVertex2f(xn,yn);

vertices_fractal_mandelbrot[loop_fractal_mandelbr ot] = xn;

vertices_fractal_mandelbrot[loop_fractal_mandelbr ot + 1] = yn;

vertices_fractal_mandelbrot[loop_fractal_mandelbr ot + 2] = 0;

loop_fractal_mandelbrot += 3;

// mengenerate warna untuk setiap vertex

vertices_color_fractal_mandelbrot[loop_color_frac tal_mandelbrot] = 0.5f*xn;

vertices_color_fractal_mandelbrot[loop_color_frac tal_mandelbrot + 1] = 1.0f;

vertices_color_fractal_mandelbrot[loop_color_frac tal_mandelbrot + 2] = 0.5f*yn;

vertices_color_fractal_mandelbrot[loop_color_frac tal_mandelbrot + 3] = 1.0f;

loop_color_fractal_mandelbrot += 4;

// ============ end to generate vertices to fractal mandelbrot

//start fractal set julia /*int length_fractal_julia=10000; vertices_fractal_julia=new

float[(int) (3*length_fractal_julia) * 3]; vertices_color_fractal_julia=new float[(int) (3*length_fractal_julia) * 4];

int min_rand = 0; int max_rand = 10; float my_random;

int idx_vertex = 0; int idx_vertex_color = 0; float k_julia=0.01f;

float z0=1; float z_next; z_next=z0;

//Inisialisasi bilangan komplek untuk k //mycomplex_k = new MyComplex(0.3, 0.6); MyComplex k_complex = new MyComplex(0.3, 0.6); //MyComplex k_complex = new MyComplex(0.01, 1.2); //MyComplex k_complex = new MyComplex(0.109, 0.603); MyComplex z0_complex = new MyComplex(1, 0); MyComplex znext_complex = new MyComplex(z0_complex.re(), z0_complex.im()); float abs_znext_complex ; float akar_abs_znext_complex; float teta; float delta=0.01f; //for (int

k=1;k<=length_fractal_julia;k++){ //k_complex = new MyComplex(1/k, 2/k);

for(i=0;i<length_fractal_julia;i++){

z0_complex = znext_complex; //znext_complex = (z0_complex.times(z0_complex)).plus(k_complex);

Random init_random = new Random(); my_random = (float)(init_random.nextInt(max_rand - min_rand + 1) + min_rand)/max_rand; Random init_random = new Random(); my_random = (float)(init_random.nextInt(max_rand - min_rand + 1) + min_rand)/max_rand;

znext_complex=z0_complex.minus(k_complex);

znext_complex = new MyComplex(znext_complex.pow(0.5,2).re(),znext_complex .pow(0.5,2).im());

}else{

znext_complex=z0_complex.minus(k_complex);

znext_complex = new MyComplex(- znext_complex.pow(0.5,2).re(),- znext_complex.pow(0.5,2).im());

//Log.v("float znext_complex.im() : ", ""+(float) znext_complex.im());

//Log.v("float znext_complex.re() : ", ""+(float) znext_complex.re());

//Log.v("atan yx : ", ""+Math.atan(1/1)); //Log.v("atan2 yx : ", ""+Math.atan2(1,2));

//if(Math.pow(abs_znext_complex,2)<=4){

//delta=(float) Math.abs(znext_complex.re()-znext_complex.im());

vertices_fractal_julia[idx_vertex++] = (float) znext_complex.re();

vertices_fractal_julia[idx_vertex++] = (float) znext_complex.im();

vertices_fractal_julia[idx_vertex++] = 0;

vertices_color_fractal_julia[idx_vertex_color++] = (float) Math.abs(znext_complex.re());

vertices_color_fractal_julia[idx_vertex_color++] = (float) Math.abs(znext_complex.im());

vertices_color_fractal_julia[idx_vertex_color++] = 1.f;

vertices_color_fractal_julia[idx_vertex_color++] = 0.5f; vertices_color_fractal_julia[idx_vertex_color++] = 0.5f;

vertices_fractal_julia[idx_vertex++] = (float) znext_complex.im()+delta;

vertices_fractal_julia[idx_vertex++] = 0;

vertices_color_fractal_julia[idx_vertex_color++] = (float) Math.abs(znext_complex.re());

vertices_color_fractal_julia[idx_vertex_color++] = (float) Math.abs(znext_complex.im());

vertices_color_fractal_julia[idx_vertex_color++] = 1.f;

vertices_color_fractal_julia[idx_vertex_color++] = 0.5f;

vertices_fractal_julia[idx_vertex++] = (float) znext_complex.re()+delta;

vertices_fractal_julia[idx_vertex++] = (float) znext_complex.im()+delta;

vertices_fractal_julia[idx_vertex++] = 0;

vertices_color_fractal_julia[idx_vertex_color++] = (float) Math.abs(znext_complex.re());

vertices_color_fractal_julia[idx_vertex_color++] = (float) Math.abs(znext_complex.im());

vertices_color_fractal_julia[idx_vertex_color++] = 1.f;

vertices_color_fractal_julia[idx_vertex_color++] = 0.5f;

//segitiga dua

/*vertices_fractal_julia[idx_vertex++] = (float) znext_complex.re();

vertices_fractal_julia[idx_vertex++] = (float) znext_complex.im();

vertices_fractal_julia[idx_vertex++] = 0;

vertices_color_fractal_julia[idx_vertex_color++] = (float) Math.abs(znext_complex.re()); vertices_color_fractal_julia[idx_vertex_color++] = (float) Math.abs(znext_complex.re());

vertices_color_fractal_julia[idx_vertex_color++] = 1.f;

vertices_color_fractal_julia[idx_vertex_color++] = 0.5f;

vertices_fractal_julia[idx_vertex++] = (float) znext_complex.re()+delta;

vertices_fractal_julia[idx_vertex++] = (float) znext_complex.im();

vertices_fractal_julia[idx_vertex++] = 0;

vertices_color_fractal_julia[idx_vertex_color++] = (float) Math.abs(znext_complex.re());

vertices_color_fractal_julia[idx_vertex_color++] = (float) Math.abs(znext_complex.im());

vertices_color_fractal_julia[idx_vertex_color++] = 1.f;

vertices_color_fractal_julia[idx_vertex_color++] = 0.5f;

vertices_fractal_julia[idx_vertex++] = (float) znext_complex.re()+delta;

vertices_fractal_julia[idx_vertex++] = (float) znext_complex.im()+delta;

vertices_fractal_julia[idx_vertex++] = 0;

vertices_color_fractal_julia[idx_vertex_color++] = (float) Math.abs(znext_complex.re());

vertices_color_fractal_julia[idx_vertex_color++] = (float) Math.abs(znext_complex.im());

vertices_color_fractal_julia[idx_vertex_color++] = 1.f;

vertices_color_fractal_julia[idx_vertex_color++] = 0.5f; */

//vertices_color_fractal_julia[idx_vertex_color++ ] = 1/z0;

//vertices_color_fractal_julia[idx_vertex_color++ ] = 1/z_next;

//vertices_color_fractal_julia[idx_vertex_color++ ] = 1/(z0-z_next);

//vertices_color_fractal_julia[idx_vertex_color++ ] = 1.f;

//end fractal set julia

// start merget fractal julia & mandelbrot //int length_fractal_julia_m=width*height; //vertices_fractal_julia_m=new float[(int) (6*length_fractal_julia_m) * 3];

//vertices_color_fractal_julia_m=new float[(int) (6*length_fractal_julia_m) * 4]; /* float left = -2.0f, right = 2.0f, bottom = -2.0f;//, top = 1.5f; // loop over the pixels on the screen float delta = (right - left)/width; for( float j_l=0; j_l < 100; j_l+=1f )

for( float i_l=0; i_l < 100; i_l+=1f ) { // convert pixel location to world coordinates float xf = left + i_l*delta; float yf = bottom + j_l*delta;

//float xf = i; //float yf = j;

// test for convergence //int its = 0; //float R = 0; MyComplex b_ = new

MyComplex(xf,yf); MyComplex c = new MyComplex(0.109, 0.603); MyComplex(xf,yf); MyComplex c = new MyComplex(0.109, 0.603);

else{ mandelbrot(b_);}

// turn iterations and radius to color

if( its_loop ==256 ){

vertices_color_fractal_julia_m[idx_vertex_color++ ]=0;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=0;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=0;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=1;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=0;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=0;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=0;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=1;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=0;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=0;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=0;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=1;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=0;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=0;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=0; vertices_color_fractal_julia_m[idx_vertex_color++ ]=0;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=0;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=0;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=0;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=1;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=0;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=0;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=0;

vertices_color_fractal_julia_m[idx_vertex_color++ ]=1;

}else {

float r = r_julia_m/(3.f); float g = its_loop/(128.f); float b = r_julia_m/(its_loop+1.f);

//glColor3d(r,g,b);

vertices_color_fractal_julia_m[idx_vertex_color++]=r;

vertices_color_fractal_julia_m[idx_vertex_color++]=g;

vertices_color_fractal_julia_m[idx_vertex_color++]=b;

vertices_color_fractal_julia_m[idx_vertex_color++]=0. 5f;

vertices_color_fractal_julia_m[idx_vertex_color++]=r;

vertices_color_fractal_julia_m[idx_vertex_color++]=g;

vertices_color_fractal_julia_m[idx_vertex_color++]=b; vertices_color_fractal_julia_m[idx_vertex_color++]=b;

vertices_color_fractal_julia_m[idx_vertex_color++]=r;

vertices_color_fractal_julia_m[idx_vertex_color++]=g;

vertices_color_fractal_julia_m[idx_vertex_color++]=b;

vertices_color_fractal_julia_m[idx_vertex_color++]=0. 5f;

vertices_color_fractal_julia_m[idx_vertex_color++]=r;

vertices_color_fractal_julia_m[idx_vertex_color++]=g;

vertices_color_fractal_julia_m[idx_vertex_color++]=b;

vertices_color_fractal_julia_m[idx_vertex_color++]=0. 5f;

vertices_color_fractal_julia_m[idx_vertex_color++]=r;

vertices_color_fractal_julia_m[idx_vertex_color++]=g;

vertices_color_fractal_julia_m[idx_vertex_color++]=b;

vertices_color_fractal_julia_m[idx_vertex_color++]=0. 5f;

vertices_color_fractal_julia_m[idx_vertex_color++]=r;

vertices_color_fractal_julia_m[idx_vertex_color++]=g;

vertices_color_fractal_julia_m[idx_vertex_color++]=b;

vertices_color_fractal_julia_m[idx_vertex_color++]=0. 5f;

} //delta = 0.0001f;

vertices_fractal_julia_m[idx_vertex++]=xf;

vertices_fractal_julia_m[idx_vertex++]=yf;

vertices_fractal_julia_m[idx_vertex++]=0;

vertices_fractal_julia_m[idx_vertex++]=xf;

vertices_fractal_julia_m[idx_vertex++]=yf+delta;

vertices_fractal_julia_m[idx_vertex++]=0; vertices_fractal_julia_m[idx_vertex++]=0;

vertices_fractal_julia_m[idx_vertex++]=yf+delta;

vertices_fractal_julia_m[idx_vertex++]=0;

vertices_fractal_julia_m[idx_vertex++]=xf;

vertices_fractal_julia_m[idx_vertex++]=yf;

vertices_fractal_julia_m[idx_vertex++]=0;

vertices_fractal_julia_m[idx_vertex++]=xf+delta;

vertices_fractal_julia_m[idx_vertex++]=yf+delta;

vertices_fractal_julia_m[idx_vertex++]=0;

vertices_fractal_julia_m[idx_vertex++]=xf+delta;

vertices_fractal_julia_m[idx_vertex++]=yf;

vertices_fractal_julia_m[idx_vertex++]=0; //}

// draw polygon

//glBegin(GL_POLYGON); //glVertex2d(x, y); //glVertex2d(x, y+delta);

//glVertex2d(x+delta, y+delta);

//glVertex2d(x+delta, y); //glEnd();

} // glFlush(); } */

// end merger fractal julia & mandelbrot

//--- start merger julia & Mandelbrot fractal --- --------------

/*public void julia( MyComplex p, MyComplex c) { /*public void julia( MyComplex p, MyComplex c) {

its_loop++ ) { //p = p.times(p).plus(c); //Log.v("its_loop julia : ", ""+its_loop); p = new MyComplex(p.times(p).plus(c).re(),p.times(p).plus(c). im());

rSqr = (float) (p.re()*p.re() + p.im()*p.im()); //Log.v("rSqr julia : ", ""+rSqr); if( rSqr > 4 ){

break; } } r_julia_m = (float) Math.sqrt(rSqr);

public void mandelbrot( MyComplex b_) {

float rSqr = 0; int maxIterations = 256; MyComplex p = new MyComplex(0,0); for(its_loop=0; its_loop < maxIterations;

its_loop++ ) { //p = p.times(p).plus(c); //Log.v("its_loop mandelbrot : ", ""+its_loop); p = new MyComplex(p.times(p).plus(b_).re(),p.times(p).plus(b_ ).im());

rSqr = (float) (p.re()*p.re() + p.im()*p.im()); //Log.v("rSqr mandelbrot : ", ""+rSqr); if( rSqr > 4 ){

break; } } r_julia_m = (float) Math.sqrt(rSqr);

// ------------- end Julia & Mandelbrol Fractal - -------------------

// membuat inisialisasi jaring-jaring (generate Maze) public void generateMaze() {

//inisialisasi maze int i,j; Log.v("Test get numberRow : ", "" +

numberRow);

Log.v("Test get numberCol : ", "" + numberCol); for (i = 0; i < numberRow; i++){ Log.v("Test get numberCol : ", "" + numberCol); for (i = 0; i < numberRow; i++){

maze[i][j] = 0; verti[i][j] = 1; hori[i][j] = 1;

} } for (i = 0; i < numberRow; i++){

verti[i][numberCol] = 1;} for (j = 0; j < numberCol; j++){ hori[numberRow][j] = 1;}

//random cell

i = (int) (Math.random()*10%numberRow); j = (int) (Math.random()*10%numberCol); track(i,j);

//create in & out door

i = (int) (Math.random()*10%numberRow); j = (int) (Math.random()*10%numberRow);

verti[i][0] = 0; verti[j][numberCol] = 0;

// first position triangle positionRow = i; positionCol = 0; positionRow_end = j; positionCol_end = numberCol; Navigate = 0;

//rekursif public void track(int RowTrack, int ColTrack) {

int i,j; while (CheckNeighbor(RowTrack,ColTrack)) {

do { //random cell to check neighbor

that not yet visit

i = RowTrack; j = ColTrack; //int k = rand()%4; int k = (int)

(Math.random()*10%4); if (k==0) j = ColTrack-1; else if (k==1) i = RowTrack-1; else if (k==2) j = ColTrack+1; else i = RowTrack+1;

}while(i<0 || i>=numberRow || j<0 || j>=numberCol || maze[i][j]==1);

maze[i][j] = 1; //mark cell that has been visit RemoveLine(RowTrack,ColTrack,i,j); track(i,j);

public boolean CheckNeighbor(int i, int j)

{ if ((i-1 >=0) && (maze[i-1][j]==0)) return true; if ((i+1 <numberRow) && (maze[i+1][j]==0)) return true; if ((j-1 >=0) && (maze[i][j-1]==0)) return true; if ((j+1 <numberCol) && (maze[i][j+1]==0)) return true; return false; }

//remove line between 2 cell public void RemoveLine(int a1,int b1, int a2, int

b2) { if(a1==a2) {

//this.x_player_end=a1-(WidthObject/2);

if(b1 > b2) { verti[a1][b1] = 0; //this.y_player_end=b2-

(WidthObject/2); } else {

verti[a1][b2] = 0; //this.y_player_end=b1-

(WidthObject/2); } } else if(b1==b2) {

if(a1 > a2) hori[a1][b1] = 0; else hori[a2][b1] = 0;

// Point to our vertex buffer, return buffer holding the vertices public static FloatBuffer makeFloatBuffer(float[] arr) { ByteBuffer bb = ByteBuffer.allocateDirect(arr.length * 4); bb.order(ByteOrder.nativeOrder()); FloatBuffer fb = bb.asFloatBuffer(); fb.put(arr); fb.position(0); return fb;

/** The draw method for the primitive object with the GL context */ public void draw_background(GL10 gl) {

//menempelkan tekstur ke objek gl.glEnable(GL10.GL_TEXTURE_2D);

// bind the previously generated texture gl.glBindTexture(GL10.GL_TEXTURE_2D, // bind the previously generated texture gl.glBindTexture(GL10.GL_TEXTURE_2D,

// Point to our buffers

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRA Y);

gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

// Set the face rotation gl.glFrontFace(GL10.GL_CW);

// Point to our vertex buffer gl.glVertexPointer(3, GL10.GL_FLOAT, 0,

makeFloatBuffer(verticesbackground)); gl.glTexCoordPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(texturebackground));

// Draw the vertices as triangle strip gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,

0, verticesbackground.length / 3); //Log.v("verticesbackground.length : ", ""+verticesbackground.length); //Log.v("verticesbackground.length / 3 : ", ""+verticesbackground.length / 3); //gl.glDrawArrays(GL10.GL_TRIANGLE_FAN,

0, verticesbackground.length / 3);

//Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARR AY); gl.glDisable( GL10.GL_TEXTURE_2D ); // Disable Texture Mapping } public void draw_points(GL10 gl) {

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

// gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour for the points (pemberian warna untuk titik) gl.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);

// Point to our vertex buffer (mendata nilai lokasi/posisi titik) gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(new float[] { 1.0f, 1.0f, 0.0f, // V1 - first vertex (x,y,z) 1.0f, 0.8f, 0.0f, // V2 1.0f, 0.6f, 0.0f, // V3 1.0f, 0.4f, 0.0f, // V4

1.0f, 0.2f, 0.0f, // V5 1.0f, 0.0f, 0.0f, // V6 1.0f, -0.2f, 0.0f, // V7 1.0f, -0.4f, 0.0f, // V8 1.0f, -0.6f, 0.0f, // V9 1.0f, -0.8f, 0.0f, // V10 1.0f, -1.0f, 0.0f, // V11

0.8f, -1.0f, 0.0f, // V12 0.6f, -1.0f, 0.0f, // V13 0.4f, -1.0f, 0.0f, // V14 0.2f, -1.0f, 0.0f, // V15 0.0f, -1.0f, 0.0f, // V16 -0.2f, -1.0f, 0.0f, // V17 -0.4f, -1.0f, 0.0f, // V18 -0.6f, -1.0f, 0.0f, // V19 -0.7f, -1.0f, 0.0f, // V20 -0.8f, -1.0f, 0.0f, // V21 -1.0f, -1.0f, 0.0f, // V22

// Draw the vertices as points

(menggambar titik-titik) gl.glDrawArrays(GL10.GL_POINTS, 0, 22);

// Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

// gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

public void draw_fractal_julia_m(GL10 gl) {

//gl.glFrontFace(GL10.GL_CW); // Front face in counter-clockwise

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour for the points (pemberian warna untuk titik) //gl.glColor4f(0.0f, 0.0f, 1.0f, 0.5f);

// Point to our vertex buffer (mendata nilai lokasi/posisi titik) gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_fractal_julia_m));

gl.glColorPointer(4, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_color_fractal_julia_m));

// Draw the vertices as points

(menggambar titik-titik) gl.glDrawArrays(GL10.GL_POINTS, 0, (int) ((idx_vertex-1)/3)); //gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,

0, (int) ((idx_vertex-1)/3)); //gl.glDrawArrays(GL10.GL_POINTS, 0, 3); //gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,

0, (int) (vertices_fractal_julia_m.length)/3); //gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 2,3); //gl.glDrawArrays(GL10.GL_LINES, 0, (int) (vertices_fractal_julia.length)/3);

//gl.glDrawArrays(GLES20.GL_POLYGON_OFFSET_FILL,

0, (int) (vertices_fractal_julia.length)/3);

// Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

public void draw_fractal_julia(GL10 gl) {

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour for the points (pemberian warna untuk titik) //gl.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);

// Point to our vertex buffer (mendata nilai lokasi/posisi titik) gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_fractal_julia));

gl.glColorPointer(4, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_color_fractal_julia));

// Draw the vertices as points

(menggambar titik-titik) gl.glDrawArrays(GL10.GL_POINTS, 0, (int) (vertices_fractal_julia.length)/3); //gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,

0, (int) (vertices_fractal_julia.length)/3); //gl.glDrawArrays(GL10.GL_LINES, 0, (int) (vertices_fractal_julia.length)/3);

//gl.glDrawArrays(GLES20.GL_POLYGON_OFFSET_FILL,

0, (int) (vertices_fractal_julia.length)/3);

// Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

public void draw_fractal_mandelbrot(GL10 gl) {

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour for the points (pemberian warna untuk titik) //gl.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);

// Point to our vertex buffer (mendata nilai lokasi/posisi titik) gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_fractal_mandelbrot));

gl.glColorPointer(4, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_color_fractal_mandelbrot));

// Draw the vertices as points

(menggambar titik-titik) gl.glDrawArrays(GL10.GL_POINTS, 0, (int) (vertices_fractal_mandelbrot.length)/3);

// Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

public void draw_line_maze_horiverti(GL10 gl) {

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

//gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour for the line (pemberian warna untuk garis) gl.glColor4f(0.5f, 0.1f, 0.3f, 1.0f); //gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); gl.glVertexPointer(3, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices_horiverti)); gl.glDrawArrays(GL10.GL_LINES,0, (int) (vertices_horiverti.length/3));

// Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

//gl.glDisableClientState(GL10.GL_COLOR_ARRAY); //gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

vertices_labirin_player[0]=(positionCol_in * WidthObject) + (WidthObject/2);

vertices_labirin_player[1]=(numberRow - positionRow_in - 1)*WidthObject + (WidthObject * 3 / 4);

vertices_labirin_player[2]=0;

vertices_labirin_player[3]=(positionCol_in * WidthObject) + (WidthObject/4); vertices_labirin_player[4]=(numberRow - positionRow_in - 1)*WidthObject + (WidthObject / 4); vertices_labirin_player[5]=0;

vertices_labirin_player[6]=(positionCol_in * WidthObject) + (WidthObject*3/4); vertices_labirin_player[7]=(numberRow - positionRow_in - 1)*WidthObject + (WidthObject / 4); vertices_labirin_player[8]=0;

//x = (positionCol * WidthObject) + (WidthObject/2); //y = (numberRow - positionRow - 1)*WidthObject + (WidthObject / 2);

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour for the triangle //gl.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);

gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_labirin_player));

// Draw the vertices as triangle gl.glColorPointer(4, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices_color)); gl.glDrawArrays(GLES20.GL_TRIANGLES, 0, 3);

// Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

public void draw_segitiga_labirin_player(GL10 gl

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour for the triangle //gl.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);

gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_labirin_player));

// Draw the vertices as triangle gl.glColorPointer(4, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices_color)); gl.glDrawArrays(GLES20.GL_TRIANGLES, 0, 3);

// Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

public void draw_segitiga_texture(GL10 gl, int positionCol_in, int positionRow_in) { gl.glFrontFace(GL10.GL_CCW); // Front face in counter-clockwise

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

//gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

vertices_labirin_player[0]=(positionCol_in * WidthObject) + (WidthObject/2); vertices_labirin_player[1]=(numberRow - positionRow_in - 1)*WidthObject + (WidthObject * 3 / 4);

vertices_labirin_player[2]=0;

vertices_labirin_player[3]=(positionCol_in * WidthObject) + (WidthObject/4); vertices_labirin_player[4]=(numberRow - positionRow_in - 1)*WidthObject + (WidthObject / 4); vertices_labirin_player[5]=0;

vertices_labirin_player[6]=(positionCol_in * WidthObject) + (WidthObject*3/4); vertices_labirin_player[7]=(numberRow - positionRow_in - 1)*WidthObject + (WidthObject / 4); vertices_labirin_player[8]=0;

// set the colour for the triangle (menghilangkan effect dari warna objek sebelumnya) gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

/*gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(new float [] { 1.0f, 1.0f, 0.0f, // V3 0.0f, 1.0f, 0.0f, // V2 0.5f, 0.0f, 0.0f,

// V1 - first vertex (x,y,z) }));*/

gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_labirin_player));

// Draw the vertices as triangle //gl.glColorPointer(4, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices_color));

//menempelkan tekstur ke objek gl.glEnable(GL10.GL_TEXTURE_2D);

gl.glEnable(GL10.GL_BLEND); gl.glBlendFunc(GL10.GL_SRC_ALPHA,

GL10.GL_ONE_MINUS_SRC_ALPHA);

gl.glBindTexture(GL10.GL_TEXTURE_2D, textures_indek[0]); // gl.glTexCoordPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(textCoord_Triagle)); //

gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRA Y);

gl.glDrawArrays(GLES20.GL_TRIANGLE_STRIP,

//Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

//gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

gl.glDisable( GL10.GL_BLEND );

// Disable Alpha Blend

gl.glDisable( GL10.GL_TEXTURE_2D ); // Disable Texture Mapping

public void draw_line(GL10 gl) {

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

// gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour for the line (pemberian warna untuk garis) gl.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);

// Point to our vertex buffer (mendata nilai lokasi/posisi titik yang // menyusun garis) gl.glVertexPointer(3, GL10.GL_FLOAT, 0,

makeFloatBuffer(new float[] { 1.0f, 1.0f, 0.0f, // V1 - first vertex (x,y,z) -1.0f, -1.0f, 0.0f, // V2 - second vertex }));

// Draw the vertices as lines (menggambar garis dari titik-titik) gl.glDrawArrays(GL10.GL_LINES, 0, 2); /*

* gl.glDrawElements(GL10.GL_LINES, 2, GL10.GL_UNSIGNED_SHORT, * makeFloatBuffer(new float [] { 1.0f, 1.0f, 0.0f, // V1 - first vertex * (x,y,z) -1.0f, -1.0f, 0.0f, // V2 - second vertex })); */

// Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

// gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

public void draw_line_color(GL10 gl) {

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour for the line (pemberian warna untuk garis) gl.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);

// Point to our vertex buffer (mendata nilai lokasi/posisi titik yang // menyusun garis) gl.glVertexPointer(3, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices_line));

// memetakan warna untuk setiap vertex gl.glColorPointer(4, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices_line_color));

// Draw the vertices as lines (menggambar garis dari titik-titik) gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, (int) (2 * (x2 - x1) / step_line));

/* * gl.glDrawElements(GL10.GL_LINES, 2, GL10.GL_UNSIGNED_SHORT, * makeFloatBuffer(new float [] { 1.0f, 1.0f, 0.0f, // V1 - first vertex * (x,y,z) -1.0f, -1.0f, 0.0f, // V2 - second vertex })); */

// Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

public void draw_circle(GL10 gl) {

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

// gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour for the object circle gl.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);

// create VBO from buffer with

glBufferData() gl.glVertexPointer(3, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices_circle));

// draw circle as filled shape // gl.glDrawArrays(GL10.GL_TRIANGLE_FAN,

1, (int) ((int) // 2*batas_sudut/step));

// draw circle contours // gl.glDrawArrays(GL10.GL_LINES, 1,

(int) ((int) 2*batas_sudut/step)); // // membuat garis putus-putus pada tepi lingkaran gl.glDrawArrays(GL10.GL_LINES, 1, (int) ((int) 2 * batas_sudut / step)); // gl.glDrawArrays(GL10.GL_LINE_STRIP, 1, (int) ((int) // 2*batas_sudut/step)); // gl.glDrawArrays(GL10.GL_POINTS, 1,

(int) ((int) 2*batas_sudut/step));

// Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

// gl.glDisableClientState(GL10.GL_COLOR_ARRAY); } // gl.glDisableClientState(GL10.GL_COLOR_ARRAY); }

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour edge for the object circle gl.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);

// create VBO from buffer with

glBufferData() gl.glVertexPointer(3, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices_circle));

// memetakan warna untuk setiap vertex gl.glColorPointer(4, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices_circle_color));

// draw circle as filled shape // gl.glDrawArrays(GL10.GL_TRIANGLE_FAN,

1, (int) ((int) // 2*batas_sudut/step)); gl.glDrawArrays(GL10.GL_LINE_STRIP, 1,

(int) ((int) 2 * batas_sudut / step));

// Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

gl.glDisableClientState(GL10.GL_COLOR_ARRAY); }

public void draw_kotak(GL10 gl) {

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// Point to our vertex buffer gl.glVertexPointer(3, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices));

// Draw the vertices as square gl.glColorPointer(4, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices_color)); gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 3);

gl.glColorPointer(4, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_color)); gl.glDrawArrays(GL10.GL_TRIANGLES, 2, 3);

// Disable the client state before leaving // Disable the client state before leaving

gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

public void draw_segitiga(GL10 gl) {

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour for the triangle gl.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);

gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(new float[] { -0.5f, -0.5f, 0.0f, // V1 - first vertex (x,y,z) 0.5f, -0.5f, 0.0f, // V2 - second vertex 0.0f, 0.5f, 0.0f // V3 - third vertex

// Draw the vertices as triangle gl.glColorPointer(4, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices_color)); gl.glDrawArrays(GLES20.GL_TRIANGLES, 0, 3);

// Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

// Render the shape quad public void draw_quad(GL10 gl) {

// Enable vertex-array and define its buffer

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_quad)); // Draw the primitives from the vertex- array directly

gl.glPolygonOffset(0.0f, 1.0f); gl.glScalef(0.5f, 0.5f, 0.5f); gl.glColor4f(0.5f, 0.5f, 1.0f, 1.0f); //

Set the current color (NEW) gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,

0, vertices_quad.length / 3); //gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 0, vertices_quad.length / 3); //gl.glDrawArrays(GL10.GL_TRIANGLES, 0,

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); }

public void loadBallTexture(GL10 gl, Context context,int index_Texture) { // Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), // resource);

/*Bitmap bitmap = BitmapFactory.decodeStream(context.getResources()

.openRawResource(R.drawable.nature));*/

Bitmap bitmap = BitmapFactory.decodeStream(context.getResources()

.openRawResource(imageFileIDs[index_Texture]));

gl.glGenTextures(1, textures_indek, 0); gl.glBindTexture(GL10.GL_TEXTURE_2D,

textures_indek[0]);

/*gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); */

//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.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST); gl.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);

//gl.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_REPEAT );

//gl.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_REPEAT );

///gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, //GL10.GL_NEAREST); //gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, //GL10.GL_LINEAR);

GLUtils.texImage2D(GLES20.GL_TEXTURE_2D,

0, bitmap, 0);

bitmap.recycle(); }

public void loadBallTexture2(GL10 gl, Context context,int index_Texture) { // Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), // resource);

/*Bitmap bitmap = BitmapFactory.decodeStream(context.getResources()

.openRawResource(R.drawable.nature));*/

Bitmap bitmap = BitmapFactory.decodeStream(context.getResources()

.openRawResource(imageFileIDs2[index_Texture]));

gl.glGenTextures(1, textures_indek, 0); gl.glBindTexture(GL10.GL_TEXTURE_2D,

textures_indek[0]);

/*gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); */

//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.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST); gl.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);

//gl.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_REPEAT );

//gl.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_REPEAT );

///gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, //GL10.GL_NEAREST); //gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, //GL10.GL_LINEAR);

GLUtils.texImage2D(GLES20.GL_TEXTURE_2D,

0, bitmap, 0);

bitmap.recycle(); }

SplashScreen.java

package com.fractalbackground;

import android.app.Activity; import android.content.Intent; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.os.Handler; import android.view.Window; import android.view.WindowManager;

public class SplashScreen extends Activity {

// Splash screen timer private static int SPLASH_TIME_OUT = 1000;

@Override protected void onCreate(Bundle

savedInstanceState) {

super.onCreate(savedInstanceState);

// requesting to turn the title OFF

requestWindowFeature(Window.FEATURE_NO_TITLE); // making it full screen

getWindow().setFlags(WindowManager.LayoutParams.F LAG_FULLSCREEN,

WindowManager.LayoutParams.FLAG_FULLSCREEN);

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATI ON_LANDSCAPE);

setContentView(R.layout.activity_splash);

//@Override // protected void onCreate(final Bundle savedInstance) { // super.onCreate(savedInstance);

//setRequestedOrientation(ActivityInfo.SCREEN_ORIENTA TION_LANDSCAPE);

new Handler().postDelayed(new Runnable() {

/* * Showing splash screen with a timer. This will be useful when you * want to show case your app logo / company */

@Override public void run() {

// This method will be executed once the timer is over // Start your app main activity Intent i = new

Intent(SplashScreen.this, SplashScreen5.class);

i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);

startActivity(i);

// close this activity finish();

} }, SPLASH_TIME_OUT); }

SplashScreen1.java

package com.fractalbackground;

import android.app.Activity; import android.content.Intent; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.os.Handler; import android.view.Window; import android.view.WindowManager;

public class SplashScreen1 extends Activity {

// Splash screen timer // Splash screen timer

@Override protected void onCreate(Bundle

savedInstanceState) { super.onCreate(savedInstanceState);

// requesting to turn the title OFF

requestWindowFeature(Window.FEATURE_NO_TITLE); // making it full screen

getWindow().setFlags(WindowManager.LayoutParams.F LAG_FULLSCREEN,

WindowManager.LayoutParams.FLAG_FULLSCREEN);

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATI ON_LANDSCAPE);

setContentView(R.layout.activity_splash1);

//@Override // protected void onCreate(final Bundle savedInstance) {

// super.onCreate(savedInstance);

//setRequestedOrientation(ActivityInfo.SCREEN_ORIENTA TION_LANDSCAPE);

new Handler().postDelayed(new Runnable() {

/* * Showing splash screen with a timer. This will be useful when you * want to show case your app logo / company */

@Override public void run() {

// This method will be executed once the timer is over // Start your app main activity Intent i = new

Intent(SplashScreen1.this, MainActivity.class);

i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(i);

// close this activity finish();

} }, SPLASH_TIME_OUT); }

SplashScreen2.java

package com.fractalbackground;

import android.app.Activity; import android.content.Intent; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.os.Handler; import android.view.Window; import android.view.WindowManager;

public class SplashScreen2 extends Activity {

// Splash screen timer private static int SPLASH_TIME_OUT = 5;

@Override protected void onCreate(Bundle

savedInstanceState) {

super.onCreate(savedInstanceState);

// requesting to turn the title OFF

requestWindowFeature(Window.FEATURE_NO_TITLE); // making it full screen

getWindow().setFlags(WindowManager.LayoutParams.F LAG_FULLSCREEN,

WindowManager.LayoutParams.FLAG_FULLSCREEN);

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATI ON_LANDSCAPE);

setContentView(R.layout.activity_splash2);

//@Override // protected void onCreate(final Bundle savedInstance) { // super.onCreate(savedInstance);

//setRequestedOrientation(ActivityInfo.SCREEN_ORIENTA TION_LANDSCAPE);

new Handler().postDelayed(new Runnable() {

/* * Showing splash screen with a timer. This will be useful when you * want to show case your app logo / company */

@Override public void run() {

// This method will be executed once the timer is over // Start your app main activity Intent i = new

Intent(SplashScreen2.this, SplashScreen1.class);

i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);

startActivity(i);

// close this activity finish();

} }, SPLASH_TIME_OUT); }

SplashScreen3.java

package com.fractalbackground;

import android.app.Activity; import android.content.Intent; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.os.Handler; import android.view.Window; import android.view.WindowManager;

public class SplashScreen3 extends Activity {

// Splash screen timer private static int SPLASH_TIME_OUT = 5;

@Override protected void onCreate(Bundle

savedInstanceState) {

super.onCreate(savedInstanceState);

// requesting to turn the title OFF

requestWindowFeature(Window.FEATURE_NO_TITLE); // making it full screen

getWindow().setFlags(WindowManager.LayoutParams.F LAG_FULLSCREEN,

WindowManager.LayoutParams.FLAG_FULLSCREEN); WindowManager.LayoutParams.FLAG_FULLSCREEN);

setContentView(R.layout.activity_splash3);

//@Override // protected void onCreate(final Bundle savedInstance) { // super.onCreate(savedInstance);

//setRequestedOrientation(ActivityInfo.SCREEN_ORIENTA TION_LANDSCAPE);

new Handler().postDelayed(new Runnable() {

/* * Showing splash screen with a timer. This will be useful when you * want to show case your app logo / company */

@Override public void run() {

// This method will be executed once the timer is over // Start your app main activity Intent i = new

Intent(SplashScreen3.this, SplashScreen2.class);

i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);

startActivity(i);

// close this activity finish();

} }, SPLASH_TIME_OUT); }

SplashScreen4.java

package com.fractalbackground;

import android.app.Activity; import android.content.Intent; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.os.Handler; import android.view.Window; import android.view.WindowManager; import android.app.Activity; import android.content.Intent; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.os.Handler; import android.view.Window; import android.view.WindowManager;

// Splash screen timer private static int SPLASH_TIME_OUT = 5;

@Override protected void onCreate(Bundle

savedInstanceState) { super.onCreate(savedInstanceState);

// requesting to turn the title OFF

requestWindowFeature(Window.FEATURE_NO_TITLE); // making it full screen

getWindow().setFlags(WindowManager.LayoutParams.F LAG_FULLSCREEN,

WindowManager.LayoutParams.FLAG_FULLSCREEN);

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATI ON_LANDSCAPE);

setContentView(R.layout.activity_splash4);

//@Override // protected void onCreate(final Bundle savedInstance) {

// super.onCreate(savedInstance);

//setRequestedOrientation(ActivityInfo.SCREEN_ORIENTA TION_LANDSCAPE);

new Handler().postDelayed(new Runnable() {

/* * Showing splash screen with a timer. This will be useful when you * want to show case your app logo / company */

@Override public void run() {

// This method will be executed once the timer is over // Start your app main activity Intent i = new

Intent(SplashScreen4.this, SplashScreen3.class);

i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(i);

// close this activity finish();

} }, SPLASH_TIME_OUT); }

SplashScreen5.java

package com.fractalbackground;

import android.app.Activity; import android.content.Intent; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.os.Handler; import android.view.Window; import android.view.WindowManager;

public class SplashScreen5 extends Activity {

// Splash screen timer private static int SPLASH_TIME_OUT = 5;

@Override protected void onCreate(Bundle

savedInstanceState) {

super.onCreate(savedInstanceState);

// requesting to turn the title OFF

requestWindowFeature(Window.FEATURE_NO_TITLE); // making it full screen

getWindow().setFlags(WindowManager.LayoutParams.F LAG_FULLSCREEN,

WindowManager.LayoutParams.FLAG_FULLSCREEN);

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATI ON_LANDSCAPE);

setContentView(R.layout.activity_splash5);

//@Override // protected void onCreate(final Bundle savedInstance) { // super.onCreate(savedInstance);

//setRequestedOrientation(ActivityInfo.SCREEN_ORIENTA TION_LANDSCAPE);

new Handler().postDelayed(new Runnable() {

/* * Showing splash screen with a timer. This will be useful when you * want to show case your app logo / company */

@Override public void run() {

// This method will be executed once the timer is over // Start your app main activity Intent i = new

Intent(SplashScreen5.this, SplashScreen4.class);

i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);

startActivity(i);

// close this activity finish();

} }, SPLASH_TIME_OUT); }

SpriteBatch.java

package com.fractalbackground;

import javax.microedition.khronos.opengles.GL10;

public class SpriteBatch {

//--Constants--// final static int VERTEX_SIZE = 4;

// Vertex Size (in Components) ie. (X,Y,U,V) final static int VERTICES_PER_SPRITE = 4; // Vertices Per Sprite final static int INDICES_PER_SPRITE = 6; // Indices Per Sprite

//--Members--// GL10 gl;

// GL Instance Vertices vertices;

// Vertices Instance Used for Rendering float[] vertexBuffer; // Vertex Buffer int bufferIndex; // Vertex Buffer Start Index int maxSprites; // Maximum Sprites Allowed in Buffer int numSprites; // Number of Sprites Currently in Buffer

//--Constructor--// // D: prepare the sprite batcher for specified

maximum number of sprites

// A: gl - the gl instance to use for rendering // maxSprites - the maximum allowed sprites per

batch

public SpriteBatch(GL10 gl, int maxSprites) {

this.gl = gl; // Save GL Instance

this.vertexBuffer = new float[maxSprites * VERTICES_PER_SPRITE * VERTEX_SIZE]; // Create Vertex Buffer

this.vertices = new Vertices( gl, maxSprites * VERTICES_PER_SPRITE, maxSprites * INDICES_PER_SPRITE, false, true, false ); // Create Rendering Vertices

this.bufferIndex = 0; // Reset Buffer Index this.maxSprites = maxSprites; // Save Maximum Sprites this.numSprites = 0; // Clear Sprite Counter

short[] indices = new short[maxSprites * INDICES_PER_SPRITE]; // Create Temp Index Buffer int len = indices.length; // Get Index Buffer Length short j = 0; // Counter for ( int i = 0; i < len; i+= INDICES_PER_SPRITE, j += VERTICES_PER_SPRITE ) { // FOR Each Index Set (Per Sprite)

indices[i + 0] = (short)( j + 0 ); // Calculate Index 0

indices[i + 1] = (short)( j + 1 ); // Calculate Index 1

indices[i + 2] = (short)( j + 2 ); // Calculate Index 2

indices[i + 3] = (short)( j + 2 ); // Calculate Index 3

indices[i + 4] = (short)( j + 3 ); // Calculate Index 4

indices[i + 5] = (short)( j + 0 ); // Calculate Index 5 } vertices.setIndices( indices, 0, len );

// Set Index Buffer for Rendering }

//--Begin Batch--//

// D: signal the start of a batch. set the texture and clear buffer

// NOTE: the overloaded (non-texture) version assumes that the texture is already bound! // A: textureId - the ID of the texture to use for the batch // R: [none] public void beginBatch(int textureId) {

gl.glBindTexture( GL10.GL_TEXTURE_2D, textureId ); // Bind the Texture numSprites = 0; // Empty Sprite Counter bufferIndex = 0; // Reset Buffer Index (Empty) } public void beginBatch() {

numSprites = 0; // Empty Sprite Counter bufferIndex = 0; // Reset Buffer Index (Empty) }

//--End Batch--// // D: signal the end of a batch. render the

batched sprites // A: [none] // R: [none] public void endBatch() {

if ( numSprites > 0 ) { // IF Any Sprites to Render vertices.setVertices( vertexBuffer, 0, bufferIndex ); // Set Vertices from Buffer vertices.bind(); // Bind Vertices

vertices.draw( GL10.GL_TRIANGLES, 0, numSprites * INDICES_PER_SPRITE ); // Render Batched Sprites

vertices.unbind(); // Unbind Vertices } }

//--Draw Sprite to Batch--// // D: batch specified sprite to batch. adds

vertices for sprite to vertex buffer // NOTE: MUST be called after beginBatch(), and before endBatch()! // NOTE: if the batch overflows, this will render the current batch, restart it, // and then batch this sprite. // A: x, y - the x,y position of the sprite

(center)

// width, height - the width and height of the sprite // region - the texture region to use for sprite // R: [none] public void drawSprite(float x, float y, float

width, float height, TextureRegion region) { width, float height, TextureRegion region) {

// Empty Sprite Counter bufferIndex = 0; // Reset Buffer Index (Empty) }

float halfWidth = width / 2.0f; // Calculate Half Width

float halfHeight = height / 2.0f; // Calculate Half Height float x1 = x - halfWidth; // Calculate Left X float y1 = y - halfHeight; // Calculate Bottom Y float x2 = x + halfWidth; // Calculate Right X float y2 = y + halfHeight; // Calculate Top Y

vertexBuffer[bufferIndex++] = x1; // Add X for Vertex 0

vertexBuffer[bufferIndex++] = y1; // Add Y for Vertex 0 vertexBuffer[bufferIndex++] = region.u1; // Add U for Vertex 0 vertexBuffer[bufferIndex++] = region.v2; // Add V for Vertex 0

vertexBuffer[bufferIndex++] = x2; // Add X for Vertex 1

vertexBuffer[bufferIndex++] = y1; // Add Y for Vertex 1 vertexBuffer[bufferIndex++] = region.u2; // Add U for Vertex 1 vertexBuffer[bufferIndex++] = region.v2; // Add V for Vertex 1

vertexBuffer[bufferIndex++] = x2; // Add X for Vertex 2

vertexBuffer[bufferIndex++] = y2; // Add Y for Vertex 2 vertexBuffer[bufferIndex++] = region.u2; // Add U for Vertex 2 vertexBuffer[bufferIndex++] = region.v1; // Add V for Vertex 2

vertexBuffer[bufferIndex++] = x1; // Add X for Vertex 3

vertexBuffer[bufferIndex++] = y2; // Add Y for Vertex 3 vertexBuffer[bufferIndex++] = region.u1; // Add U for Vertex 3 vertexBuffer[bufferIndex++] = region.v1; // Add V for Vertex 3 vertexBuffer[bufferIndex++] = y2; // Add Y for Vertex 3 vertexBuffer[bufferIndex++] = region.u1; // Add U for Vertex 3 vertexBuffer[bufferIndex++] = region.v1; // Add V for Vertex 3

TextureRegion.java

package com.fractalbackground; class TextureRegion { //--Members--//

public float u1, v1; // Top/Left U,V Coordinates public float u2, v2; // Bottom/Right U,V Coordinates

//--Constructor--// // D: calculate U,V coordinates from specified

texture coordinates // A: texWidth, texHeight - the width and height of the texture the region is for // x, y - the top/left (x,y) of the region on the texture (in pixels) // width, height - the width and height of the region on the texture (in pixels)

public TextureRegion(float texWidth, float texHeight, float x, float y, float width, float height) {

this.u1 = x / texWidth; // Calculate U1 this.v1 = y / texHeight; // Calculate V1 this.u2 = this.u1 + ( width / texWidth ); // Calculate U2 this.v2 = this.v1 + ( height / texHeight ); // Calculate V2 }

TransObject.java TransObject.java

import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; import javax.microedition.khronos.opengles.GL10; import android.opengl.GLES20;

public class TransObject {

private float vertices[] = { -0.5f, -0.5f, 0.0f,

// V1 - first vertex (x,y,z) -0.5f, 0.5f, 0.0f,

V2 0.5f, 0.5f, 0.0f,

V3 0.5f, -0.5f, 0.0f,

// V4 -0.5f, -0.5f, 0.0f

V5 };

private float vertices_color[] = { 1.0f, 0.0f, 0.0f, 1.0f,

// CV1 - first color (red,green,blue) 0.0f, 1.0f, 0.0f, 1.0f,

// CV2 0.0f, 0.0f, 1.0f, 1.0f,

// CV3 0.0f, 1.0f, 0.0f, 1.0f,

// CV4 1.0f, 0.0f, 0.0f, 1.0f // CV5 };

// list vertices kubus private float vertices_kubus[]= {

0.0f,0.0f,1.0f, 1.0f,0.0f,1.0f, 0.0f,1.0f,1.0f, 1.0f,1.0f,1.0f, 0.0f,0.0f,0.0f, 1.0f,0.0f,0.0f, 0.0f,1.0f,0.0f, 1.0f,1.0f,0.0f

// list color (kombinasi angka nol dan satu) private float colors_kubus[] = {

0.0f,0.0f,0.0f,1.0f, 1.0f,0.0f,0.0f,1.0f, 1.0f,1.0f,0.0f,1.0f, 0.0f,1.0f,0.0f,1.0f, 0.0f,0.0f,1.0f,1.0f, 1.0f,0.0f,1.0f,1.0f, 1.0f,1.0f,1.0f,1.0f, 0.0f,1.0f,1.0f,1.0f

4,5,7, // belakang 1 7,6,4, // belakang 2

2,3,7, // atas 1 7,6,2, // atas 2

0,1,5, // bawah 1 5,4,0, // bawah 2

1,5,7, // kanan 1 7,3,1, // kanan 2

0,4,6, // kiri 1 6,4,0, // kiri 2

0,2,6, // kiri 3 6,2,0 // kiri 4

private float vertices_circle[]={0.0f,0.0f,0.0f}; private float

vertices_circle_color[]={0.0f,0.0f,0.0f,0.5f}; private float vertices_line[]={0.0f,0.0f,0.0f}; private float

vertices_line_color[]={0.0f,0.0f,0.0f,1.0f}; private int batas_sudut=360; float jari_jari; float a,b; float x,y; float step=3.0f,step_line=0.2f; float x1,y1; float x2,y2; private int

loop,loop_color,loop_line,loop_line_color;

public TransObject() {

// ============ start to generate vertices to circle ========================== //Inisialisasi jari_jari=1.0f;

// Titik Pusat

a = 0.0f; b = 0.0f ; x=a+jari_jari; y=b;

loop=3; loop_color=4; vertices_circle=new

float[(int)(3*batas_sudut/step)*3]; vertices_circle_color=new float[(int)(3*batas_sudut/step)*4]; for(float float[(int)(3*batas_sudut/step)*3]; vertices_circle_color=new float[(int)(3*batas_sudut/step)*4]; for(float

vertices_circle[loop+1] = (float) ((x- a)*Math.sin((teta/180)*(22/7)) - ((y- b)*Math.cos((teta/180)*(22/7))) + b);

vertices_circle[loop+2]=0; loop+=3;

//mengenerate warna untuk setiap vertex vertices_circle_color[loop_color]=(float)

((x-a)*Math.cos((teta/180)*(22/7)) - ((y- b)*Math.sin((teta/180)*(22/7))) + a);

vertices_circle_color[loop_color+1]=(float) ((x- a)*Math.sin((teta/180)*(22/7)) - ((y- b)*Math.cos((teta/180)*(22/7))) + b);

vertices_circle_color[loop_color+2]=0.5f; vertices_circle_color[loop_color+3]=0.5f; loop_color+=4; }

// ============= end for generate vertices to circle ====================

// ============ start to generate vertices to line ========================== x1 = -1.0f; y1 = -1.0f; x2= 1.0f; y2 = 1.0f;

loop_line=3; loop_line_color=4; vertices_line=new float[(int)(2*(x2-

x1)/step_line)*3]; vertices_line_color=new float[(int)(2*(x2- x1)/step_line)*4];

float m = (y2-y1)/(x2-x1); for(x=x1;x<=x2;x+=step_line){

vertices_line[loop_line] = (float) (x); vertices_line[loop_line+1] = (float)

(m*(x-x1)+y1);

vertices_line[loop_line+2]=0; loop_line+=3;

//mengenerate warna untuk setiap vertex

vertices_line_color[loop_line_color]=(float) (0.5*x);

vertices_line_color[loop_line_color+1]=(float) (0.5*m*(x-x1)+y1);

vertices_line_color[loop_line_color+2]=1.0f;

vertices_line_color[loop_line_color+3]=1.0f;

loop_line_color+=4; }

// ============= end for generate vertices to // ============= end for generate vertices to

// Point to our vertex buffer, return buffer holding the vertices public static FloatBuffer makeFloatBuffer(float[] arr){ ByteBuffer bb = ByteBuffer.allocateDirect(arr.length * 4); bb.order(ByteOrder.nativeOrder()); FloatBuffer fb = bb.asFloatBuffer(); fb.put(arr); fb.position(0); return fb;

// Setup index-array buffer. Indices in byte. public static ByteBuffer makeByteBuffer(byte[]

arr){ ByteBuffer bb = ByteBuffer.allocateDirect(arr.length); bb.put(arr); bb.position(0); return bb;

/** The draw method for the primitive object with the GL context */

public void draw_kubus(GL10 gl) { gl.glFrontFace(GL10.GL_CCW); // Front face in counter-clockwise

// orientation // Enable arrays and define their buffers

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_kubus));

gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

gl.glColorPointer(4, GL10.GL_FLOAT, 0, makeFloatBuffer(colors_kubus)); gl.glDrawElements(GL10.GL_TRIANGLES, indices_kubus.length, GL10.GL_UNSIGNED_BYTE, makeByteBuffer(indices_kubus)); //gl.glDrawElements(GL10.GL_LINE_STRIP, indices_kubus2.length, //GL10.GL_UNSIGNED_BYTE, makeByteBuffer(indices_kubus2));

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

gl.glDisableClientState(GL10.GL_COLOR_ARRAY); }

public void draw_points(GL10 gl) { public void draw_points(GL10 gl) {

//gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour for the points (pemberian warna untuk titik) gl.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);

// Point to our vertex buffer (mendata nilai lokasi/posisi titik) gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(new float [] { 1.0f, 1.0f, 0.0f, // V1 - first vertex (x,y,z) 1.0f, 0.8f, 0.0f, // V2 1.0f, 0.6f, 0.0f, // V3 1.0f, 0.4f, 0.0f, // V4 1.0f, 0.2f, 0.0f, // V5 1.0f, 0.0f, 0.0f, // V6 1.0f, -0.2f, 0.0f, // V7 1.0f, -0.4f, 0.0f, // V8 1.0f, -0.6f, 0.0f, // V9 1.0f, -0.8f, 0.0f, // V10 1.0f, -1.0f, 0.0f, // V11

0.8f, -1.0f, 0.0f, // V12 0.6f, -1.0f, 0.0f, // V13 0.4f, -1.0f, 0.0f, // V14 0.2f, -1.0f, 0.0f, // V15 0.0f, -1.0f, 0.0f, // V16 -0.2f, -1.0f, 0.0f,

// V17 -0.4f, -1.0f, 0.0f,

// V18 -0.6f, -1.0f, 0.0f,

// V19 -0.7f, -1.0f, 0.0f,

// V20 -0.8f, -1.0f, 0.0f,

// V21 -1.0f, -1.0f, 0.0f,

// V22

// Draw the vertices as points

(menggambar titik-titik) gl.glDrawArrays(GL10.GL_POINTS, 0, 22);

//Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

//gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

} public void draw_line(GL10 gl) {

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

//gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour for the line (pemberian warna untuk garis) gl.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);

// Point to our vertex buffer (mendata nilai lokasi/posisi titik yang menyusun garis) gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(new float [] { 1.0f, 1.0f, 0.0f, // V1 - first vertex (x,y,z) -1.0f, -1.0f, 0.0f,

// V2 - second vertex }));

// Draw the vertices as lines (menggambar garis dari titik-titik) gl.glDrawArrays(GL10.GL_LINES, 0, 2); /*gl.glDrawElements(GL10.GL_LINES, 2,

GL10.GL_UNSIGNED_SHORT, makeFloatBuffer(new float [] { 1.0f, 1.0f, 0.0f, // V1 - first vertex (x,y,z) -1.0f, -1.0f, 0.0f,

// V2 - second vertex }));*/

//Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

//gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

public void draw_line_color(GL10 gl) {

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

// set the colour for the line (pemberian warna untuk garis) gl.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);

// Point to our vertex buffer (mendata nilai lokasi/posisi titik yang menyusun garis) gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_line));

//memetakan warna untuk setiap vertex gl.glColorPointer(4, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_line_color));

// Draw the vertices as lines (menggambar garis dari titik-titik) gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, (int) (2*(x2-x1)/step_line)); /*gl.glDrawElements(GL10.GL_LINES, 2, GL10.GL_UNSIGNED_SHORT, makeFloatBuffer(new float [] { 1.0f, 1.0f, 0.0f, // V1 - first vertex (x,y,z) -1.0f, -1.0f, 0.0f,

// V2 - second vertex }));*/

//Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

public void draw_circle(GL10 gl) {

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

//gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour for the object circle gl.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);

//create VBO from buffer with

glBufferData() gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_circle));

//draw circle as filled shape //gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 1,

(int) ((int) 2*batas_sudut/step));

//draw circle contours //gl.glDrawArrays(GL10.GL_LINES, 1, (int)

((int) 2*batas_sudut/step)); // membuat garis putus- putus pada tepi lingkaran

gl.glDrawArrays(GL10.GL_LINES, 1, (int)

((int) 2*batas_sudut/step)); //gl.glDrawArrays(GL10.GL_LINE_STRIP, 1, (int) ((int) 2*batas_sudut/step)); //gl.glDrawArrays(GL10.GL_POINTS, 1, (int) ((int) 2*batas_sudut/step));

//Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

//gl.glDisableClientState(GL10.GL_COLOR_ARRAY); }

public void draw_circle_color(GL10 gl) {

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour edge for the object circle gl.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);

//create VBO from buffer with

glBufferData() gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_circle));

//memetakan warna untuk setiap vertex gl.glColorPointer(4, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices_circle_color));

//draw circle as filled shape gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 1,

(int) ((int) 2*batas_sudut/step)); //gl.glDrawArrays(GL10.GL_LINE_STRIP, 1, (int) ((int) 2*batas_sudut/step)); //gl.glDrawElements(GL10.GL_TRIANGLES, (int) ((int) 2*batas_sudut/step), // GL10.GL_UNSIGNED_SHORT, makeFloatBuffer(vertices_circle));

//draw circle contours //gl.glDrawArrays(GL10.GL_LINES, 1, (int)

((int) 2*batas_sudut/step)); // membuat garis putus- putus pada tepi lingkaran

//gl.glDrawArrays(GL10.GL_LINE_STRIP, 1, (int) ((int) 2*batas_sudut/step)); //gl.glDrawArrays(GL10.GL_POINTS, 1, (int) ((int) 2*batas_sudut/step));

//Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

gl.glDisableClientState(GL10.GL_COLOR_ARRAY); } gl.glDisableClientState(GL10.GL_COLOR_ARRAY); }

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// Point to our vertex buffer gl.glVertexPointer(3, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices));

// Draw the vertices as square

gl.glColorPointer(4, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_color)); gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 3);

gl.glColorPointer(4, GL10.GL_FLOAT, 0, makeFloatBuffer(vertices_color)); gl.glDrawArrays(GL10.GL_TRIANGLES, 2, 3);

//Disable the client state before leaving

gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

public void draw_segitiga(GL10 gl) {

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

// set the colour for the triangle gl.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);

gl.glVertexPointer(3, GL10.GL_FLOAT, 0, makeFloatBuffer(new float [] { -0.5f, -0.5f, 0.0f,

// V1 - first vertex (x,y,z) 0.5f, -0.5f, 0.0f,

// V2 - second vertex 0.0f, 0.5f, 0.0f // V3 - third vertex

// Draw the vertices as triangle gl.glColorPointer(4, GL10.GL_FLOAT, 0,

makeFloatBuffer(vertices_color)); gl.glDrawArrays(GLES20.GL_TRIANGLES, 0, 3);

//Disable the client state before leaving //Disable the client state before leaving

gl.glDisableClientState(GL10.GL_COLOR_ARRAY);

Vertices.java

package com.fractalbackground;

import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.IntBuffer; import java.nio.ShortBuffer;

import javax.microedition.khronos.opengles.GL10;

public class Vertices {

//--Constants--// final static int POSITION_CNT_2D = 2;

// Number of Components in Vertex Position for 2D

final static int POSITION_CNT_3D = 3; // Number of Components in Vertex Position for 3D

final static int COLOR_CNT = 4; // Number of Components in Vertex Color final static int TEXCOORD_CNT = 2; // Number of Components in Vertex Texture Coords

final static int NORMAL_CNT = 3; // Number of Components in Vertex Normal

final static int INDEX_SIZE = Short.SIZE / 8; // Index Byte Size (Short.SIZE = bits)

//--Members--// // NOTE: all members are constant, and initialized

in constructor! final GL10 gl; // GL Instance final boolean hasColor; // Use Color in Vertices final boolean hasTexCoords; // Use Texture Coords in Vertices final boolean hasNormals; // Use Normals in Vertices public final int positionCnt; // Number of Position Components (2=2D, 3=3D) public final int vertexStride; // Vertex Stride (Element Size of a Single Vertex)

public final int vertexSize; // Bytesize of a Single Vertex public final int vertexSize; // Bytesize of a Single Vertex

//--Constructor--// // D: create the vertices/indices as specified

(for 2d/3d) // A: gl - the gl instance to use // maxVertices - maximum vertices allowed in

buffer // maxIndices - maximum indices allowed in buffer // hasColor - use color values in vertices // hasTexCoords - use texture coordinates in

vertices // hasNormals - use normals in vertices // use3D - (false, default) use 2d positions

(ie. x/y only)

// (true) use 3d positions (ie. x/y/z) public Vertices(GL10 gl, int maxVertices, int

maxIndices, boolean hasColor, boolean hasTexCoords, boolean hasNormals) {

this( gl, maxVertices, maxIndices, hasColor, hasTexCoords, hasNormals, false ); // Call Overloaded Constructor

} public Vertices(GL10 gl, int maxVertices, int

maxIndices, boolean hasColor, boolean hasTexCoords, boolean hasNormals, boolean use3D) {

this.gl = gl; // Save GL Instance this.hasColor = hasColor; // Save Color Flag this.hasTexCoords = hasTexCoords; // Save Texture Coords Flag this.hasNormals = hasNormals; // Save Normals Flag this.positionCnt = use3D ? POSITION_CNT_3D : POSITION_CNT_2D; // Set Position Component Count

this.vertexStride = this.positionCnt + ( hasColor ? COLOR_CNT : 0 ) + ( hasTexCoords ? TEXCOORD_CNT : 0 ) + ( hasNormals ? NORMAL_CNT : 0 ); // Calculate Vertex Stride

this.vertexSize = this.vertexStride * 4; // Calculate Vertex Byte Size

ByteBuffer buffer = ByteBuffer.allocateDirect( maxVertices * vertexSize ); // Allocate Buffer for Vertices (Max)

buffer.order( ByteOrder.nativeOrder() ); // Set Native Byte Order this.vertices = buffer.asIntBuffer();

// Save Vertex Buffer

if ( maxIndices > 0 ) { // IF Indices Required

buffer = ByteBuffer.allocateDirect( maxIndices * INDEX_SIZE ); // Allocate Buffer for Indices (MAX)

buffer.order( ByteOrder.nativeOrder() ); // Set Native Byte Order this.indices = buffer.asShortBuffer(); // Save Index Buffer } else

// ELSE Indices Not Required indices = null; // No Index Buffer

numVertices = 0; // Zero Vertices in Buffer numIndices = 0; // Zero Indices in Buffer

this.tmpBuffer = new int[maxVertices * vertexSize / 4]; // Create Temp Buffer }

//--Set Vertices--// // D: set the specified vertices in the vertex

buffer // NOTE: optimized to use integer buffer! // A: vertices - array of vertices (floats) to set // offset - offset to first vertex in array // length - number of floats in the vertex

array (total)

// for easy setting use: vtx_cnt * (this.vertexSize / 4) // R: [none] public void setVertices(float[] vertices, int

offset, int length) { this.vertices.clear(); // Remove Existing Vertices int last = offset + length; // Calculate Last Element for ( int i = offset, j = 0; i < last; i++, j++ ) // FOR Each Specified Vertex tmpBuffer[j] = Float.floatToRawIntBits( vertices[i] ); // Set Vertex as Raw Integer Bits in Buffer

this.vertices.put( tmpBuffer, 0, length ); // Set New Vertices this.vertices.flip(); // Flip Vertex Buffer this.numVertices = length / this.vertexStride; // Save Number of Vertices //this.numVertices = length / ( this.vertexSize / 4 ); // Save Number of Vertices }

//--Set Indices--//

// D: set the specified indices in the index buffer

// A: indices - array of indices (shorts) to set // offset - offset to first index in array // length - number of indices in array (from

offset) // R: [none] public void setIndices(short[] indices, int

offset, int length) { this.indices.clear(); // Clear Existing Indices this.indices.put( indices, offset, length ); // Set New Indices this.indices.flip(); // Flip Index Buffer this.numIndices = length; // Save Number of Indices }

//--Bind--// // D: perform all required binding/state changes

before rendering batches. // USAGE: call once before calling draw() multiple times for this buffer. // A: [none] // R: [none] public void bind() {

gl.glEnableClientState( GL10.GL_VERTEX_ARRAY ); // Enable Position in Vertices vertices.position( 0 ); // Set Vertex Buffer to Position gl.glVertexPointer( positionCnt, GL10.GL_FLOAT, vertexSize, vertices ); // Set Vertex Pointer

if ( hasColor ) { // IF Vertices Have Color gl.glEnableClientState( GL10.GL_COLOR_ARRAY ); // Enable Color in Vertices

vertices.position( positionCnt ); // Set Vertex Buffer to Color gl.glColorPointer( COLOR_CNT, GL10.GL_FLOAT, vertexSize, vertices ); // Set Color Pointer }

if ( hasTexCoords ) { // IF Vertices Have Texture Coords gl.glEnableClientState( GL10.GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coords in Vertices

vertices.position( positionCnt + ( hasColor ? COLOR_CNT : 0 ) ); // Set Vertex Buffer to Texture Coords (NOTE: position based on whether color is also specified)

gl.glTexCoordPointer( TEXCOORD_CNT, GL10.GL_FLOAT, vertexSize, vertices ); // Set Texture Coords Pointer

if ( hasNormals ) { if ( hasNormals ) {

gl.glNormalPointer( GL10.GL_FLOAT, vertexSize, vertices ); // Set Normals Pointer } }

//--Draw--// // D: draw the currently bound vertices in the

vertex/index buffers // USAGE: can only be called after calling bind() for this buffer.

// A: primitiveType - the type of primitive to draw // offset - the offset in the vertex/index buffer to start at // numVertices - the number of vertices (indices) to draw // R: [none] public void draw(int primitiveType, int offset,

int numVertices) { if ( indices != null ) { // IF Indices Exist indices.position( offset ); // Set Index Buffer to Specified Offset gl.glDrawElements( primitiveType, numVertices, GL10.GL_UNSIGNED_SHORT, indices ); // Draw Indexed

} else {

// ELSE No Indices Exist gl.glDrawArrays( primitiveType, offset, numVertices ); // Draw Direct (Array) } }

//--Unbind--// // D: clear binding states when done rendering

batches. // USAGE: call once before calling draw() multiple times for this buffer. // A: [none] // R: [none] public void unbind() {

if ( hasColor ) // IF Vertices Have Color gl.glDisableClientState( GL10.GL_COLOR_ARRAY ); // Clear Color State

if ( hasTexCoords ) // IF Vertices Have Texture Coords gl.glDisableClientState( GL10.GL_TEXTURE_COORD_ARRAY ); // Clear Texture Coords State if ( hasTexCoords ) // IF Vertices Have Texture Coords gl.glDisableClientState( GL10.GL_TEXTURE_COORD_ARRAY ); // Clear Texture Coords State

//--Draw Full--// // D: draw the vertices in the vertex/index

buffers // NOTE: unoptimized version! use bind()/draw()/unbind() for batches

// A: primitiveType - the type of primitive to draw // offset - the offset in the vertex/index buffer to start at // numVertices - the number of vertices (indices) to draw // R: [none] public void drawFull(int primitiveType, int

offset, int numVertices) { gl.glEnableClientState( GL10.GL_VERTEX_ARRAY ); // Enable Position in Vertices vertices.position( 0 ); // Set Vertex Buffer to Position gl.glVertexPointer( positionCnt, GL10.GL_FLOAT, vertexSize, vertices ); // Set Vertex Pointer

if ( hasColor ) { // IF Vertices Have Color gl.glEnableClientState( GL10.GL_COLOR_ARRAY ); // Enable Color in Vertices

vertices.position( positionCnt ); // Set Vertex Buffer to Color gl.glColorPointer( COLOR_CNT, GL10.GL_FLOAT, vertexSize, vertices ); // Set Color Pointer }

if ( hasTexCoords ) { // IF Vertices Have Texture Coords gl.glEnableClientState( GL10.GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coords in Vertices

vertices.position( positionCnt + ( hasColor ? COLOR_CNT : 0 ) ); // Set Vertex Buffer to Texture Coords (NOTE: position based on whether color is also specified)

gl.glTexCoordPointer( TEXCOORD_CNT, GL10.GL_FLOAT, vertexSize, vertices ); // Set Texture Coords Pointer

if ( indices != null ) { // IF Indices Exist indices.position( offset ); // Set Index Buffer to Specified Offset gl.glDrawElements( primitiveType, numVertices, GL10.GL_UNSIGNED_SHORT, indices ); // Draw Indexed if ( indices != null ) { // IF Indices Exist indices.position( offset ); // Set Index Buffer to Specified Offset gl.glDrawElements( primitiveType, numVertices, GL10.GL_UNSIGNED_SHORT, indices ); // Draw Indexed

if ( hasTexCoords ) // IF Vertices Have Texture Coords gl.glDisableClientState( GL10.GL_TEXTURE_COORD_ARRAY ); // Clear Texture Coords State

if ( hasColor ) // IF Vertices Have Color gl.glDisableClientState( GL10.GL_COLOR_ARRAY ); // Clear Color State }

//--Set Vertex Elements--// // D: use these methods to alter the values

(position, color, textcoords, normals) for vertices

// WARNING: these do NOT validate any values, ensure that the index AND specified // elements EXIST before using!! // A: x, y, z - the x,y,z position to set in

buffer

// r, g, b, a - the r,g,b,a color to set in buffer // u, v - the u,v texture coords to set in buffer // nx, ny, nz - the x,y,z normal to set in buffer // R: [none] void setVtxPosition(int vtxIdx, float x, float y)

{ int index = vtxIdx * vertexStride; // Calculate Actual Index vertices.put( index + 0, Float.floatToRawIntBits( x ) ); // Set X vertices.put( index + 1, Float.floatToRawIntBits( y ) ); // Set Y } void setVtxPosition(int vtxIdx, float x, float y,

float z) { int index = vtxIdx * vertexStride; // Calculate Actual Index vertices.put( index + 0, Float.floatToRawIntBits( x ) ); // Set X vertices.put( index + 1, Float.floatToRawIntBits( y ) ); // Set Y vertices.put( index + 2, Float.floatToRawIntBits( z ) ); // Set Z } void setVtxColor(int vtxIdx, float r, float g,

float b, float a) { int index = ( vtxIdx * vertexStride ) + positionCnt; // Calculate Actual Index vertices.put( index + 0, Float.floatToRawIntBits( r ) ); // Set Red float b, float a) { int index = ( vtxIdx * vertexStride ) + positionCnt; // Calculate Actual Index vertices.put( index + 0, Float.floatToRawIntBits( r ) ); // Set Red

float b) {

int index = ( vtxIdx * vertexStride ) + positionCnt; // Calculate Actual Index vertices.put( index + 0, Float.floatToRawIntBits( r ) ); // Set Red vertices.put( index + 1, Float.floatToRawIntBits( g ) ); // Set Green vertices.put( index + 2, Float.floatToRawIntBits( b ) ); // Set Blue } void setVtxColor(int vtxIdx, float a) {

int index = ( vtxIdx * vertexStride ) + positionCnt; // Calculate Actual Index vertices.put( index + 3, Float.floatToRawIntBits( a ) ); // Set Alpha } void setVtxTexCoords(int vtxIdx, float u, float v)

int index = ( vtxIdx * vertexStride ) + positionCnt + ( hasColor ? COLOR_CNT : 0 ); // Calculate Actual Index

vertices.put( index + 0, Float.floatToRawIntBits( u ) ); // Set U vertices.put( index + 1, Float.floatToRawIntBits( v ) ); // Set V } void setVtxNormal(int vtxIdx, float x, float y,

float z) {

int index = ( vtxIdx * vertexStride ) + positionCnt + ( hasColor ? COLOR_CNT : 0 ) + ( hasTexCoords ? TEXCOORD_CNT : 0 ); // Calculate Actual Index

vertices.put( index + 0, Float.floatToRawIntBits( x ) ); // Set X vertices.put( index + 1, Float.floatToRawIntBits( y ) ); // Set Y vertices.put( index + 2, Float.floatToRawIntBits( z ) ); // Set Z }

Struktur folder pada aplikasi tersebut, pada folder “assets”, terdapat file “Roboto-Regular.ttf”.

Gambar 9.5 file “Roboto-Regular.ttf”

Kemudian pada folder “res\layout”, terdapat beberapa file berikut, khususnya untuk membuat animasi loading ketika pertama kali

aplikasi dijalanakan,

Gambar 9.6 File res\layout Gambar 9.6 File res\layout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/and roid"

xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"

android:paddingBottom="@dimen/activity_vertical_margi n"

android:paddingLeft="@dimen/activity_horizontal_margi n"

android:paddingRight="@dimen/activity_horizontal_marg in"

android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" >

<TextView

android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" />

</RelativeLayout>

activity_splash.xml

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/and roid"

android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/splash" >

</RelativeLayout>

activity_splash1.xml

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/and roid"

android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/splash1" >

</RelativeLayout>

activity_splash2.xml

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/and roid"

android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/splash2" >

</RelativeLayout>

activity_splash3.xml

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/and roid"

android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/splash3" >

</RelativeLayout>

activity_splash4.xml

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/and roid"

android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/splash4" >

</RelativeLayout>

activity_splash5.xml

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/and roid"

android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/splash5" >

</RelativeLayout>

Kemudian pada folder “res\raw” terdapat beberapa file audio sebagai back sound, maupun untuk bunyi ketika tombol diklik adalah berikut,

Gambar 9.7 File Audio

Kemudian pada folder “res\drawable-hdpi”, terdapat beberapa file gambar untuk texture mapping adalah berikut,

Gambar 9.8 File Gambar untuk Texture Mapping