Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Atte Sillanpaeae
VR-demos
Commits
f184aa26
Commit
f184aa26
authored
Feb 27, 2018
by
Ruben Jesus Garcia Hernandez
Browse files
Add gitignore
Add license to Google Cardboard Add scaling to google cardboard.
parent
e7524e46
Changes
8
Hide whitespace changes
Inline
Side-by-side
.gitignore
0 → 100644
View file @
f184aa26
Thumbs.db
\ No newline at end of file
GoogleCardboardAndroid/NOMADgvrT/build.gradle
View file @
f184aa26
...
...
@@ -6,12 +6,13 @@ model {
buildToolsVersion
=
"25.0.2"
defaultConfig
.
with
{
applicationId
=
"com.
google.vr.ndk.samples.treasurehunt
"
applicationId
=
"com.
lrz.nomadvr
"
minSdkVersion
.
apiLevel
=
19
targetSdkVersion
.
apiLevel
=
23
versionCode
=
1
versionName
=
"1.
0
"
versionCode
=
8
versionName
=
"1.
2
"
}
}
android
.
buildTypes
{
release
{
...
...
GoogleCardboardAndroid/NOMADgvrT/src/main/java/com/google/vr/ndk/samples/treasurehunt/Filepath.java
View file @
f184aa26
/*Uses code from Stackoverflow which uses the MIT license and the CC BY-SA 3.0*/
/*These licenses are compatible with Apache 2.0*/
/*
# 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.
*/
package
com.google.vr.ndk.samples.treasurehunt
;
//https://stackoverflow.com/questions/3401579/get-filename-and-path-from-uri-from-mediastore/7265235#7265235
...
...
GoogleCardboardAndroid/NOMADgvrT/src/main/java/com/google/vr/ndk/samples/treasurehunt/MainActivity.java
View file @
f184aa26
/*Uses code from Stackoverflow which uses the MIT license and the CC BY-SA 3.0*/
/*These licenses are compatible with Apache 2.0*/
/*
# Copyright 2016-2018 The NOMAD Developers Group
*/
/* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
...
...
@@ -50,6 +57,18 @@ public class MainActivity extends Activity {
System
.
loadLibrary
(
"treasurehunt_jni"
);
}
@Override
public
boolean
onKeyUp
(
int
keyCode
,
KeyEvent
event
)
{
android
.
util
.
Log
.
d
(
"NOMADgvrT"
,
"onKeyUp, keycode="
+
keyCode
);
nativekeyPress
(
nativeTreasureHuntRenderer
,
keyCode
);
return
true
;
//Matthias Scheffler Bluetooth Controller, in GAME MODE @->B
//KeyEvent.BUTTON_X, KeyEvent.BUTTON_Y, KeyEvent.BUTTON_A, KeyEvent.BUTTON_B
}
//http://stackoverflow.com/questions/8854359/exception-open-failed-eacces-permission-denied-on-android
// Storage Permissions
private
static
final
int
REQUEST_EXTERNAL_STORAGE
=
1
;
...
...
@@ -112,12 +131,6 @@ public static void verifyStoragePermissions(Activity activity) {
verifyStoragePermissions
(
this
);
//http://stackoverflow.com/questions/36557879/how-to-use-native-android-file-open-dialog
/////////
//setContentView(R.layout.activity_main);
///////////
String
externalsd
=
android
.
os
.
Environment
.
getExternalStorageDirectory
().
getPath
()
+
"/"
;
...
...
@@ -337,24 +350,5 @@ public static void verifyStoragePermissions(Activity activity) {
private
native
void
nativeSetConfigFile
(
String
s
,
String
e
);
private
native
void
nativeLoadConfigFile
(
long
nativeTreasureHuntRenderer
);
public
void
DisplayMessage
(
final
String
s
)
{
//http://stackoverflow.com/questions/3875184/cant-create-handler-inside-thread-that-has-not-called-looper-prepare
//rgh: this hangs, need to investigate
new
Thread
()
{
public
void
run
()
{
MainActivity
.
this
.
runOnUiThread
(
new
Runnable
()
{
public
void
run
()
{
android
.
widget
.
Toast
toast
=
android
.
widget
.
Toast
.
makeText
(
MainActivity
.
this
.
getApplicationContext
(),
s
,
android
.
widget
.
Toast
.
LENGTH_LONG
);
}
});
}
}.
start
();
}
private
native
void
nativekeyPress
(
long
nativeTreasureHuntRenderer
,
int
k
);
}
GoogleCardboardAndroid/NOMADgvrT/src/main/jni/treasure_hunt_jni.cc
View file @
f184aa26
/*Uses code from Stackoverflow which uses the MIT license and the CC BY-SA 3.0*/
/*These licenses are compatible with Apache 2.0*/
/*
# Copyright 2016-2018 The NOMAD Developers Group
*/
/* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
...
...
@@ -18,12 +25,11 @@
#include
<memory>
#include
"treasure_hunt_renderer.h"
// NOLINT
#include
"vr/gvr/capi/include/gvr.h"
#include
"vr/gvr/capi/include/gvr_audio.h"
#include
"NOMADVRLib/atoms.hpp"
//for TMPDIR
#include
"treasure_hunt_
jni
.h"
#include
"treasure_hunt_
renderer
.h"
#define JNI_METHOD(return_type, method_name) \
JNIEXPORT return_type JNICALL \
...
...
@@ -56,16 +62,6 @@ inline TreasureHuntRenderer *native(jlong ptr) {
genv->CallStaticVoidMethod(jc, mid, jurl, jpath);
}*/
void
DisplayMessage
(
const
char
*
s
)
{
JNIEnv
*
env
;
javaVM
->
AttachCurrentThread
(
&
env
,
nullptr
);
jstring
js
=
env
->
NewStringUTF
(
s
);
jclass
cls
=
env
->
GetObjectClass
(
jo
);
jmethodID
mid
=
env
->
GetMethodID
(
cls
,
"DisplayMessage"
,
"(Ljava/lang/String;)V"
);
env
->
CallVoidMethod
(
jo
,
mid
,
js
);
}
extern
"C"
{
JNI_METHOD
(
jlong
,
nativeCreateRenderer
)
...
...
GoogleCardboardAndroid/NOMADgvrT/src/main/jni/treasure_hunt_jni.h
deleted
100644 → 0
View file @
e7524e46
//void GetUrl (const char *url, const char *path);
void
DisplayMessage
(
const
char
*
s
);
GoogleCardboardAndroid/NOMADgvrT/src/main/jni/treasure_hunt_renderer.cc
View file @
f184aa26
/*Uses code from Stackoverflow which uses the MIT license and the CC BY-SA 3.0*/
/*These licenses are compatible with Apache 2.0*/
/*
# Copyright 2016-2018 The NOMAD Developers Group
*/
/* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
...
...
@@ -16,7 +22,6 @@
#include
<unistd.h>
#include
"treasure_hunt_renderer.h"
// NOLINT
#include
"treasure_hunt_jni.h"
#include
<android/log.h>
#include
<assert.h>
...
...
@@ -60,8 +65,6 @@ void eprintf( const char *fmt, ... )
if
(
*
fmt
==
'\0'
)
LOGD
(
"Empty format"
);
LOGD
(
"<%s>"
,
buffer
);
//rgh: does not work yet
//DisplayMessage(buffer);
}
...
...
@@ -99,6 +102,11 @@ gvr::Mat4f ScalingMatrix (float v[3])
return
ScalingMatrix
(
v
[
0
],
v
[
1
],
v
[
2
]);
}
gvr
::
Mat4f
ScalingMatrix
(
float
s
)
{
return
ScalingMatrix
(
s
,
s
,
s
);
}
//static const float kZNear = 1.0f;
//static const float kZFar = 100.0f;
static
const
float
kZNear
=
0.01
f
;
...
...
@@ -587,7 +595,7 @@ glGenTextures(2+ZLAYERS, textDepthPeeling);
plyfiles
[
p
%
ISOS
]);
gvr
::
Mat4f
trans
;
gvr
::
Mat4f
matFinal
,
matcubetrans
,
mvs
,
sc
,
sctrans
;
//rotateX(-90)
if
(
voxelSize
[
0
]
!=-
1
)
{
mvs
=
ScalingMatrix
(
scaling
/
(
float
)
voxelSize
[
0
],
scaling
/
(
float
)
voxelSize
[
1
],
scaling
/
(
float
)
voxelSize
[
2
]);
...
...
@@ -603,19 +611,12 @@ glGenTextures(2+ZLAYERS, textDepthPeeling);
matFinal
=
MatrixMul
(
matFinal
,
sc
);
matFinal
=
MatrixMul
(
matFinal
,
mvs
);
}
else
{
/*trans.m[0][0]=1;trans.m[0][1]=0;trans.m[0][2]=0; trans.m[0][3]=0;
trans.m[1][0]=0;trans.m[1][1]=0;trans.m[1][2]=1;trans.m[1][3]=0;
trans.m[2][0]=0;trans.m[2][1]=-1;trans.m[2][2]=0; trans.m[2][3]=0;
trans.m[3][0]=0;trans.m[3][1]=0;trans.m[3][2]=0; trans.m[3][3]=1;*/
for
(
int
i
=
0
;
i
<
4
;
i
++
)
for
(
int
j
=
0
;
j
<
4
;
j
++
)
matFinal
.
m
[
i
][
j
]
=
(
i
==
j
);
for
(
int
i
=
0
;
i
<
3
;
i
++
)
matFinal
.
m
[
i
][
3
]
=
translations
[
p
%
ISOS
][
i
];
//matFinal=MatrixMul(trans, matFinal);
trans
.
m
[
0
][
0
]
=
scaling
;
trans
.
m
[
0
][
1
]
=
0
;
trans
.
m
[
0
][
2
]
=
0
;
trans
.
m
[
0
][
3
]
=
0
;
trans
.
m
[
1
][
0
]
=
0
;
trans
.
m
[
1
][
1
]
=
scaling
;
trans
.
m
[
1
][
2
]
=
0
;
trans
.
m
[
1
][
3
]
=
0
;
trans
.
m
[
2
][
0
]
=
0
;
trans
.
m
[
2
][
1
]
=
0
;
trans
.
m
[
2
][
2
]
=
scaling
;
trans
.
m
[
2
][
3
]
=
0
;
...
...
@@ -1055,10 +1056,11 @@ void TreasureHuntRenderer::RenderAtomTrajectories(const gvr::Mat4f eyeViewProjec
int
e
;
if
(
!
numAtoms
)
return
;
gvr
::
Mat4f
trans
=
TranslationMatrix
(
UserTranslation
[
0
],
UserTranslation
[
1
],
UserTranslation
[
2
]);
gvr
::
Mat4f
sc
=
ScalingMatrix
(
scaling
);
gvr
::
Mat4f
trans
=
TranslationMatrix
(
UserTranslation
[
0
]
/
scaling
,
UserTranslation
[
1
]
/
scaling
,
UserTranslation
[
2
]
/
scaling
);
const
gvr
::
Mat4f
rot
=
{.
m
=
{
1
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
-
1
,
0
,
0
,
0
,
0
,
0
,
1
}};
//trans.translate(iPos).rotateX(-90).translate(UserPosition);
gvr
::
Mat4f
transform
=
MatrixMul
(
eyeViewProjection
,
MatrixMul
(
trans
,
rot
));
gvr
::
Mat4f
transform
=
MatrixMul
(
eyeViewProjection
,
MatrixMul
(
sc
,
MatrixMul
(
trans
,
rot
))
)
;
//gvr::Mat4f transform=eyeViewProjection;
float
t
[
16
];
for
(
int
i
=
0
;
i
<
4
;
i
++
)
...
...
@@ -1095,6 +1097,8 @@ if ((e = glGetError()) != GL_NO_ERROR)
//glDisableVertexAttribArray(1);
//LOG("atomtrajectories.size()=%d", atomtrajectories.size());
//rgh FIXME, old code which does not work with large atom sets!
glBindBuffer
(
GL_ARRAY_BUFFER
,
AtomTBuffer
[
0
]);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"3 Gl error RenderAtomTrajectoriesUnitCell: %d
\n
"
,
e
);
...
...
@@ -1135,6 +1139,7 @@ void TreasureHuntRenderer::RenderUnitCell(const gvr::Mat4f eyeViewProjection)
int
e
;
int
p
[
3
];
gvr
::
Mat4f
sc
=
ScalingMatrix
(
scaling
);
for
(
p
[
0
]
=
0
;
p
[
0
]
<
repetitions
[
0
];(
p
[
0
])
++
)
for
(
p
[
1
]
=
0
;
p
[
1
]
<
repetitions
[
1
];(
p
[
1
])
++
)
for
(
p
[
2
]
=
0
;
p
[
2
]
<
repetitions
[
2
];(
p
[
2
])
++
)
...
...
@@ -1145,10 +1150,11 @@ void TreasureHuntRenderer::RenderUnitCell(const gvr::Mat4f eyeViewProjection)
0,1,0,delta[1]+UserTranslation[1],
0,0,1,delta[2]+UserTranslation[2],
0,0,0,1};*/
gvr
::
Mat4f
trans
=
TranslationMatrix
(
UserTranslation
[
0
],
UserTranslation
[
1
],
UserTranslation
[
2
]);
gvr
::
Mat4f
trans
=
TranslationMatrix
(
delta
[
0
]
+
UserTranslation
[
0
]
/
scaling
,
delta
[
2
]
+
UserTranslation
[
1
]
/
scaling
,
-
delta
[
1
]
+
UserTranslation
[
2
]
/
scaling
);
const
gvr
::
Mat4f
rot
=
{.
m
=
{
1
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
-
1
,
0
,
0
,
0
,
0
,
0
,
1
}};
//trans.translate(iPos).rotateX(-90).translate(UserPosition);
gvr
::
Mat4f
transform
=
MatrixMul
(
eyeViewProjection
,
MatrixMul
(
trans
,
rot
));
gvr
::
Mat4f
transform
=
MatrixMul
(
eyeViewProjection
,
MatrixMul
(
sc
,
MatrixMul
(
trans
,
rot
))
)
;
...
...
@@ -1161,26 +1167,28 @@ gvr::Mat4f transform = MatrixMul(eyeViewProjection, MatrixMul(trans,rot));
glUseProgram
(
UnitCellP
);
glUniformMatrix4fv
(
UnitCellMatrixLoc
,
1
,
GL_FALSE
,
t
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error after glUniform4fv 1 RenderUnitCell: %d
\n
"
,
e
);
glUniform4fv
(
UnitCellColourLoc
,
1
,
unitcellcolour
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error after glUniform4fv 2 RenderUnitCell: %d
\n
"
,
e
);
glBindVertexArray
(
UnitCellVAO
);
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
UnitCellIndexBuffer
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"1 Gl error RenderAtom timestep =%d: %d
\n
"
,
currentSet
,
e
);
glBindBuffer
(
GL_ARRAY_BUFFER
,
UnitCellBuffer
);
glVertexAttribPointer
(
0
,
3
,
GL_FLOAT
,
GL_FALSE
,
3
*
sizeof
(
float
),
(
const
void
*
)(
0
));
glEnableVertexAttribArray
(
0
);
glDisableVertexAttribArray
(
1
);
glDisableVertexAttribArray
(
2
);
glDisableVertexAttribArray
(
3
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error after glBindVertexArray RenderUnitCell: %d
\n
"
,
e
);
glDrawElements
(
GL_LINES
,
24
,
GL_UNSIGNED_INT
,
0
);
//glDrawElements(GL_TRIANGLES, 24, GL_UNSIGNED_INT, 0);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error after RenderUnitCell: %d
\n
"
,
e
);
eprintf
(
"Gl error after glUniform4fv 1 RenderUnitCell: %d
\n
"
,
e
);
if
(
displayunitcell
)
{
glUniform4fv
(
UnitCellColourLoc
,
1
,
unitcellcolour
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error after glUniform4fv 2 RenderUnitCell: %d
\n
"
,
e
);
glBindVertexArray
(
UnitCellVAO
);
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
UnitCellIndexBuffer
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"1 Gl error RenderAtom timestep =%d: %d
\n
"
,
currentSet
,
e
);
glBindBuffer
(
GL_ARRAY_BUFFER
,
UnitCellBuffer
);
glVertexAttribPointer
(
0
,
3
,
GL_FLOAT
,
GL_FALSE
,
3
*
sizeof
(
float
),
(
const
void
*
)(
0
));
glEnableVertexAttribArray
(
0
);
glDisableVertexAttribArray
(
1
);
glDisableVertexAttribArray
(
2
);
glDisableVertexAttribArray
(
3
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error after glBindVertexArray RenderUnitCell: %d
\n
"
,
e
);
glDrawElements
(
GL_LINES
,
24
,
GL_UNSIGNED_INT
,
0
);
//glDrawElements(GL_TRIANGLES, 24, GL_UNSIGNED_INT, 0);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error after RenderUnitCell: %d
\n
"
,
e
);
}
//atom trajectories
RenderAtomTrajectoriesUnitCell
();
RenderAtoms
(
t
);
...
...
GoogleCardboardAndroid/NOMADgvrT/src/main/jni/treasure_hunt_renderer.h
View file @
f184aa26
/* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment