├── Antikythera ├── default.properties ├── bin │ ├── classes.dex │ ├── Antikythera.apk │ ├── resources.ap_ │ ├── res │ │ ├── drawable │ │ │ ├── boxt.png │ │ │ └── fragmenta.png │ │ ├── drawable-hdpi │ │ │ ├── icon.png │ │ │ ├── move.png │ │ │ └── rotate.png │ │ ├── drawable-ldpi │ │ │ ├── icon.png │ │ │ ├── move.png │ │ │ └── rotate.png │ │ └── drawable-mdpi │ │ │ ├── icon.png │ │ │ ├── move.png │ │ │ └── rotate.png │ ├── jarlist.cache │ └── classes │ │ └── com │ │ └── fivasim │ │ └── antikythera │ │ ├── R.class │ │ ├── Gear.class │ │ ├── R$id.class │ │ ├── help.class │ │ ├── main.class │ │ ├── About.class │ │ ├── Initial.class │ │ ├── Plate.class │ │ ├── Pointer.class │ │ ├── R$array.class │ │ ├── R$attr.class │ │ ├── R$xml.class │ │ ├── main$1.class │ │ ├── main$2.class │ │ ├── main$3.class │ │ ├── main$4.class │ │ ├── main$5.class │ │ ├── Initial2.class │ │ ├── R$layout.class │ │ ├── R$string.class │ │ ├── BuildConfig.class │ │ ├── Preferences.class │ │ ├── R$drawable.class │ │ ├── antikythera2.class │ │ ├── antikytherap.class │ │ ├── OpenGLRenderer.class │ │ ├── antikythera2$1.class │ │ ├── antikythera2$2.class │ │ ├── antikytherap$1.class │ │ ├── antikytherap$2.class │ │ ├── OpenGLRenderer2.class │ │ ├── antikythera2_nomulti$1.class │ │ ├── antikythera2_nomulti$2.class │ │ ├── antikythera2_nomulti.class │ │ ├── antikytherap_nomulti$1.class │ │ ├── antikytherap_nomulti$2.class │ │ └── antikytherap_nomulti.class ├── res │ ├── drawable │ │ ├── boxt.png │ │ ├── fragmenta.png │ │ └── transparent_button.xml │ ├── drawable-hdpi │ │ ├── icon.png │ │ ├── move.png │ │ └── rotate.png │ ├── drawable-ldpi │ │ ├── icon.png │ │ ├── move.png │ │ └── rotate.png │ ├── drawable-mdpi │ │ ├── icon.png │ │ ├── move.png │ │ └── rotate.png │ ├── values │ │ ├── array.xml │ │ └── strings.xml │ ├── layout │ │ ├── gllayout.xml │ │ ├── help.xml │ │ ├── about.xml │ │ └── main.xml │ └── xml │ │ └── preferences.xml ├── gen │ └── com │ │ └── fivasim │ │ └── antikythera │ │ ├── BuildConfig.java │ │ └── R.java ├── .classpath ├── project.properties ├── .settings │ └── org.eclipse.jdt.core.prefs ├── src │ └── com │ │ └── fivasim │ │ └── antikythera │ │ ├── About.java │ │ ├── help.java │ │ ├── Preferences.java │ │ ├── main.java │ │ ├── Plate.java │ │ ├── Pointer.java │ │ ├── antikytherap_nomulti.java │ │ ├── antikythera2_nomulti.java │ │ ├── antikytherap.java │ │ ├── antikythera2.java │ │ ├── OpenGLRenderer.java │ │ ├── Initial2.java │ │ ├── OpenGLRenderer2.java │ │ ├── Initial.java │ │ └── Gear.java ├── .project └── AndroidManifest.xml └── README /Antikythera/default.properties: -------------------------------------------------------------------------------- 1 | # Project target. 2 | target=android-10 3 | -------------------------------------------------------------------------------- /Antikythera/bin/classes.dex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes.dex -------------------------------------------------------------------------------- /Antikythera/bin/Antikythera.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/Antikythera.apk -------------------------------------------------------------------------------- /Antikythera/bin/resources.ap_: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/resources.ap_ -------------------------------------------------------------------------------- /Antikythera/res/drawable/boxt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/res/drawable/boxt.png -------------------------------------------------------------------------------- /Antikythera/bin/res/drawable/boxt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/res/drawable/boxt.png -------------------------------------------------------------------------------- /Antikythera/res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /Antikythera/res/drawable-hdpi/move.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/res/drawable-hdpi/move.png -------------------------------------------------------------------------------- /Antikythera/res/drawable-ldpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/res/drawable-ldpi/icon.png -------------------------------------------------------------------------------- /Antikythera/res/drawable-ldpi/move.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/res/drawable-ldpi/move.png -------------------------------------------------------------------------------- /Antikythera/res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /Antikythera/res/drawable-mdpi/move.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/res/drawable-mdpi/move.png -------------------------------------------------------------------------------- /Antikythera/res/drawable/fragmenta.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/res/drawable/fragmenta.png -------------------------------------------------------------------------------- /Antikythera/res/drawable-hdpi/rotate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/res/drawable-hdpi/rotate.png -------------------------------------------------------------------------------- /Antikythera/res/drawable-ldpi/rotate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/res/drawable-ldpi/rotate.png -------------------------------------------------------------------------------- /Antikythera/res/drawable-mdpi/rotate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/res/drawable-mdpi/rotate.png -------------------------------------------------------------------------------- /Antikythera/bin/res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /Antikythera/bin/res/drawable-hdpi/move.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/res/drawable-hdpi/move.png -------------------------------------------------------------------------------- /Antikythera/bin/res/drawable-ldpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/res/drawable-ldpi/icon.png -------------------------------------------------------------------------------- /Antikythera/bin/res/drawable-ldpi/move.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/res/drawable-ldpi/move.png -------------------------------------------------------------------------------- /Antikythera/bin/res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /Antikythera/bin/res/drawable-mdpi/move.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/res/drawable-mdpi/move.png -------------------------------------------------------------------------------- /Antikythera/bin/res/drawable/fragmenta.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/res/drawable/fragmenta.png -------------------------------------------------------------------------------- /Antikythera/bin/res/drawable-hdpi/rotate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/res/drawable-hdpi/rotate.png -------------------------------------------------------------------------------- /Antikythera/bin/res/drawable-ldpi/rotate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/res/drawable-ldpi/rotate.png -------------------------------------------------------------------------------- /Antikythera/bin/res/drawable-mdpi/rotate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/res/drawable-mdpi/rotate.png -------------------------------------------------------------------------------- /Antikythera/bin/jarlist.cache: -------------------------------------------------------------------------------- 1 | # cache for current jar dependecy. DO NOT EDIT. 2 | # format is 3 | # Encoding is UTF-8 4 | -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/R.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/R.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/Gear.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/Gear.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/R$id.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/R$id.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/help.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/help.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/main.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/About.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/About.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/Initial.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/Initial.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/Plate.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/Plate.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/Pointer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/Pointer.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/R$array.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/R$array.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/R$attr.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/R$attr.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/R$xml.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/R$xml.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/main$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/main$1.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/main$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/main$2.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/main$3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/main$3.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/main$4.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/main$4.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/main$5.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/main$5.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/Initial2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/Initial2.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/R$layout.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/R$layout.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/R$string.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/R$string.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/BuildConfig.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/BuildConfig.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/Preferences.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/Preferences.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/R$drawable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/R$drawable.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/antikythera2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/antikythera2.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/antikytherap.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/antikytherap.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/OpenGLRenderer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/OpenGLRenderer.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/antikythera2$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/antikythera2$1.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/antikythera2$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/antikythera2$2.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/antikytherap$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/antikytherap$1.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/antikytherap$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/antikytherap$2.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/OpenGLRenderer2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/OpenGLRenderer2.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/antikythera2_nomulti$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/antikythera2_nomulti$1.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/antikythera2_nomulti$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/antikythera2_nomulti$2.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/antikythera2_nomulti.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/antikythera2_nomulti.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/antikytherap_nomulti$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/antikytherap_nomulti$1.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/antikytherap_nomulti$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/antikytherap_nomulti$2.class -------------------------------------------------------------------------------- /Antikythera/bin/classes/com/fivasim/antikythera/antikytherap_nomulti.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fivasim/Antikythera-Simulation/HEAD/Antikythera/bin/classes/com/fivasim/antikythera/antikytherap_nomulti.class -------------------------------------------------------------------------------- /Antikythera/gen/com/fivasim/antikythera/BuildConfig.java: -------------------------------------------------------------------------------- 1 | /** Automatically generated file. DO NOT MODIFY */ 2 | package com.fivasim.antikythera; 3 | 4 | public final class BuildConfig { 5 | public final static boolean DEBUG = true; 6 | } -------------------------------------------------------------------------------- /Antikythera/res/drawable/transparent_button.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 8 | -------------------------------------------------------------------------------- /Antikythera/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Antikythera/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Project target. 11 | target=android-10 12 | -------------------------------------------------------------------------------- /Antikythera/res/values/array.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Paused 5 | Slow 6 | Normal 7 | Fast 8 | Very Fast 9 | 10 | 11 | 0.0 12 | 0.5 13 | 1.0 14 | 2.0 15 | 5.0 16 | 17 | 18 | -------------------------------------------------------------------------------- /Antikythera/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | #Fri Dec 02 00:16:08 EET 2011 2 | eclipse.preferences.version=1 3 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.5 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.source=1.5 13 | -------------------------------------------------------------------------------- /Antikythera/src/com/fivasim/antikythera/About.java: -------------------------------------------------------------------------------- 1 | package com.fivasim.antikythera; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.view.KeyEvent; 7 | 8 | public class About extends Activity { 9 | 10 | @Override 11 | public void onCreate(Bundle savedInstanceState) { 12 | super.onCreate(savedInstanceState); 13 | setContentView(R.layout.about); 14 | } 15 | 16 | @Override 17 | public boolean onKeyDown(int keyCode, KeyEvent event) { 18 | if ( keyCode == KeyEvent.KEYCODE_BACK ) { 19 | finish(); 20 | } 21 | if ( keyCode == KeyEvent.KEYCODE_MENU ) { 22 | startActivity(new Intent(this, Preferences.class)); 23 | } 24 | return true; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Antikythera/src/com/fivasim/antikythera/help.java: -------------------------------------------------------------------------------- 1 | package com.fivasim.antikythera; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.view.KeyEvent; 7 | 8 | public class help extends Activity { 9 | 10 | @Override 11 | public void onCreate(Bundle savedInstanceState) { 12 | super.onCreate(savedInstanceState); 13 | setContentView(R.layout.help); 14 | } 15 | 16 | @Override 17 | public boolean onKeyDown(int keyCode, KeyEvent event) { 18 | if ( keyCode == KeyEvent.KEYCODE_BACK ) { 19 | finish(); 20 | } 21 | if ( keyCode == KeyEvent.KEYCODE_MENU ) { 22 | startActivity(new Intent(this, Preferences.class)); 23 | } 24 | return true; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Antikythera/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Antikythera 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /Antikythera/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Antikythera/res/layout/gllayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 8 | 12 | 15 | 25 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Antikythera/res/layout/help.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 9 | 13 | 17 | 21 | 25 | 29 | 33 | 37 | 41 | 42 | -------------------------------------------------------------------------------- /Antikythera/src/com/fivasim/antikythera/Preferences.java: -------------------------------------------------------------------------------- 1 | package com.fivasim.antikythera; 2 | 3 | import android.content.SharedPreferences; 4 | import android.os.Bundle; 5 | import android.preference.PreferenceActivity; 6 | import android.preference.PreferenceManager; 7 | import android.view.KeyEvent; 8 | 9 | public class Preferences extends PreferenceActivity { 10 | public static float rotation_speed; 11 | public static boolean plate_visibility,rotate_backwards,hidemoverotate,trackball_rotate,show_fps; 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | storePreferences(); 17 | addPreferencesFromResource(R.xml.preferences); 18 | } 19 | 20 | public void storePreferences() { 21 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); 22 | SharedPreferences.Editor editor = sp.edit(); 23 | editor.putBoolean("trackball_rotate", trackball_rotate); 24 | editor.commit(); 25 | } 26 | 27 | public void updatePreferences() { 28 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); 29 | plate_visibility = sp.getBoolean("plate_visibility",false); 30 | rotation_speed = Float.parseFloat( sp.getString("rotation_speed","1") ); 31 | rotate_backwards = sp.getBoolean("rotate_backwards",false); 32 | trackball_rotate = sp.getBoolean("trackball_rotate",false); 33 | hidemoverotate = sp.getBoolean("hidemoverotate",false); 34 | show_fps = sp.getBoolean("show_fps",false); 35 | } 36 | 37 | @Override 38 | public boolean onKeyDown(int keyCode, KeyEvent event) { 39 | if ( keyCode == KeyEvent.KEYCODE_BACK ) { 40 | updatePreferences(); 41 | finish(); 42 | } 43 | return true; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Antikythera/res/xml/preferences.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 14 | 15 | 16 | 21 | 24 | 25 | 26 | 30 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Antikythera/res/layout/about.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 9 | 13 | 17 | 21 | 25 | 29 | 33 | 37 | 41 | 45 | 49 | 53 | 57 | 58 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012, Fivos Asim 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 18 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | The views and conclusions contained in the software and documentation are those 26 | of the authors and should not be interpreted as representing official policies, 27 | either expressed or implied, of the FreeBSD Project. 28 | */ 29 | 30 | The Antikythera Simulation android app is an interactive 3D simulation drawn with OpenGLES of the 2 best known models of the Antikythera Mechanism as developed by scientists, and in the same time a showcase of the capabilities of your android powered handset! 31 | These versions are preliminary ones, without much attention to the relative gear diameters or vertical positions. 32 | 33 | This android app is actually a port to Java of a C project with a few minor corrections and additions added in the way. It was developed using the Eclipse IDE under Ubuntu. 34 | You may find the original C project in the link below. It will run on any Windows machine and via Wine on Linux. 35 | http://www.etl.uom.gr/mr/index.php?mypage=antikythera_sim 36 | The C project is not yet open-sourced but it will become available sometime. 37 | 38 | The source code is published under the FreeBSD license, so you may use the code freely and for any cause you wish. Using a reference to the original source is encouraged and appreciated. Feel free to fork the program and make it even better. I will gladly commit good patches and acknowledge the contributors. 39 | 40 | Thanks for visiting. 41 | 42 | fivasim@gmail.com 43 | -------------------------------------------------------------------------------- /Antikythera/gen/com/fivasim/antikythera/R.java: -------------------------------------------------------------------------------- 1 | /* AUTO-GENERATED FILE. DO NOT MODIFY. 2 | * 3 | * This class was automatically generated by the 4 | * aapt tool from the resource data it found. It 5 | * should not be modified by hand. 6 | */ 7 | 8 | package com.fivasim.antikythera; 9 | 10 | public final class R { 11 | public static final class array { 12 | public static final int rotation_speed=0x7f050001; 13 | public static final int rotation_speed_titles=0x7f050000; 14 | } 15 | public static final class attr { 16 | } 17 | public static final class drawable { 18 | public static final int boxt=0x7f020000; 19 | public static final int fragmenta=0x7f020001; 20 | public static final int icon=0x7f020002; 21 | public static final int move=0x7f020003; 22 | public static final int rotate=0x7f020004; 23 | public static final int transparent_button=0x7f020005; 24 | } 25 | public static final class id { 26 | public static final int Button01=0x7f070003; 27 | public static final int Button02=0x7f070004; 28 | public static final int Button03=0x7f070005; 29 | public static final int Button04=0x7f070006; 30 | public static final int Button05=0x7f070007; 31 | public static final int glsurfaceview1=0x7f070000; 32 | public static final int moveresize=0x7f070002; 33 | public static final int tv=0x7f070001; 34 | } 35 | public static final class layout { 36 | public static final int about=0x7f030000; 37 | public static final int gllayout=0x7f030001; 38 | public static final int help=0x7f030002; 39 | public static final int main=0x7f030003; 40 | } 41 | public static final class string { 42 | public static final int about_text1=0x7f060003; 43 | public static final int about_text10=0x7f060010; 44 | public static final int about_text11=0x7f060011; 45 | public static final int about_text12=0x7f060013; 46 | public static final int about_text2=0x7f060012; 47 | public static final int about_text3=0x7f060004; 48 | public static final int about_text4=0x7f060005; 49 | public static final int about_text5=0x7f060006; 50 | public static final int about_text6=0x7f060007; 51 | public static final int about_text7=0x7f060008; 52 | public static final int about_text8=0x7f06000e; 53 | public static final int about_text9=0x7f06000f; 54 | public static final int about_title=0x7f060002; 55 | public static final int app_name=0x7f060001; 56 | public static final int controls_text=0x7f060009; 57 | public static final int controls_text1=0x7f06000a; 58 | public static final int controls_text2=0x7f06000b; 59 | public static final int controls_text3=0x7f06000c; 60 | public static final int controls_text4=0x7f06000d; 61 | public static final int hello=0x7f060000; 62 | public static final int version=0x7f060014; 63 | } 64 | public static final class xml { 65 | public static final int preferences=0x7f040000; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Antikythera/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 12 | 21 | 22 | 27 | 35 | 36 | 41 | 50 | 51 | 56 | 61 | 69 | 70 | 75 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /Antikythera/src/com/fivasim/antikythera/main.java: -------------------------------------------------------------------------------- 1 | package com.fivasim.antikythera; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.content.SharedPreferences; 6 | import android.os.Build; 7 | import android.os.Bundle; 8 | import android.preference.PreferenceManager; 9 | import android.view.KeyEvent; 10 | import android.view.View; 11 | import android.widget.Button; 12 | 13 | public class main extends Activity { 14 | /** Called when the activity is first created. */ 15 | @Override 16 | public void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.main); 19 | 20 | loadPreferences(); 21 | 22 | Button price = (Button) findViewById(R.id.Button01); 23 | price.setOnClickListener(new View.OnClickListener() { 24 | public void onClick(View view) { 25 | if( Build.VERSION.SDK_INT >= 7 ){ 26 | Intent myIntent = new Intent(view.getContext(), antikytherap.class); 27 | startActivityForResult(myIntent, 0); 28 | } else { 29 | Intent myIntent = new Intent(view.getContext(), antikytherap_nomulti.class); 30 | startActivityForResult(myIntent, 0); 31 | } 32 | } 33 | }); 34 | 35 | Button amrp = (Button) findViewById(R.id.Button02); 36 | amrp.setOnClickListener(new View.OnClickListener() { 37 | public void onClick(View view) { 38 | if( Build.VERSION.SDK_INT >= 7 ){ 39 | Intent myIntent = new Intent(view.getContext(), antikythera2.class); 40 | startActivityForResult(myIntent, 0); 41 | } else { 42 | Intent myIntent = new Intent(view.getContext(), antikythera2_nomulti.class); 43 | startActivityForResult(myIntent, 0); 44 | } 45 | } 46 | }); 47 | 48 | Button tests = (Button) findViewById(R.id.Button03); 49 | tests.setOnClickListener(new View.OnClickListener() { 50 | public void onClick(View view) { 51 | Intent myIntent = new Intent(view.getContext(), Preferences.class); 52 | startActivityForResult(myIntent, 0); 53 | } 54 | }); 55 | 56 | Button help = (Button) findViewById(R.id.Button04); 57 | help.setOnClickListener(new View.OnClickListener() { 58 | public void onClick(View view) { 59 | Intent myIntent = new Intent(view.getContext(), help.class); 60 | startActivityForResult(myIntent, 0); 61 | } 62 | }); 63 | 64 | Button about = (Button) findViewById(R.id.Button05); 65 | about.setOnClickListener(new View.OnClickListener() { 66 | public void onClick(View view) { 67 | Intent myIntent = new Intent(view.getContext(), About.class); 68 | startActivityForResult(myIntent, 0); 69 | } 70 | }); 71 | } 72 | 73 | private void loadPreferences() { 74 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); 75 | Preferences.plate_visibility = sp.getBoolean("plate_visibility",false); 76 | Preferences.rotation_speed = Float.parseFloat( sp.getString("rotation_speed","1") ); 77 | Preferences.rotate_backwards = sp.getBoolean("rotate_backwards",false); 78 | Preferences.trackball_rotate = sp.getBoolean("trackball_rotate",false); 79 | Preferences.show_fps = sp.getBoolean("show_fps",false); 80 | } 81 | 82 | @Override 83 | public boolean onKeyDown(int keyCode, KeyEvent event) { 84 | if ( keyCode == KeyEvent.KEYCODE_BACK ) { 85 | finish(); 86 | } 87 | if ( keyCode == KeyEvent.KEYCODE_MENU ) { 88 | startActivity(new Intent(this, Preferences.class)); 89 | } 90 | return true; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /Antikythera/src/com/fivasim/antikythera/Plate.java: -------------------------------------------------------------------------------- 1 | package com.fivasim.antikythera; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.nio.ByteOrder; 5 | import java.nio.FloatBuffer; 6 | import java.nio.ShortBuffer; 7 | 8 | import javax.microedition.khronos.opengles.GL10; 9 | 10 | public class Plate { 11 | private float plate_v[]; 12 | private short tplate_i[]; 13 | private short plate_i[]; 14 | private float ftexture_v[]; 15 | private float texture_v[]; 16 | private ShortBuffer tplate_indexBuffer; 17 | private FloatBuffer plate_vertexBuffer; 18 | private ShortBuffer plate_indexBuffer; 19 | private FloatBuffer ftextureBuffer; 20 | private FloatBuffer textureBuffer; 21 | 22 | public Plate( float width, float length, float z ) 23 | { 24 | plate_v = new float[]{ -width, length, z+1, 25 | width, length, z+1, 26 | width, -length, z+1, 27 | -width, -length, z+1, 28 | -width, length, z-1, 29 | width, length, z-1, 30 | width, -length, z-1, 31 | -width, -length, z-1 32 | }; 33 | if(z>0) { 34 | tplate_i = new short[]{1,0,3, 1,3,2};//front 35 | plate_i = new short[]{2,6,5, 2,5,1,//right 36 | 7,4,5, 7,5,6,//back 37 | 0,4,7, 0,7,3,//left 38 | 5,4,0, 5,0,1,//top 39 | 3,7,6, 3,6,2 //bottom 40 | }; 41 | ftexture_v = new float[]{ 42 | 0.86f, 1.0f, 43 | 0.125f,1.0f, 44 | 0.125f,0.51f, 45 | 0.86f, 0.51f 46 | }; 47 | }else{ 48 | tplate_i = new short[]{7,4,5, 6,7,5};//front 49 | plate_i = new short[]{2,6,5, 2,5,1,//right 50 | 1,0,3, 1,3,2,//back 51 | 0,4,7, 0,7,3,//left 52 | 5,4,0, 5,0,1,//top 53 | 3,7,6, 3,6,2 //bottom 54 | }; 55 | ftexture_v = new float[]{ 56 | 0.0f, 0.0f, 57 | 0.0f, 0.0f, 58 | 0.0f, 0.0f, 59 | 0.0f, 0.0f, 60 | 1.0f,0.52f, 61 | 0.0f,0.52f, 62 | 0.0f,0.0f, 63 | 1.0f,0.0f 64 | }; 65 | } 66 | 67 | texture_v = new float[]{ 68 | 0.2f, 1.0f, 69 | 0.0f, 1.0f, 70 | 0.0f, 0.5f, 71 | 0.2f, 0.5f, 72 | 0.2f, 1.0f, 73 | 0.0f, 1.0f, 74 | 0.0f, 0.5f, 75 | 0.2f, 0.5f 76 | }; 77 | // a float is 4 bytes, therefore we multiply the number of vertices with 4. 78 | ByteBuffer vbb1 = ByteBuffer.allocateDirect(plate_v.length * 4); 79 | vbb1.order(ByteOrder.nativeOrder()); 80 | plate_vertexBuffer = vbb1.asFloatBuffer(); 81 | plate_vertexBuffer.put(plate_v); 82 | plate_vertexBuffer.position(0); 83 | // short is 2 bytes, therefore we multiply the number of vertices with 2. 84 | ByteBuffer ibb1 = ByteBuffer.allocateDirect(plate_i.length * 2); 85 | ibb1.order(ByteOrder.nativeOrder()); 86 | plate_indexBuffer = ibb1.asShortBuffer(); 87 | plate_indexBuffer.put(plate_i); 88 | plate_indexBuffer.position(0); 89 | // short is 2 bytes, therefore we multiply the number of vertices with 2. 90 | ByteBuffer ibb2 = ByteBuffer.allocateDirect(tplate_i.length * 2); 91 | ibb2.order(ByteOrder.nativeOrder()); 92 | tplate_indexBuffer = ibb2.asShortBuffer(); 93 | tplate_indexBuffer.put(tplate_i); 94 | tplate_indexBuffer.position(0); 95 | 96 | // a float is 4 bytes, therefore we multiply the number of vertices with 4. 97 | ByteBuffer tbb2 = ByteBuffer.allocateDirect(ftexture_v.length * 4); 98 | tbb2.order(ByteOrder.nativeOrder()); 99 | ftextureBuffer = tbb2.asFloatBuffer(); 100 | ftextureBuffer.put(ftexture_v); 101 | ftextureBuffer.position(0); 102 | // a float is 4 bytes, therefore we multiply the number of vertices with 4. 103 | ByteBuffer tbb = ByteBuffer.allocateDirect(texture_v.length * 4); 104 | tbb.order(ByteOrder.nativeOrder()); 105 | textureBuffer = tbb.asFloatBuffer(); 106 | textureBuffer.put(texture_v); 107 | textureBuffer.position(0); 108 | } 109 | 110 | public void draw(GL10 gl) { 111 | // Counter-clockwise winding. 112 | gl.glFrontFace(GL10.GL_CCW); 113 | gl.glEnable(GL10.GL_CULL_FACE); 114 | gl.glCullFace(GL10.GL_BACK); 115 | gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); 116 | 117 | gl.glEnable(GL10.GL_TEXTURE_2D); 118 | gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); 119 | // Specifies the location and data format of an array of vertex coordinates to use when rendering. 120 | gl.glVertexPointer(3, GL10.GL_FLOAT, 0, plate_vertexBuffer); 121 | gl.glEnable(GL10.GL_TEXTURE_2D); 122 | gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer); 123 | gl.glDrawElements(GL10.GL_TRIANGLES, plate_i.length, GL10.GL_UNSIGNED_SHORT, plate_indexBuffer); 124 | gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, ftextureBuffer); 125 | gl.glDrawElements(GL10.GL_TRIANGLES, tplate_i.length, GL10.GL_UNSIGNED_SHORT, tplate_indexBuffer); 126 | 127 | gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); 128 | gl.glDisable(GL10.GL_CULL_FACE); 129 | 130 | gl.glDisable(GL10.GL_TEXTURE_2D); 131 | gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); 132 | } 133 | 134 | } 135 | 136 | -------------------------------------------------------------------------------- /Antikythera/src/com/fivasim/antikythera/Pointer.java: -------------------------------------------------------------------------------- 1 | package com.fivasim.antikythera; 2 | 3 | import static com.fivasim.antikythera.Initial.color; 4 | 5 | import java.nio.ByteBuffer; 6 | import java.nio.ByteOrder; 7 | import java.nio.FloatBuffer; 8 | import java.nio.ShortBuffer; 9 | 10 | import javax.microedition.khronos.opengles.GL10; 11 | 12 | public class Pointer { 13 | private float pointer_v[]; 14 | private short pointer_i[]; 15 | private short pointerpin_i[]; 16 | private FloatBuffer pointer_vertexBuffer; 17 | private ShortBuffer pointer_indexBuffer; 18 | private ShortBuffer pointerpin_indexBuffer; 19 | 20 | public Pointer( float length, float[] pointerpos ) 21 | { 22 | pointerpin_i = new short[9]; 23 | pointer_i = new short[10]; 24 | pointer_v = new float[33]; 25 | 26 | short count = 0; 27 | short count_i = 0; 28 | if(length>=3f) { 29 | float width = 2.0f; //Πλάτος δείκτη 30 | float thickness = 0.9f; //Πάχος δείκτη 31 | //Βραχίονας δείκτη 32 | //front1 33 | pointer_v[count] = (float)(length-3); count++; 34 | pointer_v[count] = (float)(-width/2); count++; 35 | pointer_v[count] = (float)(-thickness/2); count++; 36 | pointer_i[count_i]=count_i;count_i++; 37 | pointer_v[count] = 0.0f; count++; 38 | pointer_v[count] = (float)(-width/2); count++; 39 | pointer_v[count] = (float)(-thickness/2); count++; 40 | pointer_i[count_i]=count_i;count_i++; 41 | pointer_v[count] = (float)(length-3); count++; 42 | pointer_v[count] = (float)( width/2); count++; 43 | pointer_v[count] = (float)(-thickness/2); count++; 44 | pointer_i[count_i]=count_i;count_i++; 45 | //front2 46 | pointer_v[count] = 0.0f; count++; 47 | pointer_v[count] = (float)( width/2); count++; 48 | pointer_v[count] = (float)(-thickness/2); count++; 49 | pointer_i[count_i]=count_i;count_i++; 50 | //up1 51 | pointer_v[count] = (float)(length-3); count++; 52 | pointer_v[count] = (float)( width/2); count++; 53 | pointer_v[count] = (float)( thickness/2); count++; 54 | pointer_i[count_i]=count_i;count_i++; 55 | //up2 56 | pointer_v[count] = 0.0f; count++; 57 | pointer_v[count] = (float)( width/2); count++; 58 | pointer_v[count] = (float)( thickness/2); count++; 59 | pointer_i[count_i]=count_i;count_i++; 60 | //back1 61 | pointer_v[count] = (float)(length-3); count++; 62 | pointer_v[count] = (float)(-width/2); count++; 63 | pointer_v[count] = (float)( thickness/2); count++; 64 | pointer_i[count_i]=count_i;count_i++; 65 | //back2 66 | pointer_v[count] = 0.0f; count++; 67 | pointer_v[count] = (float)(-width/2); count++; 68 | pointer_v[count] = (float)( thickness/2); count++; 69 | pointer_i[count_i]=count_i;count_i++; 70 | //down1 71 | pointer_v[count] = (float)(length-3); count++; 72 | pointer_v[count] = (float)(-width/2); count++; 73 | pointer_v[count] = (float)(-thickness/2); count++; 74 | pointer_i[count_i]=count_i;count_i++; 75 | //down2 76 | pointer_v[count] = 0.0f; count++; 77 | pointer_v[count] = (float)(-width/2); count++; 78 | pointer_v[count] = (float)(-thickness/2); count++; 79 | pointer_i[count_i]=count_i;count_i++; 80 | //final bound to start pointer pin 81 | short arrow_point = count_i; 82 | pointer_v[count] = length; count++; 83 | pointer_v[count] = 0f; count++; 84 | pointer_v[count] = 0f; count++; 85 | //Βέλος δείκτη 86 | count_i = 0; 87 | pointerpin_i[count_i]=0;count_i++; 88 | pointerpin_i[count_i]=2;count_i++; 89 | pointerpin_i[count_i]=arrow_point;count_i++; 90 | pointerpin_i[count_i]=4;count_i++; 91 | pointerpin_i[count_i]=arrow_point;count_i++; 92 | pointerpin_i[count_i]=6;count_i++; 93 | pointerpin_i[count_i]=arrow_point;count_i++; 94 | pointerpin_i[count_i]=0;count_i++; 95 | pointerpin_i[count_i]=arrow_point;count_i++; 96 | } 97 | // a float is 4 bytes, therefore we multiply the number of vertices with 4. 98 | ByteBuffer vbb1 = ByteBuffer.allocateDirect(pointer_v.length * 4); 99 | vbb1.order(ByteOrder.nativeOrder()); 100 | pointer_vertexBuffer = vbb1.asFloatBuffer(); 101 | pointer_vertexBuffer.put(pointer_v); 102 | pointer_vertexBuffer.position(0); 103 | // short is 2 bytes, therefore we multiply the number of vertices with 2. 104 | ByteBuffer ibb1 = ByteBuffer.allocateDirect(pointer_i.length * 2); 105 | ibb1.order(ByteOrder.nativeOrder()); 106 | pointer_indexBuffer = ibb1.asShortBuffer(); 107 | pointer_indexBuffer.put(pointer_i); 108 | pointer_indexBuffer.position(0); 109 | // short is 2 bytes, therefore we multiply the number of vertices with 2. 110 | ByteBuffer ibb2 = ByteBuffer.allocateDirect(pointerpin_i.length * 2); 111 | ibb2.order(ByteOrder.nativeOrder()); 112 | pointerpin_indexBuffer = ibb2.asShortBuffer(); 113 | pointerpin_indexBuffer.put(pointerpin_i); 114 | pointerpin_indexBuffer.position(0); 115 | 116 | } 117 | 118 | public void draw(GL10 gl, int color_pointer ) { 119 | // Counter-clockwise winding. 120 | gl.glFrontFace(GL10.GL_CCW); 121 | gl.glEnable(GL10.GL_CULL_FACE); 122 | gl.glCullFace(GL10.GL_BACK); 123 | gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); 124 | 125 | gl.glColor4f( color[color_pointer][0], color[color_pointer][1], 126 | color[color_pointer][2], color[color_pointer][3] ); 127 | // Specifies the location and data format of an array of vertex 128 | // coordinates to use when rendering. 129 | gl.glVertexPointer(3, GL10.GL_FLOAT, 0, pointer_vertexBuffer); 130 | gl.glDrawElements(GL10.GL_TRIANGLE_STRIP, pointer_i.length, GL10.GL_UNSIGNED_SHORT, pointer_indexBuffer); 131 | gl.glDrawElements(GL10.GL_TRIANGLE_STRIP, pointerpin_i.length, GL10.GL_UNSIGNED_SHORT, pointerpin_indexBuffer); 132 | 133 | 134 | gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); 135 | gl.glDisable(GL10.GL_CULL_FACE); 136 | 137 | } 138 | 139 | } 140 | 141 | -------------------------------------------------------------------------------- /Antikythera/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello World, antikythera! 4 | Antikythera Simulation 5 | 6 | Antikythera Mechanism 3D Simulation 7 | 8 | 9 | The extraordinary \"Antikythera Mechanism\" is the oldest known complex scientific calculator, 10 | and it was built in Ancient Greece. 11 | Although it was built around 150-100BC it\'s degree of mechanical sophistication is 12 | comparable to a 19th century Swiss clock. 13 | It was discovered in 1900 an ancient mechanism was found by sponge divers at 14 | the bottom of the sea near the island of Antikythera. Though it\'s complexity was not yet 15 | acknowledged it astonished the whole international community of experts on the ancient world. 16 | 17 | 18 | This app is a 3D simulation of the 2 best known models, using OpenGLES 1.0 for 3D modelling. 19 | Discover the 3D capabilities of OpenGLES on Android smartphones. 20 | 21 | 22 | - The model of Brittish science historian Derek De Solla Price: 23 | In 1974 and after 23 years of research he published a model of how the mechanism 24 | could have functioned. 25 | 26 | 27 | - The model of Antikythera Mechanism Research Project (AMRP): 28 | A joint program between Cardiff University (M. Edmunds, T. Freeth), the National and 29 | Kapodistrian University of Athens (X. Moussas, Y. Bitsakis), the Aristotle University of 30 | Thessaloniki (J.H. Seiradakis), the National Archaeological Museum of Athens, X-Tek Systems UK[47] 31 | and Hewlett-Packard USA, funded by the Leverhulme Trust and supported by the 32 | Cultural Foundation of the National Bank of Greece. 33 | 34 | 35 | These versions are preliminary ones, without much attention to the relative gear 36 | diameters or vertical positions. However, the tooth count of the gears and the operation are 37 | accurate. 38 | 39 | 40 | Rotate the mechanism, pinch zoom in and out and do lots of fun stuff to this high quality 41 | 3D model. 42 | 43 | 44 | Controls 45 | 46 | 47 | Touch screen to rotate or pan (see \"preferences\"). Trackball and touchpad are supported. 48 | 49 | 50 | Pinch with two fingers to zoom in / zoom out, or use the VolUp / VolDown keys. 51 | (Multi-touch not supported on certain devices) 52 | 53 | 54 | Toggle touch input to cause rotation or panning of the model by tapping the appropriate button in the bottom right of the screen (or by clicking the trackball, 55 | DPAD center, or the camera button). 56 | 57 | 58 | Click MENU to show the Preference screen at any time. 59 | 60 | 61 | Have fun! 62 | 63 | 64 | For reporting bugs or making suggestions please contact me at fivasim@gmail.com 65 | Thank you!\n\n\n 66 | The Antikythera Simulation is an open source project created by Fiv Asim. The sources can be found at github:\n 67 | https://github.com/fivasim/Antikythera-Simulation\n\n\n 68 | 69 | 70 | Enjoy! 71 | 72 | 73 | How did it work? 74 | 75 | 76 | 110 years of research and still we are not fully aware of the Antikythera Mechanism functionality, 77 | although we now know that it was used for astronomical measurements with extreme complexity and precision. 78 | It is also possible that it was used for navigational purposes as well. 79 | Functionality is summarized below. 80 | 81 | 82 | On the side of the mechanism there is a handle which the user turns to set the mechanism in motion. 83 | Via the gears the motion is transferred to the pointers in the front and back faces of the mechanism. 84 | On the front side the long pointer indicates the position of the sun, and the short one is about the moon.\n 85 | The readings on the front side indicate the greek names of the signs of the zodiac circle (the constellations along the ecliptic- 86 | the apparent movement of the sun on the sky), and the egyptian names of the months, but written in greek letters. 87 | The ancient greeks used to calculate years according to the sun and months according to the moon. 88 | In the back side there are three dials on this simulation but probably more existed in the real thing. 89 | Those dials are calculating the Metonian period (6949 days) which is the smallest time period containing an 90 | non-decimal number of moon months and sun years, the Callipic period which equals four Metonian periods and 91 | the Saros period which combined to the two periods mentioned before could help predict a solar or lunar eclipse. 92 | Movement of planets visible with the naked eye is also speculated to have existed.\n 93 | Also, it might have been used for navigation since its precision allowed the user to determine the difference 94 | in the readings compared to the actual vision of the sky, thus showing if there is any difference between the 95 | users speculative position and his actual position.\n 96 | Last but not least, a full instruction text was written all over the container of the mechanism, 97 | a \"user manual\" making it usable by an average person (average meaning not a scientist) and 98 | it most certainly was a highly mobile device, used for precise and sophisticated calendar-like calculations. 99 | Much of the Mechanism\'s mysteries still await to be brought to light... 100 | 101 | 102 | Antikythera Simulation v0.97 103 | 104 | 105 | -------------------------------------------------------------------------------- /Antikythera/src/com/fivasim/antikythera/antikytherap_nomulti.java: -------------------------------------------------------------------------------- 1 | package com.fivasim.antikythera; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.content.SharedPreferences; 6 | import android.graphics.Bitmap; 7 | import android.graphics.BitmapFactory; 8 | import android.os.Bundle; 9 | import android.opengl.GLSurfaceView; 10 | import android.view.KeyEvent; 11 | import android.view.MotionEvent; 12 | import android.view.View; 13 | import android.view.View.OnClickListener; 14 | import android.widget.ImageView; 15 | import android.widget.TextView; 16 | import android.widget.Toast; 17 | import android.os.Handler; 18 | import android.preference.PreferenceManager; 19 | 20 | import static com.fivasim.antikythera.OpenGLRenderer.*; 21 | 22 | public class antikytherap_nomulti extends Activity { 23 | public char type = 'p'; 24 | public static TextView tv; 25 | public static ImageView iv; 26 | public static float fps; 27 | public static Bitmap bitmap; 28 | private Handler mHandler = new Handler(); 29 | /** Called when the activity is first created. */ 30 | @Override 31 | public void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | BitmapFactory.Options opt = new BitmapFactory.Options(); 34 | opt.inPreferredConfig = Bitmap.Config.RGB_565; 35 | opt.inScaled = false; 36 | bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.boxt, opt); 37 | 38 | setContentView(R.layout.gllayout); 39 | GLSurfaceView view = (GLSurfaceView) findViewById(R.id.glsurfaceview1); 40 | view.setRenderer(new OpenGLRenderer()); 41 | 42 | tv = (TextView) findViewById(R.id.tv); 43 | iv = (ImageView) findViewById(R.id.moveresize); 44 | } 45 | 46 | @Override 47 | public void onPause() { 48 | super.onPause(); 49 | mHandler.removeCallbacks(mUpdateTimeTask); 50 | } 51 | 52 | @Override 53 | public void onResume() { 54 | super.onResume(); 55 | timestamp = 0; 56 | fps = 0f; 57 | } 58 | 59 | @Override 60 | public void onStart() { 61 | super.onStart(); 62 | loadPreferences(); 63 | timestamp = 0; 64 | fps = 0f; 65 | if (Preferences.hidemoverotate) {iv.setVisibility(View.INVISIBLE);} 66 | else {iv.setVisibility(View.VISIBLE);} 67 | if (Preferences.trackball_rotate) {iv.setImageResource(R.drawable.move);} 68 | iv.setOnClickListener(new OnClickListener() { 69 | public void onClick(View v) { 70 | Preferences.trackball_rotate = !Preferences.trackball_rotate; 71 | if (Preferences.trackball_rotate) { 72 | Toast.makeText( getApplicationContext(), "Touch screen to pan", Toast.LENGTH_SHORT).show(); 73 | iv.setImageResource(R.drawable.move); 74 | } else { 75 | Toast.makeText( getApplicationContext(), "Touch screen to rotate", Toast.LENGTH_SHORT).show(); 76 | iv.setImageResource(R.drawable.rotate); 77 | } 78 | } 79 | }); 80 | 81 | mHandler.removeCallbacks(mUpdateTimeTask); 82 | if (Preferences.show_fps) { 83 | tv.setVisibility(View.VISIBLE); 84 | mHandler.postDelayed(mUpdateTimeTask, 100); 85 | } else { 86 | tv.setVisibility(View.INVISIBLE); 87 | } 88 | } 89 | 90 | private void loadPreferences() { 91 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); 92 | Preferences.plate_visibility = sp.getBoolean("plate_visibility",false); 93 | Preferences.rotation_speed = Float.parseFloat( sp.getString("rotation_speed","1") ); 94 | Preferences.rotate_backwards = sp.getBoolean("rotate_backwards",false); 95 | Preferences.trackball_rotate = sp.getBoolean("trackball_rotate",false); 96 | Preferences.show_fps = sp.getBoolean("show_fps",false); 97 | Preferences.hidemoverotate = sp.getBoolean("hidemoverotate",false); 98 | } 99 | 100 | private Runnable mUpdateTimeTask = new Runnable() { 101 | public void run() { 102 | if (Preferences.show_fps) { 103 | tv.setText( String.format("%.2f fps",fps)); 104 | } else { 105 | tv.setVisibility(View.INVISIBLE); 106 | } 107 | mHandler.postDelayed(this, 400 ); 108 | } 109 | }; 110 | 111 | @Override 112 | public boolean onTouchEvent(MotionEvent event) { 113 | switch (event.getAction() & MotionEvent.ACTION_MASK ) { 114 | case MotionEvent.ACTION_MOVE: 115 | if(touchmode == 1) { 116 | if (Preferences.trackball_rotate) { 117 | position_x -= (float)( (curX-event.getX())/10 ); 118 | position_y += (float)( (curY-event.getY())/10 ); 119 | curX = event.getX(); 120 | curY = event.getY(); 121 | } else { 122 | fullrotate_y -= (float)( (curX-event.getX())/10 ); 123 | fullrotate_x -= (float)( (curY-event.getY())/10 ); 124 | curX = event.getX(); 125 | curY = event.getY(); 126 | } 127 | } 128 | break; 129 | case MotionEvent.ACTION_DOWN: 130 | touchmode = 1; 131 | curX = event.getX(); 132 | curY = event.getY(); 133 | break; 134 | case MotionEvent.ACTION_UP: 135 | touchmode = 0; 136 | curX = event.getX(); 137 | curY = event.getY(); 138 | break; 139 | } 140 | return true; 141 | } 142 | 143 | @Override 144 | public boolean onTrackballEvent(MotionEvent event) { 145 | if (event.getAction() == MotionEvent.ACTION_MOVE) { 146 | if (Preferences.trackball_rotate) { 147 | fullrotate_y += (float)( (6*event.getX()) ); 148 | fullrotate_x += (float)( (6*event.getY()) ); 149 | } else { 150 | position_x += (float)( (6*event.getX()) ); 151 | position_y -= (float)( (6*event.getY()) ); 152 | } 153 | } else if (event.getAction() == MotionEvent.ACTION_DOWN) { 154 | Preferences.trackball_rotate = !Preferences.trackball_rotate; 155 | if (Preferences.trackball_rotate) { 156 | Toast.makeText( getApplicationContext(), "Touch screen to pan", Toast.LENGTH_SHORT).show(); 157 | } else { 158 | Toast.makeText( getApplicationContext(), "Touch screen to rotate", Toast.LENGTH_SHORT).show(); 159 | } 160 | } 161 | return true; 162 | } 163 | 164 | @Override 165 | public boolean onKeyDown(int keyCode, KeyEvent event) { 166 | if ( keyCode == KeyEvent.KEYCODE_BACK ) { 167 | bitmap.recycle(); 168 | mHandler.removeCallbacks(mUpdateTimeTask); 169 | finish(); 170 | } else if ( keyCode == KeyEvent.KEYCODE_MENU ) { 171 | startActivity(new Intent(this, Preferences.class)); 172 | } else if ( keyCode == KeyEvent.KEYCODE_VOLUME_UP ) { 173 | zoomfac += 5f; 174 | } else if ( keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ) { 175 | zoomfac -= 5f; 176 | } else if ( keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_CAMERA ) { 177 | Preferences.trackball_rotate = !Preferences.trackball_rotate; 178 | if (Preferences.trackball_rotate) { 179 | Toast.makeText( getApplicationContext(), "Touch screen to pan", Toast.LENGTH_SHORT).show(); 180 | } else { 181 | Toast.makeText( getApplicationContext(), "Touch screen to rotate", Toast.LENGTH_SHORT).show(); 182 | } 183 | } 184 | return true; 185 | } 186 | } -------------------------------------------------------------------------------- /Antikythera/src/com/fivasim/antikythera/antikythera2_nomulti.java: -------------------------------------------------------------------------------- 1 | package com.fivasim.antikythera; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.content.SharedPreferences; 6 | import android.graphics.Bitmap; 7 | import android.graphics.BitmapFactory; 8 | import android.os.Bundle; 9 | import android.opengl.GLSurfaceView; 10 | import android.view.KeyEvent; 11 | import android.view.MotionEvent; 12 | import android.view.View; 13 | import android.view.View.OnClickListener; 14 | import android.widget.ImageView; 15 | import android.widget.TextView; 16 | import android.widget.Toast; 17 | import android.os.Handler; 18 | import android.preference.PreferenceManager; 19 | 20 | import static com.fivasim.antikythera.OpenGLRenderer2.*; 21 | 22 | public class antikythera2_nomulti extends Activity { 23 | public char type = 'p'; 24 | public static TextView tv; 25 | public static ImageView iv; 26 | public static float fps; 27 | public static Bitmap bitmap; 28 | private Handler mHandler = new Handler(); 29 | /** Called when the activity is first created. */ 30 | @Override 31 | public void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | BitmapFactory.Options opt = new BitmapFactory.Options(); 34 | opt.inPreferredConfig = Bitmap.Config.RGB_565; 35 | opt.inScaled = false; 36 | bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.boxt, opt); 37 | 38 | setContentView(R.layout.gllayout); 39 | GLSurfaceView view = (GLSurfaceView) findViewById(R.id.glsurfaceview1); 40 | view.setRenderer(new OpenGLRenderer2()); 41 | 42 | tv = (TextView) findViewById(R.id.tv); 43 | iv = (ImageView) findViewById(R.id.moveresize); 44 | } 45 | 46 | @Override 47 | public void onPause() { 48 | super.onPause(); 49 | mHandler.removeCallbacks(mUpdateTimeTask); 50 | } 51 | 52 | @Override 53 | public void onResume() { 54 | super.onResume(); 55 | timestamp = 0; 56 | fps = 0f; 57 | } 58 | 59 | @Override 60 | public void onStart() { 61 | super.onStart(); 62 | loadPreferences(); 63 | timestamp = 0; 64 | fps = 0f; 65 | if (Preferences.hidemoverotate) {iv.setVisibility(View.INVISIBLE);} 66 | else {iv.setVisibility(View.VISIBLE);} 67 | if (Preferences.trackball_rotate) {iv.setImageResource(R.drawable.move);} 68 | iv.setOnClickListener(new OnClickListener() { 69 | public void onClick(View v) { 70 | Preferences.trackball_rotate = !Preferences.trackball_rotate; 71 | if (Preferences.trackball_rotate) { 72 | Toast.makeText( getApplicationContext(), "Touch screen to pan", Toast.LENGTH_SHORT).show(); 73 | iv.setImageResource(R.drawable.move); 74 | } else { 75 | Toast.makeText( getApplicationContext(), "Touch screen to rotate", Toast.LENGTH_SHORT).show(); 76 | iv.setImageResource(R.drawable.rotate); 77 | } 78 | } 79 | }); 80 | 81 | mHandler.removeCallbacks(mUpdateTimeTask); 82 | if (Preferences.show_fps) { 83 | tv.setVisibility(View.VISIBLE); 84 | mHandler.postDelayed(mUpdateTimeTask, 100); 85 | } else { 86 | tv.setVisibility(View.INVISIBLE); 87 | } 88 | } 89 | 90 | private void loadPreferences() { 91 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); 92 | Preferences.plate_visibility = sp.getBoolean("plate_visibility",false); 93 | Preferences.rotation_speed = Float.parseFloat( sp.getString("rotation_speed","1") ); 94 | Preferences.rotate_backwards = sp.getBoolean("rotate_backwards",false); 95 | Preferences.trackball_rotate = sp.getBoolean("trackball_rotate",false); 96 | Preferences.show_fps = sp.getBoolean("show_fps",false); 97 | Preferences.hidemoverotate = sp.getBoolean("hidemoverotate",false); 98 | } 99 | 100 | private Runnable mUpdateTimeTask = new Runnable() { 101 | public void run() { 102 | if (Preferences.show_fps) { 103 | tv.setText( String.format("%.2f fps",fps)); 104 | } else { 105 | tv.setVisibility(View.INVISIBLE); 106 | } 107 | mHandler.postDelayed(this, 400 ); 108 | } 109 | }; 110 | 111 | @Override 112 | public boolean onTouchEvent(MotionEvent event) { 113 | switch (event.getAction() & MotionEvent.ACTION_MASK ) { 114 | case MotionEvent.ACTION_MOVE: 115 | if(touchmode == 1) { 116 | if (Preferences.trackball_rotate) { 117 | position_x -= (float)( (curX-event.getX())/10 ); 118 | position_y += (float)( (curY-event.getY())/10 ); 119 | curX = event.getX(); 120 | curY = event.getY(); 121 | } else { 122 | fullrotate_y -= (float)( (curX-event.getX())/10 ); 123 | fullrotate_x -= (float)( (curY-event.getY())/10 ); 124 | curX = event.getX(); 125 | curY = event.getY(); 126 | } 127 | } 128 | break; 129 | case MotionEvent.ACTION_DOWN: 130 | touchmode = 1; 131 | curX = event.getX(); 132 | curY = event.getY(); 133 | break; 134 | case MotionEvent.ACTION_UP: 135 | touchmode = 0; 136 | curX = event.getX(); 137 | curY = event.getY(); 138 | break; 139 | } 140 | return true; 141 | } 142 | 143 | @Override 144 | public boolean onTrackballEvent(MotionEvent event) { 145 | if (event.getAction() == MotionEvent.ACTION_MOVE) { 146 | if (Preferences.trackball_rotate) { 147 | fullrotate_y += (float)( (6*event.getX()) ); 148 | fullrotate_x += (float)( (6*event.getY()) ); 149 | } else { 150 | position_x += (float)( (6*event.getX()) ); 151 | position_y -= (float)( (6*event.getY()) ); 152 | } 153 | } else if (event.getAction() == MotionEvent.ACTION_DOWN) { 154 | Preferences.trackball_rotate = !Preferences.trackball_rotate; 155 | if (Preferences.trackball_rotate) { 156 | Toast.makeText( getApplicationContext(), "Touch screen to pan", Toast.LENGTH_SHORT).show(); 157 | } else { 158 | Toast.makeText( getApplicationContext(), "Touch screen to rotate", Toast.LENGTH_SHORT).show(); 159 | } 160 | } 161 | return true; 162 | } 163 | 164 | @Override 165 | public boolean onKeyDown(int keyCode, KeyEvent event) { 166 | if ( keyCode == KeyEvent.KEYCODE_BACK ) { 167 | bitmap.recycle(); 168 | mHandler.removeCallbacks(mUpdateTimeTask); 169 | finish(); 170 | } else if ( keyCode == KeyEvent.KEYCODE_MENU ) { 171 | startActivity(new Intent(this, Preferences.class)); 172 | } else if ( keyCode == KeyEvent.KEYCODE_VOLUME_UP ) { 173 | zoomfac += 5f; 174 | } else if ( keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ) { 175 | zoomfac -= 5f; 176 | } else if ( keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_CAMERA ) { 177 | Preferences.trackball_rotate = !Preferences.trackball_rotate; 178 | if (Preferences.trackball_rotate) { 179 | Toast.makeText( getApplicationContext(), "Touch screen to pan", Toast.LENGTH_SHORT).show(); 180 | } else { 181 | Toast.makeText( getApplicationContext(), "Touch screen to rotate", Toast.LENGTH_SHORT).show(); 182 | } 183 | } 184 | return true; 185 | } 186 | 187 | } -------------------------------------------------------------------------------- /Antikythera/src/com/fivasim/antikythera/antikytherap.java: -------------------------------------------------------------------------------- 1 | package com.fivasim.antikythera; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.content.SharedPreferences; 6 | import android.graphics.Bitmap; 7 | import android.graphics.BitmapFactory; 8 | import android.os.Bundle; 9 | import android.opengl.GLSurfaceView; 10 | import android.view.KeyEvent; 11 | import android.view.MotionEvent; 12 | import android.view.View; 13 | import android.view.View.OnClickListener; 14 | import android.widget.ImageView; 15 | import android.widget.TextView; 16 | import android.widget.Toast; 17 | import android.os.Handler; 18 | import android.preference.PreferenceManager; 19 | 20 | import static com.fivasim.antikythera.OpenGLRenderer.*; 21 | 22 | public class antikytherap extends Activity { 23 | public char type = 'p'; 24 | public static TextView tv; 25 | public static ImageView iv; 26 | public static float fps; 27 | public static Bitmap bitmap; 28 | private Handler mHandler = new Handler(); 29 | /** Called when the activity is first created. */ 30 | @Override 31 | public void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | BitmapFactory.Options opt = new BitmapFactory.Options(); 34 | opt.inPreferredConfig = Bitmap.Config.RGB_565; 35 | opt.inScaled = false; 36 | bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.boxt, opt); 37 | 38 | setContentView(R.layout.gllayout); 39 | GLSurfaceView view = (GLSurfaceView) findViewById(R.id.glsurfaceview1); 40 | view.setRenderer(new OpenGLRenderer()); 41 | 42 | tv = (TextView) findViewById(R.id.tv); 43 | iv = (ImageView) findViewById(R.id.moveresize); 44 | } 45 | 46 | @Override 47 | public void onPause() { 48 | super.onPause(); 49 | mHandler.removeCallbacks(mUpdateTimeTask); 50 | } 51 | 52 | @Override 53 | public void onResume() { 54 | super.onResume(); 55 | timestamp = 0; 56 | fps = 0f; 57 | } 58 | 59 | @Override 60 | public void onStart() { 61 | super.onStart(); 62 | loadPreferences(); 63 | timestamp = 0; 64 | fps = 0f; 65 | if (Preferences.hidemoverotate) {iv.setVisibility(View.INVISIBLE);} 66 | else {iv.setVisibility(View.VISIBLE);} 67 | if (Preferences.trackball_rotate) {iv.setImageResource(R.drawable.move);} 68 | iv.setOnClickListener(new OnClickListener() { 69 | public void onClick(View v) { 70 | Preferences.trackball_rotate = !Preferences.trackball_rotate; 71 | if (Preferences.trackball_rotate) { 72 | Toast.makeText( getApplicationContext(), "Touch screen to pan", Toast.LENGTH_SHORT).show(); 73 | iv.setImageResource(R.drawable.move); 74 | } else { 75 | Toast.makeText( getApplicationContext(), "Touch screen to rotate", Toast.LENGTH_SHORT).show(); 76 | iv.setImageResource(R.drawable.rotate); 77 | } 78 | } 79 | }); 80 | 81 | mHandler.removeCallbacks(mUpdateTimeTask); 82 | if (Preferences.show_fps) { 83 | tv.setVisibility(View.VISIBLE); 84 | mHandler.postDelayed(mUpdateTimeTask, 100); 85 | } else { 86 | tv.setVisibility(View.INVISIBLE); 87 | } 88 | } 89 | 90 | private void loadPreferences() { 91 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); 92 | Preferences.plate_visibility = sp.getBoolean("plate_visibility",false); 93 | Preferences.rotation_speed = Float.parseFloat( sp.getString("rotation_speed","1") ); 94 | Preferences.rotate_backwards = sp.getBoolean("rotate_backwards",false); 95 | Preferences.trackball_rotate = sp.getBoolean("trackball_rotate",false); 96 | Preferences.show_fps = sp.getBoolean("show_fps",false); 97 | Preferences.hidemoverotate = sp.getBoolean("hidemoverotate",false); 98 | } 99 | 100 | private Runnable mUpdateTimeTask = new Runnable() { 101 | public void run() { 102 | if (Preferences.show_fps) { 103 | tv.setText( String.format("%.2f fps",fps)); 104 | } else { 105 | tv.setVisibility(View.INVISIBLE); 106 | } 107 | mHandler.postDelayed(this, 400 ); 108 | } 109 | }; 110 | 111 | @Override 112 | public boolean onTouchEvent(MotionEvent event) { 113 | switch (event.getAction() & MotionEvent.ACTION_MASK ) { 114 | case MotionEvent.ACTION_MOVE: 115 | if(touchmode == 1) { 116 | if (Preferences.trackball_rotate) { 117 | position_x -= (float)( (curX-event.getX(0))/10 ); 118 | position_y += (float)( (curY-event.getY(0))/10 ); 119 | curX = event.getX(0); 120 | curY = event.getY(0); 121 | } else { 122 | fullrotate_y -= (float)( (curX-event.getX(0))/10 ); 123 | fullrotate_x -= (float)( (curY-event.getY(0))/10 ); 124 | curX = event.getX(0); 125 | curY = event.getY(0); 126 | } 127 | } else if (touchmode == 2) { 128 | float x = event.getX(0) - event.getX(1); 129 | float y = event.getY(0) - event.getY(1); 130 | float Dist = (float)Math.sqrt(x * x + y * y); 131 | zoomfac += (float)((Dist - curDist)/10); 132 | curDist = (float)Math.sqrt(x * x + y * y); 133 | } 134 | break; 135 | case MotionEvent.ACTION_DOWN: 136 | touchmode = 1; 137 | curX = event.getX(0); 138 | curY = event.getY(0); 139 | break; 140 | case MotionEvent.ACTION_UP: 141 | touchmode = 0; 142 | curX = event.getX(0); 143 | curY = event.getY(0); 144 | break; 145 | case MotionEvent.ACTION_POINTER_DOWN: 146 | touchmode = 2; 147 | float x = event.getX(0) - event.getX(1); 148 | float y = event.getY(0) - event.getY(1); 149 | curDist = (float)Math.sqrt(x * x + y * y); 150 | break; 151 | case MotionEvent.ACTION_POINTER_UP: 152 | touchmode = 0; 153 | break; 154 | } 155 | return true; 156 | } 157 | 158 | @Override 159 | public boolean onTrackballEvent(MotionEvent event) { 160 | if (event.getAction() == MotionEvent.ACTION_MOVE) { 161 | if (Preferences.trackball_rotate) { 162 | fullrotate_y += (float)( (6*event.getX(0)) ); 163 | fullrotate_x += (float)( (6*event.getY(0)) ); 164 | } else { 165 | position_x += (float)( (6*event.getX(0)) ); 166 | position_y -= (float)( (6*event.getY(0)) ); 167 | } 168 | } else if (event.getAction() == MotionEvent.ACTION_DOWN) { 169 | Preferences.trackball_rotate = !Preferences.trackball_rotate; 170 | if (Preferences.trackball_rotate) { 171 | Toast.makeText( getApplicationContext(), "Touch screen to pan", Toast.LENGTH_SHORT).show(); 172 | } else { 173 | Toast.makeText( getApplicationContext(), "Touch screen to rotate", Toast.LENGTH_SHORT).show(); 174 | } 175 | } 176 | return true; 177 | } 178 | 179 | @Override 180 | public boolean onKeyDown(int keyCode, KeyEvent event) { 181 | if ( keyCode == KeyEvent.KEYCODE_BACK ) { 182 | bitmap.recycle(); 183 | mHandler.removeCallbacks(mUpdateTimeTask); 184 | finish(); 185 | } else if ( keyCode == KeyEvent.KEYCODE_MENU ) { 186 | startActivity(new Intent(this, Preferences.class)); 187 | } else if ( keyCode == KeyEvent.KEYCODE_VOLUME_UP ) { 188 | zoomfac += 5f; 189 | } else if ( keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ) { 190 | zoomfac -= 5f; 191 | } else if ( keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_CAMERA ) { 192 | Preferences.trackball_rotate = !Preferences.trackball_rotate; 193 | if (Preferences.trackball_rotate) { 194 | Toast.makeText( getApplicationContext(), "Touch screen to pan", Toast.LENGTH_SHORT).show(); 195 | } else { 196 | Toast.makeText( getApplicationContext(), "Touch screen to rotate", Toast.LENGTH_SHORT).show(); 197 | } 198 | } 199 | return true; 200 | } 201 | } -------------------------------------------------------------------------------- /Antikythera/src/com/fivasim/antikythera/antikythera2.java: -------------------------------------------------------------------------------- 1 | package com.fivasim.antikythera; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.content.SharedPreferences; 6 | import android.graphics.Bitmap; 7 | import android.graphics.BitmapFactory; 8 | import android.os.Bundle; 9 | import android.opengl.GLSurfaceView; 10 | import android.view.KeyEvent; 11 | import android.view.MotionEvent; 12 | import android.view.View; 13 | import android.view.View.OnClickListener; 14 | import android.widget.ImageView; 15 | import android.widget.TextView; 16 | import android.widget.Toast; 17 | import android.os.Handler; 18 | import android.preference.PreferenceManager; 19 | 20 | import static com.fivasim.antikythera.OpenGLRenderer2.*; 21 | 22 | public class antikythera2 extends Activity { 23 | public char type = 'p'; 24 | public static TextView tv; 25 | public static ImageView iv; 26 | public static float fps; 27 | public static Bitmap bitmap; 28 | private Handler mHandler = new Handler(); 29 | /** Called when the activity is first created. */ 30 | @Override 31 | public void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | BitmapFactory.Options opt = new BitmapFactory.Options(); 34 | opt.inPreferredConfig = Bitmap.Config.RGB_565; 35 | opt.inScaled = false; 36 | bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.boxt, opt); 37 | 38 | setContentView(R.layout.gllayout); 39 | GLSurfaceView view = (GLSurfaceView) findViewById(R.id.glsurfaceview1); 40 | view.setRenderer(new OpenGLRenderer2()); 41 | 42 | tv = (TextView) findViewById(R.id.tv); 43 | iv = (ImageView) findViewById(R.id.moveresize); 44 | } 45 | 46 | @Override 47 | public void onPause() { 48 | super.onPause(); 49 | mHandler.removeCallbacks(mUpdateTimeTask); 50 | } 51 | 52 | @Override 53 | public void onResume() { 54 | super.onResume(); 55 | timestamp = 0; 56 | fps = 0f; 57 | } 58 | 59 | @Override 60 | public void onStart() { 61 | super.onStart(); 62 | loadPreferences(); 63 | timestamp = 0; 64 | fps = 0f; 65 | if (Preferences.hidemoverotate) {iv.setVisibility(View.INVISIBLE);} 66 | else {iv.setVisibility(View.VISIBLE);} 67 | if (Preferences.trackball_rotate) {iv.setImageResource(R.drawable.move);} 68 | iv.setOnClickListener(new OnClickListener() { 69 | public void onClick(View v) { 70 | Preferences.trackball_rotate = !Preferences.trackball_rotate; 71 | if (Preferences.trackball_rotate) { 72 | Toast.makeText( getApplicationContext(), "Touch screen to pan", Toast.LENGTH_SHORT).show(); 73 | iv.setImageResource(R.drawable.move); 74 | } else { 75 | Toast.makeText( getApplicationContext(), "Touch screen to rotate", Toast.LENGTH_SHORT).show(); 76 | iv.setImageResource(R.drawable.rotate); 77 | } 78 | } 79 | }); 80 | 81 | mHandler.removeCallbacks(mUpdateTimeTask); 82 | if (Preferences.show_fps) { 83 | tv.setVisibility(View.VISIBLE); 84 | mHandler.postDelayed(mUpdateTimeTask, 100); 85 | } else { 86 | tv.setVisibility(View.INVISIBLE); 87 | } 88 | } 89 | 90 | private void loadPreferences() { 91 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); 92 | Preferences.plate_visibility = sp.getBoolean("plate_visibility",false); 93 | Preferences.rotation_speed = Float.parseFloat( sp.getString("rotation_speed","1") ); 94 | Preferences.rotate_backwards = sp.getBoolean("rotate_backwards",false); 95 | Preferences.trackball_rotate = sp.getBoolean("trackball_rotate",false); 96 | Preferences.show_fps = sp.getBoolean("show_fps",false); 97 | Preferences.hidemoverotate = sp.getBoolean("hidemoverotate",false); 98 | } 99 | 100 | private Runnable mUpdateTimeTask = new Runnable() { 101 | public void run() { 102 | if (Preferences.show_fps) { 103 | tv.setText( String.format("%.2f fps",fps)); 104 | } else { 105 | tv.setVisibility(View.INVISIBLE); 106 | } 107 | mHandler.postDelayed(this, 400 ); 108 | } 109 | }; 110 | 111 | @Override 112 | public boolean onTouchEvent(MotionEvent event) { 113 | switch (event.getAction() & MotionEvent.ACTION_MASK ) { 114 | case MotionEvent.ACTION_MOVE: 115 | if(touchmode == 1) { 116 | if (Preferences.trackball_rotate) { 117 | position_x -= (float)( (curX-event.getX(0))/10 ); 118 | position_y += (float)( (curY-event.getY(0))/10 ); 119 | curX = event.getX(0); 120 | curY = event.getY(0); 121 | } else { 122 | fullrotate_y -= (float)( (curX-event.getX(0))/10 ); 123 | fullrotate_x -= (float)( (curY-event.getY(0))/10 ); 124 | curX = event.getX(0); 125 | curY = event.getY(0); 126 | } 127 | } else if (touchmode == 2) { 128 | float x = event.getX(0) - event.getX(1); 129 | float y = event.getY(0) - event.getY(1); 130 | float Dist = (float)Math.sqrt(x * x + y * y); 131 | zoomfac += (float)((Dist - curDist)/10); 132 | curDist = (float)Math.sqrt(x * x + y * y); 133 | } 134 | break; 135 | case MotionEvent.ACTION_DOWN: 136 | touchmode = 1; 137 | curX = event.getX(0); 138 | curY = event.getY(0); 139 | break; 140 | case MotionEvent.ACTION_UP: 141 | touchmode = 0; 142 | curX = event.getX(0); 143 | curY = event.getY(0); 144 | break; 145 | case MotionEvent.ACTION_POINTER_DOWN: 146 | touchmode = 2; 147 | float x = event.getX(0) - event.getX(1); 148 | float y = event.getY(0) - event.getY(1); 149 | curDist = (float)Math.sqrt(x * x + y * y); 150 | break; 151 | case MotionEvent.ACTION_POINTER_UP: 152 | touchmode = 0; 153 | break; 154 | } 155 | return true; 156 | } 157 | 158 | @Override 159 | public boolean onTrackballEvent(MotionEvent event) { 160 | if (event.getAction() == MotionEvent.ACTION_MOVE) { 161 | if (Preferences.trackball_rotate) { 162 | fullrotate_y += (float)( (6*event.getX(0)) ); 163 | fullrotate_x += (float)( (6*event.getY(0)) ); 164 | } else { 165 | position_x += (float)( (6*event.getX(0)) ); 166 | position_y -= (float)( (6*event.getY(0)) ); 167 | } 168 | } else if (event.getAction() == MotionEvent.ACTION_DOWN) { 169 | Preferences.trackball_rotate = !Preferences.trackball_rotate; 170 | if (Preferences.trackball_rotate) { 171 | Toast.makeText( getApplicationContext(), "Touch screen to pan", Toast.LENGTH_SHORT).show(); 172 | } else { 173 | Toast.makeText( getApplicationContext(), "Touch screen to rotate", Toast.LENGTH_SHORT).show(); 174 | } 175 | } 176 | return true; 177 | } 178 | 179 | @Override 180 | public boolean onKeyDown(int keyCode, KeyEvent event) { 181 | if ( keyCode == KeyEvent.KEYCODE_BACK ) { 182 | bitmap.recycle(); 183 | mHandler.removeCallbacks(mUpdateTimeTask); 184 | finish(); 185 | } else if ( keyCode == KeyEvent.KEYCODE_MENU ) { 186 | startActivity(new Intent(this, Preferences.class)); 187 | } else if ( keyCode == KeyEvent.KEYCODE_VOLUME_UP ) { 188 | zoomfac += 5f; 189 | } else if ( keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ) { 190 | zoomfac -= 5f; 191 | } else if ( keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_CAMERA ) { 192 | Preferences.trackball_rotate = !Preferences.trackball_rotate; 193 | if (Preferences.trackball_rotate) { 194 | Toast.makeText( getApplicationContext(), "Touch screen to pan", Toast.LENGTH_SHORT).show(); 195 | } else { 196 | Toast.makeText( getApplicationContext(), "Touch screen to rotate", Toast.LENGTH_SHORT).show(); 197 | } 198 | } 199 | return true; 200 | } 201 | 202 | } -------------------------------------------------------------------------------- /Antikythera/src/com/fivasim/antikythera/OpenGLRenderer.java: -------------------------------------------------------------------------------- 1 | package com.fivasim.antikythera; 2 | 3 | import javax.microedition.khronos.egl.EGLConfig; 4 | import javax.microedition.khronos.opengles.GL10; 5 | 6 | import android.graphics.Bitmap; 7 | import android.opengl.GLU; 8 | import android.opengl.GLUtils; 9 | import android.opengl.GLSurfaceView.Renderer; 10 | import android.os.Build; 11 | 12 | import static com.fivasim.antikythera.Initial.*; 13 | 14 | public class OpenGLRenderer implements Renderer { 15 | private Gear gears[] = new Gear[num_gears]; 16 | private Gear axles[] = new Gear[num_axles]; 17 | private Pointer pointers[] = new Pointer[num_pointers]; 18 | private Gear pointerbase = new Gear( new float[]{0f, 1.5f, 1f, 50f, 0f, 0f} ); 19 | private Plate plates[] = new Plate[2]; 20 | 21 | private static int framecount = 0; 22 | public static float curX = 0f; 23 | public static float curY = 0f; 24 | public static float curX1 = 0f; 25 | public static float curY1 = 0f; 26 | public static float curDist = 0f; 27 | public static int touchmode = 0; 28 | 29 | public static float fullrotate_x = 0f; 30 | public static float fullrotate_y = 0f; 31 | public static float fullrotate_z = 0f; 32 | public static float position_x = 0f; 33 | public static float position_y = 0f; 34 | public static float zoomfac = 0f; 35 | 36 | public static long timestamp = System.currentTimeMillis(); 37 | 38 | private Bitmap bitmap; 39 | 40 | public OpenGLRenderer() { 41 | int i; 42 | // Initialize our gears. 43 | for (i=0;i= 7 ){ 80 | framecount++; 81 | if (framecount == 10) { 82 | antikytherap.fps = (float)(framecount*1000)/(float)(System.currentTimeMillis()-timestamp); 83 | timestamp = System.currentTimeMillis(); 84 | framecount = 0; 85 | } else if (antikytherap.fps == 0f) { 86 | if (timestamp == 0) { 87 | timestamp = System.currentTimeMillis(); 88 | } else { 89 | framecount = 0; 90 | antikytherap.fps = (float)(1000f/(float)(System.currentTimeMillis()-timestamp) ); 91 | timestamp = System.currentTimeMillis(); 92 | } 93 | } 94 | } else { 95 | framecount++; 96 | if (framecount == 10) { 97 | antikytherap_nomulti.fps = (float)(framecount*1000)/(float)(System.currentTimeMillis()-timestamp); 98 | timestamp = System.currentTimeMillis(); 99 | framecount = 0; 100 | } else if (antikytherap.fps == 0f) { 101 | if (timestamp == 0) { 102 | timestamp = System.currentTimeMillis(); 103 | } else { 104 | framecount = 0; 105 | antikytherap_nomulti.fps = (float)(1000f/(float)(System.currentTimeMillis()-timestamp) ); 106 | timestamp = System.currentTimeMillis(); 107 | } 108 | } 109 | } 110 | 111 | gl.glDisable(GL10.GL_DITHER); 112 | gl.glDisable(GL10.GL_LIGHTING); 113 | // Clears the screen and depth buffer. 114 | gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); 115 | // Replace the current matrix with the identity matrix 116 | gl.glLoadIdentity(); 117 | // Translates 4 units into the screen. 118 | if (position_x > 100f) { position_x = 100f;} 119 | if (position_x <-100f) { position_x =-100f;} 120 | if (position_y > 100f) { position_y = 100f;} 121 | if (position_y <-100f) { position_y =-100f;} 122 | gl.glTranslatef(position_x, position_y, -120f + zoomfac); 123 | 124 | gl.glRotatef( fullrotate_x, 1f, 0f, 0f); 125 | gl.glRotatef( fullrotate_y, 0f, 1f, 0f); 126 | gl.glRotatef( fullrotate_z, 0f, 0f, 1f); 127 | // Draw our gears 128 | int i; 129 | for (i=0;i=num_axles-3) { //Αν είναι η μανιβέλα να πάρει σωστή θέση (κάθετο στα υπόλοιπα) 179 | gl.glRotatef( 90f, 0.0f, 1.0f, 0.0f); 180 | } 181 | 182 | if (Preferences.rotate_backwards) { 183 | axle_angle[i] -= Preferences.rotation_speed * axlepos[i][3]; 184 | } else { 185 | axle_angle[i] += Preferences.rotation_speed * axlepos[i][3]; 186 | } 187 | gl.glRotatef( axle_angle[i], 0f, 0f, 1f); //Περιστροφή γραναζιού 188 | 189 | axles[i].draw(gl, (int)axlepos[i][4]); 190 | 191 | gl.glPopMatrix(); 192 | } 193 | //pointers 194 | for (i=0;i= 7 ){ 228 | bitmap = antikytherap.bitmap; 229 | } else { 230 | bitmap = antikytherap_nomulti.bitmap; 231 | } 232 | 233 | gl.glEnable(GL10.GL_TEXTURE_2D); 234 | gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST); 235 | gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); 236 | gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE); 237 | gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE); 238 | gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_REPLACE); 239 | GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0); 240 | gl.glDisable(GL10.GL_TEXTURE_2D); 241 | } 242 | // Sets the current view port to the new size. 243 | gl.glViewport(0, 0, width, height); 244 | // Select the projection matrix 245 | gl.glMatrixMode(GL10.GL_PROJECTION); 246 | // Reset the projection matrix 247 | gl.glLoadIdentity(); 248 | // Calculate the aspect ratio of the window 249 | GLU.gluPerspective(gl, 75.0f, (float) width / (float) height, 0.1f, 750.0f); 250 | // Select the modelview matrix 251 | gl.glMatrixMode(GL10.GL_MODELVIEW); 252 | // Reset the modelview matrix 253 | gl.glLoadIdentity(); 254 | } 255 | 256 | } 257 | -------------------------------------------------------------------------------- /Antikythera/src/com/fivasim/antikythera/Initial2.java: -------------------------------------------------------------------------------- 1 | package com.fivasim.antikythera; 2 | 3 | public class Initial2 { 4 | public static final float M_PI = (float)Math.PI; 5 | public static final int num_gears = 33; //Αριθμός γραναζιών 6 | public static final float gear_width = 1.0f; //Πάχος κάθε γραναζιού 7 | public static final float gear_tooth = 0.6f; //Βάθος δοντιών 8 | public static final int num_axles = 19; //Αριθμός αξόνων 9 | public static final int num_pointers = 5; //Αριθμός δεικτών 10 | 11 | //Μεταβλητές και σταθερές για την χρήση του ποντικιού 12 | public static final int MOUSE_ROTATE_YX = 0; 13 | public static final int MOUSE_ZOOM = 8; 14 | public static final int MOUSE_MOVE = 2; 15 | public static float m_last_x; 16 | public static float m_last_y; 17 | public static int mouse_mode; 18 | 19 | // x y z ταχύτητα χρώμα 20 | static public float gearpos[][] = new float[][] { 21 | { 0.0f, 0.0f, 7.7f, 0.0748f, 1f }, //A 22 | { 0.0f, 0.0f, 2.7f, 0.0748f, 1f }, //B1 23 | { 0.0f, 0.0f, -3.3f, -0.0f, 2f }, //B2 24 | { 15.72f, 0.0f, 2.7f, -0.125984f, 4f }, //B3 25 | { 15.72f, 0.0f, 1.7f, -0.125984f, 4f }, //B4 26 | { 23.56f, -7.64f, 1.7f, 0.251968f, 3f }, //C1f 27 | { 23.56f, -7.64f, -8.3f, 0.251968f, 3f }, //C2 28 | { 0.0f, -9.68f, -3.3f, -0.0f, 7f }, //D1 29 | { 0.0f, -9.68f, -8.3f, -1.0f, 6f }, //D2 30 | { 0.0f, -9.68f, -19.3f, -0.008418f, 5f }, //E1 31 | { 0.0f, -9.68f, -18.3f, -0.008418f, 14f }, //E2a 32 | { 0.0f, -9.68f, -23.8f, -1.0f, 6f }, //E2b 33 | { 0.0f, -9.68f, -25.8f, -0.0f, 7f }, //E3 34 | { 28.01f, 0.0f, -19.3f, 0.02986f, 9f },//E4 35 | { 28.01f, 0.0f, -23.8f, 0.02986f, 9f }, //E5 36 | { 28.01f, -13.82f, -28.8f, -0.016589f, 10f }, //F1 37 | { 28.01f, -13.82f, -23.8f, -0.016589f, 10f }, //F2 38 | { 28.01f, -26.06f, -28.8f, 0.00553f, 11f },//G1 39 | { 28.01f, -26.06f, -33.8f, 0.00553f, 11f },//G2 40 | { 39.46f, -26.06f, -33.8f, -0.001382f, 12f },//H1 41 | {-14.30f, -9.68f, -23.8f, 1.0f, 13f },//H2 42 | {-14.80f, -9.68f, -25.8f, -0.0f, 3f },//I 43 | { -15.4f, 0.0f, 2.7f, -0.125984f, 15f },//J 44 | { -15.4f, 0.0f, 1.7f, -0.125984f, 15f },//K1 45 | {-38.78f, 0.0f, 1.7f, 0.069553f, 16f },//K2 46 | {-38.78f, 0.0f, -8.3f, 0.069553f, 16f },//L1 47 | {-38.78f, 0.0f, -18.3f, 0.069553f, 16f },//L2 48 | {-41.70f, -8.80f, -8.3f, -0.019685f, 17f },//M1 49 | {-41.70f, -8.80f, -13.3f, -0.019685f, 17f },//M2 50 | {-45.06f, -20.45f, -13.3f, 0.004921f, 18f },//O1 51 | {-45.06f, -20.45f, -18.3f, 0.004921f, 18f },//O2 52 | {-45.06f, -11.45f, -18.3f, -0.000984f, 3f },//Ένδειξη Τετραετίας 53 | { 36.00f, 0.0f, 13.85f, 0.5236f, 19f } //Μανιβέλα 54 | }; 55 | static public float geardata[][] = new float[][] { //only 1f cross supported 56 | {28.0f, 35.56f, gear_width, 224f, gear_tooth, 1f}, //A 57 | { 6.0f, 9.93f, gear_width, 64f, gear_tooth, 1f}, //B1 58 | { 0.0f, 4.83f, gear_width, 32f, gear_tooth, 1f}, //B2 59 | { 0.0f, 5.79f, gear_width, 38f, gear_tooth, 1f}, //B3 60 | { 0.0f, 7.38f, gear_width, 48f, gear_tooth, 1f}, //B4 61 | { 0.0f, 3.56f, gear_width, 24f, gear_tooth, 1f}, //C1 62 | { 8.0f, 18.81f, gear_width, 127f, gear_tooth, 1f}, //C2 63 | { 0.0f, 4.83f, gear_width, 32f, gear_tooth, 1f}, //D1 64 | { 0.0f, 4.83f, gear_width, 32f, gear_tooth, 1f}, //D2 65 | {10.0f, 23.21f, gear_width, 188f, gear_tooth, 1f}, //E1 66 | {10.0f, 35.98f, gear_width, 223f, gear_tooth, 1f}, //E2a 67 | { 0.0f, 7.17f, gear_width, 50f, gear_tooth, 1f}, //E2b 68 | { 0.0f, 7.40f, gear_width, 50f, gear_tooth, 1f}, //E3 69 | { 0.0f, 6.34f, gear_width, 53f, gear_tooth, 1f}, //E4 70 | { 0.0f, 4.51f, gear_width, 30f, gear_tooth, 1f}, //E5 71 | { 0.0f, 2.92f, gear_width, 20f, gear_tooth, 1f}, //F1 72 | { 5.0f, 9.29f, gear_width, 54f, gear_tooth, 1f}, //F2 73 | { 5.0f, 9.29f, gear_width, 60f, gear_tooth, 1f}, //G1 74 | { 0.0f, 2.18f, gear_width, 15f, gear_tooth, 1f}, //G2 75 | { 5.0f, 9.29f, gear_width, 60f, gear_tooth, 1f}, //H1 76 | { 0.5f, 7.17f, gear_width, 50f, gear_tooth, 0f}, //H2 77 | { 0.5f, 7.40f, gear_width, 50f, gear_tooth, 0f}, //I 78 | { 0.0f, 5.46f, gear_width, 38f, gear_tooth, 1f}, //J 79 | { 0.0f, 8.34f, gear_width, 53f, gear_tooth, 1f}, //K1 80 | { 8.0f, 15.03f, gear_width, 96f, gear_tooth, 1f}, //K2 81 | { 0.0f, 2.00f, gear_width, 15f, gear_tooth, 1f}, //L1 82 | { 0.0f, 3.97f, gear_width, 27f, gear_tooth, 1f}, //L2 83 | { 0.0f, 7.28f, gear_width, 53f, gear_tooth, 1f}, //M1 84 | { 0.0f, 2.26f, gear_width, 15f, gear_tooth, 1f}, //M2 85 | { 5.0f, 9.84f, gear_width, 60f, gear_tooth, 1f}, //O1 86 | { 0.0f, 1.59f, gear_width, 12f, gear_tooth, 1f}, //O2 87 | { 0.0f, 7.38f, gear_width, 60f, gear_tooth, 1f}, //Ένδειξη Τετραετίας 88 | { 0.0f, 5.75f, gear_width, 32f, gear_tooth, 1f} //Μανιβέλα 89 | }; 90 | static public float color[][] = new float[][] { 91 | {0.7f, 0.0f, 0.0f, 1.0f},//Κόκκινο 92 | {0.0f, 0.7f, 0.0f, 1.0f},//Πράσινο 93 | {0.0f, 0.0f, 0.7f, 1.0f},//Μπλε 94 | {0.7f, 0.7f, 0.0f, 1.0f},//Κίτρινο 95 | {0.7f, 0.0f, 0.7f, 1.0f},//Μωβ 96 | {0.0f, 0.7f, 0.7f, 1.0f},//Τυρκουάζ 97 | {0.8f, 0.4f, 0.0f, 1.0f},//Πορτοκαλί 98 | {0.8f, 0.0f, 0.4f, 1.0f},//Φούξια 99 | {1.0f, 0.5f, 0.5f, 1.0f},//Ροζ 100 | 101 | {0.4f, 0.0f, 0.0f, 1.0f},//Σκούρο Κόκκινο 102 | {0.3f, 0.3f, 0.3f, 1.0f},//Γκρι 103 | {0.0f, 0.4f, 0.0f, 1.0f},//Σκούρο Πράσινο 104 | {0.4f, 0.4f, 0.0f, 1.0f},//Μουσταρδί 105 | {0.4f, 0.0f, 0.4f, 1.0f},//Σκούρο Μωβ 106 | {0.1f, 0.5f, 0.5f, 1.0f},//Σκούρο Τυρκουάζ 107 | {0.5f, 0.3f, 0.1f, 1.0f},//Καφετί 108 | {0.7f, 0.5f, 0.3f, 1.0f},//Ανοιχτό Πορτοκαλί 109 | {0.4f, 0.7f, 0.2f, 1.0f},//Λαχανί 110 | 111 | {0.0f, 0.0f, 0.4f, 1.0f},//Σκούρο Μπλε 112 | {1.0f, 1.0f, 1.0f, 1.0f} //Άσπρο 113 | }; 114 | static public boolean gear_visibility[] = new boolean[] {true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true, 115 | true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true}; 116 | static public float startangle[] = new float[] { 117 | // A B1f B2f B3f B4f C1f C2f D1f D2f E1f E2a E2bE3f E4f E5f F1f F2f 118 | 0f ,0f ,0f ,0f ,0.6f ,5f ,0f ,9.5f ,0f ,5.6f ,5f ,0f ,3f ,0f ,0f ,4f ,0f , 119 | // G1f G2f H1f H2f I J K1f K2f L1f L2f M1f M2f O1f O2f e4f ,m 120 | 9f ,0f ,0f ,12f ,0f ,2.8f ,0f ,3.6f ,5f ,3.3f ,0f ,9.1f ,9f ,0f ,1.2f ,0f}; 121 | 122 | // x y z ταχύτητα χρώμα 123 | static public float axlepos[][] = new float[][] { 124 | { 0.0f, 0.0f, 14.85f, 1.0f, 2f},//A 125 | { 0.0f, 0.0f, 17.35f, 0.0748f, 1f},//B1 126 | { 23.56f, -7.64f, -3.30f, 0.251968f, 3f},//B2 127 | { 0.0f, -9.68f, -14.55f, -1.0f, 7f},//D 128 | { 0.0f, -9.68f, -16.05f, -1.0f, 6f},//E1 129 | { 28.01f, 0.0f, -21.55f, 0.02986f, 9f},//E2 130 | { 28.01f, -13.82f, -33.80f, -0.016589f, 10f},//F 131 | { 28.01f, -26.06f, -31.30f, 0.00553f, 11f},//G 132 | { 39.46f, -26.06f, -38.80f, -0.001382f, 12f},//H 133 | { -13.55f, -3.82f, -25.00f, 0.0f, 19f},//I 134 | { -14.30f, -9.68f, -23.80f, 1.0f, 13f},//J (διαφορικό) 135 | { -14.80f, -9.68f, -25.80f, 1.0f, 14f},//K (διαφορικό) 136 | { -38.78f, 0.0f, -8.30f, 0.069553f, 16f},//M 137 | { -41.70f, -8.80f, -10.80f, -0.019685f, 17f},//O 138 | { -45.06f, -11.45f, -31.25f, -0.000984f, 3f},//Ένδειξη Τετραετίας 139 | { -45.06f, -20.45f, -15.80f, 0.004921f, 18f},//Άξονας Μανιβέλας 140 | { 53.00f, 0.0f, 13.85f, 0.2992f, 19f},//Βάση Μανιβέλας 141 | { 70.00f, 0.0f, 13.85f, 0.2992f, 19f},//Χερούλι Μανιβέλας 142 | { 2.50f, 0.0f, 5.50f, 0.0f, 19f} //Οι συντεταγμένες του χερουλιού απλώς προστίθενται 143 | //σε αυτές της βάσης (είναι σχετικές) 144 | }; 145 | //Η μανιβέλα (το χερούλι) να είνα ΠΑΝΤΑ τελευταία 146 | static public float axledata[][] = new float[][] { 147 | {0.0f, 0.6f, 36.3f, 20f},//B1 148 | {0.0f, 1.0f, 29.3f, 20f},//B2 149 | {0.0f, 0.6f, 10.0f, 20f},//D 150 | {0.0f, 0.6f, 21.5f, 20f},//E1 151 | {0.0f, 1.0f, 15.0f, 20f},//E2 152 | {0.0f, 0.6f, 4.5f, 20f},//F 153 | {0.0f, 0.6f, 20.0f, 20f},//G 154 | {0.0f, 0.6f, 5.0f, 20f},//H 155 | {0.0f, 0.6f, 10.0f, 20f},//I 156 | {0.0f, 0.6f, 4.0f, 20f},//πυρρος 157 | {0.0f, 0.6f, 1.0f, 20f},//K1 158 | {0.0f, 0.6f, 1.0f, 20f},//K2 159 | {0.0f, 0.6f, 20.5f, 20f},//M 160 | {0.0f, 0.6f, 5.0f, 20f},//N 161 | {0.0f, 0.6f, 25.0f, 20f},//O 162 | {0.0f, 0.6f, 5.0f, 20f},//P 163 | {0.0f, 0.6f, 34.0f, 20f},//Άξονας Μανιβέλας 164 | {0.0f, 6.15f, 1.0f, 20f},//Βάση Μανιβέλας 165 | {0.0f, 0.5f, 5.0f, 20f} //Χερούλι Μανιβέλας (διαφορικό) 166 | }; 167 | static public boolean axle_visibility[] = new boolean[] {true,true,true,true,true,true,true,true,true, 168 | true,true,true,true,true,true,true,true,true,true}; 169 | static public float axle_angle[] = new float[] {0f,0f,0f,0f,0f,0f,0f,0f,0f, 170 | 0f,0f,0f,0f,0f,0f,0f,0f,0f,0f}; 171 | 172 | //Η μανιβέλα (το χερούλι) να είνα ΠΑΝΤΑ τελευταία 173 | static public float axle_differential[] = new float[] { 0f,0f,0f,0f,0f,0f,0f,0f,0f, 174 | gearpos[20][3],0f,0f,0f,0f,0f,0f,0f,0f,0.5f}; 175 | static public float axle_differential_angle[] = new float[] { 0f,0f,0f,0f,0f,0f,0f,0f,0f, 176 | 0.01f,0f,0f,0f,0f,0f,0f,0f,0f,0.001f}; 177 | 178 | 179 | static float pointer_pos[][] = new float[][] { 180 | { 0.0f, 0.0f, 31.9f, 0.0748f, 10f},//Ήλιος 181 | { 0.0f, 0.0f, 33.3f, -0.0f, 2f},//Σελήνη 182 | {-45.06f,-11.45f, -43.8f, -0.000984f, 3f},//Ένδειξη Τετραετίας 183 | {28.01f, -13.82f, -43.8f, -0.016589f,10f},//Συνοδικός Μήνας 184 | {39.46f, -26.06f, -43.8f, -0.001382f,12f}//Σεληνιακό Έτος 185 | }; 186 | static public float pointer_len[] = new float[] { 30f, 20f, 8f, 7f, 8f}; 187 | static public float pointer_angle[] = new float[] { 0f, 0f, 0f, 0f, 0f}; 188 | 189 | static public boolean pointer_visibility[] = new boolean[] {true,true,true,true,true}; 190 | 191 | static public boolean plate_visibility; 192 | } 193 | -------------------------------------------------------------------------------- /Antikythera/src/com/fivasim/antikythera/OpenGLRenderer2.java: -------------------------------------------------------------------------------- 1 | package com.fivasim.antikythera; 2 | 3 | import javax.microedition.khronos.egl.EGLConfig; 4 | import javax.microedition.khronos.opengles.GL10; 5 | 6 | import android.graphics.Bitmap; 7 | import android.opengl.GLU; 8 | import android.opengl.GLUtils; 9 | import android.opengl.GLSurfaceView.Renderer; 10 | import android.os.Build; 11 | 12 | import static com.fivasim.antikythera.Initial2.*; 13 | 14 | public class OpenGLRenderer2 implements Renderer { 15 | private Gear gears[] = new Gear[num_gears]; 16 | private Gear axles[] = new Gear[num_axles]; 17 | private Pointer pointers[] = new Pointer[num_pointers]; 18 | private Gear pointerbase = new Gear( new float[]{0f, 1.5f, 1f, 50f, 0f, 0f} ); 19 | private Plate plates[] = new Plate[2]; 20 | 21 | private static int framecount = 0; 22 | public static float curX = 0f; 23 | public static float curY = 0f; 24 | public static float curX1 = 0f; 25 | public static float curY1 = 0f; 26 | public static float curDist = 0f; 27 | public static int touchmode = 0; 28 | 29 | public static float angle = 0f; 30 | public static float fullrotate_x = 0f; 31 | public static float fullrotate_y = 0f; 32 | public static float fullrotate_z = 0f; 33 | public static float position_x = 0f; 34 | public static float position_y = 0f; 35 | public static float zoomfac = 0f; 36 | 37 | public static long timestamp = System.currentTimeMillis(); 38 | 39 | private Bitmap bitmap; 40 | 41 | public OpenGLRenderer2() { 42 | int i; 43 | // Initialize our gears. 44 | for (i=0;i= 7 ){ 88 | framecount++; 89 | if (framecount == 10) { 90 | antikythera2.fps = (float)(framecount*1000)/(float)(System.currentTimeMillis()-timestamp); 91 | timestamp = System.currentTimeMillis(); 92 | framecount = 0; 93 | } else if (antikythera2.fps == 0f) { 94 | if (timestamp == 0) { 95 | timestamp = System.currentTimeMillis(); 96 | } else { 97 | framecount = 0; 98 | antikythera2.fps = (float)(1000f/(float)(System.currentTimeMillis()-timestamp) ); 99 | timestamp = System.currentTimeMillis(); 100 | } 101 | } 102 | } else { 103 | framecount++; 104 | if (framecount == 10) { 105 | antikythera2_nomulti.fps = (float)(framecount*1000)/(float)(System.currentTimeMillis()-timestamp); 106 | timestamp = System.currentTimeMillis(); 107 | framecount = 0; 108 | } else if (antikythera2.fps == 0f) { 109 | if (timestamp == 0) { 110 | timestamp = System.currentTimeMillis(); 111 | } else { 112 | framecount = 0; 113 | antikythera2_nomulti.fps = (float)(1000f/(float)(System.currentTimeMillis()-timestamp) ); 114 | timestamp = System.currentTimeMillis(); 115 | } 116 | } 117 | } 118 | //timestamp = System.currentTimeMillis(); 119 | 120 | double rmik=4.0; 121 | double rmeg, cosx; 122 | //double kentro_k1 = 0.0; //x=0, y=0 123 | double kentro_k2 = gearpos[21][0] - gearpos[20][0]; //x=;, y=0 124 | double kentro_k[] = {0.0, 0.0}; //κεντρο πυρρου k 125 | 126 | gl.glDisable(GL10.GL_LIGHTING); 127 | // Clears the screen and depth buffer. 128 | gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); 129 | // Replace the current matrix with the identity matrix 130 | gl.glLoadIdentity(); 131 | // Translates 4 units into the screen. 132 | if (position_x > 100f) { position_x = 100f;} 133 | if (position_x <-100f) { position_x =-100f;} 134 | if (position_y > 100f) { position_y = 100f;} 135 | if (position_y <-100f) { position_y =-100f;} 136 | gl.glTranslatef(position_x, position_y, -120f + zoomfac); 137 | 138 | gl.glRotatef( fullrotate_x, 1f, 0f, 0f); 139 | gl.glRotatef( fullrotate_y, 0f, 1f, 0f); 140 | gl.glRotatef( fullrotate_z, 0f, 0f, 1f); 141 | // Draw our gears 142 | int i; 143 | for (i=0;i=num_axles-3) { //Αν είναι η μανιβέλα να πάρει σωστή θέση (κάθετο στα υπόλοιπα) 203 | gl.glRotatef( 90f, 0.0f, 1.0f, 0.0f); 204 | } 205 | 206 | if (!Preferences.rotate_backwards) { 207 | axle_angle[i] -= Preferences.rotation_speed * axlepos[i][3]; 208 | } else { 209 | axle_angle[i] += Preferences.rotation_speed * axlepos[i][3]; 210 | } 211 | gl.glRotatef( axle_angle[i], 0f, 0f, 1f); //Περιστροφή γραναζιού 212 | 213 | axles[i].draw(gl, (int)axlepos[i][4]); 214 | 215 | gl.glPopMatrix(); 216 | } 217 | //pointers 218 | for (i=0;i= 7 ){ 256 | bitmap = antikythera2.bitmap; 257 | } else { 258 | bitmap = antikythera2_nomulti.bitmap; 259 | } 260 | 261 | gl.glEnable(GL10.GL_TEXTURE_2D); 262 | gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST); 263 | gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); 264 | gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE); 265 | gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE); 266 | gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_REPLACE); 267 | GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0); 268 | gl.glDisable(GL10.GL_TEXTURE_2D); 269 | } 270 | // Sets the current view port to the new size. 271 | gl.glViewport(0, 0, width, height); 272 | // Select the projection matrix 273 | gl.glMatrixMode(GL10.GL_PROJECTION); 274 | // Reset the projection matrix 275 | gl.glLoadIdentity(); 276 | // Calculate the aspect ratio of the window 277 | GLU.gluPerspective(gl, 75.0f, (float) width / (float) height, 0.1f, 750.0f); 278 | // Select the modelview matrix 279 | gl.glMatrixMode(GL10.GL_MODELVIEW); 280 | // Reset the modelview matrix 281 | gl.glLoadIdentity(); 282 | } 283 | 284 | } 285 | -------------------------------------------------------------------------------- /Antikythera/src/com/fivasim/antikythera/Initial.java: -------------------------------------------------------------------------------- 1 | package com.fivasim.antikythera; 2 | 3 | public class Initial { 4 | public static final float M_PI = (float)Math.PI; 5 | public static final int num_gears = 33; //Αριθμός γραναζιών 6 | public static final float gear_width = 1.0f; //Πάχος κάθε γραναζιού 7 | public static final float gear_tooth = 0.6f; //Βάθος δοντιών 8 | public static final int num_axles = 18; //Αριθμός αξόνων 9 | public static final int num_pointers = 5; //Αριθμός δεικτών 10 | 11 | //Μεταβλητές και σταθερές για την χρήση του ποντικιού 12 | public static final int MOUSE_ROTATE_YX = 0; 13 | public static final int MOUSE_ZOOM = 8; 14 | public static final int MOUSE_MOVE = 2; 15 | public static float m_last_x; 16 | public static float m_last_y; 17 | public static int mouse_mode; 18 | 19 | // x y z ταχύτητα χρώμα 20 | static public float gearpos[][] = new float[][] { 21 | { 0.0f, 0.0f, 20.0f, -0.1f, 1f}, //A 22 | { 0.0f, 0.0f, 7.7f, 0.1f, 2f}, //B1 23 | { 0.0f, 0.0f, 2.7f, 0.1f, 2f}, //B2 24 | { 0.0f, 0.0f, -3.3f, 0.1f, 2f}, //B3 25 | { 0.0f, 0.0f, -8.3f, -1.336842f, 3f}, //B4 26 | { 15.72f, 0.0f, 2.7f, -0.16842f, 4f}, //C1f 27 | { 15.72f, 0.0f, 1.5f, -0.16842f, 4f}, //C2 28 | { 23.56f, -7.64f, 1.5f, 0.336842f, 8f}, //D1 29 | { 23.56f, -7.64f, -8.3f, 0.336842f, 8f}, //D2 30 | { -9.68f, 0.0f, -3.3f, -0.1f, 6f}, //E1 31 | { -9.68f, 0.0f, -8.3f, 1.336842f, 7f}, //E2a 32 | { -9.68f, 0.0f, -13.3f, 1.336842f, 7f}, //E2b 33 | { -9.68f, 0.0f, -19.3f, 0.618421f, 5f}, //E3 34 | { -9.68f, 0.0f, -18.3f, 0.618421f, 14f},//E4 35 | { -9.68f, 0.0f, -23.8f, -0.1f, 6f}, //E5 36 | { 28.01f, 0.0f, -19.3f, -2.473684f, 4f}, //F1 37 | { 28.01f, 0.0f, -23.8f, -2.473684f, 4f}, //F2 38 | { 28.01f, -13.82f, -28.8f, 1.236842f, 10f},//G1 39 | { 28.01f, -13.82f, -23.8f, 1.236842f, 10f},//G2 40 | { 28.01f, -26.06f, -28.8f, -0.41228f, 11f},//H1 41 | { 28.01f, -26.06f, -33.8f, -0.41228f, 11f},//H2 42 | { 39.46f, -26.06f, -33.8f, 0.10307f, 12f},//I 43 | { -20.12f + 9.68f, 10.44f, -13.3f, -0.35921f, 13f},//J 44 | { -23.95f + 9.68f, -3.82f, -13.3f, 0.718421f, 9f},//K1 45 | { -23.95f + 9.68f, -3.82f, -23.8f, 0.718421f, 9f},//K2 46 | { -15.4f, 0.0f, 2.7f, -0.1777778f, 15f},//L1 47 | { -15.4f, 0.0f, 1.5f, -0.1777778f, 15f},//L2 48 | { -38.78f, 0.0f, 1.5f, 0.1f, 16f},//M1 49 | { -38.78f, 0.0f, -8.3f, 0.1f, 16f},//M2 50 | { -41.70f, -24.80f, -8.3f, 0.05f, 17f},//O1 51 | { -41.70f, -24.80f, -13.3f, 0.05f, 17f},//O2 52 | { -45.06f, -10.45f, -8.3f, -0.025f, 18f},//Ένδειξη Τετραετίας 53 | { 36.00f, 0.0f, 13.85f, 0.5f, 19f} //Μανιβέλα 54 | }; 55 | static public float geardata[][] = new float[][] { //only 1 cross supported 56 | {28.0f, 35.56f, gear_width, 225f, gear_tooth, 2f}, //A 57 | {28.0f, 35.56f, gear_width, 225f, gear_tooth, 1f}, //B1 58 | { 6.0f, 9.93f, gear_width, 64f, gear_tooth, 1f}, //B2 59 | { 0.0f, 4.83f, gear_width, 32f, gear_tooth, 1f}, //B3 60 | { 0.0f, 4.83f, gear_width, 32f, gear_tooth, 1f}, //B4 61 | { 0.0f, 5.79f, gear_width, 38f, gear_tooth, 1f}, //C1 62 | { 0.0f, 7.38f, gear_width, 48f, gear_tooth, 1f}, //C2 63 | { 0.0f, 3.56f, gear_width, 24f, gear_tooth, 1f}, //D1 64 | { 8.0f, 19.96f, gear_width, 127f, gear_tooth, 1f}, //D2 65 | { 0.0f, 4.83f, gear_width, 32f, gear_tooth, 1f}, //E1 66 | { 0.0f, 4.83f, gear_width, 32f, gear_tooth, 1f}, //E2a 67 | { 0.0f, 4.83f, gear_width, 32f, gear_tooth, 1f}, //E2b 68 | {10.0f, 30.32f, gear_width, 192f, gear_tooth, 1f}, //E3 69 | {10.0f, 35.08f, gear_width, 222f, gear_tooth, 0f}, //E4 70 | { 0.0f, 7.38f, gear_width, 48f, gear_tooth, 1f}, //E5 71 | { 0.0f, 7.38f, gear_width, 48f, gear_tooth, 1f}, //F1 72 | { 0.0f, 4.51f, gear_width, 30f, gear_tooth, 1f}, //F2 73 | { 0.0f, 2.92f, gear_width, 20f, gear_tooth, 1f}, //G1 74 | { 7.0f, 9.29f, gear_width, 60f, gear_tooth, 1f}, //G2 75 | { 7.0f, 9.29f, gear_width, 60f, gear_tooth, 1f}, //H1 76 | { 0.0f, 2.18f, gear_width, 15f, gear_tooth, 1f}, //H2 77 | { 6.0f, 9.29f, gear_width, 60f, gear_tooth, 1f}, //I 78 | { 6.0f, 9.93f, gear_width, 64f, gear_tooth, 1f}, //J 79 | { 0.0f, 4.83f, gear_width, 32f, gear_tooth, 1f}, //K1 80 | { 0.0f, 7.38f, gear_width, 48f, gear_tooth, 1f}, //K2 81 | { 0.0f, 5.46f, gear_width, 36f, gear_tooth, 1f}, //L1 82 | { 0.0f, 8.34f, gear_width, 54f, gear_tooth, 1f}, //L2 83 | { 8.0f, 15.03f, gear_width, 96f, gear_tooth, 1f}, //M1 84 | { 0.0f, 2.28f, gear_width, 16f, gear_tooth, 1f}, //M2 85 | { 0.0f, 4.83f, gear_width, 32f, gear_tooth, 1f}, //O1 86 | { 0.0f, 7.38f, gear_width, 48f, gear_tooth, 1f}, //O2 87 | { 6.0f, 9.92f, gear_width, 64f, gear_tooth, 1f}, //Ένδειξη Τετραετίας 88 | { 0.0f, 6.15f, gear_width, 45f, gear_tooth, 1f} //Μανιβέλα 89 | }; 90 | static public float color[][] = new float[][] { 91 | {0.7f, 0.0f, 0.0f, 1.0f},//Κόκκινο 92 | {0.0f, 0.7f, 0.0f, 1.0f},//Πράσινο 93 | {0.0f, 0.0f, 0.7f, 1.0f},//Μπλε 94 | {0.7f, 0.7f, 0.0f, 1.0f},//Κίτρινο 95 | {0.7f, 0.0f, 0.7f, 1.0f},//Μωβ 96 | {0.0f, 0.7f, 0.7f, 1.0f},//Τυρκουάζ 97 | {0.8f, 0.4f, 0.0f, 1.0f},//Πορτοκαλί 98 | {0.8f, 0.0f, 0.4f, 1.0f},//Φούξια 99 | {1.0f, 0.5f, 0.5f, 1.0f},//Ροζ 100 | 101 | {0.4f, 0.0f, 0.0f, 1.0f},//Σκούρο Κόκκινο 102 | {0.3f, 0.3f, 0.3f, 1.0f},//Γκρι 103 | {0.0f, 0.4f, 0.0f, 1.0f},//Σκούρο Πράσινο 104 | {0.4f, 0.4f, 0.0f, 1.0f},//Μουσταρδί 105 | {0.4f, 0.0f, 0.4f, 1.0f},//Σκούρο Μωβ 106 | {0.1f, 0.5f, 0.5f, 1.0f},//Σκούρο Τυρκουάζ 107 | {0.5f, 0.3f, 0.1f, 1.0f},//Καφετί 108 | {0.7f, 0.5f, 0.3f, 1.0f},//Ανοιχτό Πορτοκαλί 109 | {0.4f, 0.7f, 0.2f, 1.0f},//Λαχανί 110 | 111 | {0.0f, 0.0f, 0.4f, 1.0f},//Σκούρο Μπλε 112 | {1.0f, 1.0f, 1.0f, 1.0f} //Άσπρο 113 | }; 114 | static public boolean gear_visibility[] = new boolean[] {true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true, 115 | true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true}; 116 | static public float startangle[] = new float[] { 117 | // A B1f B2f B3f B4f C1f C2f D1f D2f E1f E2a E2bE3f E4f E5f F1f F2f 118 | 0f ,0f ,0f ,0f ,0.6f ,5f ,0f ,9.5f ,0f ,5.6f ,5f ,0f ,0f ,0f ,0f ,4f ,0f , 119 | // G1f G2f H1f H2f I J K1f K2f L1f L2f M1f M2f O1f O2f e4f ,m 120 | 9f ,0f ,0f ,12f ,0f ,2.8f ,0f ,3.6f ,5f ,3.3f ,0f ,9.1f ,9f ,0f ,1.2f ,0f}; 121 | static public float differential[] = new float[] { 0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f, 122 | 0.618421f,0.618421f,0.618421f,0f,0f,0f,0f,0f,0f,0f,0f}; 123 | static public float differential_angle[] = new float[] { 0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f,0f, 124 | 0.001f,0.001f,0.001f,0f,0f,0f,0f,0f,0f,0f,0f}; 125 | // x y z ταχύτητα χρώμα 126 | static public float axlepos[][] = new float[][] { 127 | { 0.0f, 0.0f, 26.0f, -0.1f, 1f},//A 128 | { 0.0f, 0.0f, 5.85f, -1.336842f, 3f},//B1 129 | { 0.0f, 0.0f, 2.20f, 0.1f, 2f},//B2 130 | { 23.56f, -7.64f, -3.30f, 0.336842f, 8f},//D 131 | { -9.68f, 0.0f, -13.55f, -0.1f, 6f},//E1 132 | { -9.68f, 0.0f, -10.80f, 1.336842f, 7f},//E2 133 | { 28.01f, 0.0f, -21.55f, -2.473684f, 4f},//F 134 | { 28.01f, -13.82f, -33.80f, 1.236842f, 10f},//G 135 | { 28.01f, -26.06f, -31.30f, -0.41228f, 11f},//H 136 | { 39.46f, -26.06f, -38.80f, 0.10307f, 12f},//I 137 | {-20.12f + 9.68f, 10.44f, -15.80f, -0.35921f, 13f},//J (διαφορικό) 138 | {-23.95f + 9.68f, -3.82f, -18.55f, 0.718421f, 9f },//K (διαφορικό) 139 | {-38.78f, 0.0f, -3.30f, 0.1f, 16f},//M 140 | {-41.70f, -24.80f, -10.80f, 0.05f, 17f},//O 141 | {-45.06f, -10.45f, -25.80f, -0.025f, 18f},//Ένδειξη Τετραετίας 142 | { 53.00f, 0.0f, 13.85f, 0.5f, 19f},//Άξονας Μανιβέλας 143 | { 70.00f, 0.0f, 13.85f, 0.5f, 19f},//Βάση Μανιβέλας 144 | { 2.50f, 0.0f, 5.50f, 0.0f, 19f},//Χερούλι Μανιβέλας 145 | //Οι συντεταγμένες του χερουλιού απλώς προστίθενται 146 | //σε αυτές της βάσης (είναι σχετικές) 147 | }; 148 | //Η μανιβέλα (το χερούλι) να είνα ΠΑΝΤΑ τελευταία 149 | static public float axledata[][] = new float[][] { 150 | {0.0f, 1.0f, 12.0f, 20f},//A 151 | {0.0f, 0.6f, 28.3f, 20f},//B1 152 | {0.0f, 1.0f, 11.0f, 20f},//B2 153 | {0.0f, 0.6f, 10.0f, 20f},//D 154 | {0.0f, 0.6f, 20.5f, 20f},//E1 155 | {0.0f, 1.0f, 5.0f, 20f},//E2 156 | {0.0f, 0.6f, 4.5f, 20f},//F 157 | {0.0f, 0.6f, 20.0f, 20f},//G 158 | {0.0f, 0.6f, 5.0f, 20f},//H 159 | {0.0f, 0.6f, 10.0f, 20f},//I 160 | {0.0f, 0.6f, 5.0f, 20f},//J (διαφορικό) 161 | {0.0f, 0.6f, 10.5f, 20f},//K (διαφορικό) 162 | {0.0f, 0.6f, 10.0f, 20f},//M 163 | {0.0f, 0.6f, 5.0f, 20f},//O 164 | {0.0f, 0.6f, 35.0f, 20f},//Ένδειξη Τετραετίας 165 | {0.0f, 0.6f, 34.0f, 20f},//Άξονας Μανιβέλας 166 | {0.0f, 6.15f, 1.0f, 80f},//Βάση Μανιβέλας 167 | {0.0f, 0.5f, 5.0f, 20f},//Χερούλι Μανιβέλας (διαφορικό) 168 | }; 169 | static public boolean axle_visibility[] = new boolean[] {true,true,true,true,true,true,true,true, 170 | true,true,true,true,true,true,true,true,true,true}; 171 | static public float axle_angle[] = new float[] {0f,0f,0f,0f,0f,0f,0f,0f,0f,0f, 172 | 0f,0f,0f,0f,0f,0f,0f,0f,0f,0f}; 173 | 174 | //Η μανιβέλα (το χερούλι) να είνα ΠΑΝΤΑ τελευταία 175 | static public float axle_differential[] = new float[] {0f,0f,0f,0f,0f,0f,0f,0f,0f,0f, 176 | 0.618421f , 0.618421f ,0f,0f,0f,0f,0f, 0.5f}; 177 | static public float axle_differential_angle[] = new float[] {0f,0f,0f,0f,0f,0f,0f,0f,0f,0f, 178 | 0.001f , 0.001f ,0f,0f,0f,0f,0f, 0.001f}; 179 | 180 | static public float pointer_pos[][] = new float[][] { 181 | { 0.0f , 0.0f , 32.00f, -0.1f, 10f},//Ήλιος 182 | { 0.0f , 0.0f , 33.00f, -1.336842f, 3f},//Σελήνη 183 | {-45.06f, -10.45f, -43.80f, -0.025f, 18f},//Ένδειξη Τετραετίας 184 | { 28.01f, -13.82f, -43.80f, 1.236842f, 10f},//Συνοδικός Μήνας 185 | { 39.46f, -26.06f, -43.80f, 0.10307f, 12f},//Σεληνιακό Έτος 186 | }; 187 | static public float pointer_len[] = new float[] { 30f, 20f, 8f, 7f, 8f}; 188 | static public float pointer_angle[] = new float[] { 0f, 0f, 0f, 0f, 0f}; 189 | 190 | static public boolean pointer_visibility[] = new boolean[] {true,true,true,true,true}; 191 | 192 | static public boolean plate_visibility; 193 | } 194 | -------------------------------------------------------------------------------- /Antikythera/src/com/fivasim/antikythera/Gear.java: -------------------------------------------------------------------------------- 1 | package com.fivasim.antikythera; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.nio.ByteOrder; 5 | import java.nio.FloatBuffer; 6 | import java.nio.ShortBuffer; 7 | 8 | import javax.microedition.khronos.opengles.GL10; 9 | 10 | import static com.fivasim.antikythera.Initial.color; 11 | import static com.fivasim.antikythera.Initial.M_PI; 12 | 13 | public class Gear { 14 | private float frontface_v[]; 15 | private short frontface_i[]; 16 | private float rearface_v[]; 17 | private short rearface_i[]; 18 | private float frontgear_v[]; 19 | private short frontgear_i[]; 20 | private float reargear_v[]; 21 | private short reargear_i[]; 22 | private float uppergear_v[]; 23 | private short uppergear_i[]; 24 | private float innergear_v[]; 25 | private short innergear_i[]; 26 | private float cross_v[]; 27 | private short cross_i[]; 28 | private FloatBuffer frontface_vertexBuffer; 29 | private ShortBuffer frontface_indexBuffer; 30 | private FloatBuffer rearface_vertexBuffer; 31 | private ShortBuffer rearface_indexBuffer; 32 | private FloatBuffer frontgear_vertexBuffer; 33 | private ShortBuffer frontgear_indexBuffer; 34 | private FloatBuffer reargear_vertexBuffer; 35 | private ShortBuffer reargear_indexBuffer; 36 | private FloatBuffer uppergear_vertexBuffer; 37 | private ShortBuffer uppergear_indexBuffer; 38 | private FloatBuffer innergear_vertexBuffer; 39 | private ShortBuffer innergear_indexBuffer; 40 | private FloatBuffer cross_vertexBuffer; 41 | private ShortBuffer cross_indexBuffer; 42 | 43 | public Gear( float[] geardata ) 44 | { 45 | float inner_radius = geardata[0]; 46 | float outer_radius = geardata[1]; 47 | float width = geardata[2]; 48 | int teeth = (int)geardata[3]; 49 | float tooth_depth = 0f; 50 | int cross = 0; 51 | if (geardata.length > 4) { 52 | tooth_depth = geardata[4]; 53 | cross = (int)geardata[5]; 54 | } 55 | 56 | int i; 57 | float r0, r1, r2; 58 | float angle, da; 59 | //float u, v; 60 | 61 | frontface_i = new short[teeth+3]; 62 | frontface_v = new float[3*(teeth+3)]; 63 | rearface_i = new short[teeth+3]; 64 | rearface_v = new float[3*(teeth+3)]; 65 | frontgear_i = new short[3*teeth]; 66 | frontgear_v = new float[9*teeth]; 67 | reargear_i = new short[3*teeth]; 68 | reargear_v = new float[9*teeth]; 69 | uppergear_i = new short[4*(teeth+1)]; 70 | uppergear_v = new float[12*(teeth+1)]; 71 | innergear_i = new short[2*(teeth+1)]; 72 | innergear_v = new float[6*(teeth+1)]; 73 | cross_i = new short[11*cross]; 74 | cross_v = new float[33*cross]; 75 | 76 | r0 = inner_radius; 77 | r1 = outer_radius - tooth_depth / 1.8f; //ακτίνα δίσκου (χωρίς τα δόντια) 78 | r2 = outer_radius + tooth_depth / 2.2f; //ακτίνα μαζί με τα δόντια 79 | 80 | da = 2.0f * M_PI / teeth / 4.0f; 81 | short count = 0; 82 | //κυκλική μπροστινή όψη γραναζιού 83 | for (i = 0; i <= teeth+2; i++) { 84 | angle = i * 2.0f * M_PI / teeth; 85 | if(i%2==0) { 86 | frontface_v[count] = (float)(r0 * (float)Math.cos(angle)); count++; 87 | frontface_v[count] = (float)(r0 * (float)Math.sin(angle)); count++; 88 | frontface_v[count] = (float)(width * 0.5f); count++; 89 | }else{ 90 | frontface_v[count] = (float)(r1 * (float)Math.cos(angle)); count++; 91 | frontface_v[count] = (float)(r1 * (float)Math.sin(angle)); count++; 92 | frontface_v[count] = (float)(width * 0.5f); count++; 93 | } 94 | frontface_i[i]=(short)i; 95 | } 96 | // a float is 4 bytes, therefore we multiply the number of vertices with 4. 97 | ByteBuffer vbb1 = ByteBuffer.allocateDirect(frontface_v.length * 4); 98 | vbb1.order(ByteOrder.nativeOrder()); 99 | frontface_vertexBuffer = vbb1.asFloatBuffer(); 100 | frontface_vertexBuffer.put(frontface_v); 101 | frontface_vertexBuffer.position(0); 102 | // short is 2 bytes, therefore we multiply the number of vertices with 2. 103 | ByteBuffer ibb1 = ByteBuffer.allocateDirect(frontface_i.length * 2); 104 | ibb1.order(ByteOrder.nativeOrder()); 105 | frontface_indexBuffer = ibb1.asShortBuffer(); 106 | frontface_indexBuffer.put(frontface_i); 107 | frontface_indexBuffer.position(0); 108 | 109 | //μπροστινή όψη δοντιών 110 | count = 0; 111 | short count_i=0; 112 | for (i = 0; i < teeth; i++) { 113 | angle = i * 2.0f * M_PI / teeth; 114 | frontgear_v[count] = (float)( (r1-0.1) * Math.cos(angle)); count++; 115 | frontgear_v[count] = (float)( (r1-0.1) * Math.sin(angle)); count++; 116 | frontgear_v[count] = (float)(width * 0.5f); count++; 117 | frontgear_i[count_i]=count_i;count_i++; 118 | frontgear_v[count] = (float)(r2 * Math.cos(angle + 2 * da)); count++; 119 | frontgear_v[count] = (float)(r2 * Math.sin(angle + 2 * da)); count++; 120 | frontgear_v[count] = (float)(width * 0.5f); count++; 121 | frontgear_i[count_i]=count_i;count_i++; 122 | frontgear_v[count] = (float)( (r1-0.1) * Math.cos(angle + 4 * da)); count++; 123 | frontgear_v[count] = (float)( (r1-0.1) * Math.sin(angle + 4 * da)); count++; 124 | frontgear_v[count] = (float)(width * 0.5f); count++; 125 | frontgear_i[count_i]=count_i;count_i++; 126 | } 127 | // a float is 4 bytes, therefore we multiply the number of vertices with 4. 128 | ByteBuffer vbb2 = ByteBuffer.allocateDirect(frontgear_v.length * 4); 129 | vbb2.order(ByteOrder.nativeOrder()); 130 | frontgear_vertexBuffer = vbb2.asFloatBuffer(); 131 | frontgear_vertexBuffer.put(frontgear_v); 132 | frontgear_vertexBuffer.position(0); 133 | // short is 2 bytes, therefore we multiply the number of vertices with 2. 134 | ByteBuffer ibb2 = ByteBuffer.allocateDirect(frontgear_i.length * 2); 135 | ibb2.order(ByteOrder.nativeOrder()); 136 | frontgear_indexBuffer = ibb2.asShortBuffer(); 137 | frontgear_indexBuffer.put(frontgear_i); 138 | frontgear_indexBuffer.position(0); 139 | 140 | //κυκλική πίσω όψη γραναζιού 141 | if (teeth == 222 ) {r0 = 30f;}//stupid small depth buffer 142 | if (teeth == 223 ) {r0 = 22.9f;}//stupid small depth buffer 143 | count = 0; 144 | for (i = 0; i <= teeth+2; i++) { 145 | angle = i * 2.0f * M_PI / teeth; 146 | if(i%2==0) { 147 | rearface_v[count] = (float)(r0 * Math.cos(angle)); count++; 148 | rearface_v[count] = (float)(r0 * Math.sin(angle)); count++; 149 | rearface_v[count] = (float)(-width * 0.5f); count++; 150 | }else{ 151 | rearface_v[count] = (float)(r1 * Math.cos(angle)); count++; 152 | rearface_v[count] = (float)(r1 * Math.sin(angle)); count++; 153 | rearface_v[count] = (float)(-width * 0.5f); count++; 154 | } 155 | rearface_i[i]=(short)i; 156 | } 157 | if (teeth == 222 ) {r0 = 12f;}//stupid small depth buffer 158 | // a float is 4 bytes, therefore we multiply the number of vertices with 4. 159 | ByteBuffer vbb3 = ByteBuffer.allocateDirect(rearface_v.length * 4); 160 | vbb3.order(ByteOrder.nativeOrder()); 161 | rearface_vertexBuffer = vbb3.asFloatBuffer(); 162 | rearface_vertexBuffer.put(rearface_v); 163 | rearface_vertexBuffer.position(0); 164 | // short is 2 bytes, therefore we multiply the number of vertices with 2. 165 | ByteBuffer ibb3 = ByteBuffer.allocateDirect(rearface_i.length * 2); 166 | ibb3.order(ByteOrder.nativeOrder()); 167 | rearface_indexBuffer = ibb3.asShortBuffer(); 168 | rearface_indexBuffer.put(rearface_i); 169 | rearface_indexBuffer.position(0); 170 | 171 | //πίσω όψη δοντιών 172 | count = 0; 173 | count_i=0; 174 | for (i = 0; i < teeth; i++) { 175 | angle = i * 2.0f * M_PI / teeth; 176 | reargear_v[count] = (float)( (r1-0.1) * Math.cos(angle)); count++; 177 | reargear_v[count] = (float)( (r1-0.1) * Math.sin(angle)); count++; 178 | reargear_v[count] = (float)(-width * 0.5f); count++; 179 | reargear_i[count_i]=count_i;count_i++; 180 | reargear_v[count] = (float)(r2 * Math.cos(angle + 2 * da)); count++; 181 | reargear_v[count] = (float)(r2 * Math.sin(angle + 2 * da)); count++; 182 | reargear_v[count] = (float)(-width * 0.5f); count++; 183 | reargear_i[count_i]=count_i;count_i++; 184 | reargear_v[count] = (float)( (r1-0.1) * Math.cos(angle + 4 * da)); count++; 185 | reargear_v[count] = (float)( (r1-0.1) * Math.sin(angle + 4 * da)); count++; 186 | reargear_v[count] = (float)(-width * 0.5f); count++; 187 | reargear_i[count_i]=count_i;count_i++; 188 | } 189 | // a float is 4 bytes, therefore we multiply the number of vertices with 4. 190 | ByteBuffer vbb4 = ByteBuffer.allocateDirect(reargear_v.length * 4); 191 | vbb4.order(ByteOrder.nativeOrder()); 192 | reargear_vertexBuffer = vbb4.asFloatBuffer(); 193 | reargear_vertexBuffer.put(reargear_v); 194 | reargear_vertexBuffer.position(0); 195 | // short is 2 bytes, therefore we multiply the number of vertices with 2. 196 | ByteBuffer ibb4 = ByteBuffer.allocateDirect(reargear_i.length * 2); 197 | ibb4.order(ByteOrder.nativeOrder()); 198 | reargear_indexBuffer = ibb4.asShortBuffer(); 199 | reargear_indexBuffer.put(reargear_i); 200 | reargear_indexBuffer.position(0); 201 | 202 | //εξωτερική όψη δοντιών 203 | count = 0; 204 | count_i=0; 205 | for (i = 0; i <= teeth; i++) { 206 | angle = i * 2.0f * M_PI / teeth; 207 | uppergear_v[count] = (float)( (r1-0.1) * Math.cos(angle)); count++; 208 | uppergear_v[count] = (float)( (r1-0.1) * Math.sin(angle)); count++; 209 | uppergear_v[count] = (float)(width * 0.5f); count++; 210 | uppergear_i[count_i]=count_i;count_i++; 211 | uppergear_v[count] = (float)( (r1-0.1) * Math.cos(angle)); count++; 212 | uppergear_v[count] = (float)( (r1-0.1) * Math.sin(angle)); count++; 213 | uppergear_v[count] = (float)(-width * 0.5f); count++; 214 | uppergear_i[count_i]=count_i;count_i++; 215 | uppergear_v[count] = (float)(r2 * Math.cos(angle + 2 * da)); count++; 216 | uppergear_v[count] = (float)(r2 * Math.sin(angle + 2 * da)); count++; 217 | uppergear_v[count] = (float)(width * 0.5f); count++; 218 | uppergear_i[count_i]=count_i;count_i++; 219 | uppergear_v[count] = (float)(r2 * Math.cos(angle + 2 * da)); count++; 220 | uppergear_v[count] = (float)(r2 * Math.sin(angle + 2 * da)); count++; 221 | uppergear_v[count] = (float)(-width * 0.5f); count++; 222 | uppergear_i[count_i]=count_i;count_i++; 223 | } 224 | // a float is 4 bytes, therefore we multiply the number of vertices with 4. 225 | ByteBuffer vbb5 = ByteBuffer.allocateDirect(uppergear_v.length * 4); 226 | vbb5.order(ByteOrder.nativeOrder()); 227 | uppergear_vertexBuffer = vbb5.asFloatBuffer(); 228 | uppergear_vertexBuffer.put(uppergear_v); 229 | uppergear_vertexBuffer.position(0); 230 | // short is 2 bytes, therefore we multiply the number of vertices with 2. 231 | ByteBuffer ibb5 = ByteBuffer.allocateDirect(uppergear_i.length * 2); 232 | ibb5.order(ByteOrder.nativeOrder()); 233 | uppergear_indexBuffer = ibb5.asShortBuffer(); 234 | uppergear_indexBuffer.put(uppergear_i); 235 | uppergear_indexBuffer.position(0); 236 | 237 | //εσωτερικός κύλινδρος (τρύπα στο κέντρο) 238 | count = 0; 239 | count_i=0; 240 | for (i = 0; i <= teeth; i++) { 241 | angle = i * 2.0f * M_PI / teeth; 242 | innergear_v[count] = (float)(r0 * Math.cos(angle)); count++; 243 | innergear_v[count] = (float)(r0 * Math.sin(angle)); count++; 244 | innergear_v[count] = (float)(-width * 0.5f); count++; 245 | innergear_i[count_i]=count_i;count_i++; 246 | innergear_v[count] = (float)(r0 * Math.cos(angle)); count++; 247 | innergear_v[count] = (float)(r0 * Math.sin(angle)); count++; 248 | innergear_v[count] = (float)(width * 0.5f); count++; 249 | innergear_i[count_i]=count_i;count_i++; 250 | } 251 | // a float is 4 bytes, therefore we multiply the number of vertices with 4. 252 | ByteBuffer vbb6 = ByteBuffer.allocateDirect(innergear_v.length * 4); 253 | vbb6.order(ByteOrder.nativeOrder()); 254 | innergear_vertexBuffer = vbb6.asFloatBuffer(); 255 | innergear_vertexBuffer.put(innergear_v); 256 | innergear_vertexBuffer.position(0); 257 | // short is 2 bytes, therefore we multiply the number of vertices with 2. 258 | ByteBuffer ibb6 = ByteBuffer.allocateDirect(innergear_i.length * 2); 259 | ibb6.order(ByteOrder.nativeOrder()); 260 | innergear_indexBuffer = ibb6.asShortBuffer(); 261 | innergear_indexBuffer.put(innergear_i); 262 | innergear_indexBuffer.position(0); 263 | 264 | //Βραχίονες γραναζιού 265 | count = 0; 266 | count_i=0; 267 | if ( (cross>0) & (r0>0.0f) ) { 268 | float length = (r0 + r1)/2; //Μήκος βραχίονα 269 | float thicknessy = r0 * 0.2f; //Πάχος βραχίονα κατά την διάμετρο του γραναζιού 270 | float thicknessz = width * 0.8f; //Πάχος βραχίονα κατά το πάχος του γραναζιού 271 | 272 | //Βραχίονας δείκτη 273 | if(cross>=1) { 274 | //front1 275 | cross_v[count] = length; count++; 276 | cross_v[count] = (float)(-thicknessy/2); count++; 277 | cross_v[count] = (float)(-thicknessz/2); count++; 278 | cross_i[count_i]=count_i;count_i++; 279 | cross_v[count] = -length; count++; 280 | cross_v[count] = (float)(-thicknessy/2); count++; 281 | cross_v[count] = (float)(-thicknessz/2); count++; 282 | cross_i[count_i]=count_i;count_i++; 283 | cross_v[count] = length; count++; 284 | cross_v[count] = (float)( thicknessy/2); count++; 285 | cross_v[count] = (float)(-thicknessz/2); count++; 286 | cross_i[count_i]=count_i;count_i++; 287 | //front2 288 | cross_v[count] = -length; count++; 289 | cross_v[count] = (float)( thicknessy/2); count++; 290 | cross_v[count] = (float)(-thicknessz/2); count++; 291 | cross_i[count_i]=count_i;count_i++; 292 | //up1 293 | cross_v[count] = length; count++; 294 | cross_v[count] = (float)( thicknessy/2); count++; 295 | cross_v[count] = (float)( thicknessz/2); count++; 296 | cross_i[count_i]=count_i;count_i++; 297 | //up2 298 | cross_v[count] = -length; count++; 299 | cross_v[count] = (float)( thicknessy/2); count++; 300 | cross_v[count] = (float)( thicknessz/2); count++; 301 | cross_i[count_i]=count_i;count_i++; 302 | //back1 303 | cross_v[count] = length; count++; 304 | cross_v[count] = (float)(-thicknessy/2); count++; 305 | cross_v[count] = (float)( thicknessz/2); count++; 306 | cross_i[count_i]=count_i;count_i++; 307 | //back2 308 | cross_v[count] = -length; count++; 309 | cross_v[count] = (float)(-thicknessy/2); count++; 310 | cross_v[count] = (float)( thicknessz/2); count++; 311 | cross_i[count_i]=count_i;count_i++; 312 | //down1 313 | cross_v[count] = length; count++; 314 | cross_v[count] = (float)(-thicknessy/2); count++; 315 | cross_v[count] = (float)(-thicknessz/2); count++; 316 | cross_i[count_i]=count_i;count_i++; 317 | //down2 318 | cross_v[count] = -length; count++; 319 | cross_v[count] = (float)(-thicknessy/2); count++; 320 | cross_v[count] = (float)(-thicknessz/2); count++; 321 | cross_i[count_i]=count_i;count_i++; 322 | //final bound with beginning 323 | cross_v[count] = length; count++; 324 | cross_v[count] = (float)(-thicknessy/2); count++; 325 | cross_v[count] = (float)(-thicknessz/2); count++; 326 | cross_i[count_i]=count_i;count_i++; 327 | } 328 | } 329 | // a float is 4 bytes, therefore we multiply the number of vertices with 4. 330 | ByteBuffer vbb7 = ByteBuffer.allocateDirect(cross_v.length * 4); 331 | vbb7.order(ByteOrder.nativeOrder()); 332 | cross_vertexBuffer = vbb7.asFloatBuffer(); 333 | cross_vertexBuffer.put(cross_v); 334 | cross_vertexBuffer.position(0); 335 | // short is 2 bytes, therefore we multiply the number of vertices with 2. 336 | ByteBuffer ibb7 = ByteBuffer.allocateDirect(cross_i.length * 2); 337 | ibb7.order(ByteOrder.nativeOrder()); 338 | cross_indexBuffer = ibb7.asShortBuffer(); 339 | cross_indexBuffer.put(cross_i); 340 | cross_indexBuffer.position(0); 341 | 342 | } 343 | 344 | public void draw(GL10 gl, int color_pointer ) { 345 | // Counter-clockwise winding. 346 | gl.glFrontFace(GL10.GL_CCW); 347 | gl.glEnable(GL10.GL_CULL_FACE); 348 | gl.glCullFace(GL10.GL_BACK); 349 | gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); 350 | 351 | gl.glColor4f( color[color_pointer][0], color[color_pointer][1], color[color_pointer][2], color[color_pointer][3] ); 352 | // Specifies the location and data format of an array of vertex coordinates to use when rendering. 353 | gl.glVertexPointer(3, GL10.GL_FLOAT, 0, frontface_vertexBuffer); 354 | gl.glDrawElements(GL10.GL_TRIANGLE_STRIP, frontface_i.length, GL10.GL_UNSIGNED_SHORT, frontface_indexBuffer); 355 | 356 | gl.glColor4f( color[color_pointer][0], color[color_pointer][1], color[color_pointer][2], color[color_pointer][3] ); 357 | gl.glVertexPointer(3, GL10.GL_FLOAT, 0, frontgear_vertexBuffer); 358 | gl.glDrawElements(GL10.GL_TRIANGLES, frontgear_i.length, GL10.GL_UNSIGNED_SHORT, frontgear_indexBuffer); 359 | 360 | gl.glColor4f( color[color_pointer][0], color[color_pointer][1], color[color_pointer][2], color[color_pointer][3] ); 361 | gl.glVertexPointer(3, GL10.GL_FLOAT, 0, uppergear_vertexBuffer); 362 | gl.glDrawElements(GL10.GL_TRIANGLE_STRIP, uppergear_i.length, GL10.GL_UNSIGNED_SHORT, uppergear_indexBuffer); 363 | 364 | gl.glColor4f( color[color_pointer][0], color[color_pointer][1], color[color_pointer][2], color[color_pointer][3] ); 365 | gl.glVertexPointer(3, GL10.GL_FLOAT, 0, innergear_vertexBuffer); 366 | gl.glDrawElements(GL10.GL_TRIANGLE_STRIP, innergear_i.length, GL10.GL_UNSIGNED_SHORT, innergear_indexBuffer); 367 | 368 | gl.glColor4f( color[color_pointer][0], color[color_pointer][1], color[color_pointer][2], color[color_pointer][3] ); 369 | gl.glVertexPointer(3, GL10.GL_FLOAT, 0, cross_vertexBuffer); 370 | gl.glDrawElements(GL10.GL_TRIANGLE_STRIP, cross_i.length, GL10.GL_UNSIGNED_SHORT, cross_indexBuffer); 371 | 372 | gl.glDisable(GL10.GL_CULL_FACE); 373 | gl.glEnable(GL10.GL_CULL_FACE); 374 | gl.glCullFace(GL10.GL_FRONT); 375 | 376 | gl.glColor4f( color[color_pointer][0], color[color_pointer][1], color[color_pointer][2], color[color_pointer][3] ); 377 | gl.glVertexPointer(3, GL10.GL_FLOAT, 0, rearface_vertexBuffer); 378 | gl.glDrawElements(GL10.GL_TRIANGLE_STRIP, rearface_i.length, GL10.GL_UNSIGNED_SHORT, rearface_indexBuffer); 379 | 380 | gl.glColor4f( color[color_pointer][0], color[color_pointer][1], color[color_pointer][2], color[color_pointer][3] ); 381 | gl.glVertexPointer(3, GL10.GL_FLOAT, 0, reargear_vertexBuffer); 382 | gl.glDrawElements(GL10.GL_TRIANGLES, reargear_i.length, GL10.GL_UNSIGNED_SHORT, reargear_indexBuffer); 383 | 384 | gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); 385 | gl.glDisable(GL10.GL_CULL_FACE); 386 | 387 | } 388 | 389 | } 390 | --------------------------------------------------------------------------------