menubutton option: screenshot, infobox, nothing

bondscaling (useful for gas phase, etc)
Only calculate bonds if needed
Render transparent markers
parent 9402e3a4
...@@ -77,6 +77,8 @@ float ** markercolours; ...@@ -77,6 +77,8 @@ float ** markercolours;
float animationspeed; float animationspeed;
float movementspeed; float movementspeed;
menubutton_t menubutton;
std::vector<information> info; std::vector<information> info;
const char * loadConfigFileErrors[] = const char * loadConfigFileErrors[] =
...@@ -233,6 +235,10 @@ void initState() ...@@ -233,6 +235,10 @@ void initState()
infolinecolour[1] = 1.0f; infolinecolour[1] = 1.0f;
infolinecolour[2] = 0.0f; infolinecolour[2] = 0.0f;
infolinecolour[3] = 1.0f; infolinecolour[3] = 1.0f;
menubutton = Record;
bondscaling = 0.7f;
} }
int loadConfigFile(const char * f) int loadConfigFile(const char * f)
...@@ -636,10 +642,25 @@ int loadConfigFile(const char * f) ...@@ -636,10 +642,25 @@ int loadConfigFile(const char * f)
r=fscanf (F, "%f %f %f", infolinecolour, infolinecolour+1, infolinecolour+2); r=fscanf (F, "%f %f %f", infolinecolour, infolinecolour+1, infolinecolour+2);
if (r<3) if (r<3)
eprintf ("Error reading atomtrajectorycolour value"); eprintf ("Error reading atomtrajectorycolour value");
} else if (!strcmp (s, "animationspeed")) { }
r=fscanf (F, "%f", &animationspeed); else if (!strcmp(s, "animationspeed")) {
r = fscanf(F, "%f", &animationspeed);
if (r < 1)
eprintf("Error reading animationspeed");
}
else if (!strcmp(s, "")) {
r = fscanf(F, "%f", &bondscaling);
if (r<1) if (r<1)
eprintf ("Error reading animationspeed"); eprintf("Error reading bondscaling");
bondscaling = sqrt(bondscaling);
} else if (!strcmp(s, "menubutton")) {
r = fscanf(F, "%s", s);
if (!strcmp(s, "Record"))
menubutton = Record;
else if (!strcmp(s, "Infobox"))
menubutton = Infobox;
else if (!strcmp (s, "Nothing"))
menubutton = Nothing;
} else if (!strcmp (s, "movementspeed")) { } else if (!strcmp (s, "movementspeed")) {
r=fscanf (F, "%f", &movementspeed); r=fscanf (F, "%f", &movementspeed);
if (r<1) if (r<1)
......
...@@ -89,6 +89,15 @@ struct information { ...@@ -89,6 +89,15 @@ struct information {
GLuint tex; GLuint tex;
}; };
typedef enum {
Record,
Infobox,
Nothing
} menubutton_t;
extern menubutton_t menubutton;
extern std::vector<information> info; extern std::vector<information> info;
#endif //__CONFIGFILE_H #endif //__CONFIGFILE_H
...@@ -25,3 +25,5 @@ float cubetrans[3]; ...@@ -25,3 +25,5 @@ float cubetrans[3];
float supercell[3]; float supercell[3];
int voxelSize[3]; int voxelSize[3];
float bondscaling;
\ No newline at end of file
...@@ -29,4 +29,6 @@ extern int voxelSize[3]; ...@@ -29,4 +29,6 @@ extern int voxelSize[3];
extern float supercell[3]; extern float supercell[3];
extern float bondscaling;
#endif //CONFIGFILEATOMS_H #endif //CONFIGFILEATOMS_H
...@@ -280,22 +280,29 @@ GLenum SetupAtoms(GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLu ...@@ -280,22 +280,29 @@ GLenum SetupAtoms(GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLu
float *current=tmp; float *current=tmp;
const int atomlimit=30; const int atomlimit=30;
const float bondscaling=0.7f;
numBonds=new int[getAtomTimesteps() ];
for (int p=0;p<getAtomTimesteps() ;p++) { for (int p=0;p<getAtomTimesteps() ;p++) {
for (int a = 0; a < numAtoms[p]; a++) { for (int a = 0; a < numAtoms[p]; a++) {
for (int k = 0; k < 4; k++) { for (int k = 0; k < 4; k++) {
*current++ = atoms[p][4 * a + k]; *current++ = atoms[p][4 * a + k];
} }
} //a } //a
}
if (!displaybonds) {
numBonds=nullptr;
for (int p=1; p<getAtomTimesteps() ;p++)
numAtoms[p]+=numAtoms[p-1];
} else {
numBonds=new int[getAtomTimesteps() ];
//can be slow, add loading screen here if Vive
for (int p=0;p<getAtomTimesteps() ;p++) {
if (numAtoms[0]<atomlimit) { if (numAtoms[p]<atomlimit) {
//eprintf ("searching bonds basic"); //eprintf ("searching bonds basic");
//bonds FIXME quadractic complexity //bonds FIXME quadractic complexity
for (int a1=0; a1 < numAtoms[p]; a1++) { for (int a1=0; a1 < numAtoms[p]; a1++) {
for (int a2=a1+1; a2 < numAtoms[p]; a2++) { for (int a2=a1+1; a2 < numAtoms[p]; a2++){
float d=0, r; float d=0, r;
for (int k=0;k<3;k++) { for (int k=0;k<3;k++) {
float dif=atoms[p][4 * a1 + k]-atoms[p][4 * a2 + k]; float dif=atoms[p][4 * a1 + k]-atoms[p][4 * a2 + k];
...@@ -342,7 +349,7 @@ GLenum SetupAtoms(GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLu ...@@ -342,7 +349,7 @@ GLenum SetupAtoms(GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLu
if (p!=0) if (p!=0)
numAtoms[p]+=numAtoms[p-1]; numAtoms[p]+=numAtoms[p-1];
} //p } //p
} // showbonds
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (const void *)(0)); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (const void *)(0));
glVertexAttribPointer(1, 1, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (const void *)(3 * sizeof(float))); glVertexAttribPointer(1, 1, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (const void *)(3 * sizeof(float)));
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * totalatoms * 4 , tmp, glBufferData(GL_ARRAY_BUFFER, sizeof(float) * totalatoms * 4 , tmp,
...@@ -405,6 +412,7 @@ GLenum SetupAtoms(GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLu ...@@ -405,6 +412,7 @@ GLenum SetupAtoms(GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLu
} }
delete[] tmp; delete[] tmp;
//bonds //bonds
if (displaybonds) {
glBindVertexArray((*AtomVAO)[2]); glBindVertexArray((*AtomVAO)[2]);
glBindBuffer(GL_ARRAY_BUFFER, (*AtomVertBuffer)[0]); glBindBuffer(GL_ARRAY_BUFFER, (*AtomVertBuffer)[0]);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, *BondIndices); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, *BondIndices);
...@@ -416,7 +424,7 @@ GLenum SetupAtoms(GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLu ...@@ -416,7 +424,7 @@ GLenum SetupAtoms(GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLu
e=glGetError(); e=glGetError();
if ((e = glGetError()) != GL_NO_ERROR) if ((e = glGetError()) != GL_NO_ERROR)
eprintf( "opengl error %d, creating chemical bonds, l %d\n", e, __LINE__); eprintf( "opengl error %d, creating chemical bonds, l %d\n", e, __LINE__);
}
//now clones //now clones
if (basisvectorreps ||!clonedAtoms) //do not replicate if (basisvectorreps ||!clonedAtoms) //do not replicate
return e; return e;
......
...@@ -577,7 +577,7 @@ bool CMainApplication::BInit() ...@@ -577,7 +577,7 @@ bool CMainApplication::BInit()
if( m_bDebugOpenGL ) if( m_bDebugOpenGL )
SDL_GL_SetAttribute( SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG ); SDL_GL_SetAttribute( SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG );
m_pWindow = SDL_CreateWindow( "Geophysics OpenVR SDL", nWindowPosX, nWindowPosY, m_nWindowWidth, m_nWindowHeight, unWindowFlags ); m_pWindow = SDL_CreateWindow( "NOMAD OpenVR", nWindowPosX, nWindowPosY, m_nWindowWidth, m_nWindowHeight, unWindowFlags );
if (m_pWindow == NULL) if (m_pWindow == NULL)
{ {
printf( "%s - Window could not be created! SDL Error: %s\n", __FUNCTION__, SDL_GetError() ); printf( "%s - Window could not be created! SDL Error: %s\n", __FUNCTION__, SDL_GetError() );
...@@ -2129,7 +2129,7 @@ void CMainApplication::RenderStereoTargets() ...@@ -2129,7 +2129,7 @@ void CMainApplication::RenderStereoTargets()
char name[100]; char name[100];
#ifndef NOSAVINGSCREENSHOTS #ifndef NOSAVINGSCREENSHOTS
if (savetodisk) { if (menubutton==Record && savetodisk) {
sprintf(name, "%sL%05d.bmp", SCREENSHOT, framecounter); sprintf(name, "%sL%05d.bmp", SCREENSHOT, framecounter);
SaveScreenshot(name); SaveScreenshot(name);
} }
...@@ -2156,7 +2156,7 @@ void CMainApplication::RenderStereoTargets() ...@@ -2156,7 +2156,7 @@ void CMainApplication::RenderStereoTargets()
RenderScene( vr::Eye_Right ); RenderScene( vr::Eye_Right );
#ifndef NOSAVINGSCREENSHOTS #ifndef NOSAVINGSCREENSHOTS
if (savetodisk && saveStereo) { if (menubutton == Record &&savetodisk && saveStereo) {
sprintf(name, "%sR%05d.bmp", SCREENSHOT, framecounter); sprintf(name, "%sR%05d.bmp", SCREENSHOT, framecounter);
SaveScreenshot(name); SaveScreenshot(name);
} }
...@@ -2175,7 +2175,7 @@ void CMainApplication::RenderStereoTargets() ...@@ -2175,7 +2175,7 @@ void CMainApplication::RenderStereoTargets()
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0 ); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0 );
#ifndef NOSAVINGSCREENSHOTS #ifndef NOSAVINGSCREENSHOTS
if (savetodisk) { if (menubutton == Record && savetodisk) {
framecounter++; framecounter++;
} }
#endif #endif
...@@ -2492,11 +2492,20 @@ void CMainApplication::RenderScene(vr::Hmd_Eye nEye) ...@@ -2492,11 +2492,20 @@ void CMainApplication::RenderScene(vr::Hmd_Eye nEye)
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
if (ISOS==0) { if (ISOS==0) {
//simple transparency model for markers
if (showAtoms) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
if (menubutton==Infobox && savetodisk)
RenderInfo(nEye); RenderInfo(nEye);
RenderAtoms(nEye); RenderAtoms(nEye);
RenderUnitCell(nEye); RenderUnitCell(nEye);
if (showcontrollers) if (showcontrollers)
RenderAllTrackedRenderModels(nEye); RenderAllTrackedRenderModels(nEye);
if (showAtoms) {
glDisable(GL_BLEND);
}
return; return;
} }
...@@ -2529,6 +2538,7 @@ void CMainApplication::RenderScene(vr::Hmd_Eye nEye) ...@@ -2529,6 +2538,7 @@ void CMainApplication::RenderScene(vr::Hmd_Eye nEye)
if ((e = glGetError()) != GL_NO_ERROR) if ((e = glGetError()) != GL_NO_ERROR)
dprintf("Gl error after paintgrid: %d, %s\n", e, gluErrorString(e)); dprintf("Gl error after paintgrid: %d, %s\n", e, gluErrorString(e));
if (numAtoms!=0) { if (numAtoms!=0) {
if (menubutton == Infobox && savetodisk)
RenderInfo(nEye); RenderInfo(nEye);
RenderAtoms(nEye); RenderAtoms(nEye);
RenderUnitCell(nEye); RenderUnitCell(nEye);
...@@ -2629,6 +2639,7 @@ void CMainApplication::RenderScene(vr::Hmd_Eye nEye) ...@@ -2629,6 +2639,7 @@ void CMainApplication::RenderScene(vr::Hmd_Eye nEye)
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
glUseProgram(m_unSceneProgramID); glUseProgram(m_unSceneProgramID);
PaintGrid(nEye, currentiso); PaintGrid(nEye, currentiso);
if (menubutton == Infobox && savetodisk)
RenderInfo(nEye); RenderInfo(nEye);
if (showcontrollers) if (showcontrollers)
RenderAllTrackedRenderModels(nEye); RenderAllTrackedRenderModels(nEye);
......
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