Add NOMAD License to various files.

Add InfoCube to Vive.
parent 70378f53
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#include <stdio.h>
#include "MyGL.h"
#include "eprintf.h"
......
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#include "MyGL.h"
#define SHADERNAME 0
......
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#include <algorithm>
#include <errno.h>
#include <string.h>
......@@ -46,6 +63,8 @@ int voxelSize[3];
float unitcellcolour[4];
float supercellcolour[4];
float infolinecolour[4];
int repetitions[3];
Solid *solid;
......@@ -65,6 +84,8 @@ float cubetrans[3];
float animationspeed;
float movementspeed;
std::vector<information> info;
const char * loadConfigFileErrors[] =
{
"All Ok",//0
......@@ -214,6 +235,11 @@ void initState()
animationspeed=1.0f;
movementspeed=1.0f;
infolinecolour[0] = 1.0f;
infolinecolour[1] = 1.0f;
infolinecolour[2] = 0.0f;
infolinecolour[3] = 1.0f;
}
int loadConfigFile(const char * f)
......@@ -609,6 +635,10 @@ int loadConfigFile(const char * f)
r=fscanf (F, "%f %f %f", atomtrajectorycolour, atomtrajectorycolour+1, atomtrajectorycolour+2);
if (r<3)
eprintf ("Error reading atomtrajectorycolour value");
}else if (!strcmp (s, "infolinecolour")) {
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);
if (r<1)
......@@ -617,6 +647,21 @@ int loadConfigFile(const char * f)
r=fscanf (F, "%f", &movementspeed);
if (r<1)
eprintf ("Error reading movementspeed");
#ifdef WIN32
} else if (!strcmp (s, "info")) {
information i;
r=fscanf (F, "%f %f %f %f %d", i.pos, i.pos+1, i.pos+2, &(i.size), &(i.atom));
if (r<5)
eprintf ("Error reading info");
r=readString(F, s);
if (r!=0)
eprintf ("Error reading info");
char file[256];
sprintf (file, "%s%s", PATH, s);
i.filename=strdup(file);
//i.tex=LoadPNG(i.filename); //opengl not initialized yet
info.push_back(i);
#endif
} else if (!strcmp (s, "\x0d")) { //discard windows newline (problem in Sebastian Kokott's phone (?!)
continue;
} else {
......
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#ifndef __CONFIGFILE_H
#define __CONFIGFILE_H
#include <vector>
#include "MyGL.h"
#include "polyhedron.h"
extern const char * PATH;
......@@ -40,6 +57,8 @@ extern float markerscaling;
extern float unitcellcolour[4];
extern float supercellcolour[4];
extern float infolinecolour[4];
extern int repetitions[3];
extern Solid *solid;
......@@ -67,4 +86,14 @@ extern const char * loadConfigFileErrors[];
int loadConfigFile(const char * f);
struct information {
float pos[3];
float size;
int atom; //-1=do not draw line
const char* filename;
GLuint tex;
};
extern std::vector<information> info;
#endif //__CONFIGFILE_H
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#include "Grid.h"
#include "atoms.hpp" //for radius
#include <math.h>
......
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#include <vector>
class grid
......
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#include "IsoShaders.h"
#define GRIDSTR "1"
......@@ -55,21 +71,15 @@ const char *const IsoTransparentShaders [] = {"Iso Transparent Renderer",
"layout(location = 0) in vec4 position;\n"
"layout(location = 1) in vec3 normalsIn;\n"
"layout(location = 2) in vec4 colorIn;\n"
// "layout(location = 3) in vec2 uvIn;\n"
"out vec4 color;\n"
"out vec3 n;\n"
"out highp vec4 pos;\n"
// "out vec2 uv;\n"
"void main()\n"
"{\n"
" color = vec4(colorIn.rgba);\n"
" n=normalize(normalsIn);\n"
// " uv=uvIn;\n"
// "int i=gl_InstanceID / " GRIDSTR ";\n"
// "int j=gl_InstanceID % " GRIDSTR ";\n"
" pos = matrix * (position /*+ vec4 (float(i)*0.15*101.0, 0, float(j)*0.15*101.0, 0)*/);\n"
" pos = matrix * position;\n"
" gl_Position = pos;\n"
//" gl_Position = matrix * position;\n"
"}\n",
// Fragment Shader
......@@ -86,16 +96,13 @@ const char *const IsoTransparentShaders [] = {"Iso Transparent Renderer",
"void main()\n"
"{\n"
"highp vec4 mytex=texture(diffuse, vec2(pos.x/pos.w*0.5+0.5, pos.y/pos.w*0.5+0.5));\n"
//http://www.gamedev.net/topic/556521-glsl-manual-shadow-map-biasscale/
//"vec2 d=vec2(dFdx(pos.z), dFdy(pos.z));\n"
//"highp float m=sqrt(d.x*d.x + d.y*d.y);\n"
"if ((pos.z/pos.w+1.0)/2.0 <= mytex.r+0.0001 ) discard;\n"
"if ((pos.z/pos.w+1.0)/2.0 <= mytex.r+0.00001 ) discard;\n"
"lowp vec3 nn=normalize(n);"
"lowp float a=max(0.0, dot(nn, vec3(0,sqrt(2.0)/2.0,sqrt(2.0)/2.0)));\n"
"lowp float b=max(0.0, dot(nn, vec3(0,0,1)));\n"
"highp vec4 res=color;\n"
//"outputColor = vec4(pos.x/pos.w*0.5+0.5, pos.y/pos.w*0.5+0.5, 0,1);\n"
" outputColor = vec4 ((res.rgb) * (0.2 + 0.2*a + 0.3*b), color.a);\n"
"}\n",
......
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
extern const char * const IsoShaders[];
extern const char *const IsoTransparentShaders [];
extern const char *const IsoBlendShaders [];
//#if 0
/*Uses code from rply which uses the MIT license*/
/*http://w3.impa.br/~diego/software/rply/*/
/*This license is compatible with Apache 2.0*/
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#include <vector>
#include <math.h>
......@@ -153,11 +171,7 @@ int vertex_cb(p_ply_argument argument) {
int face_cb(p_ply_argument argument) {
long length, value_index;
// int v;
ply_get_argument_property(argument, nullptr, &length, &value_index);
//discard the first call with a 3
//if (value_index == 0 && 3 != (v = (int)ply_get_argument_value(argument)))
// dprintf("Non-triangular face: %d vertices\n", v);
if (value_index>=0 && value_index<=2)
CubeIndices[CurrentIndex++]=(int)(ply_get_argument_value(argument));
......@@ -350,13 +364,11 @@ if ((e = glGetError()) != GL_NO_ERROR)
#else
void CleanDepthTexture (GLuint t, int width, int height)
{
//eprintf ("CleanDepthTexture, t %d, w %d, h %d\n", t, width, height);
GLenum e;
const std::vector<float> z(width * height * 4, 0.0f);
glBindTexture(GL_TEXTURE_2D, t);
if ((e = glGetError()) != GL_NO_ERROR)
eprintf("CleanDepthTexture: Gl error after glBindTexture: %d\n", e);
//rgh FIXME: invalid operation here:
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_DEPTH_COMPONENT, GL_FLOAT, z.data());
if ((e = glGetError()) != GL_NO_ERROR)
eprintf("CleanDepthTexture: Gl error after glTexSubImage2D: %d\n", e);
......@@ -416,7 +428,7 @@ return glGetError();
GLenum SetupBlending (GLuint *vao, GLuint *vertex, GLuint *indices)
{
GLenum e;
float z = 0.0f; //(m_fNearClip + m_fFarClip) / 2.0f;
float z = 0.0f;
const float points[] = {
-1, -1, z, 0, 0,
-1, 1, z, 0, 1,
......@@ -482,4 +494,4 @@ if ((e = glGetError()) != GL_NO_ERROR)
eprintf("Gl error BlendTextures glDrawElements: %d\n", e);
}
}
//#endif
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#ifndef __ISOSURFACESGL_H
#define __ISOSURFACESGL_H
......
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#ifndef __MYGL_H
#define __MYGL_H
......
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#include "TessShaders.h"
/*rgh: for now default tesselation control, using
......@@ -16,18 +32,16 @@ const char * const AtomShaders [] = {
"#version 300 es\n"
#endif
"uniform sampler2D atomData;\n"
"uniform float totalatoms;\n" //(float)atomsInPeriodicTable
"uniform float totalatoms;\n" //(float)atomsInPeriodicTable
"layout(location = 0) in vec3 center;\n"
"layout(location = 1) in float atomIn;\n"
"out vec4 vcolor;\n" //color , radius
"out vec3 vcen;"
"void main()\n"
"{\n"
//"gl_Position = matrix * vec4(position+center, 1);\n"
"float coord=atomIn/totalatoms+0.5/totalatoms;\n"
"vcolor=vec4(texture(atomData, vec2(coord, 0)));\n"
"vcen=center;\n"
//"color.a=1;\n"
"}\n",
//fragment shader
......@@ -37,20 +51,14 @@ const char * const AtomShaders [] = {
"#version 300 es\n"
#endif
"in lowp vec4 color;\n"
// "in highp vec3 vertex;"
"in highp vec3 normal;"
"out lowp vec4 outputColor;\n"
"void main()\n"
"{\n"
//"vec3 U = dFdx(vertex); "
//"vec3 V = dFdy(vertex); "
"highp vec3 nn = normalize(normal);"
//"vec3 nn = normalize(cross(U,V));"
"lowp float a=abs(dot(nn, vec3(0,sqrt(2.0)/2.0,sqrt(2.0)/2.0)));\n"
"lowp float b=max(0.0, dot(nn, vec3(0,0,1)));\n"
"highp vec4 res=color;\n"
//rgh FIXME: make this depend on the background colour. Otherwise looks almost black with white background
//version for white background:
" outputColor = vec4 ((res.rgb) * (0.4 + 0.3*a + 0.3*b), color.a);\n"
"}\n",
......@@ -60,18 +68,13 @@ const char * const AtomShaders [] = {
#else
"#version 320 es\n"
#endif
//"layout(triangles, equal_spacing, cw) in;\n"
"layout(quads, equal_spacing, cw) in;\n"
"#define pi 3.1415926535897932384626433832795\n"
"uniform mat4 matrix;\n"
//"uniform mat4 mv;\n"
"in vec4 vcolor[];\n" //color , radius
"in vec3 vcen[];"
"out vec4 color;\n" //color
"out vec3 normal;\n"
// "out vec3 vertex;"
// "uniform mat4 Projection;\n"
// "uniform mat4 Modelview;\n"
"void main()\n"
"{\n"
......@@ -87,8 +90,6 @@ const char * const AtomShaders [] = {
const char * const AtomShadersNoTess [] = {
"Atom Renderer No Tess",
//No Tess means smooth shading looks very strange. Better use per-face lighting
// vertex shader
//Android 21 gives error: only supports up to '310 es'
#if defined(WIN32) || defined(CAVE)
"#version 410\n"
......@@ -97,7 +98,7 @@ const char * const AtomShadersNoTess [] = {
#endif
"uniform sampler2D atomData;\n"
"uniform mat4 matrix;\n"
"uniform float totalatoms;\n" //(float)atomsInPeriodicTable
"uniform float totalatoms;\n" //(float)atomsInPeriodicTable
"layout(location = 0) in vec3 pos;\n"
"layout(location = 1) in vec3 normalIn;\n"
"layout(location = 2) in float atomIn;\n"
......@@ -128,7 +129,6 @@ const char * const AtomShadersNoTess [] = {
"{\n"
"highp vec3 U = dFdx(vertex); "
"highp vec3 V = dFdy(vertex); "
//"highp vec3 nn = normalize(normal);\n"
"highp vec3 nn = normalize(cross(U,V));"
"lowp float a=abs(dot(nn, vec3(0,sqrt(2.0)/2.0,sqrt(2.0)/2.0)));\n"
"lowp float b=max(0.0, dot(nn, vec3(0,0,1)));\n"
......
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
extern const char * const AtomShaders[];
extern const char * const AtomShadersNoTess [];
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#include "UnitCellShaders.h"
const char * const UnitCellShaders [] = {"Unit Cell Renderer",
......
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
extern const char * const UnitCellShaders[];
\ No newline at end of file
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#define NOMINMAX
#include <stdio.h>
......
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
//Data from https://gitlab.rzg.mpg.de/nomad-lab/encyclopedia-gui/blob/lauri_viz/viztools/structure/build/js/structureviewer.js
//rgb radius for easy transference to a texture
//jmol colours from https://gitlab.com/ase/ase/blob/master/ase/data/colors.py
......
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#include <math.h>
#include "eprintf.h"
......@@ -423,6 +440,79 @@ GLenum SetupAtoms(GLuint **AtomVAO /*[4]*/, GLuint **AtomVertBuffer /*[3]*/, GLu
return e;
}
GLenum SetupInfoCube (GLuint *VAO, GLuint *VertBuffer, GLuint *IndexBuffer)
{
glGenVertexArrays(1, VAO);
glGenBuffers(1, VertBuffer);
glGenBuffers(1, IndexBuffer);
glBindVertexArray(*VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, *IndexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, *VertBuffer);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glDisableVertexAttribArray(3);
//vec4 pos, vec3 normal, vec2 uv
const int Nvert=9*26;
const GLfloat vert[]={
-1, +1, -1, 0, 0, 0, -1, 0, 1, //-z
-1, -1, -1, 0, 0, 0, -1, 0, 0,
+1, +1, -1, 0, 0, 0, -1, 1, 1,
+1, -1, -1, 0, 0, 0, -1, 1, 0,
-1, +1, +1, 0, 0, 0, 1, 0, 0,//+z
-1, -1, +1, 0, 0, 0, 1, 0, 1,
+1, +1, +1, 0, 0, 0, 1, 1, 0,
+1, -1, +1, 0, 0, 0, 1, 1, 1,
+1, -1, -1, 0, +1, 0, 0, 0, 1,//+x
+1, -1, +1, 0, +1, 0, 0, 0, 0,//+x
+1, +1, -1, 0, +1, 0, 0, 1, 1,//+x
+1, +1, +1, 0, +1, 0, 0, 1, 0,//+x
-1, -1, -1, 0, -1, 0, 0, 0, 0,//-x
-1, -1, +1, 0, -1, 0, 0, 0, 1,//-x
-1, +1, -1, 0, -1, 0, 0, 1, 0,//-x
-1, +1, +1, 0, -1, 0, 0, 1, 1,//-x
-1, 1, +1, 0, 0, -1, 0, 0, 1, //+y
-1, 1, -1, 0, 0, -1, 0, 0, 0,
+1, 1, +1, 0, 0, -1, 0, 1, 1,
+1, 1, -1, 0, 0, -1, 0, 1, 0,
-1, -1, +1, 0, 0, +1, 0, 0, 0,//-y
-1, -1, -1, 0, 0, +1, 0, 0, 1,
+1, -1, +1, 0, 0, +1, 0, 1, 0,
+1, -1, -1, 0, 0, +1, 0, 1, 1,
0, 0, 0, 1, 0,0,0, 0,0, //for the line between the cube and the atom
0, 0, 1, 1, 0, 0, 0, 0, 0, //for the line between the cube and the atom
};
const short int ind[]={
0, 1, 2, //z
1, 3, 2,
4, 5, 6,
5, 7, 6,
8, 9, 10,//x
9, 11, 10,
12, 13, 14,
13, 15, 14,
16, 17, 18,//y
17, 19, 18,
20, 21, 22,
21, 23, 22,
};
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * Nvert , vert,
GL_STATIC_DRAW);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(ind), ind, GL_STATIC_DRAW);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 9 * sizeof(float), (const void *)(0));
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 9 * sizeof(float), (const void *)(4*sizeof(float)));
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 9 * sizeof(float), (const void *)(7*sizeof(float)));
glBindVertexArray(0);
return glGetError();
}
GLenum SetupMarker(GLuint *MarkerVAO, GLuint *MarkerVertBuffer)
{
if (!markers)
......
/*This code is based on openvr, which uses the 3-clause BSD license*/
/*https://github.com/ValveSoftware/openvr/blob/master/LICENSE*/
//========= Copyright Valve Corporaion ============//
/*This license is compatible with Apache 2.0*/
/*This code is therefore licensed under Apache 2.0*/
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/
#ifndef __ATOMSGL_H
#define __ATOMSGL_H
......@@ -9,6 +31,7 @@ GLenum SetupAtoms(GLuint **AtomVAO, GLuint **AtomVertBuffer, GLuint *BondIndices
GLenum SetupAtomsNoTess (GLuint **AtomVAO, GLuint **AtomVertBuffer, GLuint **AtomIndexBuffer);
GLenum SetupUnitCell(GLuint *UnitCellVAO, GLuint *UnitCellVertBuffer, GLuint *UnitCellIndexBuffer);
GLenum SetupMarker(GLuint *MarkerVAO, GLuint *MarkerVertBuffer);
GLenum SetupInfoCube (GLuint *VAO, GLuint *VertBuffer, GLuint *IndexBuffer);
bool PrepareUnitCellAtomShader (GLuint *AtomP, GLuint *cellP, GLuint *MarkerP,
GLint *AtomMatrixLocation, GLint *UnitCellMatrixLocation, GLint *UnitCellColourLocation,
......
/*
# Copyright 2016-2018 The NOMAD Developers Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.