NOMADVR for HTC Vive:

Allow multiple config files
Selection of atoms
Indication of atom # and atom-controller distance
parent b7f69000
...@@ -25,10 +25,9 @@ ...@@ -25,10 +25,9 @@
#include "eprintf.h" #include "eprintf.h"
#include "polyhedron.h" #include "polyhedron.h"
const char * PATH; char * PATH;
const char * SCREENSHOT; char * SCREENSHOT;
int ISOS; int ISOS;
int TIMESTEPS;
float **isocolours; // [ISOS][4]; float **isocolours; // [ISOS][4];
const char **plyfiles; const char **plyfiles;
float **translations; float **translations;
...@@ -113,7 +112,7 @@ const char * loadConfigFileErrors[] = ...@@ -113,7 +112,7 @@ const char * loadConfigFileErrors[] =
}; };
void updateTIMESTEPS (int timesteps) void updateTIMESTEPS (int timesteps)
{ {
if (TIMESTEPS==0) if (TIMESTEPS==0)
TIMESTEPS=timesteps; TIMESTEPS=timesteps;
else else
...@@ -164,16 +163,64 @@ while (*file!='\0') { ...@@ -164,16 +163,64 @@ while (*file!='\0') {
} }
} }
void cleanConfig()
{
for (int i = 0; i < ISOS; i++) {
delete[] isocolours[i];
delete[] translations[i];
}
delete[] isocolours;
isocolours=nullptr;
delete[] translations;
translations=nullptr;
if (plyfiles) {
for (int i=0;i<ISOS;i++)
free ((void*)(plyfiles[i])); //strdup
delete[] plyfiles;
}
plyfiles=nullptr;
free(PATH);
PATH=nullptr;
atomtrajectoryrestarts.clear();
free(SCREENSHOT);
SCREENSHOT=nullptr;
if (markers) {
for (int i=0;i<TIMESTEPS;i++) {
delete[] markers[i];
delete[] markercolours[i];
}
delete[] markers;
delete[] markercolours;
markers=nullptr;
markercolours=nullptr;
}
for (int i=0;i<info.size();i++) {
free(info[i].filename);
}
info.clear();
if (numAtoms) {
for (int i=0;i<getAtomTimesteps();i++) {
delete[] atoms[i];
}
delete[] atoms;
delete[] numAtoms;
numAtoms=nullptr;
atoms=nullptr;
}
}
void initState() void initState()
{ {
BACKGROUND[0] = 0.95f; BACKGROUND[0] = 0.95f;
BACKGROUND[1] = 0.95f; BACKGROUND[1] = 0.95f;
BACKGROUND[2] = 0.95f; BACKGROUND[2] = 0.95f;
SCREENSHOT="C:\\temp\\frame"; SCREENSHOT=strdup("C:\\temp\\frame");
ISOS = 0; ISOS = 0;
TIMESTEPS=0; TIMESTEPS=0;
PATH=strdup(""); PATH=strdup("");
numAtoms=0; numAtoms=nullptr;
atomScaling=1; atomScaling=1;
clonedAtoms=0; clonedAtoms=0;
fixedAtoms=false; fixedAtoms=false;
...@@ -357,6 +404,7 @@ int loadConfigFile(const char * f) ...@@ -357,6 +404,7 @@ int loadConfigFile(const char * f)
r=readString(F, s); r=readString(F, s);
if (r!=0) if (r!=0)
return -14; return -14;
free (SCREENSHOT);
SCREENSHOT = strdup(s); SCREENSHOT = strdup(s);
} }
else if (!strcmp(s, "xyzfile")||!strcmp(s, "atomfile")) { else if (!strcmp(s, "xyzfile")||!strcmp(s, "atomfile")) {
......
...@@ -21,10 +21,9 @@ ...@@ -21,10 +21,9 @@
#include "polyhedron.h" #include "polyhedron.h"
#include "ConfigFileAtoms.h" #include "ConfigFileAtoms.h"
extern const char * PATH; extern char * PATH;
extern const char * SCREENSHOT; extern char * SCREENSHOT;
extern int ISOS; extern int ISOS;
extern int TIMESTEPS;
extern float **isocolours; // [ISOS][4]; extern float **isocolours; // [ISOS][4];
extern const char **plyfiles; extern const char **plyfiles;
extern float **translations; extern float **translations;
...@@ -81,13 +80,14 @@ extern float ** markercolours; ...@@ -81,13 +80,14 @@ extern float ** markercolours;
extern const char * loadConfigFileErrors[]; extern const char * loadConfigFileErrors[];
void cleanConfig();
int loadConfigFile(const char * f); int loadConfigFile(const char * f);
struct information { struct information {
float pos[3]; float pos[3];
float size; float size;
int atom; //-1=do not draw line int atom; //-1=do not draw line
const char* filename; char* filename;
GLuint tex; GLuint tex;
}; };
......
...@@ -44,10 +44,19 @@ const char * TMPDIR;//filled by main ...@@ -44,10 +44,19 @@ const char * TMPDIR;//filled by main
bool inv_abc_init=false; bool inv_abc_init=false;
float inv_abc[3][3]; float inv_abc[3][3];
int TIMESTEPS;
std::vector<const char*> extraAtomNames; std::vector<const char*> extraAtomNames;
std::vector<float*> extraAtomData; std::vector<float*> extraAtomData;
int getAtomTimesteps()
{
if (fixedAtoms)
return 1;
else
return TIMESTEPS;
}
const char * const atomNames[] = const char * const atomNames[] =
{ {
...@@ -208,6 +217,8 @@ do { ...@@ -208,6 +217,8 @@ do {
} while (c != EOF && c != '\n'); } while (c != EOF && c != '\n');
} }
int findAtom(const char *const s) int findAtom(const char *const s)
{ {
//discard number at end //discard number at end
...@@ -252,6 +263,17 @@ const char * readAtomsXYZErrors[] = { ...@@ -252,6 +263,17 @@ const char * readAtomsXYZErrors[] = {
"Corrupt xyz file" //-4 "Corrupt xyz file" //-4
}; };
void cleanAtoms (int **numatoms, int timesteps, float ***pos)
{
for (int i=0;i<timesteps;i++) {
delete[] ((*pos)[i]);
}
delete[] (*numatoms);
*numatoms=nullptr;
delete[] (*pos);
*pos=nullptr;
}
int readAtomsXYZ(const char *const file, int **numatoms, int *timesteps, float ***pos) int readAtomsXYZ(const char *const file, int **numatoms, int *timesteps, float ***pos)
{ {
int mynumatoms; int mynumatoms;
......
...@@ -31,6 +31,8 @@ const int atomsInPeriodicTable=118; ...@@ -31,6 +31,8 @@ const int atomsInPeriodicTable=118;
extern const char * TMPDIR; extern const char * TMPDIR;
int getAtomTimesteps();
void cleanAtoms (int **numatoms, int timesteps, float ***pos);
int readAtomsXYZ(const char *const file, int **numatoms, int *timesteps, float ***pos); int readAtomsXYZ(const char *const file, int **numatoms, int *timesteps, float ***pos);
int readAtomsCube(const char *const file, int **numatoms, int *timesteps, float ***pos); int readAtomsCube(const char *const file, int **numatoms, int *timesteps, float ***pos);
int readAtomsJson (const char *const file, int **numatoms, int *timesteps, float ***pos, float abc[3][3], std::vector<float>** clonedAtoms, const char *const token=0); int readAtomsJson (const char *const file, int **numatoms, int *timesteps, float ***pos, float abc[3][3], std::vector<float>** clonedAtoms, const char *const token=0);
...@@ -66,4 +68,6 @@ extern const char * const atomNames[]; ...@@ -66,4 +68,6 @@ extern const char * const atomNames[];
extern std::vector<const char*> extraAtomNames; extern std::vector<const char*> extraAtomNames;
extern std::vector<float*> extraAtomData; extern std::vector<float*> extraAtomData;
extern int TIMESTEPS;
#endif //__ATOMS_H #endif //__ATOMS_H
...@@ -28,14 +28,6 @@ ...@@ -28,14 +28,6 @@
#include "polyhedron.h" #include "polyhedron.h"
#include "Grid.h" #include "Grid.h"
int getAtomTimesteps()
{
if (fixedAtoms)
return 1;
else
return TIMESTEPS;
}
GLenum atomTexture(GLuint t) GLenum atomTexture(GLuint t)
{ {
GLenum e; GLenum e;
...@@ -230,6 +222,26 @@ if (!solid) { ...@@ -230,6 +222,26 @@ if (!solid) {
return e; return e;
} //SetupAtomsNoTess } //SetupAtomsNoTess
void CleanAtoms (GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLuint *BondIndices)
{
if (!numAtoms)
return;
glDeleteVertexArrays(4, *AtomVAO);
glDeleteBuffers(3, *AtomVertBuffer);
glDeleteBuffers(1, BondIndices);
delete[] (*AtomVAO);
delete[] (*AtomVertBuffer);
*AtomVAO=nullptr;
*AtomVertBuffer=nullptr;
if (numBonds)
delete[] numBonds;
numBonds=nullptr;
bonds.clear();
}
GLenum SetupAtoms(GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLuint *BondIndices) GLenum SetupAtoms(GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLuint *BondIndices)
{ {
...@@ -245,7 +257,7 @@ GLenum SetupAtoms(GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLu ...@@ -245,7 +257,7 @@ GLenum SetupAtoms(GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLu
for (int i=0;i<getAtomTimesteps() ;i++) { for (int i=0;i<getAtomTimesteps() ;i++) {
totalatoms += numAtoms[i]; totalatoms += numAtoms[i];
} }
eprintf("SetupAtoms: totalatoms=%d", totalatoms); //eprintf("SetupAtoms: totalatoms=%d", totalatoms);
*AtomVAO = new GLuint[4]; //atoms, cloned atoms, bonds, trajectories *AtomVAO = new GLuint[4]; //atoms, cloned atoms, bonds, trajectories
*AtomVertBuffer = new GLuint[3]; //atoms, cloned atoms, trajectories *AtomVertBuffer = new GLuint[3]; //atoms, cloned atoms, trajectories
...@@ -437,6 +449,13 @@ GLenum SetupAtoms(GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLu ...@@ -437,6 +449,13 @@ GLenum SetupAtoms(GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLu
return e; return e;
} }
void CleanInfoCube (GLuint *VAO, GLuint *VertBuffer, GLuint *IndexBuffer)
{
glDeleteVertexArrays(1, VAO);
glDeleteBuffers(1, VertBuffer);
glDeleteBuffers(1, IndexBuffer);
}
GLenum SetupInfoCube (GLuint *VAO, GLuint *VertBuffer, GLuint *IndexBuffer) GLenum SetupInfoCube (GLuint *VAO, GLuint *VertBuffer, GLuint *IndexBuffer)
{ {
glGenVertexArrays(1, VAO); glGenVertexArrays(1, VAO);
...@@ -606,6 +625,12 @@ GLenum SetupMarkerNoTess(GLuint *MarkerVAO, GLuint *MarkerVertBuffer, GLuint *Ma ...@@ -606,6 +625,12 @@ GLenum SetupMarkerNoTess(GLuint *MarkerVAO, GLuint *MarkerVertBuffer, GLuint *Ma
return e; return e;
} }
void CleanMarker (GLuint *MarkerVAO, GLuint *MarkerVertBuffer)
{
glDeleteVertexArrays(1, MarkerVAO);
glDeleteBuffers(1, MarkerVertBuffer);
}
GLenum SetupMarker(GLuint *MarkerVAO, GLuint *MarkerVertBuffer) GLenum SetupMarker(GLuint *MarkerVAO, GLuint *MarkerVertBuffer)
{//requires tesselation {//requires tesselation
if (!markers) if (!markers)
...@@ -647,6 +672,13 @@ GLenum SetupMarker(GLuint *MarkerVAO, GLuint *MarkerVertBuffer) ...@@ -647,6 +672,13 @@ GLenum SetupMarker(GLuint *MarkerVAO, GLuint *MarkerVertBuffer)
return glGetError(); return glGetError();
} }
void CleanUnitCell (GLuint *UnitCellVAO, GLuint *UnitCellVertBuffer, GLuint *UnitCellIndexBuffer)
{
glDeleteVertexArrays(1, UnitCellVAO);
glDeleteBuffers(1, UnitCellVertBuffer);
glDeleteBuffers(1, UnitCellIndexBuffer);
}
GLenum SetupUnitCell(GLuint *UnitCellVAO, GLuint *UnitCellVertBuffer, GLuint *UnitCellIndexBuffer) GLenum SetupUnitCell(GLuint *UnitCellVAO, GLuint *UnitCellVertBuffer, GLuint *UnitCellIndexBuffer)
{ {
//add here both unit cell and supercell //add here both unit cell and supercell
......
...@@ -28,10 +28,14 @@ ...@@ -28,10 +28,14 @@
GLenum atomTexture(GLuint t); GLenum atomTexture(GLuint t);
GLenum SetupAtoms(GLuint **AtomVAO, GLuint **AtomVertBuffer, GLuint *BondIndices); GLenum SetupAtoms(GLuint **AtomVAO, GLuint **AtomVertBuffer, GLuint *BondIndices);
void CleanAtoms (GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLuint *BondIndices);
GLenum SetupAtomsNoTess (GLuint **AtomVAO, GLuint **AtomVertBuffer, GLuint **AtomIndexBuffer); GLenum SetupAtomsNoTess (GLuint **AtomVAO, GLuint **AtomVertBuffer, GLuint **AtomIndexBuffer);
void CleanUnitCell (GLuint *UnitCellVAO, GLuint *UnitCellVertBuffer, GLuint *UnitCellIndexBuffer);
GLenum SetupUnitCell(GLuint *UnitCellVAO, GLuint *UnitCellVertBuffer, GLuint *UnitCellIndexBuffer); GLenum SetupUnitCell(GLuint *UnitCellVAO, GLuint *UnitCellVertBuffer, GLuint *UnitCellIndexBuffer);
void CleanMarker (GLuint *MarkerVAO, GLuint *MarkerVertBuffer);
GLenum SetupMarker(GLuint *MarkerVAO, GLuint *MarkerVertBuffer); GLenum SetupMarker(GLuint *MarkerVAO, GLuint *MarkerVertBuffer);
GLenum SetupMarkerNoTess(GLuint *MarkerVAO, GLuint *MarkerVertBuffer, GLuint *MarkerIndexBuffer); GLenum SetupMarkerNoTess(GLuint *MarkerVAO, GLuint *MarkerVertBuffer, GLuint *MarkerIndexBuffer);
void CleanInfoCube (GLuint *VAO, GLuint *VertBuffer, GLuint *IndexBuffer);
GLenum SetupInfoCube (GLuint *VAO, GLuint *VertBuffer, GLuint *IndexBuffer); GLenum SetupInfoCube (GLuint *VAO, GLuint *VertBuffer, GLuint *IndexBuffer);
bool PrepareUnitCellAtomShader (GLuint *AtomP, GLuint *cellP, GLuint *MarkerP, bool PrepareUnitCellAtomShader (GLuint *AtomP, GLuint *cellP, GLuint *MarkerP,
...@@ -44,7 +48,6 @@ bool PrepareMarkerShader (GLuint *MP, GLint *MMatrixLocation); ...@@ -44,7 +48,6 @@ bool PrepareMarkerShader (GLuint *MP, GLint *MMatrixLocation);
void GetDisplacement(int p[3], float f[3]); void GetDisplacement(int p[3], float f[3]);
int getAtomTimesteps();
inline int getTotalAtomsInTexture() inline int getTotalAtomsInTexture()
{ {
return atomsInPeriodicTable+extraAtomNames.size(); return atomsInPeriodicTable+extraAtomNames.size();
......
This repository contains the demos for HTC vive using openvr version 0.9.19 This repository contains the demos for HTC vive using openvr version 0.9.19
https://github.com/ValveSoftware/openvr https://github.com/ValveSoftware/openvr
Clone that repository and add the content of this one inside the samples directory. Clone that repository and add the content of this one inside the samples
directory.
After compilation, copy ..\textures\digits_64x7_l_blank.png to the exe's
location.
List of directories List of directories
TimestepData: TimestepData:
......
This diff is collapsed.
digits_64x7_l_blank.png:
Copyright 2018 Matthias Albert
Copyright 2018 Ruben Jesus Garcia-Hernandez
Licensed under the Apache License, Version 2.0
\ No newline at end of file
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