From aef0705f3e42723a753d55d17a81cad50d919485 Mon Sep 17 00:00:00 2001 From: Syoyo Fujita Date: Mon, 15 May 2023 04:24:06 +0900 Subject: [PATCH] Fix Android example app build. Add VS solution gen batch file with Python. --- android/app/build.gradle | 1 + android/app/src/main/AndroidManifest.xml | 3 +-- android/app/src/main/cpp/CMakeLists.txt | 7 +++++++ android/build.gradle | 4 ++-- android/gradle.properties | 5 ++++- android/gradle/wrapper/gradle-wrapper.properties | 2 +- examples/common/par_shapes.h | 2 +- src/io-util.cc | 2 +- vcsetup-with-python.bat | 10 ++++++---- 9 files changed, 24 insertions(+), 12 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 7429c7c6..160029bb 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -28,6 +28,7 @@ android { //version "3.18.1" } } + namespace 'com.example.hellotinyusdz' } dependencies { diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index f524b43e..1df538f8 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + weight; } } - float r = (float) rand() / RAND_MAX; + float r = (float) rand() / float(RAND_MAX); float t = 0; for (int i = 0; i < nrules; i++) { rule = rules + i; diff --git a/src/io-util.cc b/src/io-util.cc index 9d249e63..38715d42 100644 --- a/src/io-util.cc +++ b/src/io-util.cc @@ -513,7 +513,7 @@ bool FileExists(const std::string &filepath, void *userdata) { bool ret{false}; #ifdef TINYUSDZ_ANDROID_LOAD_FROM_ASSETS if (asset_manager) { - AAsset *asset = AAssetManager_open(asset_manager, abs_filename.c_str(), + AAsset *asset = AAssetManager_open(asset_manager, filepath.c_str(), AASSET_MODE_STREAMING); if (!asset) { return false; diff --git a/vcsetup-with-python.bat b/vcsetup-with-python.bat index 2fb862e3..f2f23d7c 100644 --- a/vcsetup-with-python.bat +++ b/vcsetup-with-python.bat @@ -1,15 +1,17 @@ rem assume -rmdir /s /q build -mkdir build +rmdir /s /q build_with_py +mkdir build_with_py rem Specify absolute python.exe path if required. rem Use `whre python` to find abosolute path to python.exe in cmd +rem Conda/Miniconda installed Python recommended. +rem +rem -DPython3_EXECUTABLE=C:\Users\%%HOME%%\miniconda3\envs\pytinyusdz\python.exe ^ cmake -G "Visual Studio 17 2022" -A x64 ^ -DTINYUSDZ_WITH_OPENSUBDIV=On ^ -DTINYUSDZ_WITH_PYTHON=1 ^ -DTINYUSDZ_PREFER_LOCAL_PYTHON_INSTALLATION=1 ^ --DPython3_EXECUTABLE=C:\Users\%%HOME%%\miniconda3\envs\pytinyusdz\python.exe --Bbuild -S. +-Bbuild_with_py -S.