Atom bonds in Google Cardboard

bondthickness parameter
parent c579efe9
...@@ -1089,6 +1089,25 @@ void TreasureHuntRenderer::RenderAtoms(const float *m) //m[16] ...@@ -1089,6 +1089,25 @@ void TreasureHuntRenderer::RenderAtoms(const float *m) //m[16]
if ((e = glGetError()) != GL_NO_ERROR) if ((e = glGetError()) != GL_NO_ERROR)
eprintf("Gl error after Render cloned Atom timestep =%d: %d\n", currentSet, e); eprintf("Gl error after Render cloned Atom timestep =%d: %d\n", currentSet, e);
} // painting cloned atoms } // painting cloned atoms
//now bonds
if (numBonds && displaybonds /*&& showAtoms*/) {
glLineWidth(bondThickness);
glBindVertexArray(AtomTVAO[2]);
glUseProgram(UnitCellP);
glUniformMatrix4fv(UnitCellMatrixLoc, 1, GL_FALSE, m);
glUniform4fv(UnitCellColourLoc, 1, bondscolours);
if ((e = glGetError()) != GL_NO_ERROR)
eprintf("Gl error after Render Atom bonds uniform timestep =%d: %d\n", currentSet, e);
if (currentSet==0||fixedAtoms)
glDrawElements(GL_LINES, numBonds[0], GL_UNSIGNED_INT, (void*)0);
else
glDrawElements(GL_LINES, numBonds[currentSet]-numBonds[currentSet-1], GL_UNSIGNED_INT,
(void*)(sizeof(int)*numBonds[currentSet-1]) );
glLineWidth(1.0f);
if ((e = glGetError()) != GL_NO_ERROR)
eprintf("Gl error after Render Atom bonds timestep =%d: %d\n", currentSet, e);
glBindVertexArray(0);
}
} // no tess } // no tess
} }
......
...@@ -130,8 +130,6 @@ void loadConfigFile(void); ...@@ -130,8 +130,6 @@ void loadConfigFile(void);
//gles 2 does not have vao, porting demo to gles3 //gles 2 does not have vao, porting demo to gles3
int currentset;
gvr::Mat4f head_view_; gvr::Mat4f head_view_;
gvr::Mat4f model_cube_; gvr::Mat4f model_cube_;
gvr::Mat4f camera_; gvr::Mat4f camera_;
......
...@@ -240,6 +240,7 @@ void initState() ...@@ -240,6 +240,7 @@ void initState()
menubutton = Record; menubutton = Record;
bondscaling = 0.7f; bondscaling = 0.7f;
bondThickness = 1.0f;
} }
int loadConfigFile(const char * f) int loadConfigFile(const char * f)
...@@ -649,12 +650,17 @@ int loadConfigFile(const char * f) ...@@ -649,12 +650,17 @@ int loadConfigFile(const char * f)
if (r < 1) if (r < 1)
eprintf("Error reading animationspeed"); eprintf("Error reading animationspeed");
} }
else if (!strcmp(s, "")) { else if (!strcmp(s, "bondscaling")) {
r = fscanf(F, "%f", &bondscaling); r = fscanf(F, "%f", &bondscaling);
if (r<1) if (r<1)
eprintf("Error reading bondscaling"); eprintf("Error reading bondscaling");
bondscaling = sqrt(bondscaling); bondscaling = sqrt(bondscaling);
} else if (!strcmp(s, "menubutton")) { } else if (!strcmp(s, "bondthickness")) {
r = fscanf(F, "%f", &bondThickness);
if (r<1)
eprintf("Error reading bondthickness");
}
else if (!strcmp(s, "menubutton")) {
r = fscanf(F, "%s", s); r = fscanf(F, "%s", s);
if (!strcmp(s, "Record")) if (!strcmp(s, "Record"))
menubutton = Record; menubutton = Record;
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
# limitations under the License. # limitations under the License.
*/ */
#include "ConfigFileAtoms.h"
float abc[3][3]; //basis vectors float abc[3][3]; //basis vectors
bool has_abc = false; bool has_abc = false;
...@@ -26,4 +28,5 @@ float cubetrans[3]; ...@@ -26,4 +28,5 @@ float cubetrans[3];
float supercell[3]; float supercell[3];
int voxelSize[3]; int voxelSize[3];
float bondscaling; float bondscaling;
\ No newline at end of file float bondThickness;
...@@ -30,5 +30,6 @@ extern int voxelSize[3]; ...@@ -30,5 +30,6 @@ extern int voxelSize[3];
extern float supercell[3]; extern float supercell[3];
extern float bondscaling; extern float bondscaling;
extern float bondThickness;
#endif //CONFIGFILEATOMS_H #endif //CONFIGFILEATOMS_H
...@@ -546,7 +546,7 @@ GLenum SetupMarkerNoTess(GLuint *MarkerVAO, GLuint *MarkerVertBuffer, GLuint *Ma ...@@ -546,7 +546,7 @@ GLenum SetupMarkerNoTess(GLuint *MarkerVAO, GLuint *MarkerVertBuffer, GLuint *Ma
for (int j = 0; j < MARKERSOLID::nVerts; j++) { for (int j = 0; j < MARKERSOLID::nVerts; j++) {
for (int k = 0; k < 3; k++) { //pos for (int k = 0; k < 3; k++) { //pos
float s = getMarkerLobeScaling(l, k); float s = getMarkerLobeScaling(l, k);
*current++ = s*MARKERSOLID::Verts[j * 3 + k] * markerscaling * atomScaling/* * atomRadius(0)*/ + *current++ = s*MARKERSOLID::Verts[j * 3 + k] * markerscaling * atomScaling * atomRadius(0) +
markers[i][k]; markers[i][k];
} }
float length=0; float length=0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment