101 object_3d * new_cylinder = g_malloc0 (
sizeof*new_cylinder);
102 new_cylinder -> quality = quality;
104 new_cylinder -> vert_buffer_size = 3;
105 new_cylinder -> vertices =
allocfloat (3*new_cylinder -> num_vertices);
107 new_cylinder -> ind_buffer_size = 1;
110 float step = 2.0 *
pi / (quality-1);
114 for(i = 0; i < quality; i++)
118 new_cylinder -> vertices[j] = ra*
x;
119 new_cylinder -> vertices[j+1] = ra*
y;
120 new_cylinder -> vertices[j+2] = 0.5;
122 new_cylinder -> vertices[j] = rb*
x;
123 new_cylinder -> vertices[j+1] = rb*
y;
124 new_cylinder -> vertices[j+2] = -0.5;
128 for (i = 0; i < 2*quality; i++)
130 new_cylinder -> indices[i] = i % (2*quality-2);
173 object_3d * new_cap = g_malloc0 (
sizeof*new_cap);
174 new_cap -> quality = quality;
176 new_cap -> vert_buffer_size = 3;
177 new_cap -> vertices =
allocfloat (3*new_cap -> num_vertices);
179 new_cap -> ind_buffer_size = 1;
180 new_cap -> indices =
allocint (new_cap -> num_indices);
182 float delta = (picked) ? 0.05 : 0.0;
183 float step = 2.0 *
pi / (quality - 1);
187 new_cap -> vertices[j] = 0.0;
188 new_cap -> vertices[j+1] = 0.0;
189 new_cap -> vertices[j+2] = 0.0 - delta;
191 for(i = 0; i < quality; i++)
195 new_cap -> vertices[j] = rad*
x;
196 new_cap -> vertices[j+1] = rad*
y;
197 new_cap -> vertices[j+2] = 0.0 - delta;
201 for (i=0; i <= quality; i++)
203 new_cap -> indices[i] = i % (quality + 1);
219 c = v3_sub (vec3(
b.x,
b.y,
b.z), vec3(
a.x,
a.y,
a.z));
220 f = vec3 (0.0, 0.0, 1.0);
222 raxis = v3_cross (f,
c);
224 rangle = acos(v3_dot(f,
c) / v3_length(
c));
225 return axis_to_quat (raxis, rangle);
243 return plot -> bondrad[at][bt] + 0.05*
sel;
247 return plot -> radall[ac] + 0.05*
sel;
251 return plot -> linerad[at][bt] + 4.0*
sel;
269 vertices[s+1] = pos.
y;
270 vertices[s+2] = pos.
z;
294 vertices[s] = (pos_a.
x + pos_b.
x)/2.0;
295 vertices[s+1] = (pos_a.
y + pos_b.
y)/2.0;
296 vertices[s+2] = (pos_a.
z + pos_b.
z)/2.0;
297 vertices[s+3] = v3_length(v3_sub(pos_a, pos_b)) + delta;
300 vertices[s+5] = quat.
w;
301 vertices[s+6] = quat.
x;
302 vertices[s+7] = quat.
y;
303 vertices[s+8] = quat.
z;
326 vertices[s] = pos_b.
x;
327 vertices[s+1] = pos_b.
y;
328 vertices[s+2] = pos_b.
z;
331 vertices[s+4] = quat.
w;
332 vertices[s+5] = quat.
x;
333 vertices[s+6] = quat.
y;
334 vertices[s+7] = quat.
z;
371 gboolean show_a, show_b;
375 show_a =
plot -> at_data[bt -> id].show[bi];
376 show_b =
plot -> at_data[bt -> id].pick[
pi];
382 show_a = bt -> show[bi];
387 delta = ((show_a && show_b) && (sta == stb)) ? 0.0 : 0.1;
389 for (p=0; p<
plot -> extra_cell[0]+1;p++)
391 for (q=0; q<
plot -> extra_cell[1]+1; q++)
393 for (r=0; r<
plot -> extra_cell[2]+1; r++)
400 pos_a = vec3(at ->
x, at ->
y, at ->
z);
401 pos_b = vec3((at ->
x + bt ->
x)/2.0, (at ->
y + bt ->
y)/2.0, (at ->
z + bt ->
z)/2.0);
442void prepare_bond (
int sty, gboolean to_pick, gboolean picked,
int cap,
int bi,
int pi,
int bid,
atom * at,
atom * bt,
float * vertices)
454 if (
wingl -> bondid[
step][1][bid][0] == at ->
id) sign = -1;
461 tmp_a -> style = bt -> style;
474 tmp_a -> style = at -> style;
477 tmp_a ->
id = at -> id;
501 int i, j, k, l, m, n;
502 gboolean show_a, show_b;
510 show_a =
plot -> at_data[j].show[bi];
512 show_b =
plot -> at_data[k].show[bi];
524 if (show_a && (m == sty || to_pick))
528 if (! show_b || n != sty) l += 1 + bi;
538 if (show_b && (n == sty || to_pick))
542 if (! show_a || m != sty) l += 1 + bi;
568 gboolean show_a, show_b;
575 show_a =
plot -> at_data[j].show[bi];
577 show_b =
plot -> at_data[k].show[bi];
587 if (show_a && (l == style || to_pick))
598 if (show_b && (m == style || to_pick))
627 gboolean show_a, show_b;
634 show_a =
plot -> at_data[j].show[bi];
636 show_b =
plot -> at_data[k].show[bi];
648 if (show_a && l == style)
655 if (show_b && m == style)
678 int f, g, h, i, j, k, l, m;
686 g = (
plot -> draw_clones) ? 2 : 1;
693 nbds[f] = ncap[f] = 0;
705 if (
nbonds[f][h][i][j] > 0) l ++;
709 m += ncaps[f][h][i][j];
721 if (m > 0 && ! to_pick) nshaders ++;
732 g_debug (
"Bond LIST:: to_pick= %s, shaders= %d", (to_pick) ?
"true" :
"false", nshaders);
734 if (nshaders == 0)
return nshaders;
744 cyl -> num_instances = (nbds[f]/2) * (
plot -> extra_cell[0]+1)*(
plot -> extra_cell[1]+1)*(
plot -> extra_cell[2]+1);
751 if (to_pick && h==0)
wingl -> bonds_to_be_picked =
wingl -> to_be_picked;
761 cap -> num_instances = (ncap[f]/2) * (
plot -> extra_cell[0]+1)*(
plot -> extra_cell[1]+1)*(
plot -> extra_cell[2]+1);
790 cyl = g_malloc0 (
sizeof*cyl);
792 cyl -> num_vertices =
nbonds[f][h][i][j] * (
plot -> extra_cell[0]+1)*(
plot -> extra_cell[1]+1)*(
plot -> extra_cell[2]+1);
793 cyl -> vertices =
allocfloat (cyl -> vert_buffer_size*cyl -> num_vertices);
809 if (! to_pick) g_free (ncaps);
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
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
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_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
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.
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
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
int *** nbonds[NUM_STYLES][2]
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 * 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 * cylinder_vertex
const GLchar * line_color
const GLchar * cap_vertex
const GLchar * line_vertex