├── .idea └── vcs.xml ├── GeoAR.pdf ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── aishnaagrawal │ │ └── ardemo │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ ├── andy.obj │ │ ├── andy.png │ │ ├── andy_shadow.obj │ │ ├── andy_shadow.png │ │ ├── jb1.jpg │ │ ├── jb2.jpg │ │ ├── mchenry.jpg │ │ ├── selib.jpg │ │ ├── sign.jpg │ │ └── sign.obj │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── aishnaagrawal │ │ │ └── ardemo │ │ │ ├── activity │ │ │ └── ARActivity.java │ │ │ ├── api │ │ │ └── MarkerApi.java │ │ │ ├── helper │ │ │ └── CameraPermissionHelper.java │ │ │ ├── model │ │ │ ├── LocationTime.java │ │ │ ├── MarkerInfo.java │ │ │ └── MarkerLocation.java │ │ │ ├── renderer │ │ │ ├── BackgroundRenderer.java │ │ │ └── ObjectRenderer.java │ │ │ └── util │ │ │ └── ShaderUtil.java │ └── res │ │ ├── drawable │ │ └── background_splash.xml │ │ ├── layout │ │ └── activity_ar.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── raw │ │ ├── light_vertex.shader │ │ ├── object_fragment.shader │ │ ├── object_vertex.shader │ │ ├── passthrough_fragment.shader │ │ ├── plane_fragment.shader │ │ ├── plane_vertex.shader │ │ ├── point_cloud_vertex.shader │ │ ├── screenquad_fragment_oes.shader │ │ └── screenquad_vertex.shader │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── example │ └── aishnaagrawal │ └── ardemo │ └── ExampleUnitTest.java ├── arcore_client ├── arcore_client.aar └── build.gradle ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── obj-0.2.1 ├── build.gradle └── obj-0.2.1.jar └── settings.gradle /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /GeoAR.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/GeoAR.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Geolocation-ARCore 2 | The application serves as a base for any developer to build their own Geolocation AR app. The basic concept of the app is to help a user identify a certain building or location. When the user points their camera at a building, a 3D object like a wooden sign representing the direction and name of the building, is augmented onto their camera view. The user can view this object from any angle, interact with it by touching it for further information about the location. The sample app developed as proof of concept is a UCSC tour app that helps new UCSC students identify cafes, libraries, parking spots and academic building all around campus. 3 | The documentation for this project is available in the report GeoAR.pdf 4 | 5 | https://youtu.be/RAg6u2AZ1fI 6 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion '26.0.2' 6 | defaultConfig { 7 | applicationId "com.example.aishnaagrawal.ardemo" 8 | minSdkVersion 24 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | compile project(":arcore_client") 25 | compile project(":obj-0.2.1") 26 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 27 | exclude group: 'com.android.support', module: 'support-annotations' 28 | }) 29 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 30 | compile 'com.squareup.retrofit2:converter-gson:2.3.0' 31 | compile 'com.android.support:appcompat-v7:25.0.0' 32 | compile 'com.android.support:design:25.0.0' 33 | compile 'com.squareup.retrofit2:retrofit:2.3.0' 34 | testCompile 'junit:junit:4.12' 35 | 36 | } 37 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/aishnaagrawal/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/example/aishnaagrawal/ardemo/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.example.aishnaagrawal.ardemo; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.example.aishnaagrawal.ardemo", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 21 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/assets/andy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/app/src/main/assets/andy.png -------------------------------------------------------------------------------- /app/src/main/assets/andy_shadow.obj: -------------------------------------------------------------------------------- 1 | # This file uses centimeters as units for non-parametric coordinates. 2 | 3 | g default 4 | v -0.100000 -0.000000 0.100000 5 | v 0.100000 -0.000000 0.100000 6 | v -0.100000 0.000000 -0.100000 7 | v 0.100000 0.000000 -0.100000 8 | vt 0.000000 0.000000 9 | vt 1.000000 0.000000 10 | vt 0.000000 1.000000 11 | vt 1.000000 1.000000 12 | vn 0.000000 1.000000 0.000000 13 | vn 0.000000 1.000000 0.000000 14 | vn 0.000000 1.000000 0.000000 15 | vn 0.000000 1.000000 0.000000 16 | s off 17 | g AndyBlobShadow_GEO 18 | f 4/4/1 3/3/2 1/1/3 2/2/4 19 | -------------------------------------------------------------------------------- /app/src/main/assets/andy_shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/app/src/main/assets/andy_shadow.png -------------------------------------------------------------------------------- /app/src/main/assets/jb1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/app/src/main/assets/jb1.jpg -------------------------------------------------------------------------------- /app/src/main/assets/jb2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/app/src/main/assets/jb2.jpg -------------------------------------------------------------------------------- /app/src/main/assets/mchenry.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/app/src/main/assets/mchenry.jpg -------------------------------------------------------------------------------- /app/src/main/assets/selib.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/app/src/main/assets/selib.jpg -------------------------------------------------------------------------------- /app/src/main/assets/sign.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/app/src/main/assets/sign.jpg -------------------------------------------------------------------------------- /app/src/main/java/com/example/aishnaagrawal/ardemo/activity/ARActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.aishnaagrawal.ardemo.activity; 2 | 3 | import android.Manifest; 4 | import android.content.pm.PackageManager; 5 | import android.hardware.Sensor; 6 | import android.hardware.SensorEvent; 7 | import android.hardware.SensorEventListener; 8 | import android.hardware.SensorManager; 9 | import android.location.Location; 10 | import android.location.LocationListener; 11 | import android.location.LocationManager; 12 | import android.opengl.GLES20; 13 | import android.opengl.GLSurfaceView; 14 | import android.opengl.Matrix; 15 | import android.os.Bundle; 16 | import android.support.v4.content.ContextCompat; 17 | import android.support.v7.app.AppCompatActivity; 18 | import android.util.Log; 19 | import android.util.Range; 20 | import android.view.GestureDetector; 21 | import android.view.MotionEvent; 22 | import android.view.View; 23 | import android.view.WindowManager; 24 | import android.widget.Toast; 25 | 26 | import com.example.aishnaagrawal.ardemo.R; 27 | import com.example.aishnaagrawal.ardemo.api.MarkerApi; 28 | import com.example.aishnaagrawal.ardemo.helper.CameraPermissionHelper; 29 | import com.example.aishnaagrawal.ardemo.model.MarkerInfo; 30 | import com.example.aishnaagrawal.ardemo.renderer.BackgroundRenderer; 31 | import com.example.aishnaagrawal.ardemo.renderer.ObjectRenderer; 32 | import com.google.ar.core.Config; 33 | import com.google.ar.core.Frame; 34 | import com.google.ar.core.Frame.TrackingState; 35 | import com.google.ar.core.Pose; 36 | import com.google.ar.core.Session; 37 | 38 | import java.io.IOException; 39 | import java.util.ArrayList; 40 | import java.util.List; 41 | import java.util.concurrent.ArrayBlockingQueue; 42 | 43 | import javax.microedition.khronos.egl.EGLConfig; 44 | import javax.microedition.khronos.opengles.GL10; 45 | import javax.vecmath.Vector3f; 46 | 47 | import retrofit2.Call; 48 | import retrofit2.Callback; 49 | import retrofit2.Response; 50 | import retrofit2.Retrofit; 51 | import retrofit2.converter.gson.GsonConverterFactory; 52 | 53 | public class ARActivity extends AppCompatActivity implements GLSurfaceView.Renderer, SensorEventListener, LocationListener { 54 | 55 | private static final String TAG = ARActivity.class.getSimpleName(); 56 | 57 | private GLSurfaceView mSurfaceView; 58 | private Config mDefaultConfig; 59 | private Session mSession; 60 | private BackgroundRenderer mBackgroundRenderer = new BackgroundRenderer(); 61 | private GestureDetector mGestureDetector; 62 | private ObjectRenderer mVirtualObject = new ObjectRenderer(); 63 | 64 | private final float[] mAnchorMatrix = new float[16]; 65 | 66 | // Tap handling and UI. 67 | private ArrayBlockingQueue mQueuedSingleTaps = new ArrayBlockingQueue<>(16); 68 | 69 | //Location-based stuff 70 | private SensorManager mSensorManager; 71 | private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 0; // 10 meters 72 | private static final long MIN_TIME_BW_UPDATES = 0;//1000 * 60 * 1; // 1 minute 73 | public static final int REQUEST_LOCATION_PERMISSIONS_CODE = 0; 74 | 75 | private LocationManager mLocationManager; 76 | public Location mLocation; 77 | 78 | boolean isGPSEnabled; 79 | boolean isNetworkEnabled; 80 | boolean locationServiceAvailable; 81 | 82 | private static MarkerApi mMarkerApi; 83 | private String mBaseUrl = "http://139.59.30.117:3000/listings/"; 84 | private Retrofit mRetrofit; 85 | 86 | private List mMarkerList; 87 | private Frame mFrame; 88 | private float[] mZeroMatrix = new float[16]; 89 | 90 | float[] translation = new float[]{0.0f, -0.8f, -0.8f}; 91 | float[] rotation = new float[]{0.0f, -1.00f, 0.0f, 0.3f}; 92 | 93 | Pose mPose = new Pose(translation, rotation); 94 | 95 | 96 | @Override 97 | protected void onCreate(Bundle savedInstanceState) { 98 | super.onCreate(savedInstanceState); 99 | setContentView(R.layout.activity_ar); 100 | 101 | mSurfaceView = (GLSurfaceView) findViewById(R.id.surfaceview); 102 | mSession = new Session(/*context=*/this); 103 | mSensorManager = (SensorManager) this.getSystemService(SENSOR_SERVICE); 104 | 105 | // Create default config, check is supported, create session from that config. 106 | mDefaultConfig = Config.createDefaultConfig(); 107 | if (!mSession.isSupported(mDefaultConfig)) { 108 | Toast.makeText(this, "This device does not support AR", Toast.LENGTH_LONG).show(); 109 | finish(); 110 | return; 111 | } 112 | 113 | Matrix.setIdentityM(mZeroMatrix, 0); 114 | mPose.toMatrix(mAnchorMatrix, 0); 115 | 116 | // Set up tap listener. 117 | mGestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() { 118 | @Override 119 | public boolean onSingleTapUp(MotionEvent e) { 120 | onSingleTap(e); 121 | return true; 122 | } 123 | 124 | @Override 125 | public boolean onDown(MotionEvent e) { 126 | return true; 127 | } 128 | }); 129 | 130 | mSurfaceView.setOnTouchListener(new View.OnTouchListener() { 131 | @Override 132 | public boolean onTouch(View v, MotionEvent event) { 133 | return mGestureDetector.onTouchEvent(event); 134 | } 135 | }); 136 | 137 | // Set up renderer. 138 | mSurfaceView.setPreserveEGLContextOnPause(true); 139 | mSurfaceView.setEGLContextClientVersion(2); 140 | mSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0); // Alpha used for plane blending. 141 | mSurfaceView.setRenderer(this); 142 | mSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY); 143 | 144 | mRetrofit = new Retrofit.Builder() 145 | .baseUrl(mBaseUrl) 146 | .addConverterFactory(GsonConverterFactory.create()) 147 | .build(); 148 | mMarkerApi = mRetrofit.create(MarkerApi.class); 149 | mMarkerList = new ArrayList<>(); 150 | 151 | Call> call = mMarkerApi.getMarkers(); 152 | call.enqueue(new Callback>() { 153 | @Override 154 | public void onResponse(Call> call, Response> response) { 155 | mMarkerList.addAll(response.body()); 156 | 157 | } 158 | 159 | @Override 160 | public void onFailure(Call> call, Throwable t) { 161 | } 162 | }); 163 | 164 | } 165 | 166 | @Override 167 | protected void onResume() { 168 | super.onResume(); 169 | 170 | requestLocationPermission(); 171 | registerSensors(); 172 | requestCameraPermission(); 173 | } 174 | 175 | 176 | public void requestLocationPermission() { 177 | if (this.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { 178 | this.requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION_PERMISSIONS_CODE); 179 | } else { 180 | initLocationService(); 181 | } 182 | } 183 | 184 | public void requestCameraPermission() { 185 | if (CameraPermissionHelper.hasCameraPermission(this)) { 186 | mSession.resume(mDefaultConfig); 187 | mSurfaceView.onResume(); 188 | } else { 189 | CameraPermissionHelper.requestCameraPermission(this); 190 | } 191 | } 192 | 193 | private void registerSensors() { 194 | mSensorManager.registerListener(this, 195 | mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR), 196 | SensorManager.SENSOR_DELAY_FASTEST); 197 | } 198 | 199 | @Override 200 | public void onPause() { 201 | super.onPause(); 202 | 203 | mSurfaceView.onPause(); 204 | mSession.pause(); 205 | } 206 | 207 | @Override 208 | public void onSensorChanged(SensorEvent sensorEvent) { 209 | 210 | if (sensorEvent.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR) { 211 | 212 | float azimuth, pitch, bearing; 213 | Range azimuthRange, pitchRange; 214 | 215 | float[] rotationMatrixFromVector = new float[16]; 216 | float[] updatedRotationMatrix = new float[16]; 217 | float[] orientationValues = new float[3]; 218 | 219 | SensorManager.getRotationMatrixFromVector(rotationMatrixFromVector, sensorEvent.values); 220 | SensorManager 221 | .remapCoordinateSystem(rotationMatrixFromVector, 222 | SensorManager.AXIS_X, SensorManager.AXIS_Y, 223 | updatedRotationMatrix); 224 | SensorManager.getOrientation(updatedRotationMatrix, orientationValues); 225 | 226 | if (mMarkerList.isEmpty()) { 227 | return; 228 | } 229 | 230 | for (int i = 0; i < mMarkerList.size(); i++) { 231 | 232 | MarkerInfo marker = mMarkerList.get(i); 233 | 234 | bearing = mLocation.bearingTo(marker.getLocation()); 235 | azimuth = (float) Math.toDegrees(orientationValues[0]); 236 | pitch = (float) Math.toDegrees(orientationValues[1]); 237 | 238 | azimuthRange = new Range<>(bearing - 10, bearing + 10); 239 | pitchRange = new Range<>(-90.0f, -45.0f); 240 | 241 | if (azimuthRange.contains(azimuth) && pitchRange.contains(pitch)) { 242 | marker.setInRange(true); 243 | } else { 244 | marker.setInRange(false); 245 | } 246 | } 247 | } 248 | } 249 | 250 | @Override 251 | public void onAccuracyChanged(Sensor sensor, int i) { 252 | //do nothing 253 | } 254 | 255 | private void initLocationService() { 256 | 257 | if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { 258 | return; 259 | } 260 | 261 | try { 262 | this.mLocationManager = (LocationManager) this.getSystemService(this.LOCATION_SERVICE); 263 | 264 | // Get GPS and network status 265 | this.isGPSEnabled = mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); 266 | this.isNetworkEnabled = mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); 267 | 268 | if (!isNetworkEnabled && !isGPSEnabled) { 269 | // cannot get location 270 | this.locationServiceAvailable = false; 271 | } 272 | 273 | this.locationServiceAvailable = true; 274 | 275 | if (isNetworkEnabled) { 276 | mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 277 | MIN_TIME_BW_UPDATES, 278 | MIN_DISTANCE_CHANGE_FOR_UPDATES, this); 279 | if (mLocationManager != null) { 280 | mLocation = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); 281 | } 282 | } 283 | 284 | if (isGPSEnabled) { 285 | mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 286 | MIN_TIME_BW_UPDATES, 287 | MIN_DISTANCE_CHANGE_FOR_UPDATES, this); 288 | 289 | if (mLocationManager != null) { 290 | mLocation = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); 291 | } 292 | } 293 | } catch (Exception ex) { 294 | Log.e(TAG, ex.getMessage()); 295 | 296 | } 297 | } 298 | 299 | @Override 300 | public void onLocationChanged(Location location) { 301 | 302 | mLocation = location; 303 | MarkerInfo marker; 304 | 305 | for (int i = 0; i < mMarkerList.size(); i++) { 306 | marker = mMarkerList.get(i); 307 | marker.setDistance(location.distanceTo(marker.getLocation())); 308 | } 309 | } 310 | 311 | @Override 312 | public void onStatusChanged(String s, int i, Bundle bundle) { 313 | 314 | } 315 | 316 | @Override 317 | public void onProviderEnabled(String s) { 318 | 319 | } 320 | 321 | @Override 322 | public void onProviderDisabled(String s) { 323 | 324 | } 325 | 326 | @Override 327 | public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] results) { 328 | if (!CameraPermissionHelper.hasCameraPermission(this)) { 329 | Toast.makeText(this, 330 | "Camera permission is needed to run this application", Toast.LENGTH_LONG).show(); 331 | finish(); 332 | } 333 | } 334 | 335 | @Override 336 | public void onWindowFocusChanged(boolean hasFocus) { 337 | super.onWindowFocusChanged(hasFocus); 338 | if (hasFocus) { 339 | // Standard Android full-screen functionality. 340 | getWindow().getDecorView().setSystemUiVisibility( 341 | View.SYSTEM_UI_FLAG_LAYOUT_STABLE 342 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION 343 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 344 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION 345 | | View.SYSTEM_UI_FLAG_FULLSCREEN 346 | | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); 347 | getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 348 | } 349 | } 350 | 351 | private void onSingleTap(MotionEvent e) { 352 | // Queue tap if there is space. Tap is lost if queue is full. 353 | mQueuedSingleTaps.offer(e); 354 | } 355 | 356 | @Override 357 | public void onSurfaceCreated(GL10 gl, EGLConfig config) { 358 | GLES20.glClearColor(0.1f, 0.1f, 0.1f, 1.0f); 359 | 360 | // Create the texture and pass it to ARCore session to be filled during update(). 361 | mBackgroundRenderer.createOnGlThread(/*context=*/this); 362 | mSession.setCameraTextureName(mBackgroundRenderer.getTextureId()); 363 | 364 | // Prepare the other rendering objects. 365 | try { 366 | mVirtualObject.createOnGlThread(/*context=*/this, "sign.obj", "mchenry.jpg"); 367 | mVirtualObject.setMaterialProperties(0.0f, 3.5f, 1.0f, 6.0f); 368 | 369 | } catch (IOException e) { 370 | Log.e(TAG, "Failed to read obj file"); 371 | } 372 | 373 | } 374 | 375 | @Override 376 | public void onSurfaceChanged(GL10 gl, int width, int height) { 377 | GLES20.glViewport(0, 0, width, height); 378 | // Notify ARCore session that the view size changed so that the perspective matrix and 379 | // the video background can be properly adjusted. 380 | mSession.setDisplayGeometry(width, height); 381 | } 382 | 383 | @Override 384 | public void onDrawFrame(GL10 gl) { 385 | // Clear screen to notify driver it should not load any pixels from previous frame. 386 | GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); 387 | 388 | try { 389 | // Obtain the current frame from ARSession. When the configuration is set to 390 | // UpdateMode.BLOCKING (it is by default), this will throttle the rendering to the 391 | // camera framerate. 392 | Frame frame = mSession.update(); 393 | mFrame = frame; 394 | 395 | MotionEvent tap = mQueuedSingleTaps.poll(); 396 | 397 | // Draw background. 398 | mBackgroundRenderer.draw(frame); 399 | 400 | // If not tracking, don't draw 3d objects. 401 | if (frame.getTrackingState() == TrackingState.NOT_TRACKING) { 402 | return; 403 | } 404 | 405 | // Get projection matrix. 406 | float[] projmtx = new float[16]; 407 | mSession.getProjectionMatrix(projmtx, 0, 0.1f, 100.0f); 408 | 409 | // Get camera matrix and draw. 410 | float[] viewmtx = new float[16]; 411 | frame.getViewMatrix(viewmtx, 0); 412 | 413 | // Compute lighting from average intensity of the image. 414 | final float lightIntensity = frame.getLightEstimate().getPixelIntensity(); 415 | 416 | float scaleFactor = 0.5f; 417 | 418 | MarkerInfo marker; 419 | 420 | if (mMarkerList.isEmpty()) { 421 | return; 422 | } 423 | 424 | for (int i = 0; i < mMarkerList.size(); i++) { 425 | 426 | marker = mMarkerList.get(i); 427 | 428 | if (marker.getInRange()) { 429 | if (marker.getZeroMatrix() == null) { 430 | marker.setZeroMatrix(getCalibrationMatrix()); 431 | } 432 | } 433 | 434 | if (marker.getZeroMatrix() == null) { 435 | break; 436 | } 437 | 438 | Matrix.multiplyMM(viewmtx, 0, viewmtx, 0, marker.getZeroMatrix(), 0); 439 | 440 | mVirtualObject.updateModelMatrix(mAnchorMatrix, scaleFactor); 441 | mVirtualObject.draw(viewmtx, projmtx, lightIntensity); 442 | 443 | if (tap != null) { 444 | showToast(marker.getCategory()); 445 | } 446 | } 447 | 448 | } catch (Throwable t) { 449 | // Avoid crashing the application due to unhandled exceptions. 450 | Log.e(TAG, "Exception on the OpenGL thread", t); 451 | } 452 | 453 | } 454 | 455 | public float[] getCalibrationMatrix() { 456 | float[] t = new float[3]; 457 | float[] m = new float[16]; 458 | 459 | mFrame.getPose().getTranslation(t, 0); 460 | float[] z = mFrame.getPose().getZAxis(); 461 | Vector3f zAxis = new Vector3f(z[0], z[1], z[2]); 462 | zAxis.y = 0; 463 | zAxis.normalize(); 464 | 465 | double rotate = Math.atan2(zAxis.x, zAxis.z); 466 | 467 | Matrix.setIdentityM(m, 0); 468 | Matrix.translateM(m, 0, t[0], t[1], t[2]); 469 | Matrix.rotateM(m, 0, (float) Math.toDegrees(rotate), 0, 1, 0); 470 | return m; 471 | } 472 | 473 | private void showToast(final String category) { 474 | runOnUiThread(new Runnable() { 475 | @Override 476 | public void run() { 477 | Toast.makeText(getApplicationContext(), category, Toast.LENGTH_SHORT).show(); 478 | } 479 | }); 480 | } 481 | 482 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/aishnaagrawal/ardemo/api/MarkerApi.java: -------------------------------------------------------------------------------- 1 | package com.example.aishnaagrawal.ardemo.api; 2 | 3 | import com.example.aishnaagrawal.ardemo.model.MarkerInfo; 4 | 5 | import java.util.List; 6 | 7 | import retrofit2.Call; 8 | import retrofit2.http.GET; 9 | 10 | /** 11 | * Created by aishnaagrawal on 11/16/17. 12 | */ 13 | 14 | public interface MarkerApi { 15 | @GET("36.97398389105355/37.00942677981021/-122.08119844562987/-122.0473811543701/") 16 | Call> getMarkers(); 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/aishnaagrawal/ardemo/helper/CameraPermissionHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.example.aishnaagrawal.ardemo.helper; 16 | 17 | import android.Manifest; 18 | import android.app.Activity; 19 | import android.content.pm.PackageManager; 20 | import android.support.v4.app.ActivityCompat; 21 | import android.support.v4.content.ContextCompat; 22 | 23 | /** 24 | * Helper to ask camera permission. 25 | */ 26 | public class CameraPermissionHelper { 27 | private static final String CAMERA_PERMISSION = Manifest.permission.CAMERA; 28 | private static final int CAMERA_PERMISSION_CODE = 0; 29 | 30 | /** 31 | * Check to see we have the necessary permissions for this app. 32 | */ 33 | public static boolean hasCameraPermission(Activity activity) { 34 | return ContextCompat.checkSelfPermission(activity, CAMERA_PERMISSION) == 35 | PackageManager.PERMISSION_GRANTED; 36 | } 37 | 38 | /** 39 | * Check to see we have the necessary permissions for this app, and ask for them if we don't. 40 | */ 41 | public static void requestCameraPermission(Activity activity) { 42 | ActivityCompat.requestPermissions(activity, new String[]{CAMERA_PERMISSION}, 43 | CAMERA_PERMISSION_CODE); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/aishnaagrawal/ardemo/model/LocationTime.java: -------------------------------------------------------------------------------- 1 | package com.example.aishnaagrawal.ardemo.model; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | /** 6 | * Created by aishnaagrawal on 11/17/17. 7 | */ 8 | 9 | public class LocationTime { 10 | 11 | @SerializedName("data") 12 | private String data; 13 | 14 | @SerializedName("isOpen") 15 | private boolean isOpen; 16 | 17 | public String getData() { 18 | return data; 19 | } 20 | 21 | public void setData(String data) { 22 | this.data = data; 23 | } 24 | 25 | public boolean checkOpen() { 26 | return isOpen; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/aishnaagrawal/ardemo/model/MarkerInfo.java: -------------------------------------------------------------------------------- 1 | package com.example.aishnaagrawal.ardemo.model; 2 | 3 | import android.location.Location; 4 | 5 | import com.example.aishnaagrawal.ardemo.renderer.ObjectRenderer; 6 | import com.google.gson.annotations.Expose; 7 | import com.google.gson.annotations.SerializedName; 8 | 9 | /** 10 | * Created by aishnaagrawal on 11/16/17. 11 | */ 12 | 13 | public class MarkerInfo { 14 | 15 | @SerializedName("_id") 16 | @Expose 17 | private String id; 18 | @SerializedName("time") 19 | @Expose 20 | private LocationTime time; 21 | @SerializedName("name") 22 | @Expose 23 | private String name; 24 | @SerializedName("category") 25 | @Expose 26 | private String category; 27 | @SerializedName("location") 28 | @Expose 29 | private MarkerLocation markerLocation; 30 | 31 | //Additional variables 32 | private float distance; 33 | private boolean inRange; 34 | private float[] zeroMatrix; 35 | private ObjectRenderer virtualObject; 36 | 37 | public MarkerInfo(String name, String category, MarkerLocation markerLocation) { 38 | this.name = name; 39 | this.category = category; 40 | this.markerLocation = markerLocation; 41 | } 42 | 43 | public float getDistance() { 44 | return distance; 45 | } 46 | 47 | public void setDistance(Float distance) { 48 | this.distance = distance; 49 | } 50 | 51 | public boolean getInRange() { 52 | return inRange; 53 | } 54 | 55 | public void setInRange(Boolean inRange) { 56 | this.inRange = inRange; 57 | } 58 | 59 | public String getName() { 60 | return name; 61 | } 62 | 63 | public LocationTime getTime() { 64 | return time; 65 | } 66 | 67 | public String getCategory() { 68 | return category; 69 | } 70 | 71 | public Location getLocation() { 72 | Location location = new Location(name); 73 | location.setLatitude(markerLocation.getLat()); 74 | location.setLongitude(markerLocation.getLng()); 75 | return location; 76 | } 77 | 78 | public float[] getZeroMatrix() { 79 | return zeroMatrix; 80 | } 81 | 82 | public void setZeroMatrix(float[] zeroMatrix) { 83 | this.zeroMatrix = zeroMatrix; 84 | } 85 | 86 | public ObjectRenderer getVirtualObject() { 87 | return virtualObject; 88 | } 89 | 90 | public void setVirtualObject(ObjectRenderer virtualObject) { 91 | this.virtualObject = virtualObject; 92 | } 93 | 94 | } 95 | 96 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/aishnaagrawal/ardemo/model/MarkerLocation.java: -------------------------------------------------------------------------------- 1 | package com.example.aishnaagrawal.ardemo.model; 2 | 3 | import com.google.gson.annotations.Expose; 4 | import com.google.gson.annotations.SerializedName; 5 | 6 | /** 7 | * Created by aishnaagrawal on 11/16/17. 8 | */ 9 | 10 | public class MarkerLocation { 11 | @SerializedName("lat") 12 | @Expose 13 | private String latitude; 14 | @SerializedName("lng") 15 | @Expose 16 | private String longitude; 17 | 18 | public MarkerLocation(String latitude, String longitude) { 19 | this.latitude = latitude; 20 | this.longitude = longitude; 21 | } 22 | 23 | public float getLat() { 24 | return Float.parseFloat(latitude); 25 | } 26 | 27 | public float getLng() { 28 | return Float.parseFloat(longitude); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/aishnaagrawal/ardemo/renderer/BackgroundRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.example.aishnaagrawal.ardemo.renderer; 16 | 17 | import android.content.Context; 18 | import android.opengl.GLES11Ext; 19 | import android.opengl.GLES20; 20 | import android.opengl.GLSurfaceView; 21 | 22 | import com.example.aishnaagrawal.ardemo.R; 23 | import com.example.aishnaagrawal.ardemo.util.ShaderUtil; 24 | import com.google.ar.core.Frame; 25 | import com.google.ar.core.Session; 26 | 27 | import java.nio.ByteBuffer; 28 | import java.nio.ByteOrder; 29 | import java.nio.FloatBuffer; 30 | 31 | import javax.microedition.khronos.egl.EGLConfig; 32 | import javax.microedition.khronos.opengles.GL10; 33 | 34 | /** 35 | * This class renders the AR background from camera feed. It creates and hosts the texture 36 | * given to ARCore to be filled with the camera image. 37 | */ 38 | public class BackgroundRenderer { 39 | private static final String TAG = BackgroundRenderer.class.getSimpleName(); 40 | 41 | private static final int COORDS_PER_VERTEX = 3; 42 | private static final int TEXCOORDS_PER_VERTEX = 2; 43 | private static final int FLOAT_SIZE = 4; 44 | 45 | private FloatBuffer mQuadVertices; 46 | private FloatBuffer mQuadTexCoord; 47 | private FloatBuffer mQuadTexCoordTransformed; 48 | 49 | private int mQuadProgram; 50 | 51 | private int mQuadPositionParam; 52 | private int mQuadTexCoordParam; 53 | private int mTextureId = -1; 54 | private int mTextureTarget = GLES11Ext.GL_TEXTURE_EXTERNAL_OES; 55 | public BackgroundRenderer() { 56 | } 57 | 58 | public int getTextureId() { 59 | return mTextureId; 60 | } 61 | 62 | /** 63 | * Allocates and initializes OpenGL resources needed by the background renderer. Must be 64 | * called on the OpenGL thread, typically in 65 | * {@link GLSurfaceView.Renderer#onSurfaceCreated(GL10, EGLConfig)}. 66 | * 67 | * @param context Needed to access shader source. 68 | */ 69 | public void createOnGlThread(Context context) { 70 | // Generate the background texture. 71 | int textures[] = new int[1]; 72 | GLES20.glGenTextures(1, textures, 0); 73 | mTextureId = textures[0]; 74 | GLES20.glBindTexture(mTextureTarget, mTextureId); 75 | GLES20.glTexParameteri(mTextureTarget, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); 76 | GLES20.glTexParameteri(mTextureTarget, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); 77 | GLES20.glTexParameteri(mTextureTarget, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST); 78 | GLES20.glTexParameteri(mTextureTarget, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST); 79 | 80 | int numVertices = 4; 81 | if (numVertices != QUAD_COORDS.length / COORDS_PER_VERTEX) { 82 | throw new RuntimeException("Unexpected number of vertices in BackgroundRenderer."); 83 | } 84 | 85 | ByteBuffer bbVertices = ByteBuffer.allocateDirect(QUAD_COORDS.length * FLOAT_SIZE); 86 | bbVertices.order(ByteOrder.nativeOrder()); 87 | mQuadVertices = bbVertices.asFloatBuffer(); 88 | mQuadVertices.put(QUAD_COORDS); 89 | mQuadVertices.position(0); 90 | 91 | ByteBuffer bbTexCoords = ByteBuffer.allocateDirect( 92 | numVertices * TEXCOORDS_PER_VERTEX * FLOAT_SIZE); 93 | bbTexCoords.order(ByteOrder.nativeOrder()); 94 | mQuadTexCoord = bbTexCoords.asFloatBuffer(); 95 | mQuadTexCoord.put(QUAD_TEXCOORDS); 96 | mQuadTexCoord.position(0); 97 | 98 | ByteBuffer bbTexCoordsTransformed = ByteBuffer.allocateDirect( 99 | numVertices * TEXCOORDS_PER_VERTEX * FLOAT_SIZE); 100 | bbTexCoordsTransformed.order(ByteOrder.nativeOrder()); 101 | mQuadTexCoordTransformed = bbTexCoordsTransformed.asFloatBuffer(); 102 | 103 | int vertexShader = ShaderUtil.loadGLShader(TAG, context, 104 | GLES20.GL_VERTEX_SHADER, R.raw.screenquad_vertex); 105 | int fragmentShader = ShaderUtil.loadGLShader(TAG, context, 106 | GLES20.GL_FRAGMENT_SHADER, R.raw.screenquad_fragment_oes); 107 | 108 | mQuadProgram = GLES20.glCreateProgram(); 109 | GLES20.glAttachShader(mQuadProgram, vertexShader); 110 | GLES20.glAttachShader(mQuadProgram, fragmentShader); 111 | GLES20.glLinkProgram(mQuadProgram); 112 | GLES20.glUseProgram(mQuadProgram); 113 | 114 | ShaderUtil.checkGLError(TAG, "Program creation"); 115 | 116 | mQuadPositionParam = GLES20.glGetAttribLocation(mQuadProgram, "a_Position"); 117 | mQuadTexCoordParam = GLES20.glGetAttribLocation(mQuadProgram, "a_TexCoord"); 118 | 119 | ShaderUtil.checkGLError(TAG, "Program parameters"); 120 | } 121 | 122 | /** 123 | * Draws the AR background image. The image will be drawn such that virtual content rendered 124 | * with the matrices provided by {@link Frame#getViewMatrix(float[], int)} and 125 | * {@link Session#getProjectionMatrix(float[], int, float, float)} will accurately follow 126 | * static physical objects. This must be called before drawing virtual content. 127 | * 128 | * @param frame The last {@code Frame} returned by {@link Session#update()}. 129 | */ 130 | public void draw(Frame frame) { 131 | // If display rotation changed (also includes view size change), we need to re-query the uv 132 | // coordinates for the screen rect, as they may have changed as well. 133 | if (frame.isDisplayRotationChanged()) { 134 | frame.transformDisplayUvCoords(mQuadTexCoord, mQuadTexCoordTransformed); 135 | } 136 | 137 | // No need to test or write depth, the screen quad has arbitrary depth, and is expected 138 | // to be drawn first. 139 | GLES20.glDisable(GLES20.GL_DEPTH_TEST); 140 | GLES20.glDepthMask(false); 141 | 142 | GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureId); 143 | 144 | GLES20.glUseProgram(mQuadProgram); 145 | 146 | // Set the vertex positions. 147 | GLES20.glVertexAttribPointer( 148 | mQuadPositionParam, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, 0, mQuadVertices); 149 | 150 | // Set the texture coordinates. 151 | GLES20.glVertexAttribPointer(mQuadTexCoordParam, TEXCOORDS_PER_VERTEX, 152 | GLES20.GL_FLOAT, false, 0, mQuadTexCoordTransformed); 153 | 154 | // Enable vertex arrays 155 | GLES20.glEnableVertexAttribArray(mQuadPositionParam); 156 | GLES20.glEnableVertexAttribArray(mQuadTexCoordParam); 157 | 158 | GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); 159 | 160 | // Disable vertex arrays 161 | GLES20.glDisableVertexAttribArray(mQuadPositionParam); 162 | GLES20.glDisableVertexAttribArray(mQuadTexCoordParam); 163 | 164 | // Restore the depth state for further drawing. 165 | GLES20.glDepthMask(true); 166 | GLES20.glEnable(GLES20.GL_DEPTH_TEST); 167 | 168 | ShaderUtil.checkGLError(TAG, "Draw"); 169 | } 170 | 171 | public static final float[] QUAD_COORDS = new float[]{ 172 | -1.0f, -1.0f, 0.0f, 173 | -1.0f, +1.0f, 0.0f, 174 | +1.0f, -1.0f, 0.0f, 175 | +1.0f, +1.0f, 0.0f, 176 | }; 177 | 178 | public static final float[] QUAD_TEXCOORDS = new float[]{ 179 | 0.0f, 1.0f, 180 | 0.0f, 0.0f, 181 | 1.0f, 1.0f, 182 | 1.0f, 0.0f, 183 | }; 184 | } 185 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/aishnaagrawal/ardemo/renderer/ObjectRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.example.aishnaagrawal.ardemo.renderer; 16 | 17 | import android.content.Context; 18 | import android.graphics.Bitmap; 19 | import android.graphics.BitmapFactory; 20 | import android.opengl.GLES20; 21 | import android.opengl.GLUtils; 22 | import android.opengl.Matrix; 23 | 24 | import com.example.aishnaagrawal.ardemo.R; 25 | import com.example.aishnaagrawal.ardemo.util.ShaderUtil; 26 | 27 | import java.io.IOException; 28 | import java.io.InputStream; 29 | import java.nio.ByteBuffer; 30 | import java.nio.ByteOrder; 31 | import java.nio.FloatBuffer; 32 | import java.nio.IntBuffer; 33 | import java.nio.ShortBuffer; 34 | 35 | import de.javagl.Obj; 36 | import de.javagl.ObjData; 37 | import de.javagl.ObjReader; 38 | import de.javagl.ObjUtils; 39 | 40 | /** 41 | * Renders an object loaded from an OBJ file in OpenGL. 42 | */ 43 | public class ObjectRenderer { 44 | private static final String TAG = ObjectRenderer.class.getSimpleName(); 45 | 46 | /** 47 | * Blend mode. 48 | * 49 | * @see #setBlendMode(BlendMode) 50 | */ 51 | public enum BlendMode { 52 | /** Multiplies the destination color by the source alpha. */ 53 | Shadow, 54 | /** Normal alpha blending. */ 55 | Grid 56 | }; 57 | 58 | private static final int COORDS_PER_VERTEX = 3; 59 | 60 | // Note: the last component must be zero to avoid applying the translational part of the matrix. 61 | private static final float[] LIGHT_DIRECTION = new float[] { 0.0f, 1.0f, 0.0f, 0.0f }; 62 | private float[] mViewLightDirection = new float[4]; 63 | 64 | // Object vertex buffer variables. 65 | private int mVertexBufferId; 66 | private int mVerticesBaseAddress; 67 | private int mTexCoordsBaseAddress; 68 | private int mNormalsBaseAddress; 69 | private int mIndexBufferId; 70 | private int mIndexCount; 71 | 72 | private int mProgram; 73 | private int[] mTextures = new int[1]; 74 | 75 | // Shader location: model view projection matrix. 76 | private int mModelViewUniform; 77 | private int mModelViewProjectionUniform; 78 | 79 | // Shader location: object attributes. 80 | private int mPositionAttribute; 81 | private int mNormalAttribute; 82 | private int mTexCoordAttribute; 83 | 84 | // Shader location: texture sampler. 85 | private int mTextureUniform; 86 | 87 | // Shader location: environment properties. 88 | private int mLightingParametersUniform; 89 | 90 | // Shader location: material properties. 91 | private int mMaterialParametersUniform; 92 | 93 | private BlendMode mBlendMode = null; 94 | 95 | // Temporary matrices allocated here to reduce number of allocations for each frame. 96 | private float[] mModelMatrix = new float[16]; 97 | private float[] mModelViewMatrix = new float[16]; 98 | private float[] mModelViewProjectionMatrix = new float[16]; 99 | 100 | // Set some default material properties to use for lighting. 101 | private float mAmbient = 0.3f; 102 | private float mDiffuse = 1.0f; 103 | private float mSpecular = 1.0f; 104 | private float mSpecularPower = 6.0f; 105 | 106 | public ObjectRenderer() { 107 | } 108 | 109 | /** 110 | * Creates and initializes OpenGL resources needed for rendering the model. 111 | * 112 | * @param context Context for loading the shader and below-named model and texture assets. 113 | * @param objAssetName Name of the OBJ file containing the model geometry. 114 | * @param diffuseTextureAssetName Name of the PNG file containing the diffuse texture map. 115 | */ 116 | public void createOnGlThread(Context context, String objAssetName, 117 | String diffuseTextureAssetName) throws IOException { 118 | // Read the texture. 119 | Bitmap textureBitmap = BitmapFactory.decodeStream( 120 | context.getAssets().open(diffuseTextureAssetName)); 121 | 122 | GLES20.glActiveTexture(GLES20.GL_TEXTURE0); 123 | GLES20.glGenTextures(mTextures.length, mTextures, 0); 124 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextures[0]); 125 | 126 | GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, 127 | GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR_MIPMAP_LINEAR); 128 | GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, 129 | GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); 130 | GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, textureBitmap, 0); 131 | GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D); 132 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); 133 | 134 | textureBitmap.recycle(); 135 | 136 | ShaderUtil.checkGLError(TAG, "Texture loading"); 137 | 138 | // Read the obj file. 139 | InputStream objInputStream = context.getAssets().open(objAssetName); 140 | Obj obj = ObjReader.read(objInputStream); 141 | 142 | // Prepare the Obj so that its structure is suitable for 143 | // rendering with OpenGL: 144 | // 1. Triangulate it 145 | // 2. Make sure that texture coordinates are not ambiguous 146 | // 3. Make sure that normals are not ambiguous 147 | // 4. Convert it to single-indexed data 148 | obj = ObjUtils.convertToRenderable(obj); 149 | 150 | // OpenGL does not use Java arrays. ByteBuffers are used instead to provide data in a format 151 | // that OpenGL understands. 152 | 153 | // Obtain the data from the OBJ, as direct buffers: 154 | IntBuffer wideIndices = ObjData.getFaceVertexIndices(obj, 3); 155 | FloatBuffer vertices = ObjData.getVertices(obj); 156 | FloatBuffer texCoords = ObjData.getTexCoords(obj, 2); 157 | FloatBuffer normals = ObjData.getNormals(obj); 158 | 159 | // Convert int indices to shorts for GL ES 2.0 compatibility 160 | ShortBuffer indices = ByteBuffer.allocateDirect(2 * wideIndices.limit()) 161 | .order(ByteOrder.nativeOrder()).asShortBuffer(); 162 | while (wideIndices.hasRemaining()) { 163 | indices.put((short) wideIndices.get()); 164 | } 165 | indices.rewind(); 166 | 167 | int[] buffers = new int[2]; 168 | GLES20.glGenBuffers(2, buffers, 0); 169 | mVertexBufferId = buffers[0]; 170 | mIndexBufferId = buffers[1]; 171 | 172 | // Load vertex buffer 173 | mVerticesBaseAddress = 0; 174 | mTexCoordsBaseAddress = mVerticesBaseAddress + 4 * vertices.limit(); 175 | mNormalsBaseAddress = mTexCoordsBaseAddress + 4 * texCoords.limit(); 176 | final int totalBytes = mNormalsBaseAddress + 4 * normals.limit(); 177 | 178 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVertexBufferId); 179 | GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, totalBytes, null, GLES20.GL_STATIC_DRAW); 180 | GLES20.glBufferSubData( 181 | GLES20.GL_ARRAY_BUFFER, mVerticesBaseAddress, 4 * vertices.limit(), vertices); 182 | GLES20.glBufferSubData( 183 | GLES20.GL_ARRAY_BUFFER, mTexCoordsBaseAddress, 4 * texCoords.limit(), texCoords); 184 | GLES20.glBufferSubData( 185 | GLES20.GL_ARRAY_BUFFER, mNormalsBaseAddress, 4 * normals.limit(), normals); 186 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); 187 | 188 | // Load index buffer 189 | GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, mIndexBufferId); 190 | mIndexCount = indices.limit(); 191 | GLES20.glBufferData( 192 | GLES20.GL_ELEMENT_ARRAY_BUFFER, 2 * mIndexCount, indices, GLES20.GL_STATIC_DRAW); 193 | GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0); 194 | 195 | ShaderUtil.checkGLError(TAG, "OBJ buffer load"); 196 | 197 | final int vertexShader = ShaderUtil.loadGLShader(TAG, context, 198 | GLES20.GL_VERTEX_SHADER, R.raw.object_vertex); 199 | final int fragmentShader = ShaderUtil.loadGLShader(TAG, context, 200 | GLES20.GL_FRAGMENT_SHADER, R.raw.object_fragment); 201 | 202 | mProgram = GLES20.glCreateProgram(); 203 | GLES20.glAttachShader(mProgram, vertexShader); 204 | GLES20.glAttachShader(mProgram, fragmentShader); 205 | GLES20.glLinkProgram(mProgram); 206 | GLES20.glUseProgram(mProgram); 207 | 208 | ShaderUtil.checkGLError(TAG, "Program creation"); 209 | 210 | mModelViewUniform = GLES20.glGetUniformLocation(mProgram, "u_ModelView"); 211 | mModelViewProjectionUniform = 212 | GLES20.glGetUniformLocation(mProgram, "u_ModelViewProjection"); 213 | 214 | mPositionAttribute = GLES20.glGetAttribLocation(mProgram, "a_Position"); 215 | mNormalAttribute = GLES20.glGetAttribLocation(mProgram, "a_Normal"); 216 | mTexCoordAttribute = GLES20.glGetAttribLocation(mProgram, "a_TexCoord"); 217 | 218 | mTextureUniform = GLES20.glGetUniformLocation(mProgram, "u_Texture"); 219 | 220 | mLightingParametersUniform = GLES20.glGetUniformLocation(mProgram, "u_LightingParameters"); 221 | mMaterialParametersUniform = GLES20.glGetUniformLocation(mProgram, "u_MaterialParameters"); 222 | 223 | ShaderUtil.checkGLError(TAG, "Program parameters"); 224 | 225 | Matrix.setIdentityM(mModelMatrix, 0); 226 | } 227 | 228 | /** 229 | * Selects the blending mode for rendering. 230 | * 231 | * @param blendMode The blending mode. Null indicates no blending (opaque rendering). 232 | */ 233 | public void setBlendMode(BlendMode blendMode) { 234 | mBlendMode = blendMode; 235 | } 236 | 237 | /** 238 | * Updates the object model matrix and applies scaling. 239 | * 240 | * @param modelMatrix A 4x4 model-to-world transformation matrix, stored in column-major order. 241 | * @param scaleFactor A separate scaling factor to apply before the {@code modelMatrix}. 242 | * @see android.opengl.Matrix 243 | */ 244 | public void updateModelMatrix(float[] modelMatrix, float scaleFactor) { 245 | float[] scaleMatrix = new float[16]; 246 | Matrix.setIdentityM(scaleMatrix, 0); 247 | scaleMatrix[0] = scaleFactor; 248 | scaleMatrix[5] = scaleFactor; 249 | scaleMatrix[10] = scaleFactor; 250 | Matrix.multiplyMM(mModelMatrix, 0, modelMatrix, 0, scaleMatrix, 0); 251 | } 252 | 253 | /** 254 | * Sets the surface characteristics of the rendered model. 255 | * 256 | * @param ambient Intensity of non-directional surface illumination. 257 | * @param diffuse Diffuse (matte) surface reflectivity. 258 | * @param specular Specular (shiny) surface reflectivity. 259 | * @param specularPower Surface shininess. Larger values result in a smaller, sharper 260 | * specular highlight. 261 | */ 262 | public void setMaterialProperties( 263 | float ambient, float diffuse, float specular, float specularPower) { 264 | mAmbient = ambient; 265 | mDiffuse = diffuse; 266 | mSpecular = specular; 267 | mSpecularPower = specularPower; 268 | } 269 | 270 | /** 271 | * Draws the model. 272 | * 273 | * @param cameraView A 4x4 view matrix, in column-major order. 274 | * @param cameraPerspective A 4x4 projection matrix, in column-major order. 275 | * @param lightIntensity Illumination intensity. Combined with diffuse and specular material 276 | * properties. 277 | * @see #setBlendMode(BlendMode) 278 | * @see #updateModelMatrix(float[], float) 279 | * @see #setMaterialProperties(float, float, float, float) 280 | * @see android.opengl.Matrix 281 | */ 282 | public void draw(float[] cameraView, float[] cameraPerspective, float lightIntensity) { 283 | 284 | ShaderUtil.checkGLError(TAG, "Before draw"); 285 | 286 | // Build the ModelView and ModelViewProjection matrices 287 | // for calculating object position and light. 288 | Matrix.multiplyMM(mModelViewMatrix, 0, cameraView, 0, mModelMatrix, 0); 289 | Matrix.multiplyMM(mModelViewProjectionMatrix, 0, cameraPerspective, 0, mModelViewMatrix, 0); 290 | 291 | GLES20.glUseProgram(mProgram); 292 | 293 | // Set the lighting environment properties. 294 | Matrix.multiplyMV(mViewLightDirection, 0, mModelViewMatrix, 0, LIGHT_DIRECTION, 0); 295 | normalizeVec3(mViewLightDirection); 296 | GLES20.glUniform4f(mLightingParametersUniform, 297 | mViewLightDirection[0], mViewLightDirection[1], mViewLightDirection[2], lightIntensity); 298 | 299 | // Set the object material properties. 300 | GLES20.glUniform4f(mMaterialParametersUniform, mAmbient, mDiffuse, mSpecular, 301 | mSpecularPower); 302 | 303 | // Attach the object texture. 304 | GLES20.glActiveTexture(GLES20.GL_TEXTURE0); 305 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextures[0]); 306 | GLES20.glUniform1i(mTextureUniform, 0); 307 | 308 | // Set the vertex attributes. 309 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVertexBufferId); 310 | 311 | GLES20.glVertexAttribPointer( 312 | mPositionAttribute, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, 0, mVerticesBaseAddress); 313 | GLES20.glVertexAttribPointer( 314 | mNormalAttribute, 3, GLES20.GL_FLOAT, false, 0, mNormalsBaseAddress); 315 | GLES20.glVertexAttribPointer( 316 | mTexCoordAttribute, 2, GLES20.GL_FLOAT, false, 0, mTexCoordsBaseAddress); 317 | 318 | GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); 319 | 320 | // Set the ModelViewProjection matrix in the shader. 321 | GLES20.glUniformMatrix4fv( 322 | mModelViewUniform, 1, false, mModelViewMatrix, 0); 323 | GLES20.glUniformMatrix4fv( 324 | mModelViewProjectionUniform, 1, false, mModelViewProjectionMatrix, 0); 325 | 326 | // Enable vertex arrays 327 | GLES20.glEnableVertexAttribArray(mPositionAttribute); 328 | GLES20.glEnableVertexAttribArray(mNormalAttribute); 329 | GLES20.glEnableVertexAttribArray(mTexCoordAttribute); 330 | 331 | if (mBlendMode != null) { 332 | GLES20.glDepthMask(false); 333 | GLES20.glEnable(GLES20.GL_BLEND); 334 | switch (mBlendMode) { 335 | case Shadow: 336 | // Multiplicative blending function for Shadow. 337 | GLES20.glBlendFunc(GLES20.GL_ZERO, GLES20.GL_ONE_MINUS_SRC_ALPHA); 338 | break; 339 | case Grid: 340 | // Grid, additive blending function. 341 | GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA); 342 | break; 343 | } 344 | } 345 | 346 | GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, mIndexBufferId); 347 | GLES20.glDrawElements(GLES20.GL_TRIANGLES, mIndexCount, GLES20.GL_UNSIGNED_SHORT, 0); 348 | GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0); 349 | 350 | if (mBlendMode != null) { 351 | GLES20.glDisable(GLES20.GL_BLEND); 352 | GLES20.glDepthMask(true); 353 | } 354 | 355 | // Disable vertex arrays 356 | GLES20.glDisableVertexAttribArray(mPositionAttribute); 357 | GLES20.glDisableVertexAttribArray(mNormalAttribute); 358 | GLES20.glDisableVertexAttribArray(mTexCoordAttribute); 359 | 360 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); 361 | 362 | ShaderUtil.checkGLError(TAG, "After draw"); 363 | } 364 | 365 | public static void normalizeVec3(float[] v) { 366 | float reciprocalLength = 1.0f / (float) Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); 367 | v[0] *= reciprocalLength; 368 | v[1] *= reciprocalLength; 369 | v[2] *= reciprocalLength; 370 | } 371 | } 372 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/aishnaagrawal/ardemo/util/ShaderUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | package com.example.aishnaagrawal.ardemo.util; 16 | 17 | import android.content.Context; 18 | import android.opengl.GLES20; 19 | import android.util.Log; 20 | 21 | import java.io.BufferedReader; 22 | import java.io.IOException; 23 | import java.io.InputStream; 24 | import java.io.InputStreamReader; 25 | 26 | /** 27 | * Shader helper functions. 28 | */ 29 | public class ShaderUtil { 30 | /** 31 | * Converts a raw text file, saved as a resource, into an OpenGL ES shader. 32 | * 33 | * @param type The type of shader we will be creating. 34 | * @param resId The resource ID of the raw text file about to be turned into a shader. 35 | * @return The shader object handler. 36 | */ 37 | public static int loadGLShader(String tag, Context context, int type, int resId) { 38 | String code = readRawTextFile(context, resId); 39 | int shader = GLES20.glCreateShader(type); 40 | GLES20.glShaderSource(shader, code); 41 | GLES20.glCompileShader(shader); 42 | 43 | // Get the compilation status. 44 | final int[] compileStatus = new int[1]; 45 | GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compileStatus, 0); 46 | 47 | // If the compilation failed, delete the shader. 48 | if (compileStatus[0] == 0) { 49 | Log.e(tag, "Error compiling shader: " + GLES20.glGetShaderInfoLog(shader)); 50 | GLES20.glDeleteShader(shader); 51 | shader = 0; 52 | } 53 | 54 | if (shader == 0) { 55 | throw new RuntimeException("Error creating shader."); 56 | } 57 | 58 | return shader; 59 | } 60 | 61 | /** 62 | * Checks if we've had an error inside of OpenGL ES, and if so what that error is. 63 | * 64 | * @param label Label to report in case of error. 65 | * @throws RuntimeException If an OpenGL error is detected. 66 | */ 67 | public static void checkGLError(String tag, String label) { 68 | int error; 69 | while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { 70 | Log.e(tag, label + ": glError " + error); 71 | throw new RuntimeException(label + ": glError " + error); 72 | } 73 | } 74 | 75 | /** 76 | * Converts a raw text file into a string. 77 | * 78 | * @param resId The resource ID of the raw text file about to be turned into a shader. 79 | * @return The context of the text file, or null in case of error. 80 | */ 81 | private static String readRawTextFile(Context context, int resId) { 82 | InputStream inputStream = context.getResources().openRawResource(resId); 83 | try { 84 | BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); 85 | StringBuilder sb = new StringBuilder(); 86 | String line; 87 | while ((line = reader.readLine()) != null) { 88 | sb.append(line).append("\n"); 89 | } 90 | reader.close(); 91 | return sb.toString(); 92 | } catch (IOException e) { 93 | e.printStackTrace(); 94 | } 95 | return null; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/background_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_ar.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/raw/light_vertex.shader: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | uniform mat4 u_Model; 17 | uniform mat4 u_ModelViewProjection; 18 | uniform mat4 u_ModelView; 19 | uniform vec3 u_LightPos; 20 | 21 | attribute vec4 a_Position; 22 | attribute vec4 a_Color; 23 | attribute vec3 a_Normal; 24 | 25 | varying vec4 v_Color; 26 | varying vec3 v_Grid; 27 | 28 | void main() { 29 | v_Grid = vec3(u_Model * a_Position); 30 | 31 | vec3 modelViewVertex = vec3(u_ModelView * a_Position); 32 | vec3 modelViewNormal = vec3(u_ModelView * vec4(a_Normal, 0.0)); 33 | 34 | float distance = length(u_LightPos - modelViewVertex); 35 | vec3 lightVector = normalize(u_LightPos - modelViewVertex); 36 | float diffuse = max(dot(modelViewNormal, lightVector), 0.5); 37 | 38 | diffuse = diffuse * (1.0 / (1.0 + (0.00001 * distance * distance))); 39 | v_Color = vec4(a_Color.rgb * diffuse, a_Color.a); 40 | gl_Position = u_ModelViewProjection * a_Position; 41 | } -------------------------------------------------------------------------------- /app/src/main/res/raw/object_fragment.shader: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | precision mediump float; 17 | 18 | uniform sampler2D u_Texture; 19 | 20 | uniform vec4 u_LightingParameters; 21 | uniform vec4 u_MaterialParameters; 22 | 23 | varying vec3 v_ViewPosition; 24 | varying vec3 v_ViewNormal; 25 | varying vec2 v_TexCoord; 26 | 27 | void main() { 28 | // We support approximate sRGB gamma. 29 | const float kGamma = 0.4545454; 30 | const float kInverseGamma = 2.2; 31 | 32 | // Unpack lighting and material parameters for better naming. 33 | vec3 viewLightDirection = u_LightingParameters.xyz; 34 | float lightIntensity = u_LightingParameters.w; 35 | 36 | float materialAmbient = u_MaterialParameters.x; 37 | float materialDiffuse = u_MaterialParameters.y; 38 | float materialSpecular = u_MaterialParameters.z; 39 | float materialSpecularPower = u_MaterialParameters.w; 40 | 41 | // Normalize varying parameters, because they are linearly interpolated in the vertex shader. 42 | vec3 viewFragmentDirection = normalize(v_ViewPosition); 43 | vec3 viewNormal = normalize(v_ViewNormal); 44 | 45 | // Apply inverse SRGB gamma to the texture before making lighting calculations. 46 | // Flip the y-texture coordinate to address the texture from top-left. 47 | vec4 objectColor = texture2D(u_Texture, vec2(v_TexCoord.x, 1.0 - v_TexCoord.y)); 48 | objectColor.rgb = pow(objectColor.rgb, vec3(kInverseGamma)); 49 | 50 | // Ambient light is unaffected by the light intensity. 51 | float ambient = materialAmbient; 52 | 53 | // Approximate a hemisphere light (not a harsh directional light). 54 | float diffuse = lightIntensity * materialDiffuse * 55 | 0.5 * (dot(viewNormal, viewLightDirection) + 1.0); 56 | 57 | // Compute specular light. 58 | vec3 reflectedLightDirection = reflect(viewLightDirection, viewNormal); 59 | float specularStrength = max(0.0, dot(viewFragmentDirection, reflectedLightDirection)); 60 | float specular = lightIntensity * materialSpecular * 61 | pow(specularStrength, materialSpecularPower); 62 | 63 | // Apply SRGB gamma before writing the fragment color. 64 | gl_FragColor.a = objectColor.a; 65 | gl_FragColor.rgb = pow(objectColor.rgb * (ambient + diffuse) + specular, vec3(kGamma)); 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/res/raw/object_vertex.shader: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | uniform mat4 u_ModelView; 17 | uniform mat4 u_ModelViewProjection; 18 | 19 | attribute vec4 a_Position; 20 | attribute vec3 a_Normal; 21 | attribute vec2 a_TexCoord; 22 | 23 | varying vec3 v_ViewPosition; 24 | varying vec3 v_ViewNormal; 25 | varying vec2 v_TexCoord; 26 | 27 | void main() { 28 | v_ViewPosition = (u_ModelView * a_Position).xyz; 29 | v_ViewNormal = (u_ModelView * vec4(a_Normal, 0.0)).xyz; 30 | v_TexCoord = a_TexCoord; 31 | gl_Position = u_ModelViewProjection * a_Position; 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/res/raw/passthrough_fragment.shader: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | precision mediump float; 17 | varying vec4 v_Color; 18 | 19 | void main() { 20 | gl_FragColor = v_Color; 21 | } -------------------------------------------------------------------------------- /app/src/main/res/raw/plane_fragment.shader: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | precision highp float; 17 | uniform sampler2D u_Texture; 18 | uniform vec4 u_dotColor; 19 | uniform vec4 u_lineColor; 20 | uniform vec4 u_gridControl; // dotThreshold, lineThreshold, lineFadeShrink, occlusionShrink 21 | varying vec3 v_TexCoordAlpha; 22 | 23 | void main() { 24 | vec4 control = texture2D(u_Texture, v_TexCoordAlpha.xy); 25 | float dotScale = v_TexCoordAlpha.z; 26 | float lineFade = max(0.0, u_gridControl.z * v_TexCoordAlpha.z - (u_gridControl.z - 1.0)); 27 | vec3 color = (control.r * dotScale > u_gridControl.x) ? u_dotColor.rgb 28 | : (control.g > u_gridControl.y) ? u_lineColor.rgb * lineFade 29 | : (u_lineColor.rgb * 0.25 * lineFade) ; 30 | gl_FragColor = vec4(color, v_TexCoordAlpha.z * u_gridControl.w); 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/res/raw/plane_vertex.shader: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | uniform mat4 u_Model; 17 | uniform mat4 u_ModelViewProjection; 18 | uniform mat2 u_PlaneUvMatrix; 19 | 20 | attribute vec3 a_XZPositionAlpha; // (x, z, alpha) 21 | 22 | varying vec3 v_TexCoordAlpha; 23 | 24 | void main() { 25 | vec4 position = vec4(a_XZPositionAlpha.x, 0.0, a_XZPositionAlpha.y, 1.0); 26 | v_TexCoordAlpha = vec3(u_PlaneUvMatrix * (u_Model * position).xz, a_XZPositionAlpha.z); 27 | gl_Position = u_ModelViewProjection * position; 28 | } -------------------------------------------------------------------------------- /app/src/main/res/raw/point_cloud_vertex.shader: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | uniform mat4 u_ModelViewProjection; 17 | uniform vec4 u_Color; 18 | uniform float u_PointSize; 19 | 20 | attribute vec4 a_Position; 21 | 22 | varying vec4 v_Color; 23 | 24 | void main() { 25 | v_Color = u_Color; 26 | gl_Position = u_ModelViewProjection * vec4(a_Position.xyz, 1.0); 27 | gl_PointSize = u_PointSize; 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/res/raw/screenquad_fragment_oes.shader: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | #extension GL_OES_EGL_image_external : require 16 | 17 | precision mediump float; 18 | varying vec2 v_TexCoord; 19 | uniform samplerExternalOES sTexture; 20 | 21 | 22 | void main() { 23 | gl_FragColor = texture2D(sTexture, v_TexCoord); 24 | } -------------------------------------------------------------------------------- /app/src/main/res/raw/screenquad_vertex.shader: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | attribute vec4 a_Position; 17 | attribute vec2 a_TexCoord; 18 | 19 | varying vec2 v_TexCoord; 20 | 21 | void main() { 22 | gl_Position = a_Position; 23 | v_TexCoord = a_TexCoord; 24 | } -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ARDemo 3 | Engineering 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/example/aishnaagrawal/ardemo/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.example.aishnaagrawal.ardemo; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /arcore_client/arcore_client.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/arcore_client/arcore_client.aar -------------------------------------------------------------------------------- /arcore_client/build.gradle: -------------------------------------------------------------------------------- 1 | configurations.maybeCreate("default") 2 | artifacts.add("default", file('arcore_client.aar')) -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.3.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Nov 13 16:43:02 PST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /obj-0.2.1/build.gradle: -------------------------------------------------------------------------------- 1 | configurations.maybeCreate("default") 2 | artifacts.add("default", file('obj-0.2.1.jar')) -------------------------------------------------------------------------------- /obj-0.2.1/obj-0.2.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aishnacodes/Geolocation-ARCore/55453c1a0e01067ab677da39932c7171ae4ee435/obj-0.2.1/obj-0.2.1.jar -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':arcore_client', ':obj-0.2.1' 2 | --------------------------------------------------------------------------------