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
047843b8
Commit
047843b8
authored
May 29, 2017
by
Ruben Garcia Hernndez
Browse files
Add support for fixed atoms and bonds in CAVE
parent
8b910c51
Changes
3
Hide whitespace changes
Inline
Side-by-side
CAVE/NOMADCaveT/src/main.cpp
View file @
047843b8
...
...
@@ -108,7 +108,7 @@ GLuint textDepthPeeling[ZLAYERS+2];
GLuint
peelingFramebuffer
;
unsigned
int
geo
[
0
];
//window width, height
//if no tesselation is available, we still need the tess atoms for the trajectories!
GLuint
*
AtomTVAO
=
nullptr
,
*
AtomTBuffer
=
nullptr
,
GLuint
*
AtomTVAO
=
nullptr
,
*
AtomTBuffer
=
nullptr
,
BondIndices
=
0
,
*
AtomVAO
=
nullptr
,
*
AtomBuffer
=
nullptr
,
*
AtomIndices
=
nullptr
,
//[2], atoms, extraatoms
UnitCellVAO
,
UnitCellBuffer
,
UnitCellIndexBuffer
;
GLuint
AtomsP
,
UnitCellP
;
...
...
@@ -211,7 +211,7 @@ glGenTextures(2+ZLAYERS, textDepthPeeling);
bool
er
;
e
=
SetupAtoms
(
&
AtomTVAO
,
&
AtomTBuffer
);
e
=
SetupAtoms
(
&
AtomTVAO
,
&
AtomTBuffer
,
&
BondIndices
);
if
(
e
!=
GL_NO_ERROR
)
{
eprintf
(
"SetupAtoms error %d"
,
e
);
error
=-
404
;
...
...
@@ -667,7 +667,7 @@ void sceneManager::RenderAtoms(const float *m) //m[16]
eprintf
(
"Gl error 4 timestep =%d: %d, %s
\n
"
,
m_oldTime
,
e
,
gluErrorString
(
e
));
//eprintf ("8");
if
(
m_oldTime
==
0
)
if
(
m_oldTime
==
0
||
fixedAtoms
)
glDrawArrays
(
GL_PATCHES
,
0
,
numAtoms
[
0
]);
else
glDrawArrays
(
GL_PATCHES
,
numAtoms
[
m_oldTime
-
1
],
...
...
@@ -679,7 +679,7 @@ void sceneManager::RenderAtoms(const float *m) //m[16]
m_oldTime
,
e
,
gluErrorString
(
e
));
//now cloned atoms
if
(
numClonedAtoms
!=
0
&&
m_oldTime
==
0
)
{
if
(
numClonedAtoms
!=
0
&&
(
m_oldTime
==
0
||
fixedAtoms
)
)
{
//eprintf ("10");
glBindVertexArray
(
AtomTVAO
[
1
]);
//eprintf ("11");
...
...
@@ -690,6 +690,8 @@ void sceneManager::RenderAtoms(const float *m) //m[16]
m_oldTime
,
e
,
gluErrorString
(
e
));
}
}
else
{
//no tess
glBindVertexArray
(
AtomVAO
[
0
]);
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
AtomIndices
[
0
]);
...
...
@@ -723,8 +725,8 @@ void sceneManager::RenderAtoms(const float *m) //m[16]
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"8 Gl error RenderAtom timestep =%d: %d
\n
"
,
m_oldTime
,
e
);
if
(
m_oldTime
==
0
)
{
glDrawElements
(
GL_TRIANGLES
,
numAtoms
[
m_oldTime
]
*
3
*
solid
->
nFaces
,
if
(
m_oldTime
==
0
||
fixedAtoms
)
{
glDrawElements
(
GL_TRIANGLES
,
numAtoms
[
0
]
*
3
*
solid
->
nFaces
,
#ifndef INDICESGL32
GL_UNSIGNED_SHORT
,
#else
...
...
@@ -781,7 +783,7 @@ void sceneManager::RenderAtomTrajectories(const glm::mat4 eyeViewProjection)
int
e
;
if
(
!
numAtoms
)
return
;
eprintf
(
"RenderAtomTrajectories start"
);
//
eprintf ("RenderAtomTrajectories start");
/*glm::mat4 trans={1,0,0,UserTranslation[0],
0,1,0,UserTranslation[1],
0,0,1,UserTranslation[2],
...
...
@@ -800,6 +802,30 @@ if ((e = glGetError()) != GL_NO_ERROR)
eprintf
(
"Gl error after glUniform4fv 1 RenderAtomTrajectories: %d
\n
"
,
e
);
RenderAtomTrajectoriesUnitCell
();
RenderAtoms
(
t
);
//now bonds
//return;
if
(
numBonds
)
{
glBindVertexArray
(
AtomTVAO
[
2
]);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error after Render Atom bonds glBindVertexArray timestep =%d: %d, %s
\n
"
,
m_oldTime
,
e
,
gluErrorString
(
e
));
glUseProgram
(
UnitCellP
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error after Render Atom bonds glUseProgram timestep =%d: %d, %s
\n
"
,
m_oldTime
,
e
,
gluErrorString
(
e
));
glUniformMatrix4fv
(
UnitCellMatrixLoc
,
1
,
GL_FALSE
,
t
);
float
color
[
4
]
=
{
0.5
,
0.5
,
1
,
1
};
glUniform4fv
(
UnitCellColourLoc
,
1
,
color
);
if
(
m_oldTime
==
0
||
fixedAtoms
)
glDrawElements
(
GL_LINES
,
numBonds
[
0
],
GL_UNSIGNED_INT
,
(
void
*
)
0
);
else
glDrawElements
(
GL_LINES
,
numBonds
[
m_oldTime
]
-
numBonds
[
m_oldTime
-
1
],
GL_UNSIGNED_INT
,
(
void
*
)(
sizeof
(
int
)
*
numBonds
[
m_oldTime
-
1
])
);
if
((
e
=
glGetError
())
!=
GL_NO_ERROR
)
eprintf
(
"Gl error after Render Atom bonds timestep =%d: %d, %s
\n
"
,
m_oldTime
,
e
,
gluErrorString
(
e
));
}
glBindVertexArray
(
0
);
}
//RenderAtomTrajectories
void
sceneManager
::
RenderAtomTrajectoriesUnitCell
()
...
...
NOMADVRLib/Grid.cpp
View file @
047843b8
#include
"Grid.h"
#include
"atoms.hpp"
//for radius
#include
<math.h>
grid
::
grid
(
float
*
m
,
float
*
M
,
int
dims
,
float
s
)
:
scale
(
s
)
{
content
=
new
std
::
vector
<
float
*>
[
dims
*
dims
*
dims
];
...
...
NOMADVRLib/atomsGL.cpp
View file @
047843b8
...
...
@@ -70,7 +70,7 @@ if (!solid) {
int
totalatoms
=
numAtoms
[
getAtomTimesteps
()
-
1
];
//eprintf ("SetupAtomsNoTess 2");
*
AtomVAO
=
new
GLuint
[
3
];
//atoms, cloned atoms,
bonds
*
AtomVAO
=
new
GLuint
[
3
];
//atoms, cloned atoms,
unused (bonds use Tess atom positions)
*
AtomIndexBuffer
=
new
GLuint
[
3
];
//atoms, cloned atoms, bonds
*
AtomVertBuffer
=
new
GLuint
[
2
];
//atoms, cloned atoms
...
...
@@ -387,7 +387,7 @@ GLenum SetupAtoms(GLuint **AtomVAO /*[3]*/, GLuint **AtomVertBuffer /*[2]*/, GLu
//rgh: we will need these again if we don't have tesselation
//delete[] clonedAtoms;
//clonedAtoms=0;
glBindVertexArray
(
0
);
return
e
;
}
...
...
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