Skip to content
GitLab
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
01018576
Commit
01018576
authored
Mar 26, 2018
by
Ruben Jesus Garcia Hernandez
Browse files
Add default citosyne model to GearVR (requested by Oculus Store)
Add support for markers
parent
6d4d53ba
Changes
5
Hide whitespace changes
Inline
Side-by-side
OculusMobile/NOMADGearvrT/Projects/Android/jni/Android.mk
View file @
01018576
...
...
@@ -6,7 +6,9 @@ include ../../../../../cflags.mk
LOCAL_MODULE
:=
ovrapp
LOCAL_SRC_FILES
:=
../../../Src/OvrApp.cpp ../../../Src/rply/rply.c
\
../../../Src/NOMADVRLib/ConfigFile.cpp ../../../Src/NOMADVRLib/atoms.cpp
\
../../../Src/NOMADVRLib/ConfigFile.cpp
\
../../../Src/NOMADVRLib/ConfigFileAtoms.cpp
\
../../../Src/NOMADVRLib/atoms.cpp
\
../../../Src/happyhttp/happyhttp.cpp
\
../../../Src/NOMADVRLib/atomsGL.cpp
\
../../../Src/NOMADVRLib/CompileGLShader.cpp
\
...
...
OculusMobile/NOMADGearvrT/Projects/Android/src/oculus/Filepath.java
View file @
01018576
/*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
oculus
;
//This file is the same, except for the package above, as
//NOMADgvrT\src\main\java\com\google\vr\ndk\samples\treasurehunt\Filepath.java
...
...
OculusMobile/NOMADGearvrT/Projects/Android/src/oculus/MainActivity.java
View file @
01018576
...
...
@@ -15,6 +15,7 @@ import android.os.Bundle;
import
android.util.Log
;
import
android.content.Intent
;
import
com.oculus.vrappframework.VrActivity
;
import
com.lrz.NOMADGearvrT.R
;
public
class
MainActivity
extends
VrActivity
{
public
static
final
String
TAG
=
"NOMADGearvrT"
;
...
...
@@ -82,9 +83,53 @@ public static void verifyStoragePermissions(android.app.Activity activity) {
}
}
*/
private
void
SaveToDisk
(
java
.
io
.
InputStream
is
,
java
.
lang
.
String
name
)
{
//https://stackoverflow.com/questions/10854211/android-store-inputstream-in-file
try
{
try
{
java
.
io
.
File
f
=
new
java
.
io
.
File
(
name
);
java
.
io
.
OutputStream
output
=
new
java
.
io
.
FileOutputStream
(
f
);
try
{
byte
[]
buffer
=
new
byte
[
4
*
1024
];
// or other buffer size
int
read
;
while
((
read
=
is
.
read
(
buffer
))
!=
-
1
)
{
output
.
write
(
buffer
,
0
,
read
);
}
output
.
flush
();
}
finally
{
output
.
close
();
}
}
finally
{
is
.
close
();
}
}
catch
(
java
.
io
.
IOException
e
)
{
android
.
util
.
Log
.
d
(
"NOMADgvrT"
,
"java.io.IOException, e="
+
e
);
}
}
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
//export example file
java
.
io
.
File
d
=
new
java
.
io
.
File
(
"/sdcard/Oculus/NomadGearVR"
);
try
{
if
(!
d
.
exists
())
{
d
.
mkdir
();
}
}
catch
(
java
.
lang
.
SecurityException
e
){
android
.
util
.
Log
.
d
(
"NOMADgvrT"
,
"java.lang.SecurityException, e="
+
e
);
}
java
.
io
.
InputStream
is
=
this
.
getApplicationContext
().
getResources
().
openRawResource
(
com
.
lrz
.
NOMADGearvrT
.
R
.
raw
.
xyz
);
SaveToDisk
(
is
,
"/sdcard/Oculus/NomadGearVR/cytosine.xyz"
);
is
=
this
.
getApplicationContext
().
getResources
().
openRawResource
(
com
.
lrz
.
NOMADGearvrT
.
R
.
raw
.
ncfg
);
SaveToDisk
(
is
,
"/sdcard/Oculus/NomadGearVR/cytosine.ncfg"
);
//end export
super
.
onCreate
(
savedInstanceState
);
verifyStoragePermissions
(
this
);
...
...
@@ -98,9 +143,10 @@ public static void verifyStoragePermissions(android.app.Activity activity) {
uriString
=
Filepath
.
getFilePath
(
this
.
getApplicationContext
(),
u
);
}
catch
(
java
.
net
.
URISyntaxException
e
)
{
android
.
util
.
Log
.
d
(
"NOMADgvrT"
,
"URISyntaxException, e="
+
e
);
uriString
=
null
;
uriString
=
"/sdcard/Oculus/NomadGearVR/cytosine.ncfg"
;
}
android
.
util
.
Log
.
d
(
"NOMADgvrT"
,
"Uristring is="
+
uriString
);
setAppPtr
(
nativeSetAppInterface
(
this
,
fromPackageNameString
,
commandString
,
uriString
)
);
}
}
OculusMobile/NOMADGearvrT/Src/OvrApp.cpp
View file @
01018576
...
...
@@ -115,12 +115,12 @@ void OvrApp::OneTimeInit( const char * fromPackage, const char * launchIntentJSO
//}
const
char
*
configLocation
=
"/sdcard/NOMAD/NOMADGearVR.cfg"
;
const
char
*
defaultURI
=
"/sdcard/Oculus/N
OMAD/ViveTDefault
.ncfg"
;
const
char
*
defaultURI
=
"/sdcard/Oculus/N
omadGearVR/cytosine
.ncfg"
;
char
finalURI
[
1024
];
FILE
*
cl
=
fopen
(
configLocation
,
"r"
);
if
(
cl
==
nullptr
)
{
LOG
(
"NOMADGearVRT, /sdcard/NOMAD/NOMADGearVR.cfg not found, using default at /sdcard/Oculus/N
OMAD/ViveTDefault
.ncfg"
);
LOG
(
"NOMADGearVRT, /sdcard/NOMAD/NOMADGearVR.cfg not found, using default at /sdcard/Oculus/N
omadGearVR/cytosine
.ncfg"
);
strcpy
(
finalURI
,
defaultURI
);
}
else
{
fgets
(
finalURI
,
1024
,
cl
);
...
...
@@ -175,14 +175,14 @@ void OvrApp::OneTimeInit( const char * fromPackage, const char * launchIntentJSO
LOG
(
"NOMADGearVRT No atom glyph specified, using Icosahedron"
);
solid
=
new
Solid
(
Solid
::
Type
::
Icosahedron
);
}
LOG
(
"OneTimeInit, 2"
);
//
LOG("OneTimeInit, 2");
const
ovrJava
*
java
=
app
->
GetJava
();
SoundEffectContext
=
new
ovrSoundEffectContext
(
*
java
->
Env
,
java
->
ActivityObject
);
SoundEffectContext
->
Initialize
();
SoundEffectPlayer
=
new
OvrGuiSys
::
ovrDummySoundEffectPlayer
();
LOG
(
"OneTimeInit, 3"
);
//
LOG("OneTimeInit, 3");
Locale
=
ovrLocale
::
Create
(
*
app
,
"default"
);
LOG
(
"OneTimeInit, 4"
);
//
LOG("OneTimeInit, 4");
String
fontName
;
GetLocale
().
GetString
(
"@string/font_name"
,
"efigs.fnt"
,
fontName
);
GuiSys
->
Init
(
this
->
app
,
*
SoundEffectPlayer
,
fontName
.
ToCStr
(),
&
app
->
GetDebugLines
()
);
...
...
@@ -232,9 +232,16 @@ LOG("OneTimeInit, 4");
if
(
e
!=
GL_NO_ERROR
)
eprintf
(
"SetupUnitCell error %d"
,
e
);
if
(
ISOS
)
{
PrepareISOShader
(
&
ISOP
,
&
ISOMatrixLoc
);
e
=
SetupMarkerNoTess
(
&
MarkerVAO
,
&
MarkerVertBuffer
,
&
MarkerIndexBuffer
);
if
(
e
!=
GL_NO_ERROR
)
{
eprintf
(
"SetupMarkerNoTess error %d"
,
e
);
}
if
(
ISOS
||
markers
)
{
PrepareISOShader
(
&
ISOP
,
&
ISOMatrixLoc
);
}
if
(
ISOS
)
{
float
m
=
BACKGROUND
[
0
];
m
=
std
::
max
(
m
,
BACKGROUND
[
1
]);
m
=
std
::
max
(
m
,
BACKGROUND
[
2
]);
...
...
@@ -469,11 +476,44 @@ void OvrApp::RenderIsos(const OVR::Matrix4f eyeViewProjection, int iso) {
glBindVertexArray
(
0
);
}
void
OvrApp
::
RenderMarker
(
const
float
*
m
)
//m[16]
{
int
e
;
if
(
!
markers
)
return
;
glEnable
(
GL_BLEND
);
glBlendFunc
(
GL_SRC_ALPHA
,
GL_ONE_MINUS_SRC_ALPHA
);
glBindVertexArray
(
MarkerVAO
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"b %d"
,
e
);
glUseProgram
(
ISOP
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"c %d"
,
e
);
glUniformMatrix4fv
(
ISOMatrixLoc
,
1
,
GL_FALSE
,
m
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"d %d, matrixloc=%d, program=%d"
,
e
,
ISOMatrixLoc
,
ISOP
);
glDrawElements
(
GL_TRIANGLES
,
3
*
3
*
MARKERSOLID
::
nFaces
,
#ifndef INDICESGL32
GL_UNSIGNED_SHORT
,
(
void
*
)(
currentSet
*
sizeof
(
unsigned
short
)
*
3
*
3
*
MARKERSOLID
::
nFaces
)
#else
GL_UNSIGNED_INT
,
(
void
*
)(
currentSet
*
sizeof
(
unsigned
int
)
*
3
*
3
*
MARKERSOLID
::
nFaces
)
#endif
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"e %d"
,
e
);
glBindVertexArray
(
0
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"f %d"
,
e
);
glDisable
(
GL_BLEND
);
}
void
OvrApp
::
RenderAtoms
(
const
float
*
m
)
//m[16]
{
eprintf
(
"RenderAtoms start numatoms %d"
,
numAtoms
);
//
eprintf ("RenderAtoms start numatoms %d", numAtoms);
int
e
;
if
(
numAtoms
==
0
)
return
;
...
...
@@ -607,6 +647,7 @@ void OvrApp::RenderUnitCell(const Matrix4f eyeViewProjection)
//atom trajectories
RenderAtomTrajectoriesUnitCell
();
RenderAtoms
(
t
);
RenderMarker
(
t
);
}
}
...
...
@@ -628,6 +669,7 @@ void OvrApp::RenderAtomTrajectories (const Matrix4f eyeViewProjection)
glUniformMatrix4fv
(
UnitCellMatrixLoc
,
1
,
GL_FALSE
,
t
);
RenderAtomTrajectoriesUnitCell
();
RenderAtoms
(
t
);
RenderMarker
(
t
);
}
Matrix4f
OvrApp
::
DrawEyeView
(
const
int
eye
,
const
float
fovDegreesX
,
const
float
fovDegreesY
,
ovrFrameParms
&
frameParms
)
...
...
OculusMobile/NOMADGearvrT/Src/OvrApp.h
View file @
01018576
...
...
@@ -56,7 +56,8 @@ private:
//if no tesselation is available, we still need the tess atoms for the trajectories!
GLuint
*
AtomTVAO
=
nullptr
,
*
AtomTBuffer
=
nullptr
,
BondIndices
=
0
,
*
AtomVAO
=
nullptr
,
*
AtomBuffer
=
nullptr
,
*
AtomIndices
=
nullptr
,
//[2], atoms, extraatoms
UnitCellVAO
,
UnitCellBuffer
,
UnitCellIndexBuffer
;
UnitCellVAO
,
UnitCellBuffer
,
UnitCellIndexBuffer
,
MarkerVAO
,
MarkerVertBuffer
,
MarkerIndexBuffer
;
GLuint
*
ISOVAO
=
nullptr
/*[ISOS*TIMESTEPS]*/
,
*
ISOBuffer
=
nullptr
/*[ISOS*TIMESTEPS]*/
,
*
ISOIndices
=
nullptr
/*[ISOS*TIMESTEPS]*/
;
...
...
@@ -65,6 +66,7 @@ private:
int
*
numISOIndices
=
nullptr
/*[ISOS*TIMESTEPS]*/
;
void
RenderAtoms
(
const
float
*
m
);
void
RenderMarker
(
const
float
*
m
);
void
RenderUnitCell
(
const
OVR
::
Matrix4f
eyeViewProjection
);
void
RenderAtomTrajectories
(
const
OVR
::
Matrix4f
eyeViewProjection
);
void
RenderAtomTrajectoriesUnitCell
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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