Changes to submit NOMADGearVR to Oculus Store and to update to latest

NOMADVRLib
Add missing initialization to rply, add NOMAD License to rply.
parent 52e7546f
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lrz.NOMADGearvrT"
android:versionCode="1"
android:versionName="1.0" >
android:versionCode="2"
android:versionName="1.0"
android:installLocation="auto"
>
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21" />
<!-- Allow reading of the appropriate lens distortion file for the device. -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
......@@ -16,7 +19,7 @@
<uses-feature android:name="android.hardware.usb.host" />
<!-- Tell the system this app requires OpenGL ES 3.0. -->
<!--rgh: For tesselation, we need 3.2-->
<uses-feature android:glEsVersion="0x00030002" android:required="true" />
<uses-feature android:glEsVersion="0x00030001" android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
......@@ -30,7 +33,8 @@
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="landscape"
android:configChanges="orientation|screenSize|keyboard|keyboardHidden">
android:configChanges= "screenSize|screenLayout|orientation|keyboardHidden|keyboard|navigation"
android:excludeFromRecents="true">
<!--Test opening a NOMAD url-->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
......@@ -49,9 +53,10 @@
android:mimeType="application/octet-stream"/>
</intent-filter>
<!-- This filter lets the apk show up as a launchable icon -->
<!-- rgh: hiding as only the gearvrchooser should be shown -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.INFO" />
</intent-filter>
</activity>
</application>
......
......@@ -15,6 +15,8 @@ android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 21
versionCode 2
versionName "0.2"
}
sourceSets {
......
......@@ -14,7 +14,10 @@ LOCAL_SRC_FILES := ../../../Src/OvrApp.cpp ../../../Src/rply/rply.c \
../../../Src/NOMADVRLib/UnitCellShaders.cpp \
../../../Src/NOMADVRLib/polyhedron.cpp \
../../../Src/NOMADVRLib/IsosurfacesGL.cpp \
../../../Src/NOMADVRLib/IsoShaders.cpp
../../../Src/NOMADVRLib/IsoShaders.cpp \
../../../Src/NOMADVRLib/grid.cpp \
../../../Src/NOMADVRLib/markerShaders.cpp
LOCAL_STATIC_LIBRARIES := vrsound vrmodel vrlocale vrgui vrappframework systemutils libovrkernel
LOCAL_SHARED_LIBRARIES := vrapi
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">NOMADGearvrT</string>
<string name="app_name">NOMAD GearVR</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
......
package oculus;
//This file is the same, except for the package above, as
//NOMADgvrT\src\main\java\com\google\vr\ndk\samples\treasurehunt\Filepath.java
//https://stackoverflow.com/questions/3401579/get-filename-and-path-from-uri-from-mediastore/7265235#7265235
class Filepath {
//@SuppressLint("NewApi")
public static String getFilePath(android.content.Context context, android.net.Uri uri) throws java.net.URISyntaxException {
String selection = null;
String[] selectionArgs = null;
// Uri is different in versions after KITKAT (Android 4.4), we need to
if (android.os.Build.VERSION.SDK_INT >= 19 && android.provider.DocumentsContract.isDocumentUri(context.getApplicationContext(), uri)) {
if (isExternalStorageDocument(uri)) {
final String docId = android.provider.DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
return android.os.Environment.getExternalStorageDirectory() + "/" + split[1];
} else if (isDownloadsDocument(uri)) {
final String id = android.provider.DocumentsContract.getDocumentId(uri);
uri = android.content.ContentUris.withAppendedId(
android.net.Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
} else if (isMediaDocument(uri)) {
final String docId = android.provider.DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
if ("image".equals(type)) {
uri = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
} else if ("video".equals(type)) {
uri = android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
} else if ("audio".equals(type)) {
uri = android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
}
selection = "_id=?";
selectionArgs = new String[]{
split[1]
};
}
}
if ("content".equalsIgnoreCase(uri.getScheme())) {
String[] projection = {
android.provider.MediaStore.Images.Media.DATA
};
android.database.Cursor cursor = null;
try {
cursor = context.getContentResolver()
.query(uri, projection, selection, selectionArgs, null);
int column_index = cursor.getColumnIndexOrThrow(android.provider.MediaStore.Images.Media.DATA);
if (cursor.moveToFirst()) {
return cursor.getString(column_index);
}
} catch (Exception e) {
}
} else if ("file".equalsIgnoreCase(uri.getScheme())) {
return uri.getPath();
}
return null;
}
public static boolean isExternalStorageDocument(android.net.Uri uri) {
return "com.android.externalstorage.documents".equals(uri.getAuthority());
}
public static boolean isDownloadsDocument(android.net.Uri uri) {
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
}
public static boolean isMediaDocument(android.net.Uri uri) {
return "com.android.providers.media.documents".equals(uri.getAuthority());
}
}
......@@ -25,49 +25,82 @@ public class MainActivity extends VrActivity {
System.loadLibrary("ovrapp");
}
public static native long nativeSetAppInterface( VrActivity act, String fromPackageNameString, String commandString, String uriString );
//http://stackoverflow.com/questions/8854359/exception-open-failed-eacces-permission-denied-on-android
// Storage Permissions
private static final int REQUEST_EXTERNAL_STORAGE = 1;
private static String[] PERMISSIONS_STORAGE = {
android.Manifest.permission.READ_EXTERNAL_STORAGE,
android.Manifest.permission.WRITE_EXTERNAL_STORAGE
};
/**
* Checks if the app has permission to write to device storage
*
* If the app does not has permission then the user will be prompted to grant permissions
*
* @param activity
*/
public static void verifyStoragePermissions(android.app.Activity activity) {
// Check if we have write permission
/* int permission = android.support.v4.app.ActivityCompat.checkSelfPermission(activity, android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (permission != android.content.pm.PackageManager.PERMISSION_GRANTED) {
// We don't have permission so prompt the user
android.support.v4.app.ActivityCompat.requestPermissions(
activity,
PERMISSIONS_STORAGE,
REQUEST_EXTERNAL_STORAGE
);
}*/
}
public static native long nativeSetAppInterface( VrActivity act, String fromPackageNameString, String commandString, String uriString );
/*
@Override
protected void onActivityResult(int requestCode, int resultCode, android.content.Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==123 && resultCode==RESULT_OK) {
String s=data.getDataString();
android.util.Log.d("NOMADGearvrT","OnActivityResult, s="+s);
String uriString="";
if (s.startsWith("file://")) {
uriString=s.substring(7);
} else if (s.startsWith("content://com.asus.filemanager.OpenFileProvider/file")) {
uriString=s.substring(52);
} else {
android.net.Uri u=android.net.Uri.parse(s);
try {
uriString=Filepath.getFilePath (this.getApplicationContext(), u);
} catch (java.net.URISyntaxException e) {
android.util.Log.d("NOMADgvrT","URISyntaxException, e="+e);
uriString=null;
}
}
android.util.Log.d("NOMADgvrT","OnActivityResult, uri="+uriString);
nativeSetConfigFile(uriString, android.os.Environment.getExternalStorageDirectory().getPath() + "/");
nativeLoadConfigFile(nativeTreasureHuntRenderer);
}
}
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
verifyStoragePermissions(this);
Intent intent = getIntent();
String commandString = VrActivity.getCommandStringFromIntent( intent );
String fromPackageNameString = VrActivity.getPackageStringFromIntent( intent );
String uriString = VrActivity.getUriStringFromIntent( intent );
//rgh: if intent, save to tmp file and pass it over
if (uriString.startsWith("content://")) {
//http://stackoverflow.com/questions/14364091/retrieve-file-path-from-caught-downloadmanager-intent
//http://stackoverflow.com/questions/1477269/write-a-binary-downloaded-file-to-disk-in-java
//http://stackoverflow.com/questions/4864875/folder-for-temporary-files-creation-in-android-why-does-data-local-tmp-doesnt
uriString="file:///data/local/tmp/material.ncfg";
try {
java.io.InputStream input = getContentResolver().openInputStream(intent.getData());
byte[] buffer = new byte[8 * 1024];
java.io.FileOutputStream output = new java.io.FileOutputStream("/data/local/tmp/material.ncfg");
try{
int bytesRead;
while((bytesRead = input.read()) != -1){
output.write(buffer, 0, bytesRead);
}
} finally {
try{
output.close();
} catch (Exception e) {
uriString="error";
}
try {
input.close();
} catch (java.io.IOException e) {
uriString="error";
}
}
} catch (java.io.IOException e) {
uriString="error";
}
String uriString = VrActivity.getUriStringFromIntent( intent );
android.net.Uri u=android.net.Uri.parse(uriString);
try {
uriString=Filepath.getFilePath (this.getApplicationContext(), u);
} catch (java.net.URISyntaxException e) {
android.util.Log.d("NOMADgvrT","URISyntaxException, e="+e);
uriString=null;
}
setAppPtr( nativeSetAppInterface( this, fromPackageNameString, commandString, uriString ) );
}
}
This diff is collapsed.
......@@ -43,7 +43,7 @@ private:
class OVR::ovrLocale * Locale;
GLuint AtomsP, UnitCellP; // framework does not provide support for tesselation and provides many things we don't need.
GLint AtomMatrixLoc, UnitCellMatrixLoc, UnitCellColourLoc;
GLint AtomMatrixLoc, TotalatomsLoc, UnitCellMatrixLoc, UnitCellColourLoc;
GLint VertexTransformAttribute, VTAGrid;
ovrMatrix4f CenterEyeViewMatrix;
......@@ -54,7 +54,8 @@ private:
int animateCounter=0;
GLuint textures[2]; // white, atoms
//if no tesselation is available, we still need the tess atoms for the trajectories!
GLuint *AtomTVAO=nullptr, *AtomTBuffer=nullptr, *AtomVAO=nullptr, *AtomBuffer=nullptr, *AtomIndices=nullptr,//[2], atoms, extraatoms
GLuint *AtomTVAO=nullptr, *AtomTBuffer=nullptr, BondIndices=0, *AtomVAO=nullptr, *AtomBuffer=nullptr,
*AtomIndices=nullptr,//[2], atoms, extraatoms
UnitCellVAO, UnitCellBuffer, UnitCellIndexBuffer;
GLuint *ISOVAO=nullptr/*[ISOS*TIMESTEPS]*/, *ISOBuffer=nullptr/*[ISOS*TIMESTEPS]*/,
......@@ -65,6 +66,7 @@ private:
void RenderAtoms(const float *m);
void RenderUnitCell(const OVR::Matrix4f eyeViewProjection);
void RenderAtomTrajectories (const OVR::Matrix4f eyeViewProjection);
void RenderAtomTrajectoriesUnitCell();
bool hasTess=true;
void RenderIsos(const OVR::Matrix4f eyeViewProjection, int iso);
......
/*This code is based on rply, which uses the MIT license*/
/*This license is compatible with Apache 2.0*/
/* Changes:
Rubn Jess Garca Hernndez
Fix missing initialization, lines 379, 482
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
/* ----------------------------------------------------------------------
* RPly library, read/write PLY files
* Diego Nehab, IMPA
......@@ -6,6 +29,9 @@
* This library is distributed under the MIT License. See notice
* at the end of this file.
* ---------------------------------------------------------------------- */
#include <stdio.h>
#include <ctype.h>
#include <assert.h>
......@@ -372,7 +398,7 @@ p_ply ply_open(const char *name, p_ply_error_cb error_cb,
p_ply ply_open_from_file(FILE *fp, p_ply_error_cb error_cb,
long idata, void *pdata) {
p_ply ply;
p_ply ply=(void*)0;
if (error_cb == NULL) error_cb = ply_error_cb;
assert(fp);
if (!ply_type_check()) {
......@@ -475,7 +501,7 @@ p_ply ply_create(const char *name, e_ply_storage_mode storage_mode,
p_ply ply_create_to_file(FILE *fp, e_ply_storage_mode storage_mode,
p_ply_error_cb error_cb, long idata, void *pdata) {
p_ply ply;
p_ply ply=(void*)0;
assert(fp && storage_mode <= PLY_DEFAULT);
if (!ply_type_check()) {
error_cb(ply, "Incompatible type system");
......
......@@ -8,7 +8,7 @@
* This library is distributed under the MIT License. See notice
* at the end of this file.
* ---------------------------------------------------------------------- */
#ifdef __cplusplus
extern "C" {
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment