| 1 |
#version 330 |
| 2 |
|
| 3 |
|
| 4 |
layout(points) in; |
| 5 |
layout(triangle_strip, max_vertices = 115) out; |
| 6 |
//layout(line_strip, max_vertices = 80) out; |
| 7 |
|
| 8 |
const float PI = 3.14159265359f; |
| 9 |
const int segments = 8; |
| 10 |
|
| 11 |
uniform mat4 pmv; |
| 12 |
uniform mat3 normalMatrix; |
| 13 |
uniform int dontshowSymElement[200]; |
| 14 |
uniform int dontshowSymOperation[200]; |
| 15 |
uniform int dssesize=0; |
| 16 |
uniform int dssosize=0; |
| 17 |
uniform float glideVectorThickness = 0.04; |
| 18 |
uniform float planeFrameThinkness = 0.04; |
| 19 |
|
| 20 |
in float coli[]; |
| 21 |
in float oprn[]; |
| 22 |
in vec3 norv[]; |
| 23 |
in vec3 midv[]; |
| 24 |
in vec3 verts0v[]; |
| 25 |
in vec3 verts1v[]; |
| 26 |
in vec3 glidev[]; |
| 27 |
|
| 28 |
out vec3 Normal; |
| 29 |
out float col; |
| 30 |
out float transparent; |
| 31 |
|
| 32 |
out gl_PerVertex{ |
| 33 |
vec4 gl_Position; |
| 34 |
}; |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
void main() { |
| 40 |
for (int i=0; i<dssesize; i++) if ((dontshowSymElement[i]==coli[0])) return; |
| 41 |
for (int i=0; i<dssosize; i++) if ((dontshowSymOperation[i]==oprn[0])) return; |
| 42 |
// plane frame lines |
| 43 |
vec4 start = vec4(verts0v[0],1); |
| 44 |
vec4 end = vec4(verts1v[0],1); |
| 45 |
vec3 direction = normalize(end.xyz - start.xyz); |
| 46 |
float l = length(end.xyz - start.xyz); |
| 47 |
vec3 lot = (abs(dot(direction, vec3(1, 0, 0))) > 0.8)? |
| 48 |
(abs(dot(direction, vec3(0, 1, 0))) > 0.8)? |
| 49 |
normalize(cross(direction, vec3(0, 0, 1))): |
| 50 |
normalize(cross(direction, vec3(0, 1, 0))): |
| 51 |
normalize(cross(direction, vec3(1, 0, 0))); |
| 52 |
vec3 lot2 = normalize(cross(direction,lot)); |
| 53 |
vec3 r = vec3(0,0,0); |
| 54 |
float rad = planeFrameThinkness; |
| 55 |
vec3 vert=vec3(0,0,0); |
| 56 |
for (int i = 0; i <= 2*segments; i++){ |
| 57 |
r = sin(PI * i / segments) * lot + cos(PI * i / segments) * lot2; |
| 58 |
|
| 59 |
vert = start.xyz + rad * r; |
| 60 |
gl_Position = pmv* vec4(vert, 1); |
| 61 |
Normal = normalize(normalMatrix * r); |
| 62 |
col = coli[0]; |
| 63 |
transparent=0.0; |
| 64 |
EmitVertex(); |
| 65 |
|
| 66 |
vert = end.xyz + rad * r; |
| 67 |
gl_Position = pmv* vec4(vert , 1); |
| 68 |
Normal = normalize(normalMatrix * r); |
| 69 |
col = coli[0]; |
| 70 |
transparent=0.0; |
| 71 |
EmitVertex(); |
| 72 |
} |
| 73 |
EndPrimitive(); |
| 74 |
|
| 75 |
//glide axis line |
| 76 |
if (length(glidev[0])>0.1){ |
| 77 |
start = vec4(midv[0],1); |
| 78 |
end = vec4(midv[0]+glidev[0],1); |
| 79 |
direction = normalize(end.xyz - start.xyz); |
| 80 |
l = length(end.xyz - start.xyz); |
| 81 |
lot = (dot(direction, vec3(1, 0, 0)) > 0.8)? |
| 82 |
(dot(direction, vec3(0, 1, 0)) > 0.8)? |
| 83 |
normalize(cross(direction, vec3(0, 0, 1))): |
| 84 |
normalize(cross(direction, vec3(0, 1, 0))): |
| 85 |
normalize(cross(direction, vec3(1, 0, 0))); |
| 86 |
lot2 = normalize(cross(direction,lot)); |
| 87 |
r = vec3(0,0,0); |
| 88 |
rad = glideVectorThickness; |
| 89 |
vert=vec3(0,0,0); |
| 90 |
for (int i = 0; i <= 2*segments; i++){ |
| 91 |
r = sin(PI * i / segments) * lot + cos(PI * i / segments) * lot2; |
| 92 |
|
| 93 |
vert = start.xyz + rad * r; |
| 94 |
gl_Position = pmv* vec4(vert, 1); |
| 95 |
Normal = normalize(normalMatrix * r); |
| 96 |
col = coli[0]; |
| 97 |
transparent=0.0; |
| 98 |
EmitVertex(); |
| 99 |
|
| 100 |
vert = end.xyz + rad * r; |
| 101 |
gl_Position = pmv* vec4(vert , 1); |
| 102 |
Normal = normalize(normalMatrix * r); |
| 103 |
col = coli[0]; |
| 104 |
transparent=0.0; |
| 105 |
EmitVertex(); |
| 106 |
} |
| 107 |
EndPrimitive(); |
| 108 |
rad*=2;//arrow tip |
| 109 |
for (int i = 0; i <= 2*segments; i++){ |
| 110 |
r = sin(PI * i / segments) * lot + cos(PI * i / segments) * lot2; |
| 111 |
|
| 112 |
vert = end.xyz + rad * r; |
| 113 |
gl_Position = pmv* vec4(vert, 1); |
| 114 |
Normal = normalize(normalMatrix * r); |
| 115 |
col = coli[0]; |
| 116 |
transparent=0.0; |
| 117 |
EmitVertex(); |
| 118 |
|
| 119 |
vert = end.xyz + direction; |
| 120 |
gl_Position = pmv* vec4(vert , 1); |
| 121 |
Normal = normalize(normalMatrix * r); |
| 122 |
col = coli[0]; |
| 123 |
transparent=0.0; |
| 124 |
EmitVertex(); |
| 125 |
} |
| 126 |
EndPrimitive(); |
| 127 |
} |
| 128 |
|
| 129 |
{ |
| 130 |
gl_Position = pmv* vec4(midv[0] , 1); |
| 131 |
Normal = normalize(normalMatrix * norv[0]); |
| 132 |
col = coli[0]; |
| 133 |
transparent=2.0; |
| 134 |
EmitVertex(); |
| 135 |
|
| 136 |
gl_Position = pmv* vec4(verts0v[0] , 1); |
| 137 |
Normal = normalize(normalMatrix * norv[0]); |
| 138 |
col = coli[0]; |
| 139 |
transparent=2.0; |
| 140 |
EmitVertex(); |
| 141 |
|
| 142 |
gl_Position = pmv* vec4(verts1v[0] , 1); |
| 143 |
Normal = normalize(normalMatrix * norv[0]); |
| 144 |
col = coli[0]; |
| 145 |
transparent=2.0; |
| 146 |
EmitVertex(); |
| 147 |
} |
| 148 |
EndPrimitive(); |
| 149 |
} |