├── .gitignore ├── .idea ├── caches │ ├── build_file_checksums.ser │ └── gradle_models.ser ├── encodings.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── lineview_main_app_module ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── sampledata │ └── models │ │ ├── andy.mtl │ │ ├── andy.obj │ │ ├── andy.png │ │ ├── andy.sfa │ │ ├── arcticfox_diffuse.png │ │ ├── arcticfox_posed.mtl │ │ ├── arcticfox_posed.obj │ │ └── arcticfox_posed.sfa └── src │ └── main │ ├── AndroidManifest.xml │ ├── assets │ └── arcticfox_posed.sfb │ ├── ic_launcher-web.png │ ├── java │ └── com │ │ └── amodtech │ │ └── ar │ │ └── lineview │ │ └── LineViewMainActivity.java │ └── res │ ├── drawable-xxhdpi │ ├── ic_baseline_arrow_downward_24px.xml │ ├── ic_baseline_arrow_forward_24px.xml │ ├── ic_baseline_arrow_upward_24px.xml │ ├── ic_baseline_call_made_24px.xml │ ├── ic_baseline_call_received_24px.xml │ ├── ic_baseline_delete_24px.xml │ ├── ic_launcher.png │ └── ic_xxx_arrow_back_24px.xml │ ├── drawable │ ├── ic_baseline_edit_24px.xml │ └── ic_launcher_background.xml │ ├── layout │ └── activity_ux.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ ├── ic_launcher_foreground.png │ └── ic_launcher_round.png │ ├── raw │ ├── andy.sfb │ └── arcticfox_posed.sfb │ └── values │ ├── ic_launcher_background.xml │ ├── strings.xml │ └── styles.xml ├── screenshots ├── Screenshot_20190513-145400.png └── readme └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | *.aab 5 | 6 | # Files for the ART/Dalvik VM 7 | *.dex 8 | 9 | # Java class files 10 | *.class 11 | 12 | # Generated files 13 | bin/ 14 | gen/ 15 | out/ 16 | release/ 17 | 18 | # Gradle files 19 | .gradle/ 20 | build/ 21 | 22 | # Local configuration file (sdk path, etc) 23 | local.properties 24 | 25 | # Proguard folder generated by Eclipse 26 | proguard/ 27 | 28 | # Log Files 29 | *.log 30 | 31 | # Android Studio Navigation editor temp files 32 | .navigation/ 33 | 34 | # Android Studio captures folder 35 | captures/ 36 | 37 | # IntelliJ 38 | *.iml 39 | .idea/workspace.xml 40 | .idea/tasks.xml 41 | .idea/gradle.xml 42 | .idea/assetWizardSettings.xml 43 | .idea/dictionaries 44 | .idea/libraries 45 | # Android Studio 3 in .gitignore file. 46 | .idea/caches 47 | .idea/modules.xml 48 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you 49 | .idea/navEditor.xml 50 | 51 | # Keystore files 52 | # Uncomment the following lines if you do not want to check your keystore files in. 53 | #*.jks 54 | #*.keystore 55 | 56 | # External native build folder generated in Android Studio 2.2 and later 57 | .externalNativeBuild 58 | 59 | # Google Services (e.g. APIs or Firebase) 60 | # google-services.json 61 | 62 | # Freeline 63 | freeline.py 64 | freeline/ 65 | freeline_project_description.json 66 | 67 | # fastlane 68 | fastlane/report.xml 69 | fastlane/Preview.html 70 | fastlane/screenshots 71 | fastlane/test_output 72 | fastlane/readme.md 73 | 74 | # Version control 75 | vcs.xml 76 | 77 | # lint 78 | lint/intermediates/ 79 | lint/generated/ 80 | lint/outputs/ 81 | lint/tmp/ 82 | # lint/reports/ 83 | -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/caches/gradle_models.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/.idea/caches/gradle_models.ser -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 31 | 32 | 33 | 34 | 35 | 36 | 38 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LineView 2 | 3 | ![Screenshot](/screenshots/Screenshot_20190513-145400.png) 4 | 5 | Line View is a simple Augmented Reality application that allows you place two ‘Andy’ Android characters in your phone’s view finder, and draw a line between them. 6 | 7 | It is built on ARCore and Sceneform, extending the simple HelloSceneForm example app. 8 | 9 | Each ‘Andy’ can be moved left, right, up, down, forwards and backwards independently and a line can be added between them whenever the Andy’s are moved to a new position. 10 | 11 | As this is an Augmented reality application, using Android’s ARCore and the Sceneform framework, the Andy’s are anchored in place and will stay in the same spot as you move your phone around them. 12 | 13 | This application will allow you get a feel for the capabilities of your device and of the AR frameworks, understanding in particular, how depth and occlusion may impact how you apply and use AR in applications. 14 | 15 | The app can either be built and installed from the repository here by importing it into Android Studio, or you can test it on your device directly from the Play store at the link here: 16 | 17 | https://play.google.com/store/apps/details?id=com.amodtech.ar.lineview 18 | 19 | 20 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google LLC 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 | // Top-level build file where you can add configuration options common to 16 | // all sub-projects/modules. 17 | 18 | buildscript { 19 | repositories { 20 | google() 21 | jcenter() 22 | mavenLocal() 23 | } 24 | dependencies { 25 | classpath 'com.android.tools.build:gradle:3.4.0' 26 | classpath 'com.google.ar.sceneform:plugin:1.5.0' 27 | // NOTE: Do not place your application dependencies here; they belong 28 | // in the individual module build.gradle files 29 | } 30 | } 31 | 32 | allprojects { 33 | repositories { 34 | google() 35 | jcenter() 36 | mavenLocal() 37 | } 38 | } 39 | 40 | task clean(type: Delete) { 41 | delete rootProject.buildDir 42 | } 43 | -------------------------------------------------------------------------------- /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/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon May 13 12:00:39 IST 2019 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-5.1.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /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 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 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 Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /lineview_main_app_module/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /lineview_main_app_module/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google LLC 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 | apply plugin: 'com.android.application' 16 | 17 | android { 18 | compileSdkVersion 27 19 | defaultConfig { 20 | applicationId "com.amodtech.ar.lineview" 21 | 22 | // AR Optional apps must declare minSdkVersion >= 14. 23 | // AR Required apps must declare minSdkVersion >= 24. 24 | minSdkVersion 24 25 | targetSdkVersion 27 26 | versionCode 1 27 | versionName "1.0" 28 | ndk { 29 | /* 30 | * Sceneform is available for the following ABIs: 31 | * 'arm64-v8a', 'armeabi-v7a', 'x86_64' and 'x86'. 32 | * Your application should include the ABIs most appropriate to 33 | * minimize APK size. Listing 'arm64-v8a' is recommended. 34 | * 35 | * This sample app includes two ABIs: 36 | * 1. 'arm64-v8a' to run on devices 37 | * 2. 'x86' to run in the Android emulator 38 | */ 39 | abiFilters 'arm64-v8a', 'x86' 40 | } 41 | } 42 | // Sceneform libraries use language constructs from Java 8. 43 | // Add these compile options if targeting minSdkVersion < 26. 44 | compileOptions { 45 | sourceCompatibility JavaVersion.VERSION_1_8 46 | targetCompatibility JavaVersion.VERSION_1_8 47 | } 48 | buildTypes { 49 | release { 50 | minifyEnabled false 51 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 52 | } 53 | } 54 | 55 | lintOptions { 56 | abortOnError false 57 | } 58 | } 59 | 60 | dependencies { 61 | 62 | // Provides ArFragment, and other Sceneform UX resources: 63 | implementation "com.google.ar.sceneform.ux:sceneform-ux:1.5.0" 64 | 65 | // Use the Sceneform Ux Package built from the source files included in the sceneformux folder. 66 | //api project(":sceneformux") 67 | 68 | // Alternatively, use ArSceneView without the UX dependency. 69 | //implementation "com.google.ar.sceneform:core:1.5.0" 70 | 71 | implementation "com.android.support:appcompat-v7:27.1.1" 72 | 73 | implementation 'com.android.support:design:27.1.1' 74 | } 75 | 76 | apply plugin: 'com.google.ar.sceneform.plugin' 77 | 78 | sceneform.asset('sampledata/models/andy.obj', 79 | 'default', 80 | 'sampledata/models/andy.sfa', 81 | 'src/main/res/raw/andy') 82 | 83 | sceneform.asset('sampledata/models/arcticfox_posed.obj', 84 | 'default', 85 | 'sampledata/models/arcticfox_posed.sfa', 86 | 'src/main/res/raw/arcticfox_posed') -------------------------------------------------------------------------------- /lineview_main_app_module/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 /opt/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 | -------------------------------------------------------------------------------- /lineview_main_app_module/sampledata/models/andy.mtl: -------------------------------------------------------------------------------- 1 | newmtl unlit_material 2 | illum 2 3 | Kd 0.00 0.00 0.00 4 | Ka 0.00 0.00 0.00 5 | Tf 1.00 1.00 1.00 6 | map_Kd andy.png 7 | Ni 1.00 8 | -------------------------------------------------------------------------------- /lineview_main_app_module/sampledata/models/andy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/sampledata/models/andy.png -------------------------------------------------------------------------------- /lineview_main_app_module/sampledata/models/andy.sfa: -------------------------------------------------------------------------------- 1 | { 2 | materials: [ 3 | { 4 | name: "unlit_material", 5 | parameters: [ 6 | { 7 | baseColor: "andy", 8 | }, 9 | { 10 | baseColorTint: [ 11 | 1, 12 | 1, 13 | 1, 14 | 1, 15 | ], 16 | }, 17 | { 18 | metallic: 1, 19 | }, 20 | { 21 | roughness: 1, 22 | }, 23 | { 24 | opacity: null, 25 | }, 26 | ], 27 | source: "build/sceneform_sdk/default_materials/obj_material.sfm", 28 | }, 29 | ], 30 | model: { 31 | attributes: [ 32 | "Position", 33 | "TexCoord", 34 | "Orientation", 35 | ], 36 | file: "sampledata/models/andy.obj", 37 | name: "andy", 38 | recenter: "root", 39 | suggested_collision: { 40 | center: { 41 | x: 0, 42 | y: 0, 43 | z: 0, 44 | }, 45 | size: { 46 | x: 1, 47 | y: 1, 48 | z: 1, 49 | }, 50 | type: "Box", 51 | }, 52 | }, 53 | samplers: [ 54 | { 55 | file: "sampledata/models/andy.png", 56 | name: "andy", 57 | pipeline_name: "andy.png", 58 | }, 59 | ], 60 | version: "0.51:1", 61 | } 62 | -------------------------------------------------------------------------------- /lineview_main_app_module/sampledata/models/arcticfox_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/sampledata/models/arcticfox_diffuse.png -------------------------------------------------------------------------------- /lineview_main_app_module/sampledata/models/arcticfox_posed.mtl: -------------------------------------------------------------------------------- 1 | newmtl ArcticFox_Posed_initialShadingGroup 2 | illum 4 3 | Kd 0.00 0.00 0.00 4 | Ka 0.00 0.00 0.00 5 | Tf 1.00 1.00 1.00 6 | map_Kd ArcticFox_Diffuse.png 7 | Ni 1.00 8 | -------------------------------------------------------------------------------- /lineview_main_app_module/sampledata/models/arcticfox_posed.sfa: -------------------------------------------------------------------------------- 1 | { 2 | materials: [ 3 | { 4 | name: 'ArcticFox_Posed_initialShadingGroup', 5 | parameters: [ 6 | { 7 | baseColor: 'ArcticFox_Diffuse', 8 | }, 9 | { 10 | baseColorTint: [ 11 | 1, 12 | 1, 13 | 1, 14 | 1, 15 | ], 16 | }, 17 | { 18 | metallic: 0, 19 | }, 20 | { 21 | roughness: 1, 22 | }, 23 | { 24 | opacity: null, 25 | }, 26 | ], 27 | source: 'build/sceneform_sdk/default_materials/obj_material.sfm', 28 | }, 29 | ], 30 | model: { 31 | attributes: [ 32 | 'Position', 33 | 'TexCoord', 34 | 'Orientation', 35 | ], 36 | collision: {}, 37 | file: 'sampledata/models/arcticfox_posed.obj', 38 | name: 'arcticfox_posed', 39 | recenter: 'root', 40 | scale: 0.018886700000000001, 41 | }, 42 | samplers: [ 43 | { 44 | file: 'sampledata/models/ArcticFox_Diffuse.png', 45 | name: 'ArcticFox_Diffuse', 46 | pipeline_name: 'ArcticFox_Diffuse.png', 47 | }, 48 | ], 49 | version: '0.52:1', 50 | } 51 | -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 33 | 36 | 37 | 38 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/assets/arcticfox_posed.sfb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/src/main/assets/arcticfox_posed.sfb -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/java/com/amodtech/ar/lineview/LineViewMainActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Google LLC. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.amodtech.ar.lineview; 17 | 18 | import android.app.Activity; 19 | import android.support.design.widget.FloatingActionButton; 20 | import android.app.ActivityManager; 21 | import android.content.Context; 22 | import android.os.Build; 23 | import android.os.Build.VERSION_CODES; 24 | import android.os.Bundle; 25 | import android.support.v7.app.AppCompatActivity; 26 | import android.util.Log; 27 | import android.view.Gravity; 28 | import android.view.MotionEvent; 29 | import android.view.View; 30 | import android.widget.Toast; 31 | import com.google.ar.core.Anchor; 32 | import com.google.ar.core.Frame; 33 | import com.google.ar.core.HitResult; 34 | import com.google.ar.core.Plane; 35 | import com.google.ar.core.Pose; 36 | import com.google.ar.core.Session; 37 | import com.google.ar.sceneform.AnchorNode; 38 | import com.google.ar.sceneform.HitTestResult; 39 | import com.google.ar.sceneform.Node; 40 | import com.google.ar.sceneform.math.Quaternion; 41 | import com.google.ar.sceneform.math.Vector3; 42 | import com.google.ar.sceneform.rendering.Color; 43 | import com.google.ar.sceneform.rendering.MaterialFactory; 44 | import com.google.ar.sceneform.rendering.ModelRenderable; 45 | //import com.google.ar.sceneform.samples.hellosceneform.R; 46 | import com.google.ar.sceneform.rendering.ShapeFactory; 47 | import com.google.ar.sceneform.ux.ArFragment; 48 | 49 | import java.util.ArrayList; 50 | import java.util.List; 51 | 52 | /** 53 | * LineViewMainActivity - built on HelloSceneForm sample. 54 | */ 55 | public class LineViewMainActivity extends AppCompatActivity { 56 | private static final String TAG = LineViewMainActivity.class.getSimpleName(); 57 | private static final double MIN_OPENGL_VERSION = 3.0; 58 | private static final int MAX_ANCHORS = 2; 59 | 60 | private ArFragment arFragment; 61 | private ModelRenderable andyRenderable; 62 | private ModelRenderable foxRenderable; 63 | private AnchorNode anchorNode; 64 | private List anchorNodeList = new ArrayList<>(); 65 | private Integer numberOfAnchors = 0; 66 | private AnchorNode currentSelectedAnchorNode = null; 67 | private Node nodeForLine; 68 | 69 | 70 | @Override 71 | @SuppressWarnings({"AndroidApiChecker", "FutureReturnValueIgnored"}) 72 | // CompletableFuture requires api level 24 73 | // FutureReturnValueIgnored is not valid 74 | protected void onCreate(Bundle savedInstanceState) { 75 | super.onCreate(savedInstanceState); 76 | 77 | if (!checkIsSupportedDeviceOrFinish(this)) { 78 | return; 79 | } 80 | 81 | setContentView(R.layout.activity_ux); 82 | arFragment = (ArFragment) getSupportFragmentManager().findFragmentById(R.id.ux_fragment); 83 | 84 | // When you build a Renderable, Sceneform loads its resources in the background while returning 85 | // a CompletableFuture. Call thenAccept(), handle(), or check isDone() before calling get(). 86 | ModelRenderable.builder() 87 | .setSource(this, R.raw.andy) 88 | .build() 89 | .thenAccept(renderable -> andyRenderable = renderable) 90 | .exceptionally( 91 | throwable -> { 92 | Toast toast = 93 | Toast.makeText(this, "Unable to load andy renderable", Toast.LENGTH_LONG); 94 | toast.setGravity(Gravity.CENTER, 0, 0); 95 | toast.show(); 96 | return null; 97 | }); 98 | 99 | ModelRenderable.builder() 100 | .setSource(this, R.raw.arcticfox_posed) 101 | .build() 102 | .thenAccept(renderable -> foxRenderable = renderable) 103 | .exceptionally( 104 | throwable -> { 105 | Toast toast = 106 | Toast.makeText(this, "Unable to load fox renderable", Toast.LENGTH_LONG); 107 | toast.setGravity(Gravity.CENTER, 0, 0); 108 | toast.show(); 109 | return null; 110 | }); 111 | 112 | arFragment.setOnTapArPlaneListener( 113 | (HitResult hitResult, Plane plane, MotionEvent motionEvent) -> { 114 | // Do nothng on plane taps for now 115 | 116 | }); 117 | 118 | arFragment.getArSceneView().getScene().setOnPeekTouchListener(this::handleOnTouch); 119 | 120 | //Add a listener for the back button 121 | FloatingActionButton backButtom = findViewById(R.id.back_buttom); 122 | backButtom.setOnClickListener(new View.OnClickListener() { 123 | @Override 124 | public void onClick(View view) { 125 | //Move the anchor back 126 | Log.d(TAG,"Moving anchor back"); 127 | if (currentSelectedAnchorNode != null) { 128 | //Get the current Pose and transform it then set a new anchor at the new pose 129 | Session session = arFragment.getArSceneView().getSession(); 130 | Anchor currentAnchor = currentSelectedAnchorNode.getAnchor(); 131 | Pose oldPose = currentAnchor.getPose(); 132 | Pose newPose = oldPose.compose(Pose.makeTranslation(0,0,-0.05f)); 133 | currentSelectedAnchorNode = moveRenderable(currentSelectedAnchorNode, newPose); 134 | } 135 | } 136 | }); 137 | 138 | //Add a listener for the forward button 139 | FloatingActionButton forwardButtom = findViewById(R.id.forward_buttom); 140 | forwardButtom.setOnClickListener(new View.OnClickListener() { 141 | @Override 142 | public void onClick(View view) { 143 | //Move the anchor forward 144 | Log.d(TAG,"Moving anchor forward"); 145 | if (currentSelectedAnchorNode != null) { 146 | //Get the current Pose and transform it then set a new anchor at the new pose 147 | Session session = arFragment.getArSceneView().getSession(); 148 | Anchor currentAnchor = currentSelectedAnchorNode.getAnchor(); 149 | Pose oldPose = currentAnchor.getPose(); 150 | Pose newPose = oldPose.compose(Pose.makeTranslation(0,0,0.05f)); 151 | currentSelectedAnchorNode = moveRenderable(currentSelectedAnchorNode, newPose); 152 | } 153 | } 154 | }); 155 | 156 | //Add a listener for the left button 157 | FloatingActionButton leftButtom = findViewById(R.id.left_button); 158 | leftButtom.setOnClickListener(new View.OnClickListener() { 159 | @Override 160 | public void onClick(View view) { 161 | //Move the anchor left 162 | Log.d(TAG,"Moving anchor left"); 163 | if (currentSelectedAnchorNode != null) { 164 | //Get the current Pose and transform it then set a new anchor at the new pose 165 | Session session = arFragment.getArSceneView().getSession(); 166 | Anchor currentAnchor = currentSelectedAnchorNode.getAnchor(); 167 | Pose oldPose = currentAnchor.getPose(); 168 | Pose newPose = oldPose.compose(Pose.makeTranslation(-0.05f,0,0)); 169 | currentSelectedAnchorNode = moveRenderable(currentSelectedAnchorNode, newPose); 170 | } 171 | } 172 | }); 173 | 174 | //Add a listener for the right button 175 | FloatingActionButton rightButtom = findViewById(R.id.right_button); 176 | rightButtom.setOnClickListener(new View.OnClickListener() { 177 | @Override 178 | public void onClick(View view) { 179 | //Move the anchor right 180 | Log.d(TAG,"Moving anchor Right"); 181 | if (currentSelectedAnchorNode != null) { 182 | //Get the current Pose and transform it then set a new anchor at the new pose 183 | Session session = arFragment.getArSceneView().getSession(); 184 | Anchor currentAnchor = currentSelectedAnchorNode.getAnchor(); 185 | Pose oldPose = currentAnchor.getPose(); 186 | Pose newPose = oldPose.compose(Pose.makeTranslation(0.05f,0,0)); 187 | currentSelectedAnchorNode = moveRenderable(currentSelectedAnchorNode, newPose); 188 | } 189 | } 190 | }); 191 | 192 | //Add a listener for the up button 193 | FloatingActionButton upButtom = findViewById(R.id.up_button); 194 | upButtom.setOnClickListener(new View.OnClickListener() { 195 | @Override 196 | public void onClick(View view) { 197 | //Move the anchor up 198 | Log.d(TAG,"Moving anchor Up"); 199 | if (currentSelectedAnchorNode != null) { 200 | //Get the current Pose and transform it then set a new anchor at the new pose 201 | Session session = arFragment.getArSceneView().getSession(); 202 | Anchor currentAnchor = currentSelectedAnchorNode.getAnchor(); 203 | Pose oldPose = currentAnchor.getPose(); 204 | Pose newPose = oldPose.compose(Pose.makeTranslation(0,0.05f,0)); 205 | currentSelectedAnchorNode = moveRenderable(currentSelectedAnchorNode, newPose); 206 | } 207 | } 208 | }); 209 | 210 | //Add a listener for the down button 211 | FloatingActionButton downButtom = findViewById(R.id.down_button); 212 | downButtom.setOnClickListener(new View.OnClickListener() { 213 | @Override 214 | public void onClick(View view) { 215 | //Move the anchor down 216 | Log.d(TAG,"Moving anchor Down"); 217 | if (currentSelectedAnchorNode != null) { 218 | //Get the current Pose and transform it then set a new anchor at the new pose 219 | Session session = arFragment.getArSceneView().getSession(); 220 | Anchor currentAnchor = currentSelectedAnchorNode.getAnchor(); 221 | Pose oldPose = currentAnchor.getPose(); 222 | Pose newPose = oldPose.compose(Pose.makeTranslation(0,-0.05f,0)); 223 | currentSelectedAnchorNode = moveRenderable(currentSelectedAnchorNode, newPose); 224 | } 225 | } 226 | }); 227 | 228 | //Add a listener for the drawline button 229 | FloatingActionButton drawLineButton = findViewById(R.id.draw_buttom); 230 | drawLineButton.setOnClickListener(new View.OnClickListener() { 231 | @Override 232 | 233 | public void onClick(View view) { 234 | //draw a line bteween the two Anchors, if there are exactly two anchros 235 | Log.d(TAG,"drawing line"); 236 | if (numberOfAnchors == 2 ) { 237 | drawLine(anchorNodeList.get(0), anchorNodeList.get(1)); 238 | } 239 | } 240 | }); 241 | 242 | //Add a listener for the delete button 243 | FloatingActionButton deleteButton = findViewById(R.id.delete_buttom); 244 | deleteButton.setOnClickListener(new View.OnClickListener() { 245 | @Override 246 | 247 | public void onClick(View view) { 248 | //Delete the Anchor if it exists 249 | Log.d(TAG,"Deleteing anchor"); 250 | int currentAnchorIndex; 251 | if (numberOfAnchors < 1 ) { 252 | Toast.makeText(LineViewMainActivity.this, "All nodes deleted", Toast.LENGTH_SHORT).show(); 253 | return; 254 | } 255 | removeAnchorNode(currentSelectedAnchorNode); 256 | currentSelectedAnchorNode = null; 257 | 258 | //Remove the line if it exists also 259 | removeLine(nodeForLine); 260 | } 261 | }); 262 | } 263 | 264 | private void handleOnTouch(HitTestResult hitTestResult, MotionEvent motionEvent) { 265 | Log.d(TAG,"handleOnTouch"); 266 | // First call ArFragment's listener to handle TransformableNodes. 267 | arFragment.onPeekTouch(hitTestResult, motionEvent); 268 | 269 | //We are only interested in the ACTION_UP events - anything else just return 270 | if (motionEvent.getAction() != MotionEvent.ACTION_UP) { 271 | return; 272 | } 273 | 274 | // Check for touching a Sceneform node 275 | if (hitTestResult.getNode() != null) { 276 | Log.d(TAG,"handleOnTouch hitTestResult.getNode() != null"); 277 | //Toast.makeText(LineViewMainActivity.this, "hitTestResult is not null: ", Toast.LENGTH_SHORT).show(); 278 | Node hitNode = hitTestResult.getNode(); 279 | 280 | if (hitNode.getRenderable() == andyRenderable) { 281 | //Toast.makeText(LineViewMainActivity.this, "We've hit Andy!!", Toast.LENGTH_SHORT).show(); 282 | //First make the current (soon to be not current) selected node not highlighted 283 | if (currentSelectedAnchorNode != null) { 284 | currentSelectedAnchorNode.setRenderable(andyRenderable); 285 | } 286 | //Now highlight the new current selected node 287 | ModelRenderable highlightedAndyRenderable = andyRenderable.makeCopy(); 288 | highlightedAndyRenderable.getMaterial().setFloat3("baseColorTint", new Color(android.graphics.Color.rgb(255,0,0))); 289 | hitNode.setRenderable(highlightedAndyRenderable); 290 | currentSelectedAnchorNode = (AnchorNode) hitNode; 291 | } 292 | return; 293 | } else{ 294 | // Place the anchor 1m in front of the camera. Make sure we are not at maximum anchor first. 295 | Log.d(TAG,"adding Andy in fornt of camera"); 296 | if (numberOfAnchors < MAX_ANCHORS) { 297 | Frame frame = arFragment.getArSceneView().getArFrame(); 298 | int currentAnchorIndex = numberOfAnchors; 299 | Session session = arFragment.getArSceneView().getSession(); 300 | Anchor newMarkAnchor = session.createAnchor( 301 | frame.getCamera().getPose() 302 | .compose(Pose.makeTranslation(0, 0, -1f)) 303 | .extractTranslation()); 304 | AnchorNode addedAnchorNode = new AnchorNode(newMarkAnchor); 305 | addedAnchorNode.setRenderable(andyRenderable); 306 | addAnchorNode(addedAnchorNode); 307 | currentSelectedAnchorNode = addedAnchorNode; 308 | } else { 309 | Log.d(TAG,"MAX_ANCHORS exceeded"); 310 | } 311 | } 312 | 313 | } 314 | 315 | /** 316 | * Returns false and displays an error message if Sceneform can not run, true if Sceneform can run 317 | * on this device. 318 | * 319 | *

