source: orange/Orange/OrangeWidgets/VisualizeQt/node.vs @ 11474:df0622184ee6

Revision 11474:df0622184ee6, 1.4 KB checked in by markotoplak, 12 months ago (diff)

Renamed Visualize Qt to VisualizeQt (so it can be loaded in new canvas).

RevLine 
[9079]1/*
2 * Used by Canvas3D to render nodes.
3 */
4
5attribute vec3 position;
[9104]6attribute vec3 offset;
7attribute vec3 color;
8attribute vec2 selected_marked;
[9079]9
[9104]10const float MODE_NORMAL = 0.;
11const float MODE_SELECTED = 1.;
12const float MODE_MARKED = 2.;
13
14uniform float mode;
[9079]15uniform mat4 projection, model, view;
16uniform vec3 translation, scale;
17
[9104]18varying vec4 var_color;
19
[9079]20void main()
21{
[9104]22    vec3 offset_rotated = offset.xyz;
23    offset_rotated *= 0.01;
24
25    // Calculate inverse of rotations (in this case, inverse
26    // is actually just transpose), so that polygons face
27    // camera all the time.
28    mat3 invs;
29    mat4 modelview = view * model;
30
31    invs[0][0] = modelview[0][0];
32    invs[0][1] = modelview[1][0];
33    invs[0][2] = modelview[2][0];
34
35    invs[1][0] = modelview[0][1];
36    invs[1][1] = modelview[1][1];
37    invs[1][2] = modelview[2][1];
38
39    invs[2][0] = modelview[0][2];
40    invs[2][1] = modelview[1][2];
41    invs[2][2] = modelview[2][2];
42
43    offset_rotated = invs * offset_rotated;
44
45    vec3 pos = position.xyz;
46    pos += translation;
47    pos *= scale;
48    vec4 off_pos = vec4(pos+offset_rotated, 1.);
49
50    // Hide when unwanted
51    if (mode == MODE_SELECTED && selected_marked.x == 0.)
52        off_pos = vec4(0., 0., 0., 0.);
53
54    if (mode == MODE_MARKED && selected_marked.y == 0.)
55        off_pos = vec4(0., 0., 0., 0.);
56
57    gl_Position = projection * model * view * off_pos;
58    var_color = vec4(color, 1.);
[9079]59}
Note: See TracBrowser for help on using the repository browser.