Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
VR-demos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nomad-lab
VR-demos
Commits
9f2c90ee
Commit
9f2c90ee
authored
Nov 08, 2017
by
Ruben Jesus Garcia Hernandez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
animationspeed, movementspeed, newatom options.
Check for bom mark add sphere config option
parent
70d13df1
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
138 additions
and
31 deletions
+138
-31
GoogleCardboardAndroid/NOMADgvrT/src/main/jni/treasure_hunt_renderer.cc
...dAndroid/NOMADgvrT/src/main/jni/treasure_hunt_renderer.cc
+1
-1
NOMADVRLib/ConfigFile.cpp
NOMADVRLib/ConfigFile.cpp
+58
-9
NOMADVRLib/ConfigFile.h
NOMADVRLib/ConfigFile.h
+3
-0
NOMADVRLib/TessShaders.cpp
NOMADVRLib/TessShaders.cpp
+4
-2
NOMADVRLib/atoms.cpp
NOMADVRLib/atoms.cpp
+23
-2
NOMADVRLib/atoms.hpp
NOMADVRLib/atoms.hpp
+5
-0
NOMADVRLib/atomsGL.cpp
NOMADVRLib/atomsGL.cpp
+28
-8
NOMADVRLib/atomsGL.h
NOMADVRLib/atomsGL.h
+8
-3
NOMADVRLib/polyhedron.h
NOMADVRLib/polyhedron.h
+2
-2
OpenVR/TimestepData/hellovr_opengl_main.cpp
OpenVR/TimestepData/hellovr_opengl_main.cpp
+6
-4
No files found.
GoogleCardboardAndroid/NOMADgvrT/src/main/jni/treasure_hunt_renderer.cc
View file @
9f2c90ee
...
...
@@ -1079,7 +1079,7 @@ glBindVertexArray(AtomTVAO[0]);
eprintf
(
"1 Gl error RenderAtomTrajectoriesUnitCell: %d
\n
"
,
e
);
//glUseProgram(UnitCellP);
//glUniformMatrix4fv(m_nUnitCellMatrixLocation, 1, GL_FALSE, matrix);
glUniform4fv
(
UnitCellColourLoc
,
1
,
atomtrajectorycol
uo
r
);
glUniform4fv
(
UnitCellColourLoc
,
1
,
atomtrajectorycol
ou
r
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error after glUniform4fv 2 RenderAtomTrajectoriesUnitCell: %d
\n
"
,
e
);
//glEnableVertexAttribArray(0);
...
...
NOMADVRLib/ConfigFile.cpp
View file @
9f2c90ee
...
...
@@ -57,12 +57,13 @@ bool gazenavigation;
int
transparencyquality
;
float
nearclip
,
farclip
;
//markers such as hole positions and electron positions
float
**
markers
;
float
**
markercolours
;
float
cubetrans
[
3
];
float
animationspeed
;
float
movementspeed
;
const
char
*
loadConfigFileErrors
[]
=
{
...
...
@@ -86,6 +87,7 @@ const char * loadConfigFileErrors[] =
"markers with no previous correct timesteps parameter"
,
//-17
"markercolours with no previous correct timesteps parameter"
,
//-18
"Error reading atomcolour"
,
// -19
"Error reading newatom"
,
//-20
"Error loading xyz file, add 100 to see the error"
,
//<-100
"Error loading cube file, add 200 to see the error"
,
//<-200
"Error loading encyclopedia json file, add 300 to see the error"
,
//<-300
...
...
@@ -146,7 +148,7 @@ while (*file!='\0') {
void
initState
()
{
BACKGROUND
[
0
]
=
0.95
f
;
BACKGROUND
[
0
]
=
0.95
f
;
BACKGROUND
[
1
]
=
0.95
f
;
BACKGROUND
[
2
]
=
0.95
f
;
SCREENSHOT
=
"C:
\\
temp
\\
frame"
;
...
...
@@ -209,6 +211,9 @@ void initState()
atomtrajectorycolour
[
1
]
=
0.0
f
;
atomtrajectorycolour
[
2
]
=
0.0
f
;
atomtrajectorycolour
[
3
]
=
1.0
f
;
animationspeed
=
1.0
f
;
movementspeed
=
1.0
f
;
}
int
loadConfigFile
(
const
char
*
f
)
...
...
@@ -221,7 +226,6 @@ int loadConfigFile(const char * f)
initState
();
char
*
token
=
0
;
//
FILE
*
F
=
fopen
(
f
,
"r"
);
if
(
F
==
0
)
{
...
...
@@ -235,6 +239,8 @@ int loadConfigFile(const char * f)
r
=
fscanf
(
F
,
"%99s"
,
s
);
if
(
r
<=
0
)
continue
;
if
((
unsigned
char
)
s
[
0
]
==
0xef
&&
(
unsigned
char
)
s
[
1
]
==
0xbb
&&
(
unsigned
char
)
s
[
2
]
==
0xbf
)
//utf bom
strcpy
(
s
,
s
+
3
);
if
(
s
[
0
]
==
'#'
)
{
//comment
discardline
(
F
);
continue
;
...
...
@@ -452,6 +458,11 @@ int loadConfigFile(const char * f)
solid
=
new
Solid
(
Solid
::
Type
::
Octahedron
);
else
if
(
!
strcmp
(
s
,
"tetrahedron"
))
solid
=
new
Solid
(
Solid
::
Type
::
Tetrahedron
);
else
if
(
!
strcmp
(
s
,
"sphere"
))
{
int
subd
;
r
=
fscanf
(
F
,
"%d"
,
&
subd
);
solid
=
new
Solid
(
Solid
::
Type
::
Sphere
,
subd
);
}
else
return
-
15
;
}
else
if
(
!
strcmp
(
s
,
"token"
))
{
...
...
@@ -481,9 +492,11 @@ int loadConfigFile(const char * f)
//for (int s=0;s<3;s++)
// tmp[s]-=translations[0][s]; //using translation of iso 0
//check if coordinates are outside of cell
for
(
int
s
=
0
;
s
<
3
;
s
++
)
{
while
(
tmp
[
s
]
<-
translations
[
0
][
s
])
tmp
[
s
]
+=
supercell
[
2
-
s
];
if
(
translations
)
{
for
(
int
s
=
0
;
s
<
3
;
s
++
)
{
while
(
tmp
[
s
]
<-
translations
[
0
][
s
])
tmp
[
s
]
+=
supercell
[
2
-
s
];
}
}
for
(
int
s
=
0
;
s
<
3
;
s
++
)
{
markers
[
i
][
s
]
=
tmp
[
2
]
*
abc
[
0
][
s
]
+
tmp
[
1
]
*
abc
[
1
][
s
]
+
tmp
[
0
]
*
abc
[
2
][
s
];
//hole positions seem to be in zyx
...
...
@@ -524,6 +537,34 @@ int loadConfigFile(const char * f)
}
for
(
int
i
=
0
;
i
<
3
;
i
++
)
atomColours
[
a
][
i
]
=
rgb
[
i
];
}
else
if
(
!
strcmp
(
s
,
"newatom"
))
{
char
atom
[
100
];
float
rgb
[
3
];
float
size
;
r
=
fscanf
(
F
,
"%s %f %f %f %f"
,
atom
,
rgb
,
rgb
+
1
,
rgb
+
2
,
&
size
);
if
(
r
!=
5
)
{
eprintf
(
"Error loading newatom"
);
return
-
20
;
}
int
a
=
findAtom
(
atom
);
if
(
a
!=-
1
)
{
if
(
a
<
atomsInPeriodicTable
)
{
for
(
int
i
=
0
;
i
<
3
;
i
++
)
atomColours
[
a
][
i
]
=
rgb
[
i
];
atomColours
[
a
][
3
]
=
size
;
}
else
{
for
(
int
i
=
0
;
i
<
3
;
i
++
)
extraAtomData
[
a
-
atomsInPeriodicTable
][
i
]
=
rgb
[
i
];
extraAtomData
[
a
-
atomsInPeriodicTable
][
3
]
=
size
;
}
}
else
{
//new
extraAtomNames
.
push_back
(
strdup
(
atom
));
extraAtomData
.
push_back
(
new
float
[
4
]);
float
*
e
=
extraAtomData
.
back
();
for
(
int
i
=
0
;
i
<
3
;
i
++
)
e
[
i
]
=
rgb
[
i
];
e
[
3
]
=
size
;
}
}
else
if
(
!
strcmp
(
s
,
"markerscaling"
))
{
r
=
fscanf
(
F
,
"%f"
,
&
markerscaling
);
}
else
if
(
!
strcmp
(
s
,
"displayunitcell"
))
{
...
...
@@ -544,8 +585,6 @@ int loadConfigFile(const char * f)
showcontrollers
=
true
;
}
else
if
(
!
strcmp
(
s
,
"gazenavigation"
))
{
gazenavigation
=
true
;
}
else
if
(
!
strcmp
(
s
,
"
\x0d
"
))
{
//discard windows newline (problem in Sebastian Kokott's phone (?!)
continue
;
}
else
if
(
!
strcmp
(
s
,
"transparencyquality"
))
{
r
=
fscanf
(
F
,
"%d"
,
&
transparencyquality
);
if
(
r
<
1
)
...
...
@@ -570,7 +609,17 @@ int loadConfigFile(const char * f)
r
=
fscanf
(
F
,
"%f %f %f"
,
atomtrajectorycolour
,
atomtrajectorycolour
+
1
,
atomtrajectorycolour
+
2
);
if
(
r
<
3
)
eprintf
(
"Error reading atomtrajectorycolour value"
);
}
else
{
}
else
if
(
!
strcmp
(
s
,
"animationspeed"
))
{
r
=
fscanf
(
F
,
"%f"
,
&
animationspeed
);
if
(
r
<
1
)
eprintf
(
"Error reading animationspeed"
);
}
else
if
(
!
strcmp
(
s
,
"movementspeed"
))
{
r
=
fscanf
(
F
,
"%f"
,
&
movementspeed
);
if
(
r
<
1
)
eprintf
(
"Error reading movementspeed"
);
}
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
]);
...
...
NOMADVRLib/ConfigFile.h
View file @
9f2c90ee
...
...
@@ -54,6 +54,9 @@ extern bool gazenavigation;
extern
int
transparencyquality
;
extern
float
nearclip
,
farclip
;
extern
float
animationspeed
;
//how fast to change to next timestep
extern
float
movementspeed
;
//how fast to move the user
//markers such as hole positions and electron positions
extern
float
**
markers
;
extern
float
**
markercolours
;
...
...
NOMADVRLib/TessShaders.cpp
View file @
9f2c90ee
...
...
@@ -16,6 +16,7 @@ const char * const AtomShaders [] = {
"#version 300 es
\n
"
#endif
"uniform sampler2D atomData;
\n
"
"uniform float totalatoms=118.0;
\n
"
//(float)atomsInPeriodicTable
"layout(location = 0) in vec3 center;
\n
"
"layout(location = 1) in float atomIn;
\n
"
"out vec4 vcolor;
\n
"
//color , radius
...
...
@@ -23,7 +24,7 @@ const char * const AtomShaders [] = {
"void main()
\n
"
"{
\n
"
//"gl_Position = matrix * vec4(position+center, 1);\n"
"float coord=atomIn/
118.0+0.5/118.0
;
\n
"
"float coord=atomIn/
totalatoms+0.5/totalatoms
;
\n
"
"vcolor=vec4(texture(atomData, vec2(coord, 0)));
\n
"
"vcen=center;
\n
"
//"color.a=1;\n"
...
...
@@ -96,6 +97,7 @@ const char * const AtomShadersNoTess [] = {
#endif
"uniform sampler2D atomData;
\n
"
"uniform mat4 matrix;
\n
"
"uniform float totalatoms=118.0;
\n
"
//(float)atomsInPeriodicTable
"layout(location = 0) in vec3 pos;
\n
"
"layout(location = 1) in vec3 normalIn;
\n
"
"layout(location = 2) in float atomIn;
\n
"
...
...
@@ -106,7 +108,7 @@ const char * const AtomShadersNoTess [] = {
"{
\n
"
"gl_Position = matrix * vec4(pos, 1);
\n
"
"normal=normalIn;
\n
"
"float coord=atomIn/
118.0+0.5/118.0
;
\n
"
"float coord=atomIn/
totalatoms+0.5/totalatoms
;
\n
"
"color=vec4(texture(atomData, vec2(coord, 0)));
\n
"
"color.a=1.0;
\n
"
"vertex=pos;
\n
"
...
...
NOMADVRLib/atoms.cpp
View file @
9f2c90ee
...
...
@@ -28,7 +28,8 @@ const char * TMPDIR;//filled by main
bool
inv_abc_init
=
false
;
float
inv_abc
[
3
][
3
];
std
::
vector
<
const
char
*>
extraAtomNames
;
std
::
vector
<
float
*>
extraAtomData
;
const
char
*
const
atomNames
[]
=
...
...
@@ -176,7 +177,10 @@ float atomColours[][4] =
float
atomRadius
(
int
i
)
{
return
atomColours
[
i
][
3
];
if
(
i
<
atomsInPeriodicTable
)
return
atomColours
[
i
][
3
];
else
return
extraAtomData
[
i
-
atomsInPeriodicTable
][
3
];
}
void
discardline
(
FILE
*
F
)
...
...
@@ -190,7 +194,19 @@ do {
int
findAtom
(
const
char
*
const
s
)
{
//discard number at end
//rgh: I have C1A, so better to go from the end to avoid this being confused with C
char
x
[
10
];
strcpy
(
x
,
s
);
char
*
p
=
x
+
strlen
(
x
);
p
--
;
while
(
*
p
>
'0'
&&
*
p
<=
'9'
)
{
*
p
=
'\0'
;
*
p
--
;
if
(
p
==
x
)
break
;
}
/*
char *p=x;
const char *q=s;
while (*q!=0) {
...
...
@@ -199,10 +215,15 @@ int findAtom(const char *const s)
*p++=*q++;
}
*p=0;
*/
//rgh FIXME, add caching
for
(
unsigned
int
i
=
0
;
i
<
sizeof
(
atomNames
)
/
sizeof
(
const
char
*
);
i
++
)
if
(
!
strcmp
(
x
,
atomNames
[
i
]))
return
i
;
//now check extra atoms, starting at atomsInPeriodicTable
for
(
unsigned
int
i
=
0
;
i
<
extraAtomNames
.
size
();
i
++
)
if
(
!
strcmp
(
x
,
extraAtomNames
[
i
]))
return
i
+
atomsInPeriodicTable
;
return
-
1
;
}
...
...
NOMADVRLib/atoms.hpp
View file @
9f2c90ee
...
...
@@ -11,6 +11,8 @@
extern
float
atomColours
[][
4
];
const
int
atomsInPeriodicTable
=
118
;
extern
const
char
*
TMPDIR
;
int
readAtomsXYZ
(
const
char
*
const
file
,
int
**
numatoms
,
int
*
timesteps
,
float
***
pos
);
...
...
@@ -44,4 +46,7 @@ void TransformAtoms(std::vector<float>* clonedAtoms, const float abc[3][3]);
extern
bool
inv_abc_init
;
extern
float
inv_abc
[
3
][
3
];
extern
std
::
vector
<
const
char
*>
extraAtomNames
;
extern
std
::
vector
<
float
*>
extraAtomData
;
#endif //__ATOMS_H
NOMADVRLib/atomsGL.cpp
View file @
9f2c90ee
...
...
@@ -22,21 +22,28 @@ int getAtomTimesteps()
GLenum
atomTexture
(
GLuint
t
)
{
GLenum
e
;
int
finalatoms
=
getTotalAtomsInTexture
();
//rgh: scale atoms here
//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
++
)
{
float
*
a
=
new
float
[
finalatoms
*
4
];
for
(
int
i
=
0
;
i
<
atomsInPeriodicTable
;
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
;
}
for
(
int
i
=
0
;
i
<
extraAtomNames
.
size
();
i
++
)
{
a
[(
i
+
atomsInPeriodicTable
)
*
4
+
0
]
=
extraAtomData
[
i
][
0
];
a
[(
i
+
atomsInPeriodicTable
)
*
4
+
1
]
=
extraAtomData
[
i
][
1
];
a
[(
i
+
atomsInPeriodicTable
)
*
4
+
2
]
=
extraAtomData
[
i
][
2
];
a
[(
i
+
atomsInPeriodicTable
)
*
4
+
3
]
=
extraAtomData
[
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
);
glTexImage2D
(
GL_TEXTURE_2D
,
0
,
GL_RGBA32F
,
finalatoms
,
1
,
0
,
GL_RGBA
,
GL_FLOAT
,
a
);
glBindTexture
(
GL_TEXTURE_2D
,
0
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
{
...
...
@@ -301,7 +308,7 @@ GLenum SetupAtoms(GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLu
M
[
k
]
=
atoms
[
p
][
4
*
a
+
k
];
}
}
grid
g
(
m
,
M
,
pow
(
numAtoms
[
p
],
1.0
/
3
),
bondscaling
);
grid
g
(
m
,
M
,
pow
(
numAtoms
[
p
],
1.0
f
/
3.0
f
),
bondscaling
);
for
(
int
a
=
1
;
a
<
numAtoms
[
p
];
a
++
)
g
.
add
(
atoms
[
p
]
+
4
*
a
);
for
(
int
a
=
0
;
a
<
numAtoms
[
p
];
a
++
)
{
...
...
@@ -546,8 +553,8 @@ GLenum SetupUnitCell(GLuint *UnitCellVAO, GLuint *UnitCellVertBuffer, GLuint *Un
bool
PrepareUnitCellAtomShader
(
GLuint
*
AtomP
,
GLuint
*
cellP
,
GLuint
*
MarkerP
,
GLint
*
AtomMatrixLocation
,
GLint
*
UnitCellMatrixLocation
,
GLint
*
UnitCellColourLocation
,
GLint
*
MarkerMatrixLocation
){
if
(
!
PrepareAtomShader
(
AtomP
,
AtomMatrixLocation
))
GLint
*
MarkerMatrixLocation
,
GLint
*
totalatomsLocation
){
if
(
!
PrepareAtomShader
(
AtomP
,
AtomMatrixLocation
,
totalatomsLocation
))
return
false
;
if
(
!
PrepareUnitCellShader
(
cellP
,
UnitCellMatrixLocation
,
UnitCellColourLocation
))
...
...
@@ -559,7 +566,7 @@ bool PrepareUnitCellAtomShader (GLuint *AtomP, GLuint *cellP, GLuint *MarkerP,
return
true
;
}
bool
PrepareAtomShader
(
GLuint
*
AtomP
,
GLint
*
AtomMatrixLocation
){
bool
PrepareAtomShader
(
GLuint
*
AtomP
,
GLint
*
AtomMatrixLocation
,
GLint
*
totalatomsLocation
){
//https://www.gamedev.net/topic/591110-geometry-shader-point-sprites-to-spheres/
//no rotation, only translations means we can do directional lighting in the shader.
//FIXME
...
...
@@ -576,6 +583,13 @@ bool PrepareAtomShader (GLuint *AtomP, GLint *AtomMatrixLocation){
eprintf
(
"Unable to find matrix uniform in atom shader
\n
"
);
return
false
;
}
*
totalatomsLocation
=
glGetUniformLocation
(
*
AtomP
,
"totalatoms"
);
if
(
*
totalatomsLocation
==
-
1
)
{
eprintf
(
"Unable to find matrix uniform in atom shader
\n
"
);
return
false
;
}
return
true
;
}
...
...
@@ -599,7 +613,7 @@ bool PrepareMarkerShader (GLuint *MP, GLint *MMatrixLocation){
return
true
;
}
bool
PrepareAtomShaderNoTess
(
GLuint
*
AtomP
,
GLint
*
AtomMatrixLocation
){
bool
PrepareAtomShaderNoTess
(
GLuint
*
AtomP
,
GLint
*
AtomMatrixLocation
,
GLint
*
totalatomsLocation
){
//https://www.gamedev.net/topic/591110-geometry-shader-point-sprites-to-spheres/
//no rotation, only translations means we can do directional lighting in the shader.
//FIXME
...
...
@@ -616,6 +630,12 @@ bool PrepareAtomShaderNoTess (GLuint *AtomP, GLint *AtomMatrixLocation){
eprintf
(
"Unable to find matrix uniform in atom shader no tess
\n
"
);
return
false
;
}
*
totalatomsLocation
=
glGetUniformLocation
(
*
AtomP
,
"totalatoms"
);
if
(
*
totalatomsLocation
==
-
1
)
{
eprintf
(
"Unable to find matrix uniform in atom shader
\n
"
);
return
false
;
}
return
true
;
}
...
...
NOMADVRLib/atomsGL.h
View file @
9f2c90ee
...
...
@@ -2,6 +2,7 @@
#define __ATOMSGL_H
#include "MyGL.h"
#include "atoms.hpp"
GLenum
atomTexture
(
GLuint
t
);
GLenum
SetupAtoms
(
GLuint
**
AtomVAO
,
GLuint
**
AtomVertBuffer
,
GLuint
*
BondIndices
);
...
...
@@ -11,14 +12,18 @@ GLenum SetupMarker(GLuint *MarkerVAO, GLuint *MarkerVertBuffer);
bool
PrepareUnitCellAtomShader
(
GLuint
*
AtomP
,
GLuint
*
cellP
,
GLuint
*
MarkerP
,
GLint
*
AtomMatrixLocation
,
GLint
*
UnitCellMatrixLocation
,
GLint
*
UnitCellColourLocation
,
GLint
*
MarkerMatrixLocation
);
bool
PrepareAtomShader
(
GLuint
*
AtomP
,
GLint
*
AtomMatrixLocation
);
bool
PrepareAtomShaderNoTess
(
GLuint
*
AtomP
,
GLint
*
AtomMatrixLocation
);
GLint
*
MarkerMatrixLocation
,
GLint
*
totalatomsLocation
);
bool
PrepareAtomShader
(
GLuint
*
AtomP
,
GLint
*
AtomMatrixLocation
,
GLint
*
totalatomsLocation
);
bool
PrepareAtomShaderNoTess
(
GLuint
*
AtomP
,
GLint
*
AtomMatrixLocation
,
GLint
*
totalatomsLocation
);
bool
PrepareUnitCellShader
(
GLuint
*
cellP
,
GLint
*
UnitCellMatrixLocation
,
GLint
*
UnitCellColourLocation
);
bool
PrepareMarkerShader
(
GLuint
*
MP
,
GLint
*
MMatrixLocation
);
void
GetDisplacement
(
int
p
[
3
],
float
f
[
3
]);
int
getAtomTimesteps
();
inline
int
getTotalAtomsInTexture
()
{
return
atomsInPeriodicTable
+
extraAtomNames
.
size
();
}
#endif //__ATOMSGL_H
NOMADVRLib/polyhedron.h
View file @
9f2c90ee
...
...
@@ -63,8 +63,8 @@ public:
for
(
int
i
=
0
;
i
<
SphereFacets
;
i
++
)
for
(
int
j
=
0
;
j
<
SphereFacets
;
j
++
)
{
float
t
,
f
;
t
=
i
*
2
*
M_PI
/
(
float
)(
SphereFacets
-
1
);
f
=
j
*
M_PI
/
(
float
)(
SphereFacets
-
1
);
t
=
i
*
2
.0
f
*
(
float
)
M_PI
/
(
float
)(
SphereFacets
-
1
);
f
=
j
*
(
float
)
M_PI
/
(
float
)(
SphereFacets
-
1
);
tVerts
[
i
*
SphereFacets
*
3
+
j
*
3
]
=
sin
(
f
)
*
sin
(
t
);
tVerts
[
i
*
SphereFacets
*
3
+
j
*
3
+
1
]
=
sin
(
f
)
*
cos
(
t
);
...
...
OpenVR/TimestepData/hellovr_opengl_main.cpp
View file @
9f2c90ee
...
...
@@ -287,6 +287,7 @@ private: // OpenGL bookkeeping
GLint
m_nAtomMVLocation
;
GLint
m_nUnitCellMatrixLocation
,
m_nUnitCellColourLocation
;
GLint
m_nMarkerMatrixLocation
;
GLint
m_nTotalatomsLocation
;
struct
FramebufferDesc
{
...
...
@@ -869,7 +870,7 @@ bool CMainApplication::HandleInput()
SDL_Event
sdlEvent
;
bool
bRet
=
false
;
float
speed
=
0.02
f
;
float
speed
=
0.02
f
*
movementspeed
;
while
(
SDL_PollEvent
(
&
sdlEvent
)
!=
0
)
{
...
...
@@ -1002,8 +1003,8 @@ bool CMainApplication::HandleInput()
}
}
else
{
float
newtime
=
videospeed
*
float
(
SDL_GetTicks
());
;
if
(
newtime
-
elapsedtime
>
1
)
{
float
newtime
=
videospeed
*
float
(
SDL_GetTicks
());
if
(
newtime
-
elapsedtime
>
1
.0
f
/
animationspeed
)
{
elapsedtime
=
newtime
;
currentset
++
;
if
(
currentset
>=
TIMESTEPS
)
...
...
@@ -1300,7 +1301,7 @@ bool CMainApplication::CreateAllShaders()
}
if
(
!
PrepareUnitCellAtomShader
(
&
m_unAtomsProgramID
,
&
m_unUnitCellProgramID
,
&
m_unMarkerProgramID
,
&
m_nAtomMatrixLocation
,
&
m_nUnitCellMatrixLocation
,
&
m_nUnitCellColourLocation
,
&
m_nMarkerMatrixLocation
))
&
m_nAtomMatrixLocation
,
&
m_nUnitCellMatrixLocation
,
&
m_nUnitCellColourLocation
,
&
m_nMarkerMatrixLocation
,
&
m_nTotalatomsLocation
))
return
false
;
...
...
@@ -2196,6 +2197,7 @@ float delta[3];
::
GetDisplacement
(
p
,
delta
);
Vector3
iPos
(
delta
[
0
],
delta
[
1
],
delta
[
2
]);
glUseProgram
(
m_unAtomsProgramID
);
glUniform1f
(
m_nTotalatomsLocation
,
(
float
)
getTotalAtomsInTexture
());
float
levelso
[
4
]
=
{
TESSSUB
,
TESSSUB
,
TESSSUB
,
TESSSUB
};
float
levelsi
[
2
]
=
{
TESSSUB
,
TESSSUB
};
...
...
Write
Preview
Markdown
is supported
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