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
nomad-lab
VR-demos
Commits
4692c8ca
Commit
4692c8ca
authored
Apr 10, 2017
by
Ruben Jesus Garcia Hernandez
Browse files
Support Nexus in google cardboard. Small bugfix in oculus mobile
parent
46e1c559
Changes
11
Hide whitespace changes
Inline
Side-by-side
GoogleCardboardAndroid/NOMADgvrT/src/main/java/com/google/vr/ndk/samples/treasurehunt/MainActivity.java
View file @
4692c8ca
...
...
@@ -84,18 +84,22 @@ public static void verifyStoragePermissions(Activity activity) {
super
.
onCreate
(
savedInstanceState
);
verifyStoragePermissions
(
this
);
String
externalsd
=
android
.
os
.
Environment
.
getExternalStorageDirectory
().
getPath
()
+
"/"
;
//intents
android
.
content
.
Intent
intent
=
getIntent
();
String
s
=
intent
.
getDataString
();
String
uriString
=
"/data/local/tmp/material.ncfg"
;
String
uriString
=
externalsd
+
"material.ncfg"
;
if
(
s
==
null
)
android
.
util
.
Log
.
d
(
"NOMADgvrT"
,
"String intent is null"
);
else
android
.
util
.
Log
.
d
(
"NOMADgvrT"
,
"String intent is <"
+
s
+
">"
);
if
(
s
!=
null
)
{
if
(
s
.
startsWith
(
"content://"
))
{
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"
);
java
.
io
.
FileOutputStream
output
=
new
java
.
io
.
FileOutputStream
(
uriString
);
try
{
int
bytesRead
;
while
((
bytesRead
=
input
.
read
())
!=
-
1
){
...
...
@@ -106,24 +110,29 @@ public static void verifyStoragePermissions(Activity activity) {
output
.
close
();
}
catch
(
Exception
e
)
{
uriString
=
null
;
android
.
util
.
Log
.
d
(
"NOMADgvrT"
,
"Exception closing output stream"
);
}
try
{
input
.
close
();
}
catch
(
java
.
io
.
IOException
e
)
{
uriString
=
null
;
android
.
util
.
Log
.
d
(
"NOMADgvrT"
,
"Exception closing input stream"
);
}
}
}
catch
(
java
.
io
.
IOException
e
)
{
uriString
=
null
;
android
.
util
.
Log
.
d
(
"NOMADgvrT"
,
"Exception saving intent to disk"
);
}
if
(
uriString
!=
null
)
nativeSetConfigFile
(
uriString
);
nativeSetConfigFile
(
uriString
,
externalsd
);
}
else
if
(
s
.
startsWith
(
"file://"
))
{
uriString
=
s
.
substring
(
7
);
nativeSetConfigFile
(
uriString
);
nativeSetConfigFile
(
uriString
,
externalsd
);
}
else
{
android
.
util
.
Log
.
d
(
"NOMADgvrT"
,
"Unknown protocol in intent:"
+
s
);
}
}
else
{
//use default
nativeSetConfigFile
(
externalsd
+
"Default.ncfg"
,
externalsd
);
}
// Ensure fullscreen immersion.
...
...
@@ -277,5 +286,5 @@ public static void verifyStoragePermissions(Activity activity) {
private
native
void
nativeOnResume
(
long
nativeTreasureHuntRenderer
);
private
native
void
nativeSetConfigFile
(
String
s
);
private
native
void
nativeSetConfigFile
(
String
s
,
String
e
);
}
GoogleCardboardAndroid/NOMADgvrT/src/main/jni/treasure_hunt_jni.cc
View file @
4692c8ca
...
...
@@ -21,6 +21,7 @@
#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
#define JNI_METHOD(return_type, method_name) \
JNIEXPORT return_type JNICALL \
...
...
@@ -82,8 +83,9 @@ JNI_METHOD(void, nativeOnResume)
}
JNI_METHOD
(
void
,
nativeSetConfigFile
)
(
JNIEnv
*
env
,
jobject
obj
,
jstring
s
)
{
(
JNIEnv
*
env
,
jobject
obj
,
jstring
s
,
jstring
e
)
{
configPath
=
env
->
GetStringUTFChars
(
s
,
NULL
)
;
TMPDIR
=
env
->
GetStringUTFChars
(
e
,
NULL
)
;
}
...
...
GoogleCardboardAndroid/NOMADgvrT/src/main/jni/treasure_hunt_renderer.cc
View file @
4692c8ca
...
...
@@ -312,31 +312,32 @@ TreasureHuntRenderer::TreasureHuntRenderer(
gvr_controller_api_
(
nullptr
),
gvr_viewer_type_
(
gvr_api_
->
GetViewerType
())
{
eprintf
(
"configPath=%d"
,
configPath
);
if
(
configPath
!=
nullptr
)
eprintf
(
"configPath=<%s>"
,
configPath
);
else
eprintf
(
"configPath is null"
);
const
char
*
configfile
=
"/storage/emulated/0/Oculus/NOMAD/ViveTDefault.ncfg"
;
//change cwd so that relative paths work
if
(
configPath
!=
nullptr
)
configfile
=
configPath
;
std
::
string
s
(
configfile
);
if
(
TMPDIR
!=
nullptr
)
eprintf
(
"TMPDIR=<%s>"
,
TMPDIR
);
else
eprintf
(
"TMPDIR is null"
);
std
::
string
s
(
configPath
);
chdir
(
s
.
substr
(
0
,
s
.
find_last_of
(
"
\\
/"
)).
c_str
());
int
r
;
if
((
r
=
loadConfigFile
(
config
file
))
<
0
)
{
if
(
-
100
<
r
)
{
eprintf
(
loadConfigFileErrors
[
-
r
]);
if
((
erro
r
=
loadConfigFile
(
config
Path
))
<
0
)
{
if
(
-
100
<
erro
r
)
{
eprintf
(
loadConfigFileErrors
[
-
erro
r
]);
eprintf
(
"Config file reading error"
);
}
else
if
(
-
200
<
r
){
eprintf
(
readAtomsXYZErrors
[
-
r
-
100
]);
}
else
if
(
-
200
<
erro
r
){
eprintf
(
readAtomsXYZErrors
[
-
erro
r
-
100
]);
eprintf
(
"XYZ file reading error"
);
}
else
if
(
-
300
<
r
)
{
eprintf
(
readAtomsCubeErrors
[
-
r
-
200
]);
}
else
if
(
-
300
<
erro
r
)
{
eprintf
(
readAtomsCubeErrors
[
-
erro
r
-
200
]);
eprintf
(
"Cube file reading error"
);
}
else
{
eprintf
(
readAtomsJsonErrors
[
-
r
-
300
]);
eprintf
(
readAtomsJsonErrors
[
-
erro
r
-
300
]);
eprintf
(
"Json reading error"
);
}
}
...
...
@@ -365,6 +366,12 @@ TreasureHuntRenderer::~TreasureHuntRenderer() {
glDeleteTextures
(
2
,
textures
);
}
const
char
*
ErrorsGL
[]
=
{
"Failure compiling Unit Cell Shader"
,
//-401
"Failure compiling Atom Shader NoTess"
,
//-402;
};
void
TreasureHuntRenderer
::
InitializeGl
()
{
gvr_api_
->
InitializeGl
();
...
...
@@ -382,35 +389,46 @@ glGenTextures(2, textures);
//Leave atoms until we check if android 7 has gles 3.2 or if we use the old icosahedron method with no tesselation
if
(
!
PrepareUnitCellShader
(
&
UnitCellP
,
&
UnitCellMatrixLoc
,
&
UnitCellColourLoc
))
{
eprintf
(
"OneTimeInit, failure compiling Unit Cell Shader"
);
error
=-
401
;
return
;
}
//rgh: for now, we don't have any tess-ready phones
//if (!PrepareAtomShader(&AtomsP, &AtomMatrixLoc)) {
hasTess
=
false
;
if
(
!
PrepareAtomShaderNoTess
(
&
AtomsP
,
&
AtomMatrixLoc
))
if
(
!
PrepareAtomShaderNoTess
(
&
AtomsP
,
&
AtomMatrixLoc
))
{
error
=-
402
;
eprintf
(
"PrepareAtomShaderNoTess failed"
);
}
//};
//atom texture
int
e
;
e
=
atomTexture
(
textures
[
1
]);
if
(
e
!=
GL_NO_ERROR
)
if
(
e
!=
GL_NO_ERROR
)
{
eprintf
(
"atomTexture error %d"
,
e
);
error
=-
403
;
}
e
=
SetupAtoms
(
&
AtomTVAO
,
&
AtomTBuffer
);
if
(
e
!=
GL_NO_ERROR
)
if
(
e
!=
GL_NO_ERROR
)
{
eprintf
(
"SetupAtoms error %d"
,
e
);
error
=-
404
;
}
if
(
!
hasTess
)
e
=
SetupAtomsNoTess
(
&
AtomVAO
,
&
AtomBuffer
,
&
AtomIndices
);
if
(
e
!=
GL_NO_ERROR
)
if
(
e
!=
GL_NO_ERROR
)
{
eprintf
(
"SetupAtomsNoTess error %d, tess=%d"
,
e
,
hasTess
);
error
=-
405
;
}
e
=
SetupUnitCell
(
&
UnitCellVAO
,
&
UnitCellBuffer
,
&
UnitCellIndexBuffer
);
if
(
e
!=
GL_NO_ERROR
)
if
(
e
!=
GL_NO_ERROR
)
{
eprintf
(
"SetupUnitCell error %d"
,
e
);
error
=-
406
;
}
// Because we are using 2X MSAA, we can render to half as many pixels and
// achieve similar quality.
...
...
@@ -525,7 +543,23 @@ if (animateTimesteps) {
// Draw the world.
frame
.
BindBuffer
(
0
);
glClearColor
(
0.1
f
,
0.1
f
,
0.1
f
,
0.5
f
);
// Dark background so text shows up.
if
(
error
<
0
)
{
if
(
-
100
<
error
)
{
glClearColor
(
1.
f
,
0.
f
,
0.
f
,
1.
f
);
}
else
if
(
-
200
<
error
){
glClearColor
(
0.
f
,
1.
f
,
0.
f
,
1.
f
);
}
else
if
(
-
300
<
error
)
{
glClearColor
(
0.
f
,
0.
f
,
1.
f
,
1.
f
);
}
else
if
(
-
400
<
error
)
{
glClearColor
(
0.
f
,
1.
f
,
1.
f
,
1.
f
);
}
else
{
glClearColor
(
1.
f
,
0.
f
,
1.
f
,
1.
f
);
}
}
else
{
glClearColor
(
BACKGROUND
[
0
],
BACKGROUND
[
1
],
BACKGROUND
[
2
],
0.5
f
);
}
// Dark background so text shows up.
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
viewport_list_
->
GetBufferViewport
(
0
,
&
scratch_viewport_
);
DrawWorld
(
left_eye_view
,
scratch_viewport_
);
...
...
@@ -623,7 +657,14 @@ void TreasureHuntRenderer::DrawWorld(const gvr::Mat4f& view_matrix,
glDisable
(
GL_CULL_FACE
);
modelview_
=
view_matrix
;
modelview_projection_cube_
=
MatrixMul
(
perspective
,
modelview_
);
RenderUnitCell
(
modelview_projection_cube_
);
if
(
error
)
return
;
if
(
has_abc
)
{
RenderUnitCell
(
modelview_projection_cube_
);
}
else
{
//atom trajectories
RenderAtomTrajectories
(
modelview_projection_cube_
);
}
}
...
...
@@ -724,6 +765,31 @@ void TreasureHuntRenderer::RenderAtoms(const float *m) //m[16]
}
// no tess
}
void
TreasureHuntRenderer
::
RenderAtomTrajectories
(
const
gvr
::
Mat4f
eyeViewProjection
)
{
int
e
;
if
(
!
numAtoms
)
return
;
gvr
::
Mat4f
trans
=
{
1
,
0
,
0
,
UserTranslation
[
0
],
0
,
1
,
0
,
UserTranslation
[
1
],
0
,
0
,
1
,
UserTranslation
[
2
],
0
,
0
,
0
,
1
};
//trans.translate(iPos).rotateX(-90).translate(UserPosition);
gvr
::
Mat4f
transform
=
MatrixMul
(
eyeViewProjection
,
trans
);
//gvr::Mat4f transform=eyeViewProjection;
float
t
[
16
];
for
(
int
i
=
0
;
i
<
4
;
i
++
)
for
(
int
j
=
0
;
j
<
4
;
j
++
)
t
[
j
*
4
+
i
]
=
transform
.
m
[
i
][
j
];
glUseProgram
(
UnitCellP
);
glUniformMatrix4fv
(
UnitCellMatrixLoc
,
1
,
GL_FALSE
,
t
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error after glUniform4fv 1 RenderAtomTrajectories: %d
\n
"
,
e
);
RenderAtomTrajectoriesUnitCell
();
RenderAtoms
(
t
);
}
void
TreasureHuntRenderer
::
RenderAtomTrajectoriesUnitCell
()
{
//now trajectories
...
...
@@ -743,7 +809,7 @@ glBindVertexArray(AtomTVAO[0]);
float
color
[
4
]
=
{
1
,
0
,
0
,
1
};
glUniform4fv
(
UnitCellColourLoc
,
1
,
color
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error after glUniform4fv 2 RenderUnitCell: %d
\n
"
,
e
);
eprintf
(
"Gl error after glUniform4fv 2 Render
AtomTrajectories
UnitCell: %d
\n
"
,
e
);
//glEnableVertexAttribArray(0);
//glDisableVertexAttribArray(1);
...
...
@@ -776,13 +842,10 @@ for (unsigned int i=0;i<atomtrajectories.size();i++) {
void
TreasureHuntRenderer
::
RenderUnitCell
(
const
gvr
::
Mat4f
eyeViewProjection
)
{
eprintf
(
"eyeViewProjection"
);
for
(
int
i
=
0
;
i
<
4
;
i
++
)
for
(
int
j
=
0
;
j
<
4
;
j
++
)
eprintf
(
"%d %d = %f"
,
i
,
j
,
eyeViewProjection
.
m
[
i
][
j
]);
//repetitions[0]=10;
//repetitions[1]=10;
//repetitions[2]=10;
//eprintf ("eyeViewProjection");
//for (int i=0;i<4;i++)
// for (int j=0;j<4;j++)
// eprintf ("%d %d = %f", i, j, eyeViewProjection.m[i][j]);
eprintf
(
"RenderUnitCell, has_abc=%d"
,
has_abc
);
if
(
!
has_abc
)
return
;
...
...
GoogleCardboardAndroid/NOMADgvrT/src/main/jni/treasure_hunt_renderer.h
View file @
4692c8ca
...
...
@@ -162,9 +162,10 @@ bool animateTimesteps=false;
void
RenderAtoms
(
const
float
*
m
);
void
RenderUnitCell
(
const
gvr
::
Mat4f
eyeViewProjection
);
void
RenderAtomTrajectoriesUnitCell
();
void
RenderAtomTrajectories
(
const
gvr
::
Mat4f
eyeViewProjection
);
float
UserTranslation
[
3
]
=
{
10
,
0
,
0
};
int
error
=
0
;
};
#endif // TREASUREHUNT_APP_SRC_MAIN_JNI_TREASUREHUNTRENDERER_H_ // NOLINT
GoogleCardboardAndroid/readme.md
0 → 100644
View file @
4692c8ca
This repository contains the demos for Google cardboard using GVR Android SDK v1.20.0
https://github.com/googlevr/gvr-android-sdk
Clone that repository and add the content of this one inside the Samples directory.
Copy the content of the ../libs directory (happyhttp, rapidjson) and NOMADVRLib into
NOMADgvrT/src/main/jni
Enable support for ndk (tested: android-ndk-r10d) in settings.gradle:
include ':samples:NOMADgvrT'
List of directories
NOMADgvrT:
This program can load prepared molecular dynamics simulations, and is
compatible with the TimestepData OpenVR demo.
Ply support is not yet implemented
\ No newline at end of file
NOMADVRLib/ConfigFile.cpp
View file @
4692c8ca
...
...
@@ -128,6 +128,7 @@ int loadConfigFile(const char * f)
showTrajectories
=
false
;
basisvectorreps
=
0
;
numClonedAtoms
=
0
;
has_abc
=
false
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
repetitions
[
i
]
=
1
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
...
...
@@ -249,6 +250,7 @@ int loadConfigFile(const char * f)
if
(
e
<
0
)
return
e
-
100
;
updateTIMESTEPS
(
timesteps
);
//eprintf ("After read of xyzfile, numatoms 0 =%d", numAtoms[0]);
}
else
if
(
!
strcmp
(
s
,
"cubefile"
))
{
r
=
readString
(
F
,
s
);
...
...
@@ -345,9 +347,12 @@ int loadConfigFile(const char * f)
solid
=
new
Solid
(
Solid
::
Type
::
Tetrahedron
);
else
return
-
15
;
}
else
{
}
else
if
(
!
strcmp
(
s
,
"
\x0d
"
))
{
//discard windows newline (problem in Sebastian Kokott's phone (?!)
continue
;
}
else
{
eprintf
(
"Unrecognized parameter %s
\n
"
,
s
);
for
(
int
i
=
0
;
i
<
strlen
(
s
);
i
++
)
eprintf
(
"<%d>"
,
s
[
i
]);
fclose
(
F
);
return
-
2
;
}
...
...
@@ -381,6 +386,6 @@ int loadConfigFile(const char * f)
for
(
int
i
=
0
;
i
<*
numAtoms
;
i
++
)
atomtrajectories
.
push_back
(
i
);
}
//eprintf ("Before returning, numatoms 0 =%d", numAtoms[0]);
return
0
;
}
\ No newline at end of file
}
NOMADVRLib/UnitCellShaders.cpp
View file @
4692c8ca
...
...
@@ -5,7 +5,7 @@ const char * const UnitCellShaders [] = {"Unit Cell Renderer",
#ifdef WIN32
"#version 410
\n
"
#else
"#version 3
1
0 es
\n
"
"#version 3
0
0 es
\n
"
#endif
"uniform mat4 matrix;
\n
"
"layout(location = 0) in vec3 pos;
\n
"
...
...
@@ -18,7 +18,7 @@ const char * const UnitCellShaders [] = {"Unit Cell Renderer",
#ifdef WIN32
"#version 410
\n
"
#else
"#version 3
1
0 es
\n
"
"#version 3
0
0 es
\n
"
#endif
"uniform lowp vec4 color;
\n
"
"out lowp vec4 outputColor;
\n
"
...
...
NOMADVRLib/atoms.cpp
View file @
4692c8ca
...
...
@@ -18,7 +18,9 @@
#ifdef WIN32
const
char
*
TMPDIR
=
""
;
#else
const
char
*
TMPDIR
=
"/sdcard/Oculus/NOMAD/"
;
//const char * TMPDIR="/sdcard/Oculus/NOMAD/";
const
char
*
TMPDIR
;
//filled by main
//="/storage/540E-1AE2/";
#endif
const
char
*
const
atomNames
[]
=
...
...
@@ -204,6 +206,7 @@ int readAtomsXYZ(const char *const file, int **numatoms, int *timesteps, float *
continue
;
//there may be a blank line at the end of the file
(
*
timesteps
)
++
;
discardline
(
f
);
//eprintf ("Getting atoms, mynumatoms=%d",mynumatoms);
mypos
.
push_back
(
new
float
[
mynumatoms
*
4
]);
mynum
.
push_back
(
mynumatoms
);
discardline
(
f
);
//comment
...
...
@@ -223,6 +226,7 @@ int readAtomsXYZ(const char *const file, int **numatoms, int *timesteps, float *
for
(
int
i
=
0
;
i
<*
timesteps
;
i
++
)
{
(
*
pos
)[
i
]
=
mypos
[
i
];
(
*
numatoms
)[
i
]
=
mynum
[
i
];
//eprintf ("Getting atoms, numatoms=%d",(*numatoms)[i]);
}
return
0
;
...
...
NOMADVRLib/atomsGL.cpp
View file @
4692c8ca
...
...
@@ -13,20 +13,26 @@ GLenum atomTexture(GLuint t)
{
GLenum
e
;
//rgh: scale atoms here
for
(
int
i
=
0
;
i
<
118
;
i
++
)
atomColours
[
i
][
3
]
*=
atomScaling
;
//in google cardboard, this is called again if the program is running, so leave original or atoms get progresivelly smaller!
float
*
a
=
new
float
[
118
*
4
];
for
(
int
i
=
0
;
i
<
118
;
i
++
)
{
a
[
i
*
4
+
0
]
=
atomColours
[
i
][
0
];
a
[
i
*
4
+
1
]
=
atomColours
[
i
][
1
];
a
[
i
*
4
+
2
]
=
atomColours
[
i
][
2
];
a
[
i
*
4
+
3
]
=
atomColours
[
i
][
3
]
*
atomScaling
;
}
glBindTexture
(
GL_TEXTURE_2D
,
t
);
//atom texture
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MIN_FILTER
,
GL_NEAREST
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MAG_FILTER
,
GL_NEAREST
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_S
,
GL_CLAMP_TO_EDGE
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_T
,
GL_CLAMP_TO_EDGE
);
glTexImage2D
(
GL_TEXTURE_2D
,
0
,
GL_RGBA32F
,
118
,
1
,
0
,
GL_RGBA
,
GL_FLOAT
,
a
tomColours
);
glTexImage2D
(
GL_TEXTURE_2D
,
0
,
GL_RGBA32F
,
118
,
1
,
0
,
GL_RGBA
,
GL_FLOAT
,
a
);
glBindTexture
(
GL_TEXTURE_2D
,
0
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
{
eprintf
(
"opengl error %d, atomTexture
\n
"
,
e
);
}
delete
[]
a
;
return
e
;
}
...
...
@@ -82,7 +88,7 @@ if (!numAtoms)
for
(
int
p
=
0
;
p
<
TIMESTEPS
;
p
++
)
{
for
(
int
a
=
0
;
a
<
numAtoms
[
p
]
-
(
p
==
0
?
0
:
numAtoms
[
p
-
1
]);
a
++
)
{
const
int
atomNumber
=
static_cast
<
int
>
(
atoms
[
p
][
4
*
a
+
3
]);
const
float
radius
=
atomColours
[
atomNumber
][
3
]
/*
*atomScaling
*/
;
const
float
radius
=
atomColours
[
atomNumber
][
3
]
*
atomScaling
;
for
(
int
i
=
0
;
i
<
solid
->
nVerts
;
i
++
)
{
//verts
for
(
int
k
=
0
;
k
<
3
;
k
++
)
{
*
current
++
=
solid
->
Verts
[
3
*
i
+
k
]
*
radius
+
atoms
[
p
][
4
*
a
+
k
];
//pos
...
...
@@ -141,7 +147,7 @@ if (!numAtoms)
for
(
int
a
=
0
;
a
<
numClonedAtoms
;
a
++
)
{
const
int
atomNumber
=
static_cast
<
int
>
(
clonedAtoms
[
0
][
4
*
a
+
3
]);
const
float
radius
=
atomColours
[
atomNumber
][
3
]
/*
*atomScaling
*/
;
const
float
radius
=
atomColours
[
atomNumber
][
3
]
*
atomScaling
;
for
(
int
i
=
0
;
i
<
solid
->
nVerts
;
i
++
)
{
//verts
for
(
int
k
=
0
;
k
<
3
;
k
++
)
{
*
current
++
=
solid
->
Verts
[
3
*
i
+
k
]
*
radius
+
clonedAtoms
[
0
][
4
*
a
+
k
];
//pos
...
...
@@ -441,4 +447,4 @@ for (int i=0;i<3;i++)
for
(
int
ss
=
0
;
ss
<
3
;
ss
++
)
for
(
int
i
=
0
;
i
<
3
;
i
++
)
f
[
i
]
+=
delta
[
ss
][
i
];
}
\ No newline at end of file
}
OculusMobile/NOMADGearvrT/Src/OvrApp.cpp
View file @
4692c8ca
...
...
@@ -224,7 +224,7 @@ void OvrApp::OneTimeShutdown()
glDeleteProgram
(
AtomsP
);
glDeleteProgram
(
UnitCellP
);
GL
(
glDeleteTextures
(
1
,
textures
));
GL
(
glDeleteTextures
(
2
,
textures
));
// LOG("OneTimeShutdown 2");
}
...
...
@@ -303,13 +303,7 @@ void OvrApp::RenderAtoms(const float *m) //m[16]
LOG
(
"FIXME, No Tess code for atoms yet!"
);
return
;
}
else
{
//no tess
//eprintf ("rendering atoms, currentSet=%d", currentSet);
glBindVertexArray
(
AtomVAO
[
0
]);
//glBindVertexArray(GL_ARRAY_BUFFER, AtomBuffer[0]);
//glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 7*sizeof(float), (const void *)0);
//glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 7 * sizeof(float), (const void *)(3*sizeof(float)));
//glVertexAttribPointer(2, 1, GL_FLOAT, GL_FALSE, 7 * sizeof(float), (const void *)(6 * sizeof(float)));
glBindTexture
(
GL_TEXTURE_2D
,
textures
[
1
]);
glUseProgram
(
AtomsP
);
glUniformMatrix4fv
(
AtomMatrixLoc
,
1
,
GL_FALSE
,
m
);
...
...
@@ -322,9 +316,6 @@ void OvrApp::RenderAtoms(const float *m) //m[16]
#endif
0
);
}
else
{
//eprintf("draw elements triangles, %d, unsigned_int, %d", numAtoms[currentSet]-numAtoms[currentSet-1],
// numAtoms[currentSet-1]);
//eprintf ("solid->nfaces=%d", solid->nFaces);
glDrawElements
(
GL_TRIANGLES
,
(
numAtoms
[
currentSet
]
-
numAtoms
[
currentSet
-
1
])
*
3
*
solid
->
nFaces
,
#ifndef INDICESGL32
GL_UNSIGNED_SHORT
,
(
void
*
)(
numAtoms
[
currentSet
-
1
]
*
sizeof
(
unsigned
short
)
*
3
*
solid
->
nFaces
)
...
...
@@ -336,7 +327,6 @@ void OvrApp::RenderAtoms(const float *m) //m[16]
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error after Render Atom timestep =%d: %d
\n
"
,
currentSet
,
e
);
//now cloned atoms
//eprintf("numClonedAtoms %d, painting", numClonedAtoms);
if
(
numClonedAtoms
!=
0
&&
currentSet
==
0
)
{
glBindVertexArray
(
AtomVAO
[
1
]);
glDrawElements
(
GL_TRIANGLES
,
numClonedAtoms
*
3
*
solid
->
nFaces
,
...
...
README.md
View file @
4692c8ca
Subdirectories:
OpenVR: Demos for HTC Vive.
OculusMobile: Demos for GearVR.
GoogleCardboardAndroid: Demos for Google Cardboard (android)
NOMADVRLib: Shared code between HTC Vive and GearVR demos related to NOMAD.
libs: Other (external) supporting libs shared by HTC Vive and GearVR demos
...
...
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