atomes 1.3.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
d_box.c
Go to the documentation of this file.
1/* This file is part of the 'atomes' software
2
3'atomes' is free software: you can redistribute it and/or modify it under the terms
4of the GNU Affero General Public License as published by the Free Software Foundation,
5either version 3 of the License, or (at your option) any later version.
6
7'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9See the GNU General Public License for more details.
10
11You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12If not, see <https://www.gnu.org/licenses/>
13
14Copyright (C) 2022-2026 by CNRS and University of Strasbourg */
15
23
24/*
25* This file: 'd_box.c'
26*
27* Contains:
28*
29
30 - The functions to prepare the OpenGL rendering for the box(es)
31 - The functions to prepare the OpenGL rendering for the slab(s)
32 - The functions to prepare the OpenGL rendering for the volume(s)
33
34*
35* List of functions:
36
37 int create_box_lists (int b_step);
38
39 double draw_cuboid (gboolean draw, int SHADID, int shadnum, mat4_t rot, vec3_t cpos, double paral[3][3], ColRGBA col, double slab_alpha);
40
41 gboolean are_identical_vec3 (vec3_t va, vec3_t vb);
42 gboolean not_in_already (vec3_t a, vec3_t b, float * vertices);
43 gboolean not_in_corners (vec3_t a, float * vertices);
44
45 void setup_extra_box_vertices (vec3_t a, vec3_t b, int id, float * c_vert, float * s_vert);
46 void setup_box_vertices (vec3_t ax, vec3_t bx, int id, float * c_vert, float * s_vert);
47 void prepare_box_vertices (void (*c_func)(vec3_t, vec3_t, int, float *, float *), float * verts, float * serts, int id);
48 void prepare_cuboid (vec3_t position, int id);
49 void create_light_lists ();
50 void cuboid_slab (mat4_t rot);
51 void cylinder_slab (mat4_t rot);
52 void spherical_slab ();
53 void create_slab_lists (project * this_proj);
54 void create_volumes_lists ();
55
56*/
57
58#include "global.h"
59#include "glview.h"
60
61extern object_3d * draw_sphere (int quality);
62extern object_3d * draw_cylinder (int quality, float ra, float rb);
63extern object_3d * draw_cylinder_cap (int quality, float rad, gboolean picked);
64extern object_3d * draw_billboard_quad (void);
65extern void setup_line_vertice (float * vertices, vec3_t pos, ColRGBA col, float alpha);
66extern void setup_sphere_vertice (float * vertices, vec3_t pos, ColRGBA col, float rad, float alpha);
67extern void setup_cylinder_vertice (float * vertices, vec3_t pos_a, vec3_t pos_b, ColRGBA col, float rad, float alpha, float delta, float r_sph_a, float r_sph_b);
68extern void setup_cap_vertice (float * vertices, vec3_t pos_a, vec3_t pos_b, ColRGBA col, float rad, float alpha, gboolean sel);
69extern void create_slab_info (project * this_proj);
70extern void process_selected_atom (project * this_proj, glwin * view, int id, int ac, int se, int pi);
71extern ColRGBA pcol;
72
74
84{
85
86 if (va.x == vb.x && va.y == vb.y && va.z == vb.z)
87 {
88 return TRUE;
89 }
90 else
91 {
92 return FALSE;
93 }
94}
95
105gboolean not_in_already (vec3_t a, vec3_t b, float * vertices)
106{
107 int i, j, k;
108 vec3_t tma, tmb;
109
110 for (i=0; i<nbs/2; i=i+2)
111 {
112 j = i*BOX_BUFF_SIZE;
113 k = j+BOX_BUFF_SIZE;
114 tma = vec3(vertices[j], vertices[j+1], vertices[j+2]);
115 tmb = vec3(vertices[k], vertices[k+1], vertices[k+2]);
116 if (are_identical_vec3(a, tma) && are_identical_vec3(b, tmb))
117 {
118 return FALSE;
119 }
120 else if (are_identical_vec3(b, tma) && are_identical_vec3(a, tmb))
121 {
122 return FALSE;
123 }
124 }
125 return TRUE;
126}
127
136gboolean not_in_corners (vec3_t a, float * vertices)
137{
138 int i, j;
139 vec3_t tma;
140 for (i=0; i<nbl; i++)
141 {
142 j = i*8;
143 tma = vec3(vertices[j], vertices[j+1], vertices[j+2]);
144 if (are_identical_vec3(a, tma))
145 {
146 return FALSE;
147 }
148 }
149 return TRUE;
150}
151
162void setup_extra_box_vertices (vec3_t a, vec3_t b, float * c_vert, float * s_vert)
163{
164 float j;
165 int p, q, r;
167 vec3_t t_a, t_b;
168 for (j=-1.0; j<2.0; j=j+2.0)
169 {
170 for (p=0; p<plot -> abc -> extra_cell[0]+1; p++)
171 {
172 for (q=0; q<plot -> abc -> extra_cell[1]+1; q++)
173 {
174 for (r=0; r<plot -> abc -> extra_cell[2]+1; r++)
175 {
176 if (p > 0 || q > 0 || r > 0)
177 {
178 shift.x = p*box_gl -> vect[0][0]+q*box_gl -> vect[1][0]+r*box_gl -> vect[2][0];
179 shift.y = p*box_gl -> vect[0][1]+q*box_gl -> vect[1][1]+r*box_gl -> vect[2][1];
180 shift.z = p*box_gl -> vect[0][2]+q*box_gl -> vect[1][2]+r*box_gl -> vect[2][2];
181
182 t_a = v3_add (v3_muls (a, j), shift);
183 t_b = v3_add (v3_muls (b, j), shift);
184 if (not_in_already (t_a, t_b, c_vert))
185 {
186 if (plot -> abc -> box == WIREFRAME)
187 {
188 setup_line_vertice (c_vert, t_a, pcol, 0.5);
189 setup_line_vertice (c_vert, t_b, pcol, 0.5);
190 }
191 else
192 {
193 if (not_in_corners(t_a, s_vert)) setup_sphere_vertice (s_vert, t_a, pcol, plot -> abc -> rad, pcol.alpha*0.5);
194 if (not_in_corners(t_b, s_vert)) setup_sphere_vertice (s_vert, t_b, pcol, plot -> abc -> rad, pcol.alpha*0.5);
195 setup_cylinder_vertice (c_vert, t_a, t_b, pcol, plot -> abc -> rad, 0.5, 0.0, plot -> abc -> rad, 0.0);
196 }
197 }
198 }
199 }
200 }
201 }
202 }
203}
204
215void setup_box_vertices (vec3_t ax, vec3_t bx, float * c_vert, float * s_vert)
216{
217 float j;
218 vec3_t a, b;
219 /*vec3_t cell[3];
220 int i;
221 for (i=0; i<3; i++)
222 {
223 cell[i] = vec3(box_gl -> vect[i][0], box_gl -> vect[i][1], box_gl -> vect[i][2]);
224 cell[i] = v3_divs (cell[i], 2.0);
225 }
226 vec3_t lattice = v3_add(v3_add(cell[0], cell[1]), cell[2]);*/
227 for (j=-1.0; j<2.0; j=j+2.0)
228 {
229 /*a = v3_sub (v3_muls (ax, j), lattice);
230 b = v3_sub (v3_muls (bx, j), lattice);*/
231 a = v3_muls (ax, j);
232 b = v3_muls (bx, j);
233 if (plot -> abc -> box == WIREFRAME)
234 {
235 setup_line_vertice (c_vert, a, pcol, 1.0);
236 setup_line_vertice (c_vert, b, pcol, 1.0);
237 }
238 else
239 {
240 if (not_in_corners(a, s_vert)) setup_sphere_vertice (s_vert, a, pcol, plot -> abc -> rad, pcol.alpha*1.0);
241 if (not_in_corners(b, s_vert)) setup_sphere_vertice (s_vert, b, pcol, plot -> abc -> rad, pcol.alpha*1.0);
242 setup_cylinder_vertice (c_vert, a, b, pcol, plot -> abc -> rad, 1.0, 0.0, plot -> abc -> rad, 0.0);
243 }
244 }
245}
246
256void prepare_box_vertices (void (*c_func)(vec3_t, vec3_t, float *, float *), float * verts, float * serts)
257{
258 int i;
259 vec3_t pa, pb;
260
261 for (i=-1; i<2; i=i+2)
262 {
263 pa.x = (- box_gl -> vect[0][0] - box_gl -> vect[1][0] + i * box_gl -> vect[2][0]) / 2.0;
264 pa.y = (- box_gl -> vect[0][1] - box_gl -> vect[1][1] + i * box_gl -> vect[2][1]) / 2.0;
265 pa.z = (- box_gl -> vect[0][2] - box_gl -> vect[1][2] + i * box_gl -> vect[2][2]) / 2.0;
266 pb.x = (box_gl -> vect[0][0] - box_gl -> vect[1][0] + i * box_gl -> vect[2][0]) / 2.0;
267 pb.y = (box_gl -> vect[0][1] - box_gl -> vect[1][1] + i * box_gl -> vect[2][1]) / 2.0;
268 pb.z = (box_gl -> vect[0][2] - box_gl -> vect[1][2] + i * box_gl -> vect[2][2]) / 2.0;
269 (* c_func)(pa, pb, verts, serts);
270 pa.x = (i * box_gl -> vect[0][0] - box_gl -> vect[1][0] + box_gl -> vect[2][0]) / 2.0;
271 pa.y = (i * box_gl -> vect[0][1] - box_gl -> vect[1][1] + box_gl -> vect[2][1]) / 2.0;
272 pa.z = (i * box_gl -> vect[0][2] - box_gl -> vect[1][2] + box_gl -> vect[2][2]) / 2.0;
273 pb.x = (i * box_gl -> vect[0][0] - box_gl -> vect[1][0] - box_gl -> vect[2][0]) / 2.0;
274 pb.y = (i * box_gl -> vect[0][1] - box_gl -> vect[1][1] - box_gl -> vect[2][1]) / 2.0;
275 pb.z = (i * box_gl -> vect[0][2] - box_gl -> vect[1][2] - box_gl -> vect[2][2]) / 2.0;
276 (* c_func)(pa, pb, verts, serts);
277 pa.x = (i * box_gl -> vect[0][0] + box_gl -> vect[1][0] + box_gl -> vect[2][0]) / 2.0;
278 pa.y = (i * box_gl -> vect[0][1] + box_gl -> vect[1][1] + box_gl -> vect[2][1]) / 2.0;
279 pa.z = (i * box_gl -> vect[0][2] + box_gl -> vect[1][2] + box_gl -> vect[2][2]) / 2.0;
280 pb.x = (i * box_gl -> vect[0][0] - box_gl -> vect[1][0] + box_gl -> vect[2][0]) / 2.0;
281 pb.y = (i * box_gl -> vect[0][1] - box_gl -> vect[1][1] + box_gl -> vect[2][1]) / 2.0;
282 pb.z = (i * box_gl -> vect[0][2] - box_gl -> vect[1][2] + box_gl -> vect[2][2]) / 2.0;
283 (* c_func)(pa, pb, verts, serts);
284 }
285}
286
294int create_box_lists (int b_step)
295{
296 int vertex = 8;
297 object_3d * box_a, * box_b;
298
300 wingl -> create_shaders[MDBOX] = FALSE;
301
302 if (plot -> abc -> box == NONE) return 0;
303
304 int saved_tracing = plot -> ray_tracing;
305 plot -> ray_tracing = FALSE;
306 int shaders;
307 vertex *= (plot -> abc -> extra_cell[0]+1)*(plot -> abc -> extra_cell[1]+1)*(plot -> abc -> extra_cell[2]+1);
308
309 if (plot -> abc -> box == WIREFRAME)
310 {
311 shaders = 1;
313 box_b = g_malloc0(sizeof*box_b);
314 box_b -> vert_buffer_size = LINE_BUFF_SIZE;
315 box_b -> num_vertices = vertex*3;
316 box_b -> vertices = allocfloat (box_b -> vert_buffer_size*box_b -> num_vertices);
317 }
318 else
319 {
320 shaders = 2;
321 BOX_BUFF_SIZE = (plot -> ray_tracing) ? CYLI_BUFF_SIZE + 2 : CYLI_BUFF_SIZE;
322 // Spheres at corners
323 box_a = (plot -> ray_tracing) ? draw_billboard_quad () : draw_sphere (plot -> quality);
324 box_a -> num_instances = 3*vertex*3/2;
325 box_a -> inst_buffer_size = ATOM_BUFF_SIZE;
326 allocate_instances (box_a);
327 // Cylinders
328 box_b = (plot -> ray_tracing) ? draw_billboard_quad () : draw_cylinder (plot -> quality, 1.0, 1.0);
329 box_b -> num_instances = 3*vertex;
330 box_b -> inst_buffer_size = (plot -> ray_tracing) ? CYLI_BUFF_SIZE + 2 : CYLI_BUFF_SIZE;
331 allocate_instances (box_b);
332 }
333 wingl -> ogl_glsl[MDBOX][b_step] = g_malloc0(shaders*sizeof*wingl -> ogl_glsl[MDBOX][b_step]);
334
335 nbs = nbl = 0;
336 pcol = plot -> abc -> color;
337
339 (plot -> abc -> box == WIREFRAME) ? box_b -> vertices: box_b -> instances,
340 (plot -> abc -> box == WIREFRAME) ? NULL : box_a -> instances);
341 if (plot -> abc -> extra_cell[0] > 0 || plot -> abc -> extra_cell[1] > 0 || plot -> abc -> extra_cell[2] > 0)
342 {
343 prepare_box_vertices (setup_extra_box_vertices, (plot -> abc -> box == WIREFRAME) ? box_b -> vertices: box_b -> instances,
344 (plot -> abc -> box == WIREFRAME) ? NULL : box_a -> instances);
345 }
346 if (plot -> abc -> box == WIREFRAME)
347 {
348 wingl -> ogl_glsl[MDBOX][b_step][0] = init_shader_program (MDBOX, GLSL_LINES, line_vertex, NULL, line_color, GL_LINES, 2, 1, FALSE, box_b);
349 wingl -> ogl_glsl[MDBOX][b_step][0] -> line_width = plot -> abc -> line;
350 }
351 else
352 {
353 // Sphere at corners
354 const GLchar * vs_sph = (plot -> ray_tracing) ? sphere_vertex_ray : sphere_vertex;
355 const GLchar * fs_box = (plot -> ray_tracing) ? full_color_ray : full_color;
356 wingl -> ogl_glsl[MDBOX][b_step][0] = init_shader_program (MDBOX, GLSL_SPHERES, vs_sph, NULL, fs_box, GL_TRIANGLE_STRIP, 4, 1, TRUE, box_a);
357 // Cylinders
358 const GLchar * vs_cyl = (plot -> ray_tracing) ? cylinder_vertex_ray : cylinder_vertex;
359 int narray_cyl = plot -> ray_tracing ? 8 : 6;
360 wingl -> ogl_glsl[MDBOX][b_step][1] = init_shader_program (MDBOX, GLSL_CYLINDERS, vs_cyl, NULL, fs_box, GL_TRIANGLE_STRIP, narray_cyl, 1, TRUE, box_b);
361 }
362 plot -> ray_tracing = saved_tracing;
363 return shaders;
364}
365
366/*vec3_t center;
367
368/ *
369* void setup_cuboid_vertices (vec3_t a, vec3_t b, int id)
370
371 \brief NOT USED !
372
373 \param a
374 \param b
375 \param id
376* /
377void setup_cuboid_vertices (vec3_t a, vec3_t b, int id)
378{
379 float j;
380 for (j=-1.0; j<2.0; j=j+2.0)
381 {
382 box_axis_vertices (wingl -> d_vertices[LIGHT][id], -1, 0.0, v3_muls (v3_add(a,center), j));
383 box_axis_vertices (wingl -> d_vertices[LIGHT][id], -1, 0.0, v3_muls (v3_add(b,center), j));
384 }
385}*/
386
387GLfloat cuboid_vertices[] = {
388 // Positions // Normals
389 -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f,
390 1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f,
391 1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f,
392 1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f,
393 -1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f,
394 -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f,
395
396 -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
397 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
398 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
399 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
400 -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
401 -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
402
403 -1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 0.0f,
404 -1.0f, 1.0f, -1.0f, -1.0f, 0.0f, 0.0f,
405 -1.0f, -1.0f, -1.0f, -1.0f, 0.0f, 0.0f,
406 -1.0f, -1.0f, -1.0f, -1.0f, 0.0f, 0.0f,
407 -1.0f, -1.0f, 1.0f, -1.0f, 0.0f, 0.0f,
408 -1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 0.0f,
409
410 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f,
411 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f,
412 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f,
413 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f,
414 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f,
415 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f,
416
417 -1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f,
418 1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f,
419 1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f,
420 1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f,
421 -1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f,
422 -1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f,
423
424 -1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
425 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
426 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f,
427 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f,
428 -1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f,
429 -1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
430 };
431
441{
442 float lgt = 1.0;
443 object_3d * light = g_malloc0(sizeof*light);
444 light -> vert_buffer_size = POLY_BUFF_SIZE;
445 light -> num_vertices = 36;
446 light -> vertices = allocfloat (light -> vert_buffer_size*light -> num_vertices);
447 int i, j, k, l;
448 l = 0;
449 for (i=0; i<36; i++)
450 {
451 j = 10*l;
452 k = 6*l;
453 light -> vertices[j] = lgt*cuboid_vertices[k]*0.5 + position.x;
454 light -> vertices[j+1] = lgt*cuboid_vertices[k+1]*0.5 + position.y;
455 light -> vertices[j+2] = lgt*cuboid_vertices[k+2]*0.5 + position.z;
456 light -> vertices[j+3] = cuboid_vertices[k+3];
457 light -> vertices[j+4] = cuboid_vertices[k+4];
458 light -> vertices[j+5] = cuboid_vertices[k+5];
459 light -> vertices[j+6] = 1.0;
460 light -> vertices[j+7] = 1.0;
461 light -> vertices[j+8] = 1.0;
462 light -> vertices[j+9] = 1.0;
463 l ++;
464 }
465 wingl -> ogl_glsl[LIGHT][0][id] = init_shader_program (LIGHT, GLSL_POLYEDRA, full_vertex, NULL, full_color, GL_TRIANGLES, 3, 1, FALSE, light);
466}
467
474{
475 int i, j;
476 j = 0;
478 for (i=0; i<plot -> l_ghtning.lights; i++)
479 {
480 if (plot -> l_ghtning.spot[i] -> show) j++;
481 }
482 wingl -> n_shaders[LIGHT][0] = j;
483 if (plot -> light_loc != NULL)
484 {
485 g_free (plot -> light_loc);
486 plot -> light_loc = NULL;
487 }
488
489 if (j > 0)
490 {
491 wingl -> ogl_glsl[LIGHT][0] = g_malloc0(wingl -> n_shaders[LIGHT][0]*sizeof*wingl -> ogl_glsl[LIGHT][0]);
492 plot -> light_loc = allocint (j);
493 j = 0;
494 for (i=0; i<plot -> l_ghtning.lights; i++)
495 {
496 if (plot -> l_ghtning.spot[i] -> show)
497 {
498 prepare_cuboid (plot -> l_ghtning.spot[i] -> position, j);
499 if (plot -> l_ghtning.spot[i] -> type > 0 && plot -> l_ghtning.spot[i] -> fix == 0) plot -> light_loc[j] = 1;
500 j ++;
501 }
502 }
503 }
504 wingl -> create_shaders[LIGHT] = FALSE;
505}
506
508{
509 vec3_t edge_a = v3_sub(v3, v1);
510 vec3_t edge_b = v3_sub(v2, v1);
511 return v3_norm (v3_cross(edge_a, edge_b));
512}
513
528double draw_cuboid (gboolean draw, int SHADID, int shadnum, mat4_t rot, vec3_t cpos, double paral[3][3], ColRGBA col, double slab_alpha)
529{
530 int i, j, k, l, m, n, o;
531 vec3_t pos;
532 double cvol;
533 double shift[3];
534 cvol = (paral[0][1]*paral[1][2]-paral[0][2]*paral[1][1])*paral[2][0];
535 cvol += (paral[0][2]*paral[1][0]-paral[0][0]*paral[1][2])*paral[2][1];
536 cvol += (paral[0][0]*paral[1][1]-paral[0][1]*paral[1][0])*paral[2][2];
537 cvol = fabs(cvol);
538 if (draw)
539 {
540 object_3d * slab = g_malloc0(sizeof*slab);
541 slab -> vert_buffer_size = POLY_BUFF_SIZE;
542 slab -> num_vertices = 36*(plot -> abc -> extra_cell[0]+1)*(plot -> abc -> extra_cell[1]+1)*(plot -> abc -> extra_cell[2]+1);
543 slab -> vertices = allocfloat (slab -> vert_buffer_size*slab -> num_vertices);
544 for (i=0; i<36; i++)
545 {
546 j = i*POLY_BUFF_SIZE;
547 k = 6*i;
548 for (l=0; l<3; l++)
549 {
550 slab -> vertices[j+l] += 0.5*(cuboid_vertices[k]*paral[0][l] + cuboid_vertices[k+1]*paral[1][l] + cuboid_vertices[k+2]*paral[2][l]);
551 }
552 pos = vec3 (slab -> vertices[j], slab -> vertices[j+1], slab -> vertices[j+2]);
553 pos = m4_mul_pos (rot, pos);
554 slab -> vertices[j] = pos.x + cpos.x;
555 slab -> vertices[j+1] = pos.y + cpos.y;
556 slab -> vertices[j+2] = pos.z + cpos.z;
557 }
558 n = 0;
559 for (i=0; i<plot -> abc -> extra_cell[0]+1; i++)
560 {
561 for (j=0; j<plot -> abc -> extra_cell[1]+1; j++)
562 {
563 for (k=0; k<plot -> abc -> extra_cell[2]+1; k++)
564 {
565 for (l=0; l<3; l++) shift[l] = i*box_gl -> vect[0][l] + j*box_gl -> vect[1][l] + k*box_gl -> vect[2][l];
566 for (l=0; l<36; l++)
567 {
568 m = POLY_BUFF_SIZE*n;
569 for (o=0; o<3; o++)
570 {
571 slab -> vertices[m+o] = slab -> vertices[l*POLY_BUFF_SIZE+o] + shift[o];
572 if (SHADID == SLABS)
573 {
574 slab -> vertices[m+6+o] = (o) ? 1.0 : 0.0;
575 }
576 else
577 {
578 if (! o) slab -> vertices[m+6+o] = col.red;
579 if (o == 1) slab -> vertices[m+6+o] = col.green;
580 if (o == 2) slab -> vertices[m+6+o] = col.blue;
581 }
582 }
583 pos = vec3 (cuboid_vertices[6*l+3], cuboid_vertices[6*l+4], cuboid_vertices[6*l+5]);
584 pos = m4_mul_pos (rot, pos);
585 slab -> vertices[m+3] = pos.x;
586 slab -> vertices[m+4] = pos.y;
587 slab -> vertices[m+5] = pos.z;
588 slab -> vertices[m+9] = slab_alpha;
589 n ++;
590 }
591 }
592 }
593 }
594 wingl -> ogl_glsl[SHADID][(SHADID == SLABS) ? 0 : step][shadnum] = init_shader_program (SHADID, GLSL_POLYEDRA, full_vertex, NULL, full_color, GL_TRIANGLES, 3, 1, TRUE, slab);
595 }
596 return cvol;
597}
598
607{
608 int i, j, k, l, m;
609 double ang[3], cang[3], sang[3];
610 double paral[3][3];
611 double tmp;
612 for (i=0; i<3; i++)
613 {
614 if (wingl -> cell_win -> cparam[i+15] == 90.0)
615 {
616 ang[i] = pi/2.0;
617 sang[i] = 1.0;
618 cang[i] = 0.0;
619 }
620 else
621 {
622 ang[i] = wingl -> cell_win -> cparam[i+15]*pi/180.0;
623 sang[i] = sin(ang[i]);
624 cang[i] = cos(ang[i]);
625 }
626 }
627 paral[0][0] = wingl -> cell_win -> cparam[9];
628 paral[0][1] = 0.0;
629 paral[0][2] = 0.0;
630 paral[1][0] = wingl -> cell_win -> cparam[10] * cang[2];
631 paral[1][1] = wingl -> cell_win -> cparam[10] * sang[2];
632 paral[1][2] = 0.0;
633 paral[2][0] = wingl -> cell_win -> cparam[11] * cang[1];
634 tmp = (cang[0] - cang[1]*cang[2]) / sang[2];
635 paral[2][1] = wingl -> cell_win -> cparam[11] * tmp;
636 paral[2][2] = wingl -> cell_win -> cparam[11] * sqrt(sang[1]*sang[1] - tmp*tmp);
637 ColRGBA null; // Not used
638 wingl -> cell_win -> slab_vol = draw_cuboid (! wingl -> cell_win -> cut_this_slab, SLABS, 0, rot,
639 vec3(wingl -> cell_win -> cparam[6], wingl -> cell_win -> cparam[7], wingl -> cell_win -> cparam[8]),
640 paral, null, wingl -> cell_win -> slab_alpha);
641
642 vec3_t at, atc;
643 vec3_t ps[8];
644 vec3_t pn[6];
645 vec3_t cat = vec3(wingl -> cell_win -> cparam[6], wingl -> cell_win -> cparam[7], wingl -> cell_win -> cparam[8]);
646 l = 0;
647 float pmax[3];
648
649 for (i=-1; i<2; i+=2)
650 {
651 for (j=-1; j<2; j+=2)
652 {
653 for (k=-1; k<2; k+=2)
654 {
655 ps[l].x = 0.5*(i*paral[0][0] + j*paral[1][0] + k*paral[2][0]);
656 ps[l].y = 0.5*(i*paral[0][1] + j*paral[1][1] + k*paral[2][1]);
657 ps[l].z = 0.5*(i*paral[0][2] + j*paral[1][2] + k*paral[2][2]);
658 ps[l] = m4_mul_pos (rot, ps[l]);
659 ps[l]= v3_add (ps[l], cat);
660 if (l == 0)
661 {
662 pmax[0] = ps[l].x;
663 pmax[1] = ps[l].y;
664 pmax[2] = ps[l].z;
665 }
666 else
667 {
668 pmax[0] = max(pmax[0],ps[l].x);
669 pmax[1] = max(pmax[1],ps[l].y);
670 pmax[2] = max(pmax[2],ps[l].z);
671 }
672 l ++;
673 }
674 }
675 }
676
677 pn[0] = get_normal (ps[1], ps[0], ps[2]);
678 pn[1] = get_normal (ps[1], ps[0], ps[4]);
679 pn[2] = get_normal (ps[2], ps[0], ps[4]);
680 pn[3] = get_normal (ps[3], ps[7], ps[5]);
681 pn[4] = get_normal (ps[3], ps[7], ps[6]);
682 pn[5] = get_normal (ps[5], ps[7], ps[6]);
683
684 ps[0] = v3_sub (ps[0], cat);
685 ps[7] = v3_sub (ps[7], cat);
686
687 for (i=0; i<proj_gl -> nspec; i++) wingl -> cell_win -> slab_lot[i] = 0;
688 wingl -> cell_win -> slab_atoms = 0;
689 float val, vbl;
690 atom slab_center;
691 distance at_slab;
692 slab_center.x = cat.x;
693 slab_center.y = cat.y;
694 slab_center.z = cat.z;
695 for (i=0; i<proj_gl->natomes; i++)
696 {
697 at_slab = distance_3d (cell_gl, (cell_gl -> npt) ? step : 0, & proj_gl -> atoms[0][i], & slab_center);
698 at = vec3(slab_center.x+at_slab.x, slab_center.y+at_slab.y, slab_center.z+at_slab.z);
699 if (at.x <= pmax[0] && at.y <= pmax[1] && at.z <= pmax[2])
700 {
701 m = 0;
702 atc = v3_sub (at, cat);
703 for (j=0; j<6; j++)
704 {
705 k = (j < 3) ? 0 : 7;
706 val = v3_dot (ps[k], pn[j]);
707 vbl = v3_dot (atc, pn[j]);
708 if (fabs(vbl) < fabs(val))
709 {
710 m ++;
711 }
712 else
713 {
714 break;
715 }
716 }
717 if (m == 6 && (! at_slab.pbc || wingl -> cell_win -> slab_pbc))
718 {
719 wingl -> cell_win -> slab_atoms ++;
720 l = proj_gl -> atoms[0][i].sp;
721 wingl -> cell_win -> slab_lot[l] ++;
722 if (wingl -> cell_win -> cut_this_slab) process_selected_atom (proj_gl, wingl, i, 0, 0, 0);
723 }
724 }
725 }
726}
727
736{
737 int i, j, k;
738 vec3_t pos_a = vec3(-wingl -> cell_win -> cparam[12]/2.0, 0.0, 0.0);
739 vec3_t pos_b = vec3( wingl -> cell_win -> cparam[12]/2.0, 0.0, 0.0);
740 pos_a = m4_mul_pos (rot, pos_a);
741 pos_b = m4_mul_pos (rot, pos_b);
742 vec3_t cat = vec3 (wingl -> cell_win -> cparam[6], wingl -> cell_win -> cparam[7], wingl -> cell_win -> cparam[8]);
743 pos_a = v3_add (pos_a, cat);
744 pos_b = v3_add (pos_b, cat);
745 vec3_t axis = v3_sub (pos_b, pos_a);
746 if (! wingl -> cell_win -> cut_this_slab)
747 {
748 object_3d * slab = g_malloc0(sizeof*slab);
749 object_3d * slab_cap = g_malloc0(sizeof*slab_cap);
750 slab = (plot -> ray_tracing) ? draw_billboard_quad () : draw_cylinder (30, 1.0, 1.0);
751 slab -> num_instances = (plot -> abc -> extra_cell[0]+1)*(plot -> abc -> extra_cell[1]+1)*(plot -> abc -> extra_cell[2]+1);
752 slab -> inst_buffer_size = (plot -> ray_tracing) ? CYLI_BUFF_SIZE + 2 : CYLI_BUFF_SIZE;
753 allocate_instances (slab);
754 slab_cap = (plot -> ray_tracing) ? draw_billboard_quad () : draw_cylinder_cap (50, 1.0, FALSE);
755 slab_cap -> num_instances = 2 * slab -> num_instances;
756 slab_cap -> inst_buffer_size = CAPS_BUFF_SIZE;
757 allocate_instances (slab_cap);
758 ColRGBA col;
759 col.red = 0.0;
760 col.blue = 1.0;
761 col.green = 1.0;
762 col.alpha = wingl -> cell_win -> slab_alpha;
764 for (i=0; i<plot -> abc -> extra_cell[0]+1; i++)
765 {
766 for (j=0; j<plot -> abc -> extra_cell[1]+1; j++)
767 {
768 for (k=0; k<plot -> abc -> extra_cell[2]+1; k++)
769 {
770 shift.x = i*box_gl -> vect[0][0]+j*box_gl -> vect[1][0]+k*box_gl -> vect[2][0];
771 shift.y = i*box_gl -> vect[0][1]+j*box_gl -> vect[1][1]+k*box_gl -> vect[2][1];
772 shift.z = i*box_gl -> vect[0][2]+j*box_gl -> vect[1][2]+k*box_gl -> vect[2][2];
773 pos_a = v3_add (pos_a, shift);
774 pos_b = v3_add (pos_b, shift);
775 setup_cylinder_vertice (slab -> instances, pos_a, pos_b, col, wingl -> cell_win -> cparam[13], 1.0, 0.0, 0.0, 0.0);
776 pos_a = v3_sub (pos_a, shift);
777 pos_b = v3_sub (pos_b, shift);
778 }
779 }
780 }
781 const GLchar * vs_slc = (plot -> ray_tracing) ? cylinder_vertex_ray : cylinder_vertex;
782 const GLchar * fs_slc = (plot -> ray_tracing) ? full_color_ray : full_color;
783 int narray_cyl = plot -> ray_tracing ? 8 : 6;
784 wingl -> ogl_glsl[SLABS][0][0] = init_shader_program (SLABS, GLSL_CYLINDERS, vs_slc, NULL, fs_slc, GL_TRIANGLE_STRIP, narray_cyl, 1, TRUE, slab);
785 nbs = 0;
786 for (i=0; i<plot -> abc -> extra_cell[0]+1; i++)
787 {
788 for (j=0; j<plot -> abc -> extra_cell[1]+1; j++)
789 {
790 for (k=0; k<plot -> abc -> extra_cell[2]+1; k++)
791 {
792 shift.x = i*box_gl -> vect[0][0]+j*box_gl -> vect[1][0]+k*box_gl -> vect[2][0];
793 shift.y = i*box_gl -> vect[0][1]+j*box_gl -> vect[1][1]+k*box_gl -> vect[2][1];
794 shift.z = i*box_gl -> vect[0][2]+j*box_gl -> vect[1][2]+k*box_gl -> vect[2][2];
795 pos_a = v3_add (pos_a, shift);
796 pos_b = v3_add (pos_b, shift);
797 setup_cap_vertice (slab_cap -> instances, pos_a, pos_b, col, wingl -> cell_win -> cparam[13], 1.0, FALSE);
798 setup_cap_vertice (slab_cap -> instances, pos_b, pos_a, col, wingl -> cell_win -> cparam[13], 1.0, FALSE);
799 pos_a = v3_sub (pos_a, shift);
800 pos_b = v3_sub (pos_b, shift);
801 }
802 }
803 }
804 const GLchar * vs_slcp = (plot -> ray_tracing) ? cap_vertex_ray : cap_vertex;
805 GLenum prim_slcp = (plot -> ray_tracing) ? GL_TRIANGLE_STRIP : GL_TRIANGLE_FAN;
806 wingl -> ogl_glsl[SLABS][0][1] = init_shader_program (SLABS, GLSL_CAPS, vs_slcp, NULL, fs_slc, prim_slcp, 5, 1, TRUE, slab_cap);
807 }
808 wingl -> cell_win -> slab_vol = pi*pow(wingl -> cell_win -> cparam[13], 2)*wingl -> cell_win -> cparam[12];
809 for (i=0; i<proj_gl -> nspec; i++) wingl -> cell_win -> slab_lot[i] = 0;
810 wingl -> cell_win -> slab_atoms = 0;
811 vec3_t atc, patc;
812 atom slab_center;
813 distance at_slab;
814 slab_center.x = cat.x;
815 slab_center.y = cat.y;
816 slab_center.z = cat.z;
817 for (i=0; i<proj_gl->natomes; i++)
818 {
819 atc = vec3(proj_gl -> atoms[0][i].x, proj_gl -> atoms[0][i].y, proj_gl -> atoms[0][i].z);
820 at_slab = distance_3d (cell_gl, (cell_gl -> npt) ? step : 0, & proj_gl -> atoms[0][i], & slab_center);
821 if (wingl -> cell_win -> slab_pbc || ! at_slab.pbc)
822 {
823 atc = vec3(at_slab.x, at_slab.y, at_slab.z);
824 patc = v3_proj (atc, axis);
825 if (v3_length(patc) <= wingl -> cell_win -> cparam[12]/2.0 && v3_length(v3_sub(patc,atc)) <= wingl -> cell_win -> cparam[13])
826 {
827 wingl -> cell_win -> slab_atoms ++;
828 j = proj_gl -> atoms[0][i].sp;
829 wingl -> cell_win -> slab_lot[j] ++;
830 if (wingl -> cell_win -> cut_this_slab) process_selected_atom (proj_gl, wingl, i, 0, 0, 0);
831 }
832 }
833 }
834}
835
842{
843 int i, j, k, l;
844 vec3_t pos;
845 if (! wingl -> cell_win -> cut_this_slab)
846 {
847 object_3d * slab = g_malloc0(sizeof*slab);
848 slab = (plot -> ray_tracing) ? draw_billboard_quad () : draw_sphere (50);
849 slab -> inst_buffer_size = ATOM_BUFF_SIZE;
850 slab -> num_instances = (plot -> abc -> extra_cell[0]+1)*(plot -> abc -> extra_cell[1]+1)*(plot -> abc -> extra_cell[2]+1);
851 allocate_instances (slab);
852 ColRGBA col;
853 col.red = 0.0;
854 col.blue = 1.0;
855 col.green = 1.0;
856 col.alpha = wingl -> cell_win -> slab_alpha;
857 double shift[3];
858 for (i=0; i<plot -> abc -> extra_cell[0]+1; i++)
859 {
860 for (j=0; j<plot -> abc -> extra_cell[1]+1; j++)
861 {
862 for (k=0; k<plot -> abc -> extra_cell[2]+1; k++)
863 {
864 for (l=0; l<3; l++) shift[l] = i*box_gl -> vect[0][l] + j*box_gl -> vect[1][l] + k*box_gl -> vect[2][l] + wingl -> cell_win -> cparam[l+6];
865 pos = vec3(shift[0], shift[1], shift[2]);
866 setup_sphere_vertice (slab -> instances, pos, col, wingl -> cell_win -> cparam[14], 1.0);
867 }
868 }
869 }
870 const GLchar * vs_sls = (plot -> ray_tracing) ? sphere_vertex_ray : sphere_vertex;
871 const GLchar * fs_sls = (plot -> ray_tracing) ? full_color_ray : full_color;
872 wingl -> ogl_glsl[SLABS][0][0] = init_shader_program (SLABS, GLSL_SPHERES, vs_sls, NULL, fs_sls, GL_TRIANGLE_STRIP, 4, 1, TRUE, slab);
873 }
874 wingl -> cell_win -> slab_vol = (4.0*pi/3.0)*(pow(wingl -> cell_win -> cparam[14], 3));
875 vec3_t cat = vec3 (wingl -> cell_win -> cparam[6], wingl -> cell_win -> cparam[7], wingl -> cell_win -> cparam[8]);
876 for (i=0; i<proj_gl -> nspec; i++) wingl -> cell_win -> slab_lot[i] = 0;
877 wingl -> cell_win -> slab_atoms = 0;
878 atom slab_center;
879 distance at_slab;
880 slab_center.x = cat.x;
881 slab_center.y = cat.y;
882 slab_center.z = cat.z;
883 for (i=0; i<proj_gl->natomes; i++)
884 {
885 at_slab = distance_3d (cell_gl, (cell_gl -> npt) ? step : 0, & proj_gl -> atoms[0][i], & slab_center);
886 if (wingl -> cell_win -> slab_pbc || ! at_slab.pbc)
887 {
888 if (at_slab.length <= wingl -> cell_win -> cparam[14])
889 {
890 wingl -> cell_win -> slab_atoms ++;
891 j = proj_gl -> atoms[0][i].sp;
892 wingl -> cell_win -> slab_lot[j] ++;
893 if (wingl -> cell_win -> cut_this_slab) process_selected_atom (proj_gl, wingl, i, 0, 0, 0);
894 }
895 }
896 }
897}
898
906void create_slab_lists (project * this_proj)
907{
908 wingl = this_proj -> modelgl;
909 proj_gl = this_proj;
910 cell_gl = & proj_gl -> cell;
911 plot = wingl -> anim -> last -> img;
912 step = plot -> step;
913 box_gl = (cell_gl -> npt) ? & cell_gl -> box[step] : & cell_gl -> box[0];
915 if (wingl -> cell_win && (wingl -> cell_win -> slab_show || wingl -> cell_win -> cut_this_slab))
916 {
917 if (! wingl -> cell_win -> cut_this_slab)
918 {
919 wingl -> n_shaders[SLABS][0] = 1;
920 if (wingl -> cell_win -> slab_type == 1) wingl -> n_shaders[SLABS][0] ++;
921 wingl -> ogl_glsl[SLABS][0] = g_malloc0(wingl -> n_shaders[SLABS][0]*sizeof*wingl -> ogl_glsl[SLABS][0]);
922 nbs = nbl = 0;
923 }
924 mat4_t rot = m4_rotation_xyz (wingl -> cell_win -> cparam[18], wingl -> cell_win -> cparam[19], wingl -> cell_win -> cparam[20]);
925 switch (wingl -> cell_win -> slab_type)
926 {
927 case 0:
928 cuboid_slab (rot);
929 break;
930 case 1:
931 cylinder_slab (rot);
932 break;
933 case 2:
935 break;
936 }
937 if (! wingl -> cell_win -> cut_this_slab) create_slab_info (proj_gl);
938 }
939 wingl -> create_shaders[SLABS] = FALSE;
940}
941
948{
950 int i, j, k, l, m;
951 wingl -> n_shaders[VOLMS][step] = 0;
952 for (i=0; i<FILLED_STYLES; i++) if (plot -> show_vol[i]) wingl -> n_shaders[VOLMS][step] ++;
953 if (wingl -> adv_bonding[0])
954 {
955 for (i=0; i<FILLED_STYLES; i++)
956 {
957 if (plot -> fm_show_vol[0][i])
958 {
959 for (j=0; j<proj_gl -> coord -> totcoord[2]; j++) if (plot -> fm_show_vol[0][i][j]) wingl -> n_shaders[VOLMS][step] ++;
960 }
961 if (plot -> fm_show_vol[1][i])
962 {
963 for (j=0; j<proj_gl -> coord -> totcoord[3]; j++) if (plot -> fm_show_vol[1][i][j]) wingl -> n_shaders[VOLMS][step] += proj_gl -> modelfc -> mols[step][j].multiplicity;
964 }
965 }
966 }
967 if (wingl -> n_shaders[VOLMS][step])
968 {
969 wingl -> ogl_glsl[VOLMS][step] = g_malloc0(wingl -> n_shaders[VOLMS][step]*sizeof*wingl -> ogl_glsl[VOLMS][step]);
970 mat4_t rot;
971 vec3_t bx;
972 double paral[3][3];
973 m = 0;
974 if (wingl -> adv_bonding[1])
975 {
976 for (i=0; i<FILLED_STYLES; i++)
977 {
978 if (plot -> fm_show_vol[1][i])
979 {
980 for (j=0; j<proj_gl -> coord -> totcoord[3]; j++)
981 {
982 if (plot -> fm_show_vol[1][i][j])
983 {
984 for (k=0; k<proj_gl -> modelfc -> mols[step][j].multiplicity; k++)
985 {
986 l = proj_gl -> modelfc -> mols[step][j].fragments[k];
987 rot = m4_rotation_anti_xyz (wingl -> frag_box[i][step][l][3], wingl -> frag_box[i][step][l][4], wingl -> frag_box[i][step][l][5]);
988 paral[0][0] = wingl -> frag_box[i][step][l][0];
989 paral[0][1] = 0.0;
990 paral[0][2] = 0.0;
991 paral[1][0] = 0.0;
992 paral[1][1] = wingl -> frag_box[i][step][l][1];
993 paral[1][2] = 0.0;
994 paral[2][0] = 0.0;
995 paral[2][1] = 0.0;
996 paral[2][2] = wingl -> frag_box[i][step][l][2];
997 bx = m4_mul_coord (rot, vec3(wingl -> frag_box[i][step][l][6], wingl -> frag_box[i][step][l][7], wingl -> frag_box[i][step][l][8]));
998 draw_cuboid (TRUE, VOLMS, m, rot, bx, paral, plot -> fm_vol_col[1][i][j], plot -> fm_vol_col[1][i][j].alpha);
999 m ++;
1000 }
1001 }
1002 }
1003 }
1004 }
1005 }
1006 if (wingl -> adv_bonding[0])
1007 {
1008 for (i=0; i<FILLED_STYLES; i++)
1009 {
1010 if (plot -> fm_show_vol[0][i])
1011 {
1012 for (j=0; j<proj_gl -> coord -> totcoord[2]; j++)
1013 {
1014 if (plot -> fm_show_vol[0][i][j])
1015 {
1016 rot = m4_rotation_anti_xyz (wingl -> frag_box[i][step][j][3], wingl -> frag_box[i][step][j][4], wingl -> frag_box[i][step][j][5]);
1017 paral[0][0] = wingl -> frag_box[i][step][j][0];
1018 paral[0][1] = 0.0;
1019 paral[0][2] = 0.0;
1020 paral[1][0] = 0.0;
1021 paral[1][1] = wingl -> frag_box[i][step][j][1];
1022 paral[1][2] = 0.0;
1023 paral[2][0] = 0.0;
1024 paral[2][1] = 0.0;
1025 paral[2][2] = wingl -> frag_box[i][step][j][2];
1026 bx = m4_mul_coord (rot, vec3(wingl -> frag_box[i][step][j][6], wingl -> frag_box[i][step][j][7], wingl -> frag_box[i][step][j][8]));
1027 draw_cuboid (TRUE, VOLMS, m, rot, bx, paral, plot -> fm_vol_col[0][i][j], plot -> fm_vol_col[0][i][j].alpha);
1028 m ++;
1029 }
1030 }
1031 }
1032 }
1033 }
1034 for (i=0; i<FILLED_STYLES; i++)
1035 {
1036 if (plot -> show_vol[i])
1037 {
1038 rot = m4_rotation_anti_xyz (wingl -> volume_box[i][step][3], wingl -> volume_box[i][step][4], wingl -> volume_box[i][step][5]);
1039 paral[0][0] = wingl -> volume_box[i][step][0];
1040 paral[0][1] = 0.0;
1041 paral[0][2] = 0.0;
1042 paral[1][0] = 0.0;
1043 paral[1][1] = wingl -> volume_box[i][step][1];
1044 paral[1][2] = 0.0;
1045 paral[2][0] = 0.0;
1046 paral[2][1] = 0.0;
1047 paral[2][2] = wingl -> volume_box[i][step][2];
1048 bx = m4_mul_coord (rot, vec3(wingl -> volume_box[i][step][6], wingl -> volume_box[i][step][7], wingl -> volume_box[i][step][8]));
1049 draw_cuboid (TRUE, VOLMS, m, rot, bx, paral, plot -> vol_col[i], plot -> vol_col[i].alpha);
1050 m ++;
1051 }
1052 }
1053 }
1054 wingl -> create_shaders[VOLMS] = FALSE;
1055}
G_MODULE_EXPORT void cut_this_slab(GtkButton *but, gpointer data)
cut this slab callback
Definition cell_cut.c:488
double ax
Definition curve.c:71
int nbs
Definition d_atoms.c:165
object_3d * draw_billboard_quad()
create a camera-aligned billboard quad proxy for perfect impostors.
Definition d_atoms.c:273
int nbl
Definition d_atoms.c:165
ColRGBA pcol
Definition d_poly.c:60
void prepare_cuboid(vec3_t position, int id)
OpenGL 3D light object rendering.
Definition d_box.c:440
int create_box_lists(int b_step)
prepare box OpenGL rendering
Definition d_box.c:294
void setup_cap_vertice(float *vertices, vec3_t pos_a, vec3_t pos_b, ColRGBA col, float rad, float alpha, gboolean sel)
fill the OpenGL data buffer for a cylinder cap bond (or clone bond) to render
Definition d_bonds.c:336
object_3d * draw_billboard_quad(void)
create a camera-aligned billboard quad proxy for perfect impostors.
Definition d_atoms.c:273
object_3d * draw_sphere(int quality)
OpenGL 3D sphere object rendering.
Definition d_atoms.c:198
void setup_cylinder_vertice(float *vertices, vec3_t pos_a, vec3_t pos_b, ColRGBA col, float rad, float alpha, float delta, float r_sph_a, float r_sph_b)
fill the OpenGL data buffer for a cylinder bond (or clone bond) to render
Definition d_bonds.c:297
void create_slab_lists(project *this_proj)
prepare slab(s) OpenGL rendering
Definition d_box.c:906
void create_light_lists()
prepare light(s) OpenGL rendering
Definition d_box.c:473
double draw_cuboid(gboolean draw, int SHADID, int shadnum, mat4_t rot, vec3_t cpos, double paral[3][3], ColRGBA col, double slab_alpha)
draw cuboid vertices
Definition d_box.c:528
vec3_t get_normal(vec3_t v1, vec3_t v2, vec3_t v3)
Definition d_box.c:507
void setup_sphere_vertice(float *vertices, vec3_t pos, ColRGBA col, float rad, float alpha)
fill the OpenGL data buffer for a atom (or clone) to render
Definition d_atoms.c:345
void create_slab_info(project *this_proj)
create slab information widget
Definition cell_cut.c:109
gboolean not_in_corners(vec3_t a, float *vertices)
is this box cornder already saved ?
Definition d_box.c:136
void create_volumes_lists()
prepare volume(s) OpenGL rendering
Definition d_box.c:947
void setup_extra_box_vertices(vec3_t a, vec3_t b, float *c_vert, float *s_vert)
prepare the extra cell(s) OpenGL rendering
Definition d_box.c:162
void prepare_box_vertices(void(*c_func)(vec3_t, vec3_t, float *, float *), float *verts, float *serts)
prepare a box OpenGL rendering
Definition d_box.c:256
int BOX_BUFF_SIZE
Definition d_box.c:73
void cuboid_slab(mat4_t rot)
prepare cuboid slab OpenGL rendering
Definition d_box.c:606
void spherical_slab()
prepare spherical slab OpenGL rendering
Definition d_box.c:841
void process_selected_atom(project *this_proj, glwin *view, int id, int ac, int se, int pi)
process selected atom
Definition selection.c:514
void setup_line_vertice(float *vertices, vec3_t pos, ColRGBA col, float alpha)
fill the OpenGL data buffer for a line bond (or clone bond) to render
Definition d_bonds.c:269
object_3d * draw_cylinder_cap(int quality, float rad, gboolean picked)
OpenGL 3D cylinder cap object rendering.
Definition d_bonds.c:173
object_3d * draw_cylinder(int quality, float ra, float rb)
OpenGL 3D cylinder object rendering.
Definition d_bonds.c:102
void setup_box_vertices(vec3_t ax, vec3_t bx, float *c_vert, float *s_vert)
prepare the unit cell OpenGL rendering
Definition d_box.c:215
gboolean are_identical_vec3(vec3_t va, vec3_t vb)
are these 2 vectors indentical
Definition d_box.c:83
GLfloat cuboid_vertices[]
Definition d_box.c:387
gboolean not_in_already(vec3_t a, vec3_t b, float *vertices)
is this box edge vector already saved ?
Definition d_box.c:105
void cylinder_slab(mat4_t rot)
prepare cylinder slab OpenGL rendering
Definition d_box.c:735
ColRGBA col
Definition d_measures.c:77
int * shift
Definition d_measures.c:72
int atoms[NUM_STYLES][2]
GtkTreeSelection * sel
Definition datab.c:102
float val
Definition dlp_init.c:117
distance distance_3d(cell_info *cell, int mdstep, atom *at, atom *bt)
distance between atom a and b in 3D
Definition ogl_utils.c:81
double pi
Definition global.c:202
int * allocint(int val)
allocate an int * pointer
Definition global.c:301
float * allocfloat(int val)
allocate a float * pointer
Definition global.c:385
Global variable declarations Global convenience function declarations Global data structure defin...
#define max(a, b)
Definition global.h:92
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
image * plot
Definition ogl_draw.c:72
void draw(glwin *view)
main drawing subroutine for the OpenGL window
Definition ogl_draw.c:528
project * proj_gl
Definition ogl_draw.c:66
glwin * wingl
Definition ogl_draw.c:65
box_info * box_gl
Definition ogl_draw.c:70
void cleaning_shaders(glwin *view, int shader)
re-initialize an OpenGL shader
int step
Definition ogl_draw.c:76
glsl_program * init_shader_program(int object, int object_id, const GLchar *vertex, const GLchar *geometry, const GLchar *fragment, GLenum type_of_vertices, int narray, int nunif, gboolean lightning, object_3d *obj)
create an OpenGL shader program
cell_info * cell_gl
Definition ogl_draw.c:71
@ WIREFRAME
Definition glview.h:183
@ NONE
Definition glview.h:181
#define FILLED_STYLES
Definition glwin.h:106
shaders
The different types of shaders in the atomes program.
Definition glwin.h:88
@ VOLMS
Definition glwin.h:102
@ SLABS
Definition glwin.h:101
@ MDBOX
Definition glwin.h:93
@ LIGHT
Definition glwin.h:100
position
Definition m_proj.c:48
double z
Definition ogl_draw.c:63
double y
Definition ogl_draw.c:63
double x
Definition ogl_draw.c:63
const GLchar * full_color
const GLchar * cap_vertex_ray
const GLchar * cylinder_vertex
const GLchar * full_color_ray
const GLchar * cylinder_vertex_ray
const GLchar * full_vertex
const GLchar * line_color
Definition ogl_shaders.c:93
const GLchar * cap_vertex
const GLchar * line_vertex
Definition ogl_shaders.c:80
const GLchar * sphere_vertex
const GLchar * sphere_vertex_ray
void allocate_instances(object_3d *object)
allocate the instances buffer of a 3D object
#define LINE_BUFF_SIZE
Definition ogl_shading.h:50
#define ATOM_BUFF_SIZE
Definition ogl_shading.h:53
#define CAPS_BUFF_SIZE
Definition ogl_shading.h:52
#define POLY_BUFF_SIZE
Definition ogl_shading.h:49
#define CYLI_BUFF_SIZE
Definition ogl_shading.h:51
@ GLSL_CAPS
Definition ogl_shading.h:42
@ GLSL_LINES
Definition ogl_shading.h:40
@ GLSL_POLYEDRA
Definition ogl_shading.h:43
@ GLSL_SPHERES
Definition ogl_shading.h:39
@ GLSL_CYLINDERS
Definition ogl_shading.h:41
Definition global.h:964
double z
Definition global.h:970
double y
Definition global.h:969
double x
Definition global.h:968
Definition glwin.h:332
Definition glwin.h:350
double length
Definition glwin.h:124
double z
Definition glwin.h:127
double y
Definition glwin.h:126
gboolean pbc
Definition glwin.h:128
double x
Definition glwin.h:125
Definition glwin.h:967
float y
Definition math_3d.h:130
float x
Definition math_3d.h:130
float z
Definition math_3d.h:130
gchar * cpos[3]
Definition w_advance.c:133
GtkWidget * img
Definition workspace.c:70