atomes 1.1.16
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-2024 by CNRS and University of Strasbourg */
15
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 ();
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 void setup_line_vertice (float * vertices, vec3_t pos, ColRGBA col, float alpha);
65extern void setup_sphere_vertice (float * vertices, vec3_t pos, ColRGBA col, float rad, float alpha);
66extern void setup_cylinder_vertice (float * vertices, vec3_t pos_a, vec3_t pos_b, ColRGBA col, float rad, float alpha, float delta);
67extern void setup_cap_vertice (float * vertices, vec3_t pos_a, vec3_t pos_b, ColRGBA col, float rad, float alpha);
68extern void create_slab_info (project * this_proj);
69extern void process_selected_atom (project * this_proj, glwin * view, int id, int ac, int se, int pi);
70extern ColRGBA pcol;
71
73
83{
84
85 if (va.x == vb.x && va.y == vb.y && va.z == vb.z)
86 {
87 return TRUE;
88 }
89 else
90 {
91 return FALSE;
92 }
93}
94
104gboolean not_in_already (vec3_t a, vec3_t b, float * vertices)
105{
106 int i, j, k;
107 vec3_t tma, tmb;
108 for (i=0; i<nbs/2; i=i+2)
109 {
110 j = i*BOX_BUFF_SIZE;
111 k = j+BOX_BUFF_SIZE;
112 tma = vec3(vertices[j], vertices[j+1], vertices[j+2]);
113 tmb = vec3(vertices[k], vertices[k+1], vertices[k+2]);
114 if (are_identical_vec3(a, tma) && are_identical_vec3(b, tmb))
115 {
116 return FALSE;
117 }
118 else if (are_identical_vec3(b, tma) && are_identical_vec3(a, tmb))
119 {
120 return FALSE;
121 }
122 }
123 return TRUE;
124}
125
134gboolean not_in_corners (vec3_t a, float * vertices)
135{
136 int i, j;
137 vec3_t tma;
138 for (i=0; i<nbl; i++)
139 {
140 j = i*8;
141 tma = vec3(vertices[j], vertices[j+1], vertices[j+2]);
142 if (are_identical_vec3(a, tma))
143 {
144 return FALSE;
145 }
146 }
147 return TRUE;
148}
149
160void setup_extra_box_vertices (vec3_t a, vec3_t b, float * c_vert, float * s_vert)
161{
162 float j;
163 int p, q, r;
165 vec3_t t_a, t_b;
166 for (j=-1.0; j<2.0; j=j+2.0)
167 {
168 for (p=0; p<plot -> extra_cell[0]+1; p++)
169 {
170 for (q=0; q<plot -> extra_cell[1]+1; q++)
171 {
172 for (r=0; r<plot -> extra_cell[2]+1; r++)
173 {
174 if (p > 0 || q > 0 || r > 0)
175 {
176 shift.x = p*box_gl -> vect[0][0]+q*box_gl -> vect[1][0]+r*box_gl -> vect[2][0];
177 shift.y = p*box_gl -> vect[0][1]+q*box_gl -> vect[1][1]+r*box_gl -> vect[2][1];
178 shift.z = p*box_gl -> vect[0][2]+q*box_gl -> vect[1][2]+r*box_gl -> vect[2][2];
179
180 t_a = v3_add (v3_muls (a, j), shift);
181 t_b = v3_add (v3_muls (b, j), shift);
182 if (not_in_already (t_a, t_b, c_vert))
183 {
184 if (plot -> box_axis[BOX] == WIREFRAME)
185 {
186 setup_line_vertice (c_vert, t_a, pcol, 0.5);
187 setup_line_vertice (c_vert, t_b, pcol, 0.5);
188 }
189 else
190 {
191 if (not_in_corners(t_a, s_vert)) setup_sphere_vertice (s_vert, t_a, pcol, plot -> box_axis_rad[BOX], pcol.alpha*0.5);
192 if (not_in_corners(t_b, s_vert)) setup_sphere_vertice (s_vert, t_b, pcol, plot -> box_axis_rad[BOX], pcol.alpha*0.5);
193 setup_cylinder_vertice (c_vert, t_a, t_b, pcol, plot -> box_axis_rad[BOX], 0.5, 0.0);
194 }
195 }
196 }
197 }
198 }
199 }
200 }
201}
202
213void setup_box_vertices (vec3_t ax, vec3_t bx, float * c_vert, float * s_vert)
214{
215 float j;
216 vec3_t a, b;
217 /*vec3_t cell[3];
218 int i;
219 for (i=0; i<3; i++)
220 {
221 cell[i] = vec3(box_gl -> vect[i][0], box_gl -> vect[i][1], box_gl -> vect[i][2]);
222 cell[i] = v3_divs (cell[i], 2.0);
223 }
224 vec3_t lattice = v3_add(v3_add(cell[0], cell[1]), cell[2]);*/
225 for (j=-1.0; j<2.0; j=j+2.0)
226 {
227 /*a = v3_sub (v3_muls (ax, j), lattice);
228 b = v3_sub (v3_muls (bx, j), lattice);*/
229 a = v3_muls (ax, j);
230 b = v3_muls (bx, j);
231 if (plot -> box_axis[BOX] == WIREFRAME)
232 {
233 setup_line_vertice (c_vert, a, pcol, 1.0);
234 setup_line_vertice (c_vert, b, pcol, 1.0);
235 }
236 else
237 {
238 if (not_in_corners(a, s_vert)) setup_sphere_vertice (s_vert, a, pcol, plot -> box_axis_rad[BOX], pcol.alpha*1.0);
239 if (not_in_corners(b, s_vert)) setup_sphere_vertice (s_vert, b, pcol, plot -> box_axis_rad[BOX], pcol.alpha*1.0);
240 setup_cylinder_vertice (c_vert, a, b, pcol, plot -> box_axis_rad[BOX], 1.0, 0.0);
241 }
242 }
243}
244
254void prepare_box_vertices (void (*c_func)(vec3_t, vec3_t, float *, float *), float * verts, float * serts)
255{
256 int i;
257 vec3_t pa, pb;
258
259 for (i=-1; i<2; i=i+2)
260 {
261 pa.x = (- box_gl -> vect[0][0] - box_gl -> vect[1][0] + i * box_gl -> vect[2][0]) / 2.0;
262 pa.y = (- box_gl -> vect[0][1] - box_gl -> vect[1][1] + i * box_gl -> vect[2][1]) / 2.0;
263 pa.z = (- box_gl -> vect[0][2] - box_gl -> vect[1][2] + i * box_gl -> vect[2][2]) / 2.0;
264 pb.x = (box_gl -> vect[0][0] - box_gl -> vect[1][0] + i * box_gl -> vect[2][0]) / 2.0;
265 pb.y = (box_gl -> vect[0][1] - box_gl -> vect[1][1] + i * box_gl -> vect[2][1]) / 2.0;
266 pb.z = (box_gl -> vect[0][2] - box_gl -> vect[1][2] + i * box_gl -> vect[2][2]) / 2.0;
267 (* c_func)(pa, pb, verts, serts);
268 pa.x = (i * box_gl -> vect[0][0] - box_gl -> vect[1][0] + box_gl -> vect[2][0]) / 2.0;
269 pa.y = (i * box_gl -> vect[0][1] - box_gl -> vect[1][1] + box_gl -> vect[2][1]) / 2.0;
270 pa.z = (i * box_gl -> vect[0][2] - box_gl -> vect[1][2] + box_gl -> vect[2][2]) / 2.0;
271 pb.x = (i * box_gl -> vect[0][0] - box_gl -> vect[1][0] - box_gl -> vect[2][0]) / 2.0;
272 pb.y = (i * box_gl -> vect[0][1] - box_gl -> vect[1][1] - box_gl -> vect[2][1]) / 2.0;
273 pb.z = (i * box_gl -> vect[0][2] - box_gl -> vect[1][2] - box_gl -> vect[2][2]) / 2.0;
274 (* c_func)(pa, pb, verts, serts);
275 pa.x = (i * box_gl -> vect[0][0] + box_gl -> vect[1][0] + box_gl -> vect[2][0]) / 2.0;
276 pa.y = (i * box_gl -> vect[0][1] + box_gl -> vect[1][1] + box_gl -> vect[2][1]) / 2.0;
277 pa.z = (i * box_gl -> vect[0][2] + box_gl -> vect[1][2] + box_gl -> vect[2][2]) / 2.0;
278 pb.x = (i * box_gl -> vect[0][0] - box_gl -> vect[1][0] + box_gl -> vect[2][0]) / 2.0;
279 pb.y = (i * box_gl -> vect[0][1] - box_gl -> vect[1][1] + box_gl -> vect[2][1]) / 2.0;
280 pb.z = (i * box_gl -> vect[0][2] - box_gl -> vect[1][2] + box_gl -> vect[2][2]) / 2.0;
281 (* c_func)(pa, pb, verts, serts);
282 }
283}
284
291{
292 int vertex = 8;
293 object_3d * box_a, * box_b;
294
296 wingl -> create_shaders[MDBOX] = FALSE;
297
298 if (plot -> box_axis[BOX] == NONE) return 0;
299
300 int shaders;
301 vertex *= (plot -> extra_cell[0]+1)*(plot -> extra_cell[1]+1)*(plot -> extra_cell[2]+1);
302
303 if (plot -> box_axis[BOX] == WIREFRAME)
304 {
305 shaders = 1;
307 box_b = g_malloc0 (sizeof*box_b);
308 box_b -> vert_buffer_size = LINE_BUFF_SIZE;
309 box_b -> num_vertices = vertex*3;
310 box_b -> vertices = allocfloat (box_b -> vert_buffer_size*box_b -> num_vertices);
311 }
312 else
313 {
314 shaders = 2;
316 // Spheres at corners
317 box_a = draw_sphere (plot -> quality);
318 box_a -> num_instances = 3*vertex*3/2;
319 box_a -> inst_buffer_size = ATOM_BUFF_SIZE;
320 box_a -> instances = allocfloat (box_a -> num_instances*ATOM_BUFF_SIZE);
321 // Cylinders
322 box_b = draw_cylinder (plot -> quality, 1.0, 1.0);
323 box_b -> num_instances = 3*vertex;
324 box_b -> inst_buffer_size = CYLI_BUFF_SIZE;
325 box_b -> instances = allocfloat (box_b -> num_instances*CYLI_BUFF_SIZE);
326
327 }
328 wingl -> ogl_glsl[MDBOX][0] = g_malloc0 (shaders*sizeof*wingl -> ogl_glsl[MDBOX][0]);
329
330 nbs = nbl = 0;
331 pcol = plot -> box_color;
332
334 (plot -> box_axis[BOX] == WIREFRAME) ? box_b -> vertices: box_b -> instances,
335 (plot -> box_axis[BOX] == WIREFRAME) ? NULL : box_a -> instances);
336 if (plot -> extra_cell[0] > 0 || plot -> extra_cell[1] > 0 || plot -> extra_cell[2] > 0)
337 {
338 prepare_box_vertices (setup_extra_box_vertices, (plot -> box_axis[BOX] == WIREFRAME) ? box_b -> vertices: box_b -> instances,
339 (plot -> box_axis[BOX] == WIREFRAME) ? NULL : box_a -> instances);
340 }
341 if (plot -> box_axis[BOX] == WIREFRAME)
342 {
343 wingl -> ogl_glsl[MDBOX][0][0] = init_shader_program (MDBOX, GLSL_LINES, line_vertex, NULL, line_color, GL_LINES, 2, 1, FALSE, box_b);
344 wingl -> ogl_glsl[MDBOX][0][0] -> line_width = plot -> box_axis_line[BOX];
345 }
346 else
347 {
348 // Sphere at corners
349 wingl -> ogl_glsl[MDBOX][0][0] = init_shader_program (MDBOX, GLSL_SPHERES, sphere_vertex, NULL, full_color, GL_TRIANGLE_STRIP, 4, 1, TRUE, box_a);
350 g_free (box_a);
351 // Cylinders
352 wingl -> ogl_glsl[MDBOX][0][1] = init_shader_program (MDBOX, GLSL_CYLINDERS, cylinder_vertex, NULL, full_color, GL_TRIANGLE_STRIP, 6, 1, TRUE, box_b);
353 }
354 g_free (box_b);
355
356 return shaders;
357}
358
359/*vec3_t center;
360
361/ *
362* void setup_cuboid_vertices (vec3_t a, vec3_t b, int id)
363
364 \brief NOT USED !
365
366 \param a
367 \param b
368 \param id
369* /
370void setup_cuboid_vertices (vec3_t a, vec3_t b, int id)
371{
372 float j;
373 for (j=-1.0; j<2.0; j=j+2.0)
374 {
375 box_axis_vertices (wingl -> d_vertices[LIGHT][id], -1, 0.0, v3_muls (v3_add(a,center), j));
376 box_axis_vertices (wingl -> d_vertices[LIGHT][id], -1, 0.0, v3_muls (v3_add(b,center), j));
377 }
378}*/
379
380GLfloat cuboid_vertices[] = {
381 // Positions // Normals
382 -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f,
383 1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f,
384 1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f,
385 1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f,
386 -1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f,
387 -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f,
388
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, -1.0f, 0.0f, 0.0f,
397 -1.0f, 1.0f, -1.0f, -1.0f, 0.0f, 0.0f,
398 -1.0f, -1.0f, -1.0f, -1.0f, 0.0f, 0.0f,
399 -1.0f, -1.0f, -1.0f, -1.0f, 0.0f, 0.0f,
400 -1.0f, -1.0f, 1.0f, -1.0f, 0.0f, 0.0f,
401 -1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 0.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, 0.0f, -1.0f, 0.0f,
411 1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f,
412 1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f,
413 1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f,
414 -1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f,
415 -1.0f, -1.0f, -1.0f, 0.0f, -1.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
434{
435 float lgt = 1.0;
436 object_3d * light = g_malloc0 (sizeof*light);
437 light -> vert_buffer_size = POLY_BUFF_SIZE;
438 light -> num_vertices = 36;
439 light -> vertices = allocfloat (light -> vert_buffer_size*light -> num_vertices);
440 int i, j, k, l;
441 l = 0;
442 for (i=0; i<36; i++)
443 {
444 j = 10*l;
445 k = 6*l;
446 light -> vertices[j] = lgt*cuboid_vertices[k]*0.5 + position.x;
447 light -> vertices[j+1] = lgt*cuboid_vertices[k+1]*0.5 + position.y;
448 light -> vertices[j+2] = lgt*cuboid_vertices[k+2]*0.5 + position.z;
449 light -> vertices[j+3] = cuboid_vertices[k+3];
450 light -> vertices[j+4] = cuboid_vertices[k+4];
451 light -> vertices[j+5] = cuboid_vertices[k+5];
452 light -> vertices[j+6] = 1.0;
453 light -> vertices[j+7] = 1.0;
454 light -> vertices[j+8] = 1.0;
455 light -> vertices[j+9] = 1.0;
456 l ++;
457 }
458 wingl -> ogl_glsl[LIGHT][0][id] = init_shader_program (LIGHT, GLSL_POLYEDRA, full_vertex, NULL, full_color, GL_TRIANGLES, 3, 1, FALSE, light);
459 g_free (light);
460}
461
468{
469 int i, j;
470 j = 0;
472 for (i=0; i<plot -> lights; i++)
473 {
474 if (plot -> l_ght[i].show) j++;
475 }
476 wingl -> n_shaders[LIGHT][0] = j;
477 if (plot -> light_loc != NULL)
478 {
479 g_free (plot -> light_loc);
480 plot -> light_loc = NULL;
481 }
482
483 if (j > 0)
484 {
485 wingl -> ogl_glsl[LIGHT][0] = g_malloc0 (wingl -> n_shaders[LIGHT][0]*sizeof*wingl -> ogl_glsl[LIGHT][0]);
486 plot -> light_loc = allocint (j);
487 j = 0;
488 for (i=0; i<plot -> lights; i++)
489 {
490 if (plot -> l_ght[i].show)
491 {
492 prepare_cuboid (plot -> l_ght[i].position, j);
493 if (plot -> l_ght[i].type > 0 && plot -> l_ght[i].fix == 0) plot -> light_loc[j] = 1;
494 j ++;
495 }
496 }
497 }
498 wingl -> create_shaders[LIGHT] = FALSE;
499}
500
502{
503 vec3_t edge_a = v3_sub(v3, v1);
504 vec3_t edge_b = v3_sub(v2, v1);
505 return v3_norm (v3_cross(edge_a, edge_b));
506}
507
508
523double draw_cuboid (gboolean draw, int SHADID, int shadnum, mat4_t rot, vec3_t cpos, double paral[3][3], ColRGBA col, double slab_alpha)
524{
525 int i, j, k, l, m, n, o;
526 vec3_t pos;
527 double cvol;
528 double shift[3];
529 cvol = (paral[0][1]*paral[1][2]-paral[0][2]*paral[1][1])*paral[2][0];
530 cvol += (paral[0][2]*paral[1][0]-paral[0][0]*paral[1][2])*paral[2][1];
531 cvol += (paral[0][0]*paral[1][1]-paral[0][1]*paral[1][0])*paral[2][2];
532 cvol = fabs(cvol);
533 if (draw)
534 {
535 object_3d * slab = g_malloc0 (sizeof*slab);
536 slab -> vert_buffer_size = POLY_BUFF_SIZE;
537 slab -> num_vertices = 36*(plot -> extra_cell[0]+1)*(plot -> extra_cell[1]+1)*(plot -> extra_cell[2]+1);
538 slab -> vertices = allocfloat (slab -> vert_buffer_size*slab -> num_vertices);
539 for (i=0; i<36; i++)
540 {
541 j = i*POLY_BUFF_SIZE;
542 k = 6*i;
543 for (l=0; l<3; l++)
544 {
545 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]);
546 }
547 pos = vec3 (slab -> vertices[j], slab -> vertices[j+1], slab -> vertices[j+2]);
548 pos = m4_mul_pos (rot, pos);
549 slab -> vertices[j] = pos.x + cpos.x;
550 slab -> vertices[j+1] = pos.y + cpos.y;
551 slab -> vertices[j+2] = pos.z + cpos.z;
552 }
553 n = 0;
554 for (i=0; i<plot -> extra_cell[0]+1; i++)
555 {
556 for (j=0; j<plot -> extra_cell[1]+1; j++)
557 {
558 for (k=0; k<plot -> extra_cell[2]+1; k++)
559 {
560 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];
561 for (l=0; l<36; l++)
562 {
563 m = POLY_BUFF_SIZE*n;
564 for (o=0; o<3; o++)
565 {
566 slab -> vertices[m+o] = slab -> vertices[l*POLY_BUFF_SIZE+o] + shift[o];
567 if (SHADID == SLABS)
568 {
569 slab -> vertices[m+6+o] = (o) ? 1.0 : 0.0;
570 }
571 else
572 {
573 if (! o) slab -> vertices[m+6+o] = col.red;
574 if (o == 1) slab -> vertices[m+6+o] = col.green;
575 if (o == 2) slab -> vertices[m+6+o] = col.blue;
576 }
577 }
578 pos = vec3 (cuboid_vertices[6*l+3], cuboid_vertices[6*l+4], cuboid_vertices[6*l+5]);
579 pos = m4_mul_pos (rot, pos);
580 slab -> vertices[m+3] = pos.x;
581 slab -> vertices[m+4] = pos.y;
582 slab -> vertices[m+5] = pos.z;
583 slab -> vertices[m+9] = slab_alpha;
584 n ++;
585 }
586 }
587 }
588 }
589 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);
590 g_free (slab);
591 }
592 return cvol;
593}
594
603{
604 int i, j, k, l, m;
605 double ang[3], cang[3], sang[3];
606 double paral[3][3];
607 double tmp;
608 for (i=0; i<3; i++)
609 {
610 if (wingl -> cell_win -> cparam[i+15] == 90.0)
611 {
612 ang[i] = pi/2.0;
613 sang[i] = 1.0;
614 cang[i] = 0.0;
615 }
616 else
617 {
618 ang[i] = wingl -> cell_win -> cparam[i+15]*pi/180.0;
619 sang[i] = sin(ang[i]);
620 cang[i] = cos(ang[i]);
621 }
622 }
623 paral[0][0] = wingl -> cell_win -> cparam[9];
624 paral[0][1] = 0.0;
625 paral[0][2] = 0.0;
626 paral[1][0] = wingl -> cell_win -> cparam[10] * cang[2];
627 paral[1][1] = wingl -> cell_win -> cparam[10] * sang[2];
628 paral[1][2] = 0.0;
629 paral[2][0] = wingl -> cell_win -> cparam[11] * cang[1];
630 tmp = (cang[0] - cang[1]*cang[2]) / sang[2];
631 paral[2][1] = wingl -> cell_win -> cparam[11] * tmp;
632 paral[2][2] = wingl -> cell_win -> cparam[11] * sqrt(sang[1]*sang[1] - tmp*tmp);
633 ColRGBA null; // Not used
634 wingl -> cell_win -> slab_vol = draw_cuboid (! wingl -> cell_win -> cut_this_slab, SLABS, 0, rot,
635 vec3(wingl -> cell_win -> cparam[6], wingl -> cell_win -> cparam[7], wingl -> cell_win -> cparam[8]),
636 paral, null, wingl -> cell_win -> slab_alpha);
637
638 vec3_t at, atc;
639 vec3_t ps[8];
640 vec3_t pn[6];
641 vec3_t cat = vec3(wingl -> cell_win -> cparam[6], wingl -> cell_win -> cparam[7], wingl -> cell_win -> cparam[8]);
642 l = 0;
643 float pmax[3];
644
645 for (i=-1; i<2; i+=2)
646 {
647 for (j=-1; j<2; j+=2)
648 {
649 for (k=-1; k<2; k+=2)
650 {
651 ps[l].x = 0.5*(i*paral[0][0] + j*paral[1][0] + k*paral[2][0]);
652 ps[l].y = 0.5*(i*paral[0][1] + j*paral[1][1] + k*paral[2][1]);
653 ps[l].z = 0.5*(i*paral[0][2] + j*paral[1][2] + k*paral[2][2]);
654 ps[l] = m4_mul_pos (rot, ps[l]);
655 ps[l]= v3_add (ps[l], cat);
656 if (l == 0)
657 {
658 pmax[0] = ps[l].x;
659 pmax[1] = ps[l].y;
660 pmax[2] = ps[l].z;
661 }
662 else
663 {
664 pmax[0] = max(pmax[0],ps[l].x);
665 pmax[1] = max(pmax[1],ps[l].y);
666 pmax[2] = max(pmax[2],ps[l].z);
667 }
668 l ++;
669 }
670 }
671 }
672
673 pn[0] = get_normal (ps[1], ps[0], ps[2]);
674 pn[1] = get_normal (ps[1], ps[0], ps[4]);
675 pn[2] = get_normal (ps[2], ps[0], ps[4]);
676 pn[3] = get_normal (ps[3], ps[7], ps[5]);
677 pn[4] = get_normal (ps[3], ps[7], ps[6]);
678 pn[5] = get_normal (ps[5], ps[7], ps[6]);
679
680 ps[0] = v3_sub (ps[0], cat);
681 ps[7] = v3_sub (ps[7], cat);
682
683 for (i=0; i<proj_gl -> nspec; i++) wingl -> cell_win -> slab_lot[i] = 0;
684 wingl -> cell_win -> slab_atoms = 0;
685 float val, vbl;
686 atom slab_center;
687 distance at_slab;
688 slab_center.x = cat.x;
689 slab_center.y = cat.y;
690 slab_center.z = cat.z;
691 for (i=0; i<proj_gl->natomes; i++)
692 {
693 at_slab = distance_3d (cell_gl, (cell_gl -> npt) ? step : 0, & proj_gl -> atoms[0][i], & slab_center);
694 at = vec3(slab_center.x+at_slab.x, slab_center.y+at_slab.y, slab_center.z+at_slab.z);
695 if (at.x <= pmax[0] && at.y <= pmax[1] && at.z <= pmax[2])
696 {
697 m = 0;
698 atc = v3_sub (at, cat);
699 for (j=0; j<6; j++)
700 {
701 k = (j < 3) ? 0 : 7;
702 val = v3_dot (ps[k], pn[j]);
703 vbl = v3_dot (atc, pn[j]);
704 if (fabs(vbl) < fabs(val))
705 {
706 m ++;
707 }
708 else
709 {
710 break;
711 }
712 }
713 if (m == 6 && (! at_slab.pbc || wingl -> cell_win -> slab_pbc))
714 {
715 wingl -> cell_win -> slab_atoms ++;
716 l = proj_gl -> atoms[0][i].sp;
717 wingl -> cell_win -> slab_lot[l] ++;
718 if (wingl -> cell_win -> cut_this_slab) process_selected_atom (proj_gl, wingl, i, 0, 0, 0);
719 }
720 }
721 }
722}
723
732{
733 int i, j, k;
734 vec3_t pos_a = vec3(-wingl -> cell_win -> cparam[12]/2.0, 0.0, 0.0);
735 vec3_t pos_b = vec3( wingl -> cell_win -> cparam[12]/2.0, 0.0, 0.0);
736 pos_a = m4_mul_pos (rot, pos_a);
737 pos_b = m4_mul_pos (rot, pos_b);
738 vec3_t cat = vec3 (wingl -> cell_win -> cparam[6], wingl -> cell_win -> cparam[7], wingl -> cell_win -> cparam[8]);
739 pos_a = v3_add (pos_a, cat);
740 pos_b = v3_add (pos_b, cat);
741 vec3_t axis = v3_sub (pos_b, pos_a);
742 if (! wingl -> cell_win -> cut_this_slab)
743 {
744 object_3d * slab = g_malloc0 (sizeof*slab);
745 object_3d * slab_cap = g_malloc0 (sizeof*slab_cap);
746 slab = draw_cylinder (30, 1.0, 1.0);
747 slab -> num_instances = (plot -> extra_cell[0]+1)*(plot -> extra_cell[1]+1)*(plot -> extra_cell[2]+1);
748 slab -> inst_buffer_size = CYLI_BUFF_SIZE;
749 slab -> instances = allocfloat (slab -> num_instances*CYLI_BUFF_SIZE);
750 slab_cap = draw_cylinder_cap (50, 1.0, FALSE);
751 slab_cap -> num_instances = 2 * slab -> num_instances;
752 slab_cap -> inst_buffer_size = CAPS_BUFF_SIZE;
753 slab_cap -> instances = allocfloat (slab_cap -> num_instances*CAPS_BUFF_SIZE);
754 ColRGBA col;
755 col.red = 0.0;
756 col.blue = 1.0;
757 col.green = 1.0;
758 col.alpha = wingl -> cell_win -> slab_alpha;
760 for (i=0; i<plot -> extra_cell[0]+1; i++)
761 {
762 for (j=0; j<plot -> extra_cell[1]+1; j++)
763 {
764 for (k=0; k<plot -> extra_cell[2]+1; k++)
765 {
766 shift.x = i*box_gl -> vect[0][0]+j*box_gl -> vect[1][0]+k*box_gl -> vect[2][0];
767 shift.y = i*box_gl -> vect[0][1]+j*box_gl -> vect[1][1]+k*box_gl -> vect[2][1];
768 shift.z = i*box_gl -> vect[0][2]+j*box_gl -> vect[1][2]+k*box_gl -> vect[2][2];
769 pos_a = v3_add (pos_a, shift);
770 pos_b = v3_add (pos_b, shift);
771 setup_cylinder_vertice (slab -> instances, pos_a, pos_b, col, wingl -> cell_win -> cparam[13], 1.0, 0.0);
772 pos_a = v3_sub (pos_a, shift);
773 pos_b = v3_sub (pos_b, shift);
774 }
775 }
776 }
777 wingl -> ogl_glsl[SLABS][0][0] = init_shader_program (SLABS, GLSL_CYLINDERS, cylinder_vertex, NULL, full_color, GL_TRIANGLE_STRIP, 6, 1, TRUE, slab);
778 g_free (slab);
779 nbs = 0;
780 for (i=0; i<plot -> extra_cell[0]+1; i++)
781 {
782 for (j=0; j<plot -> extra_cell[1]+1; j++)
783 {
784 for (k=0; k<plot -> extra_cell[2]+1; k++)
785 {
786 shift.x = i*box_gl -> vect[0][0]+j*box_gl -> vect[1][0]+k*box_gl -> vect[2][0];
787 shift.y = i*box_gl -> vect[0][1]+j*box_gl -> vect[1][1]+k*box_gl -> vect[2][1];
788 shift.z = i*box_gl -> vect[0][2]+j*box_gl -> vect[1][2]+k*box_gl -> vect[2][2];
789 pos_a = v3_add (pos_a, shift);
790 pos_b = v3_add (pos_b, shift);
791 setup_cap_vertice (slab_cap -> instances, pos_a, pos_b, col, wingl -> cell_win -> cparam[13], 1.0);
792 setup_cap_vertice (slab_cap -> instances, pos_b, pos_a, col, wingl -> cell_win -> cparam[13], 1.0);
793 pos_a = v3_sub (pos_a, shift);
794 pos_b = v3_sub (pos_b, shift);
795 }
796 }
797 }
798 wingl -> ogl_glsl[SLABS][0][1] = init_shader_program (SLABS, GLSL_CAPS, cap_vertex, NULL, full_color, GL_TRIANGLE_FAN, 5, 1, TRUE, slab_cap);
799 g_free (slab_cap);
800 }
801 wingl -> cell_win -> slab_vol = pi*pow(wingl -> cell_win -> cparam[13], 2)*wingl -> cell_win -> cparam[12];
802 for (i=0; i<proj_gl -> nspec; i++) wingl -> cell_win -> slab_lot[i] = 0;
803 wingl -> cell_win -> slab_atoms = 0;
804 vec3_t atc, patc;
805 atom slab_center;
806 distance at_slab;
807 slab_center.x = cat.x;
808 slab_center.y = cat.y;
809 slab_center.z = cat.z;
810 for (i=0; i<proj_gl->natomes; i++)
811 {
812 atc = vec3(proj_gl -> atoms[0][i].x, proj_gl -> atoms[0][i].y, proj_gl -> atoms[0][i].z);
813 at_slab = distance_3d (cell_gl, (cell_gl -> npt) ? step : 0, & proj_gl -> atoms[0][i], & slab_center);
814 if (wingl -> cell_win -> slab_pbc || ! at_slab.pbc)
815 {
816 atc = vec3(at_slab.x, at_slab.y, at_slab.z);
817 patc = v3_proj (atc, axis);
818 if (v3_length(patc) <= wingl -> cell_win -> cparam[12]/2.0 && v3_length(v3_sub(patc,atc)) <= wingl -> cell_win -> cparam[13])
819 {
820 wingl -> cell_win -> slab_atoms ++;
821 j = proj_gl -> atoms[0][i].sp;
822 wingl -> cell_win -> slab_lot[j] ++;
823 if (wingl -> cell_win -> cut_this_slab) process_selected_atom (proj_gl, wingl, i, 0, 0, 0);
824 }
825 }
826 }
827}
828
835{
836 int i, j, k, l;
837 vec3_t pos;
838 if (! wingl -> cell_win -> cut_this_slab)
839 {
840 object_3d * slab = g_malloc0 (sizeof*slab);
841 slab = draw_sphere (50);
842 slab -> inst_buffer_size = ATOM_BUFF_SIZE;
843 slab -> num_instances = (plot -> extra_cell[0]+1)*(plot -> extra_cell[1]+1)*(plot -> extra_cell[2]+1);
844 slab -> instances = allocfloat (slab -> num_instances*ATOM_BUFF_SIZE);
845 ColRGBA col;
846 col.red = 0.0;
847 col.blue = 1.0;
848 col.green = 1.0;
849 col.alpha = wingl -> cell_win -> slab_alpha;
850 double shift[3];
851 for (i=0; i<plot -> extra_cell[0]+1; i++)
852 {
853 for (j=0; j<plot -> extra_cell[1]+1; j++)
854 {
855 for (k=0; k<plot -> extra_cell[2]+1; k++)
856 {
857 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];
858 pos = vec3(shift[0], shift[1], shift[2]);
859 setup_sphere_vertice (slab -> instances, pos, col, wingl -> cell_win -> cparam[14], 1.0);
860 }
861 }
862 }
863 wingl -> ogl_glsl[SLABS][0][0] = init_shader_program (SLABS, GLSL_SPHERES, sphere_vertex, NULL, full_color, GL_TRIANGLE_STRIP, 4, 1, TRUE, slab);
864 g_free (slab);
865 }
866 wingl -> cell_win -> slab_vol = (4.0*pi/3.0)*(pow(wingl -> cell_win -> cparam[14], 3));
867 vec3_t cat = vec3 (wingl -> cell_win -> cparam[6], wingl -> cell_win -> cparam[7], wingl -> cell_win -> cparam[8]);
868 for (i=0; i<proj_gl -> nspec; i++) wingl -> cell_win -> slab_lot[i] = 0;
869 wingl -> cell_win -> slab_atoms = 0;
870 atom slab_center;
871 distance at_slab;
872 slab_center.x = cat.x;
873 slab_center.y = cat.y;
874 slab_center.z = cat.z;
875 for (i=0; i<proj_gl->natomes; i++)
876 {
877 at_slab = distance_3d (cell_gl, (cell_gl -> npt) ? step : 0, & proj_gl -> atoms[0][i], & slab_center);
878 if (wingl -> cell_win -> slab_pbc || ! at_slab.pbc)
879 {
880 if (at_slab.length <= wingl -> cell_win -> cparam[14])
881 {
882 wingl -> cell_win -> slab_atoms ++;
883 j = proj_gl -> atoms[0][i].sp;
884 wingl -> cell_win -> slab_lot[j] ++;
885 if (wingl -> cell_win -> cut_this_slab) process_selected_atom (proj_gl, wingl, i, 0, 0, 0);
886 }
887 }
888 }
889}
890
898void create_slab_lists (project * this_proj)
899{
900 wingl = this_proj -> modelgl;
901 proj_gl = this_proj;
902 cell_gl = & proj_gl -> cell;
903 plot = wingl -> anim -> last -> img;
904 step = plot -> step;
905 box_gl = (cell_gl -> npt) ? & cell_gl -> box[step] : & cell_gl -> box[0];
907 if (wingl -> cell_win && (wingl -> cell_win -> slab_show || wingl -> cell_win -> cut_this_slab))
908 {
909 if (! wingl -> cell_win -> cut_this_slab)
910 {
911 wingl -> n_shaders[SLABS][0] = 1;
912 if (wingl -> cell_win -> slab_type == 1) wingl -> n_shaders[SLABS][0] ++;
913 wingl -> ogl_glsl[SLABS][0] = g_malloc0 (wingl -> n_shaders[SLABS][0]*sizeof*wingl -> ogl_glsl[SLABS][0]);
914 nbs = nbl = 0;
915 }
916 mat4_t rot = m4_rotation_xyz (wingl -> cell_win -> cparam[18], wingl -> cell_win -> cparam[19], wingl -> cell_win -> cparam[20]);
917 switch (wingl -> cell_win -> slab_type)
918 {
919 case 0:
920 cuboid_slab (rot);
921 break;
922 case 1:
923 cylinder_slab (rot);
924 break;
925 case 2:
927 break;
928 }
929 if (! wingl -> cell_win -> cut_this_slab) create_slab_info (proj_gl);
930 }
931 wingl -> create_shaders[SLABS] = FALSE;
932}
933
940{
942 int i, j, k, l, m;
943 wingl -> n_shaders[VOLMS][step] = 0;
944 for (i=0; i<FILLED_STYLES; i++) if (plot -> show_vol[i]) wingl -> n_shaders[VOLMS][step] ++;
945 if (wingl -> adv_bonding[0])
946 {
947 for (i=0; i<FILLED_STYLES; i++)
948 {
949 if (plot -> fm_show_vol[0][i])
950 {
951 for (j=0; j<proj_gl -> coord -> totcoord[2]; j++) if (plot -> fm_show_vol[0][i][j]) wingl -> n_shaders[VOLMS][step] ++;
952 }
953 if (plot -> fm_show_vol[1][i])
954 {
955 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;
956 }
957 }
958 }
959 if (wingl -> n_shaders[VOLMS][step])
960 {
961 wingl -> ogl_glsl[VOLMS][step] = g_malloc0 (wingl -> n_shaders[VOLMS][step]*sizeof*wingl -> ogl_glsl[VOLMS][step]);
962 mat4_t rot;
963 vec3_t bx;
964 double paral[3][3];
965 m = 0;
966 if (wingl -> adv_bonding[1])
967 {
968 for (i=0; i<FILLED_STYLES; i++)
969 {
970 if (plot -> fm_show_vol[1][i])
971 {
972 for (j=0; j<proj_gl -> coord -> totcoord[3]; j++)
973 {
974 if (plot -> fm_show_vol[1][i][j])
975 {
976 for (k=0; k<proj_gl -> modelfc -> mols[step][j].multiplicity; k++)
977 {
978 l = proj_gl -> modelfc -> mols[step][j].fragments[k];
979 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]);
980 paral[0][0] = wingl -> frag_box[i][step][l][0];
981 paral[0][1] = 0.0;
982 paral[0][2] = 0.0;
983 paral[1][0] = 0.0;
984 paral[1][1] = wingl -> frag_box[i][step][l][1];
985 paral[1][2] = 0.0;
986 paral[2][0] = 0.0;
987 paral[2][1] = 0.0;
988 paral[2][2] = wingl -> frag_box[i][step][l][2];
989 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]));
990 draw_cuboid (TRUE, VOLMS, m, rot, bx, paral, plot -> fm_vol_col[1][i][j], plot -> fm_vol_col[1][i][j].alpha);
991 m ++;
992 }
993 }
994 }
995 }
996 }
997 }
998 if (wingl -> adv_bonding[0])
999 {
1000 for (i=0; i<FILLED_STYLES; i++)
1001 {
1002 if (plot -> fm_show_vol[0][i])
1003 {
1004 for (j=0; j<proj_gl -> coord -> totcoord[2]; j++)
1005 {
1006 if (plot -> fm_show_vol[0][i][j])
1007 {
1008 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]);
1009 paral[0][0] = wingl -> frag_box[i][step][j][0];
1010 paral[0][1] = 0.0;
1011 paral[0][2] = 0.0;
1012 paral[1][0] = 0.0;
1013 paral[1][1] = wingl -> frag_box[i][step][j][1];
1014 paral[1][2] = 0.0;
1015 paral[2][0] = 0.0;
1016 paral[2][1] = 0.0;
1017 paral[2][2] = wingl -> frag_box[i][step][j][2];
1018 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]));
1019 draw_cuboid (TRUE, VOLMS, m, rot, bx, paral, plot -> fm_vol_col[0][i][j], plot -> fm_vol_col[0][i][j].alpha);
1020 m ++;
1021 }
1022 }
1023 }
1024 }
1025 }
1026 for (i=0; i<FILLED_STYLES; i++)
1027 {
1028 if (plot -> show_vol[i])
1029 {
1030 rot = m4_rotation_anti_xyz (wingl -> volume_box[i][step][3], wingl -> volume_box[i][step][4], wingl -> volume_box[i][step][5]);
1031 paral[0][0] = wingl -> volume_box[i][step][0];
1032 paral[0][1] = 0.0;
1033 paral[0][2] = 0.0;
1034 paral[1][0] = 0.0;
1035 paral[1][1] = wingl -> volume_box[i][step][1];
1036 paral[1][2] = 0.0;
1037 paral[2][0] = 0.0;
1038 paral[2][1] = 0.0;
1039 paral[2][2] = wingl -> volume_box[i][step][2];
1040 bx = m4_mul_coord (rot, vec3(wingl -> volume_box[i][step][6], wingl -> volume_box[i][step][7], wingl -> volume_box[i][step][8]));
1041 draw_cuboid (TRUE, VOLMS, m, rot, bx, paral, plot -> vol_col[i], plot -> vol_col[i].alpha);
1042 m ++;
1043 }
1044 }
1045 }
1046 wingl -> create_shaders[VOLMS] = FALSE;
1047}
G_MODULE_EXPORT void cut_this_slab(GtkButton *but, gpointer data)
cut this slab callback
Definition cell_cut.c:493
gchar * axis[3]
Definition w_axis.c:65
double ax
Definition curve.c:70
int nbs
Definition d_atoms.c:176
int nbl
Definition d_atoms.c:176
void prepare_cuboid(vec3_t position, int id)
OpenGL 3D light object rendering.
Definition d_box.c:433
object_3d * draw_sphere(int quality)
OpenGL 3D sphere object rendering.
Definition d_atoms.c:209
ColRGBA pcol
Definition d_poly.c:60
void create_slab_lists(project *this_proj)
prepare slab(s) OpenGL rendering
Definition d_box.c:898
void create_light_lists()
prepare light(s) OpenGL rendering
Definition d_box.c:467
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:523
vec3_t get_normal(vec3_t v1, vec3_t v2, vec3_t v3)
Definition d_box.c:501
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:312
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:134
void create_volumes_lists()
prepare volume(s) OpenGL rendering
Definition d_box.c:939
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:160
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:254
int BOX_BUFF_SIZE
Definition d_box.c:72
void cuboid_slab(mat4_t rot)
prepare cuboid slab OpenGL rendering
Definition d_box.c:602
void spherical_slab()
prepare spherical slab OpenGL rendering
Definition d_box.c:834
void setup_cylinder_vertice(float *vertices, vec3_t pos_a, vec3_t pos_b, ColRGBA col, float rad, float alpha, float delta)
fill the OpenGL data buffer for a cylinder bond (or clone bond) to render
Definition d_bonds.c:291
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:265
object_3d * draw_cylinder_cap(int quality, float rad, gboolean picked)
OpenGL 3D cylinder cap object rendering.
Definition d_bonds.c:169
object_3d * draw_cylinder(int quality, float ra, float rb)
OpenGL 3D cylinder object rendering.
Definition d_bonds.c:98
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:213
gboolean are_identical_vec3(vec3_t va, vec3_t vb)
are these 2 vectors indentical
Definition d_box.c:82
int create_box_lists()
prepare box OpenGL rendering
Definition d_box.c:290
GLfloat cuboid_vertices[]
Definition d_box.c:380
void setup_cap_vertice(float *vertices, vec3_t pos_a, vec3_t pos_b, ColRGBA col, float rad, float alpha)
fill the OpenGL data buffer for a cylinder cap bond (or clone bond) to render
Definition d_bonds.c:323
gboolean not_in_already(vec3_t a, vec3_t b, float *vertices)
is this box edge vector already saved ?
Definition d_box.c:104
void cylinder_slab(mat4_t rot)
prepare cylinder slab OpenGL rendering
Definition d_box.c:731
ColRGBA col
Definition d_measures.c:77
int * shift
Definition d_measures.c:72
int atoms[NUM_STYLES][2]
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:195
int * allocint(int val)
allocate an int * pointer
Definition global.c:314
float * allocfloat(int val)
allocate a float * pointer
Definition global.c:398
Global variable declarations Global convenience function declarations Global data structure defin...
#define max(a, b)
Definition global.h:80
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
image * plot
Definition ogl_draw.c:66
void draw(glwin *view)
main drawing subroutine for the OpenGL window
Definition ogl_draw.c:461
project * proj_gl
Definition ogl_draw.c:60
glwin * wingl
Definition ogl_draw.c:59
box_info * box_gl
Definition ogl_draw.c:64
void cleaning_shaders(glwin *view, int shader)
re-initialize an OpenGL shader
int step
Definition ogl_draw.c:70
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:65
@ WIREFRAME
Definition glview.h:174
@ NONE
Definition glview.h:172
#define FILLED_STYLES
Definition glwin.h:105
#define BOX
Definition glwin.h:54
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:47
double z
Definition ogl_draw.c:57
double y
Definition ogl_draw.c:57
double x
Definition ogl_draw.c:57
const GLchar * full_color
const GLchar * cylinder_vertex
const GLchar * full_vertex
const GLchar * line_color
const GLchar * cap_vertex
const GLchar * line_vertex
Definition ogl_shaders.c:80
const GLchar * sphere_vertex
#define LINE_BUFF_SIZE
Definition ogl_shading.h:49
#define ATOM_BUFF_SIZE
Definition ogl_shading.h:52
#define CAPS_BUFF_SIZE
Definition ogl_shading.h:51
#define POLY_BUFF_SIZE
Definition ogl_shading.h:48
#define CYLI_BUFF_SIZE
Definition ogl_shading.h:50
@ 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
float blue
Definition global.h:124
float alpha
Definition global.h:125
float red
Definition global.h:122
float green
Definition global.h:123
Definition global.h:886
double z
Definition global.h:892
double y
Definition global.h:891
double x
Definition global.h:890
double length
Definition glwin.h:123
double z
Definition glwin.h:126
double y
Definition glwin.h:125
gboolean pbc
Definition glwin.h:127
double x
Definition glwin.h:124
Definition glwin.h:875
int natomes
Definition global.h:951
float y
Definition math_3d.h:130
float x
Definition math_3d.h:130
float z
Definition math_3d.h:130
int b
Definition tab-1.c:95
int a
Definition tab-1.c:95
gchar * cpos[3]
Definition w_advance.c:138
GtkWidget * img
Definition workspace.c:70