105 object_3d * new_cylinder = g_malloc0(
sizeof*new_cylinder);
106 new_cylinder -> quality = quality;
108 new_cylinder -> vert_buffer_size = 3;
109 new_cylinder -> vertices =
allocfloat (3*new_cylinder -> num_vertices);
111 new_cylinder -> ind_buffer_size = 1;
114 float step = 2.0 *
pi / (quality-1);
118 for(i = 0; i < quality; i++)
122 new_cylinder -> vertices[j] = ra*
x;
123 new_cylinder -> vertices[j+1] = ra*
y;
124 new_cylinder -> vertices[j+2] = 0.5;
126 new_cylinder -> vertices[j] = rb*
x;
127 new_cylinder -> vertices[j+1] = rb*
y;
128 new_cylinder -> vertices[j+2] = -0.5;
132 for (i = 0; i < 2*quality; i++)
134 new_cylinder -> indices[i] = i % (2*quality-2);
177 object_3d * new_cap = g_malloc0(
sizeof*new_cap);
178 new_cap -> quality = quality;
180 new_cap -> vert_buffer_size = 3;
181 new_cap -> vertices =
allocfloat (3*new_cap -> num_vertices);
183 new_cap -> ind_buffer_size = 1;
184 new_cap -> indices =
allocint (new_cap -> num_indices);
186 float delta = (picked) ? 0.05 : 0.0;
187 float step = 2.0 *
pi / (quality - 1);
191 new_cap -> vertices[j] = 0.0;
192 new_cap -> vertices[j+1] = 0.0;
193 new_cap -> vertices[j+2] = - delta;
195 for(i = 0; i < quality; i++)
199 new_cap -> vertices[j] = rad*
x;
200 new_cap -> vertices[j+1] = rad*
y;
201 new_cap -> vertices[j+2] = 0.0 - delta;
205 for (i=0; i <= quality; i++)
207 new_cap -> indices[i] = i % (quality + 1);
223 c = v3_sub (vec3(b.
x, b.
y, b.
z), vec3(a.
x, a.
y, a.
z));
224 f = vec3 (0.0, 0.0, 1.0);
226 raxis = v3_cross (f, c);
228 rangle = acos(v3_dot(f, c) / v3_length(c));
229 return axis_to_quat (raxis, rangle);
247 return plot -> bondrad[at][bt] + 0.05*
sel;
251 return plot -> radall[ac] + 0.05*
sel;
255 return plot -> linerad[at][bt] + 4.0*
sel;
273 vertices[s+1] = pos.
y;
274 vertices[s+2] = pos.
z;
275 vertices[s+3] =
col.red;
276 vertices[s+4] =
col.green;
277 vertices[s+5] =
col.blue;
278 vertices[s+6] =
col.alpha * alpha;
301 vertices[s] = (pos_a.
x + pos_b.
x)/2.0;
302 vertices[s+1] = (pos_a.
y + pos_b.
y)/2.0;
303 vertices[s+2] = (pos_a.
z + pos_b.
z)/2.0;
304 vertices[s+3] = v3_length(v3_sub(pos_a, pos_b)) + delta;
307 vertices[s+5] = quat.
w;
308 vertices[s+6] = quat.
x;
309 vertices[s+7] = quat.
y;
310 vertices[s+8] = quat.
z;
311 vertices[s+9] =
col.red;
312 vertices[s+10] =
col.green;
313 vertices[s+11] =
col.blue;
314 vertices[s+12] =
col.alpha * alpha;
317 vertices[s+13] = r_sph_a;
318 vertices[s+14] = r_sph_b;
339 vec3_t dir = (
sel) ? v3_norm (v3_sub(pos_a, pos_b)) : vec3(0.0, 0.0, 0.0);
340 vertices[s] = pos_b.
x - 0.05*dir.
x;
341 vertices[s+1] = pos_b.
y - 0.05*dir.
y;
342 vertices[s+2] = pos_b.
z - 0.05*dir.
z;
345 vertices[s+4] = quat.
w;
346 vertices[s+5] = quat.
x;
347 vertices[s+6] = quat.
y;
348 vertices[s+7] = quat.
z;
349 vertices[s+8] =
col.red;
350 vertices[s+9] =
col.green;
351 vertices[s+10] =
col.blue;
352 vertices[s+11] =
col.alpha * alpha;
374void setup_this_bond (
int sty, gboolean to_pick, gboolean picked,
int cap,
int bi,
int pi,
atom * at,
atom * bt,
float al,
float * vertices)
385 gboolean show_a, show_b;
389 show_a =
plot -> at_data[bt -> id].show[bi];
390 show_b =
plot -> at_data[bt -> id].pick[
pi];
391 sta =
plot -> at_data[at -> id].style;
392 stb =
plot -> at_data[bt -> id].style;
396 show_a = bt -> show[bi];
401 delta = ((show_a && show_b) && (sta == stb)) ? 0.0 : 0.1;
403 for (p=0; p<
plot -> abc -> extra_cell[0]+1;p++)
405 for (q=0; q<
plot -> abc -> extra_cell[1]+1; q++)
407 for (r=0; r<
plot -> abc -> extra_cell[2]+1; r++)
414 pos_a = vec3(at ->
x, at ->
y, at ->
z);
415 pos_b = vec3((at ->
x + bt ->
x)/2.0, (at ->
y + bt ->
y)/2.0, (at ->
z + bt ->
z)/2.0);
420 setup_cap_vertice (vertices, pos_a, pos_b,
col, rad, alpha*al, (
plot -> ray_tracing && delta > 0.0) ? TRUE : FALSE);
457void prepare_bond (
int sty, gboolean to_pick, gboolean picked,
int cap,
int bi,
int pi,
int bid,
atom * at,
atom * bt,
float * vertices)
469 if (
wingl -> bondid[
step][1][bid][0] == at ->
id) sign = -1;
476 tmp_a -> style = bt -> style;
489 tmp_a -> style = at -> style;
492 tmp_a ->
id = at -> id;
516 int i, j, k, l, m, n;
517 gboolean show_a, show_b;
525 show_a =
plot -> at_data[j].show[bi];
526 m =
plot -> at_data[j].style;
527 show_b =
plot -> at_data[k].show[bi];
528 n =
plot -> at_data[k].style;
539 if (show_a && (m == sty || to_pick))
543 if (! show_b || n != sty) l += 1 + bi;
553 if (show_b && (n == sty || to_pick))
557 if (! show_a || m != sty) l += 1 + bi;
583 gboolean show_a, show_b;
590 show_a =
plot -> at_data[j].show[bi];
591 l =
plot -> at_data[j].style;
592 show_b =
plot -> at_data[k].show[bi];
593 m =
plot -> at_data[k].style;;
602 if (show_a && (l == style || to_pick))
613 if (show_b && (m == style || to_pick))
642 gboolean show_a, show_b;
649 show_a =
plot -> at_data[j].show[bi];
650 l =
plot -> at_data[j].style;
651 show_b =
plot -> at_data[k].show[bi];
652 m =
plot -> at_data[k].style;
663 if (show_a && l == style)
670 if (show_b && m == style)
693 int f, g, h, i, j, k, l, m;
701 g = (
plot -> draw_clones) ? 2 : 1;
708 nbds[f] = ncap[f] = 0;
719 k += nbonds[f][h][i][j];
720 if (nbonds[f][h][i][j] > 0) l ++;
724 m += ncaps[f][h][i][j];
736 if (m > 0 && ! to_pick) nshaders ++;
747 g_debug (
"Bond LIST:: to_pick= %s, shaders= %d", (to_pick) ?
"true" :
"false", nshaders);
749 if (nshaders == 0)
return nshaders;
759 cyl -> num_instances = (nbds[f]/2) * (
plot -> abc -> extra_cell[0]+1)*(
plot -> abc -> extra_cell[1]+1)*(
plot -> abc -> extra_cell[2]+1);
767 if (to_pick && h==0)
wingl -> bonds_to_be_picked =
wingl -> to_be_picked;
774 int narray_cyl =
plot -> ray_tracing ? 8 : 6;
780 cap -> num_instances = (ncap[f]/2) * (
plot -> abc -> extra_cell[0]+1)*(
plot -> abc -> extra_cell[1]+1)*(
plot -> abc -> extra_cell[2]+1);
789 GLenum prim_cap = (
plot -> ray_tracing) ? GL_TRIANGLE_STRIP : GL_TRIANGLE_FAN;
807 if (nbonds[f][h][i][j])
809 cyl = g_malloc0(
sizeof*cyl);
811 cyl -> num_vertices = nbonds[f][h][i][j] * (
plot -> abc -> extra_cell[0]+1)*(
plot -> abc -> extra_cell[1]+1)*(
plot -> abc -> extra_cell[2]+1);
812 cyl -> vertices =
allocfloat (cyl -> vert_buffer_size*cyl -> num_vertices);
832 g_free (nbonds[f][h][i]);
833 if (! to_pick) g_free (ncaps[f][h][i]);
835 g_free (nbonds[f][h]);
836 if (! to_pick) g_free (ncaps[f][h]);
839 if (! to_pick) g_free (ncaps[f]);
842 if (! to_pick) g_free (ncaps);
float get_sphere_radius(int style, int sp, int ac, int sel)
get an atom sphere radius
object_3d * draw_billboard_quad()
create a camera-aligned billboard quad proxy for perfect impostors.
int cylinder_indices(int qual)
return the number of OpenGL indices to render a cylinder
int create_bond_lists(gboolean to_pick)
prepare bond(s) and clone bond(s) OpenGL rendering
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
int find_bond_vertices(gboolean to_pick, int sty, int sa, int sb, int bi, int cap)
find bond(s) and clone bond(s) to render
int cylinder_vertices(int qual)
return the number of OpenGL vertices to render a cylinder
int cap_vertices(int qual)
return the number of OpenGL vertices to render a cylinder cap
object_3d * draw_billboard_quad(void)
create a camera-aligned billboard quad proxy for perfect impostors.
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
float get_sphere_radius(int style, int sp, int ac, int sel)
get an atom sphere radius
void setup_this_bond(int sty, gboolean to_pick, gboolean picked, int cap, int bi, int pi, atom *at, atom *bt, float al, float *vertices)
prepare the OpenGL rendering data of a bond / clone bond
vec4_t rotate_bond(vec3_t a, vec3_t b)
rotate a bond based on the proper orientation
void setup_line_vertices(int style, int cap, int bi, int sa, int sb, float *vertices)
prepare line bond(s) and clone bond(s) to render
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
object_3d * draw_cylinder_cap(int quality, float rad, gboolean picked)
OpenGL 3D cylinder cap object rendering.
ColRGBA get_atom_color(int i, int j, double al, int picked, gboolean to_picked)
get atom (or clone) color
object_3d * draw_cylinder(int quality, float ra, float rb)
OpenGL 3D cylinder object rendering.
int cap_indices(int qual)
return the number of OpenGL indices to render a cylinder cap
void setup_all_cylinder_vertices(int style, gboolean to_pick, int cap, int bi, float *vertices)
prepare cylinder bond(s) and clone bond(s) to render
void prepare_bond(int sty, gboolean to_pick, gboolean picked, int cap, int bi, int pi, int bid, atom *at, atom *bt, float *vertices)
prepare a bond OpenGL rendering
float get_bond_radius(int sty, int ac, int at, int bt, int sel)
get bond (clone bond) radius
atom_in_selection * tmp_a
atom_in_selection * tmp_b
Variable declarations for the creation of the DL_POLY input file(s).
gboolean in_movie_encoding
int * allocint(int val)
allocate an int * pointer
int **** allocqint(int wal, int xal, int yal, int zal)
allocate an int **** pointer
float * allocfloat(int val)
allocate a float * pointer
Global variable declarations Global convenience function declarations Global data structure defin...
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
void at_unshift(atom *at, float *shift)
correct atomic coordinates modified to display image in cell replica
void at_shift(atom *at, float *shift)
modify atomic coordinates to display image in cell replica
void cleaning_shaders(glwin *view, int shader)
re-initialize an OpenGL shader
atom * free_atom(atom *at)
free an atom data structure
atom * duplicate_atom(atom *at)
copy (partially) an atom data structure
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
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 * line_color
const GLchar * cap_vertex
const GLchar * line_vertex
void allocate_instances(object_3d *object)
allocate the instances buffer of a 3D object