Sceneform requires Android N on the device as well as OpenGL 3.0 capabilities. 320 | * 321 | *

Finishes the activity if Sceneform can not run 322 | */ 323 | public static boolean checkIsSupportedDeviceOrFinish(final Activity activity) { 324 | if (Build.VERSION.SDK_INT < VERSION_CODES.N) { 325 | Log.e(TAG, "Sceneform requires Android N or later"); 326 | Toast.makeText(activity, "Sceneform requires Android N or later", Toast.LENGTH_LONG).show(); 327 | activity.finish(); 328 | return false; 329 | } 330 | String openGlVersionString = 331 | ((ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE)) 332 | .getDeviceConfigurationInfo() 333 | .getGlEsVersion(); 334 | if (Double.parseDouble(openGlVersionString) < MIN_OPENGL_VERSION) { 335 | Log.e(TAG, "Sceneform requires OpenGL ES 3.0 later"); 336 | Toast.makeText(activity, "Sceneform requires OpenGL ES 3.0 or later", Toast.LENGTH_LONG) 337 | .show(); 338 | activity.finish(); 339 | return false; 340 | } 341 | return true; 342 | } 343 | 344 | private void removeAnchorNode(AnchorNode nodeToremove) { 345 | //Remove an anchor node 346 | if (nodeToremove != null) { 347 | arFragment.getArSceneView().getScene().removeChild(nodeToremove); 348 | anchorNodeList.remove(nodeToremove); 349 | nodeToremove.getAnchor().detach(); 350 | nodeToremove.setParent(null); 351 | nodeToremove = null; 352 | numberOfAnchors--; 353 | //Toast.makeText(LineViewMainActivity.this, "Test Delete - markAnchorNode removed", Toast.LENGTH_SHORT).show(); 354 | } else { 355 | Toast.makeText(LineViewMainActivity.this, "Delete - no node selected! Touch a node to select it.", Toast.LENGTH_SHORT).show(); 356 | } 357 | } 358 | 359 | private void removeLine(Node lineToRemove) { 360 | //remove the line 361 | Log.e(TAG, "removeLine"); 362 | if (lineToRemove != null) { 363 | Log.e(TAG, "removeLine lineToRemove is not mull"); 364 | arFragment.getArSceneView().getScene().removeChild(lineToRemove); 365 | lineToRemove.setParent(null); 366 | lineToRemove = null; 367 | } 368 | } 369 | 370 | private void addAnchorNode(AnchorNode nodeToAdd) { 371 | //Add an anchor node 372 | nodeToAdd.setParent(arFragment.getArSceneView().getScene()); 373 | anchorNodeList.add(nodeToAdd); 374 | numberOfAnchors++; 375 | } 376 | 377 | private AnchorNode moveRenderable(AnchorNode markAnchorNodeToMove, Pose newPoseToMoveTo) { 378 | //Move a renderable to a new pose 379 | if (markAnchorNodeToMove != null) { 380 | arFragment.getArSceneView().getScene().removeChild(markAnchorNodeToMove); 381 | anchorNodeList.remove(markAnchorNodeToMove); 382 | } else { 383 | Log.d(TAG,"moveRenderable - markAnchorNode was null, the little £$%^..."); 384 | return null; 385 | } 386 | Frame frame = arFragment.getArSceneView().getArFrame(); 387 | Session session = arFragment.getArSceneView().getSession(); 388 | Anchor markAnchor = session.createAnchor(newPoseToMoveTo.extractTranslation()); 389 | AnchorNode newMarkAnchorNode = new AnchorNode(markAnchor); 390 | newMarkAnchorNode.setRenderable(andyRenderable); 391 | newMarkAnchorNode.setParent(arFragment.getArSceneView().getScene()); 392 | anchorNodeList.add(newMarkAnchorNode); 393 | 394 | //Delete the line if it is drawn 395 | removeLine(nodeForLine); 396 | 397 | return newMarkAnchorNode; 398 | } 399 | 400 | private void drawLine(AnchorNode node1, AnchorNode node2) { 401 | //Draw a line between two AnchorNodes (adapted from https://stackoverflow.com/a/52816504/334402) 402 | Log.d(TAG,"drawLine"); 403 | Vector3 point1, point2; 404 | point1 = node1.getWorldPosition(); 405 | point2 = node2.getWorldPosition(); 406 | 407 | 408 | //First, find the vector extending between the two points and define a look rotation 409 | //in terms of this Vector. 410 | final Vector3 difference = Vector3.subtract(point1, point2); 411 | final Vector3 directionFromTopToBottom = difference.normalized(); 412 | final Quaternion rotationFromAToB = 413 | Quaternion.lookRotation(directionFromTopToBottom, Vector3.up()); 414 | MaterialFactory.makeOpaqueWithColor(getApplicationContext(), new Color(0, 255, 244)) 415 | .thenAccept( 416 | material -> { 417 | /* Then, create a rectangular prism, using ShapeFactory.makeCube() and use the difference vector 418 | to extend to the necessary length. */ 419 | Log.d(TAG,"drawLine insie .thenAccept"); 420 | ModelRenderable model = ShapeFactory.makeCube( 421 | new Vector3(.01f, .01f, difference.length()), 422 | Vector3.zero(), material); 423 | /* Last, set the world rotation of the node to the rotation calculated earlier and set the world position to 424 | the midpoint between the given points . */ 425 | Anchor lineAnchor = node2.getAnchor(); 426 | nodeForLine = new Node(); 427 | nodeForLine.setParent(node1); 428 | nodeForLine.setRenderable(model); 429 | nodeForLine.setWorldPosition(Vector3.add(point1, point2).scaled(.5f)); 430 | nodeForLine.setWorldRotation(rotationFromAToB); 431 | } 432 | ); 433 | 434 | } 435 | } 436 | -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/drawable-xxhdpi/ic_baseline_arrow_downward_24px.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/drawable-xxhdpi/ic_baseline_arrow_forward_24px.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/drawable-xxhdpi/ic_baseline_arrow_upward_24px.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/drawable-xxhdpi/ic_baseline_call_made_24px.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/drawable-xxhdpi/ic_baseline_call_received_24px.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/drawable-xxhdpi/ic_baseline_delete_24px.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/drawable-xxhdpi/ic_xxx_arrow_back_24px.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/drawable/ic_baseline_edit_24px.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 64 | 66 | 68 | 70 | 72 | 74 | 75 | -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/layout/activity_ux.xml: -------------------------------------------------------------------------------- 1 | 16 | 21 | 22 | 25 | 26 | 35 | 36 | 44 | 45 | 54 | 55 | 63 | 64 | 73 | 74 | 82 | 83 | 92 | 93 | 101 | 102 | 111 | 112 | 120 | 121 | 129 | 130 | 137 | 138 | 146 | 147 | 152 | 153 | 154 | 155 | 156 | -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/raw/andy.sfb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/src/main/res/raw/andy.sfb -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/raw/arcticfox_posed.sfb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mickod/LineView/a48a38c1172a89b43fc3be2747d680d5f123003b/lineview_main_app_module/src/main/res/raw/arcticfox_posed.sfb -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #1FF2FF 4 | -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | LineView 19 | 20 | -------------------------------------------------------------------------------- /lineview_main_app_module/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 |