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;
float animationspeed;
float movementspeed;
menubutton_t menubutton;
std::vector<information> info;
const char * loadConfigFileErrors[] =
......@@ -233,6 +235,10 @@ void initState()
infolinecolour[1] = 1.0f;
infolinecolour[2] = 0.0f;
infolinecolour[3] = 1.0f;
menubutton = Record;
bondscaling = 0.7f;
}
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);
if (r<3)
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)
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")) {
r=fscanf (F, "%f", &movementspeed);
if (r<1)
......
......@@ -89,6 +89,15 @@ struct information {
GLuint tex;
};
typedef enum {
Record,
Infobox,
Nothing
} menubutton_t;
extern menubutton_t menubutton;
extern std::vector<information> info;
#endif //__CONFIGFILE_H
......@@ -25,3 +25,5 @@ float cubetrans[3];
float supercell[3];
int voxelSize[3];
float bondscaling;
\ No newline at end of file
......@@ -29,4 +29,6 @@ extern int voxelSize[3];
extern float supercell[3];
extern float bondscaling;
#endif //CONFIGFILEATOMS_H
......@@ -280,22 +280,29 @@ GLenum SetupAtoms(GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLu
float *current=tmp;
const int atomlimit=30;
const float bondscaling=0.7f;
numBonds=new int[getAtomTimesteps() ];
for (int p=0;p<getAtomTimesteps() ;p++) {
for (int a = 0; a < numAtoms[p]; a++) {
for (int k = 0; k < 4; k++) {
*current++ = atoms[p][4 * a + k];
}
} //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");
//bonds FIXME quadractic complexity
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;
for (int k=0;k<3;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
if (p!=0)
numAtoms[p]+=numAtoms[p-1];
} //p
} // showbonds
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)));
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * totalatoms * 4 , tmp,
......@@ -405,6 +412,7 @@ GLenum SetupAtoms(GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLu
}
delete[] tmp;
//bonds
if (displaybonds) {
glBindVertexArray((*AtomVAO)[2]);
glBindBuffer(GL_ARRAY_BUFFER, (*AtomVertBuffer)[0]);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, *BondIndices);
......@@ -416,7 +424,7 @@ GLenum SetupAtoms(GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLu
e=glGetError();
if ((e = glGetError()) != GL_NO_ERROR)
eprintf( "opengl error %d, creating chemical bonds, l %d\n", e, __LINE__);
}
//now clones
if (basisvectorreps ||!clonedAtoms) //do not replicate
return e;
......
......@@ -577,7 +577,7 @@ bool CMainApplication::BInit()
if( m_bDebugOpenGL )
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)
{
printf( "%s - Window could not be created! SDL Error: %s\n", __FUNCTION__, SDL_GetError() );
......@@ -2129,7 +2129,7 @@ void CMainApplication::RenderStereoTargets()
char name[100];
#ifndef NOSAVINGSCREENSHOTS
if (savetodisk) {
if (menubutton==Record && savetodisk) {
sprintf(name, "%sL%05d.bmp", SCREENSHOT, framecounter);
SaveScreenshot(name);
}
......@@ -2156,7 +2156,7 @@ void CMainApplication::RenderStereoTargets()
RenderScene( vr::Eye_Right );
#ifndef NOSAVINGSCREENSHOTS
if (savetodisk && saveStereo) {
if (menubutton == Record &&savetodisk && saveStereo) {
sprintf(name, "%sR%05d.bmp", SCREENSHOT, framecounter);
SaveScreenshot(name);
}
......@@ -2175,7 +2175,7 @@ void CMainApplication::RenderStereoTargets()
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0 );
#ifndef NOSAVINGSCREENSHOTS
if (savetodisk) {
if (menubutton == Record && savetodisk) {
framecounter++;
}
#endif
......@@ -2492,11 +2492,20 @@ void CMainApplication::RenderScene(vr::Hmd_Eye nEye)
glEnable(GL_DEPTH_TEST);
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);
RenderAtoms(nEye);
RenderUnitCell(nEye);
if (showcontrollers)
RenderAllTrackedRenderModels(nEye);
if (showAtoms) {
glDisable(GL_BLEND);
}
return;
}
......@@ -2529,6 +2538,7 @@ void CMainApplication::RenderScene(vr::Hmd_Eye nEye)
if ((e = glGetError()) != GL_NO_ERROR)
dprintf("Gl error after paintgrid: %d, %s\n", e, gluErrorString(e));
if (numAtoms!=0) {
if (menubutton == Infobox && savetodisk)
RenderInfo(nEye);
RenderAtoms(nEye);
RenderUnitCell(nEye);
......@@ -2629,6 +2639,7 @@ void CMainApplication::RenderScene(vr::Hmd_Eye nEye)
glBindTexture(GL_TEXTURE_2D, 0);
glUseProgram(m_unSceneProgramID);
PaintGrid(nEye, currentiso);
if (menubutton == Infobox && savetodisk)
RenderInfo(nEye);
if (showcontrollers)
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