It is currently Fri May 31, 2024 7:54 am





Shrinker wrote:Athlete: Aha...
.











//lineOrigin in world units, nLineDirection normalized, lineWidth in pixels, gap in world units
bool lines(vec2 lineOrigin, vec2 nLineDirection, float lineWidth, vec2 gap)
{
//determine whether the check shall be done on a horizontal (x) or vertical (y) scanline
vec4
a = gl_ModelViewProjectionMatrix*vec4(pointOnPlane , 0, 1),
b = gl_ModelViewProjectionMatrix*vec4(pointOnPlane+nLineDirection, 0, 1);
vec2
a2D = a.xy/a.z,
b2D = b.xy/b.z,
c2D = b2D -a2D;
if (abs(c2D.x)/gl_ProjectionMatrix[0][0] >= abs(c2D.y))
{
//vertical (y) scanline
//determine width of line intersecting scanline
vec2 popDelta = dFdy(pointOnPlane);
//pop2D is pointOnPlane in 2D screen space
vec4 t = gl_ModelViewProjectionMatrix*vec4(pointOnPlane, 0, 1);
float pop2Dy = t.y/t.z;
//pop2D2 is for calculating the line width at the end
t = gl_ModelViewProjectionMatrix*vec4(pointOnPlane+popDelta, 0, 1);
float pop2D2y = t.y/t.z;
//find intersection point of line going through pointOnPlane with the direction delta and the first line in question, starting at lineOrigin
vec2 s = intersection(lineOrigin, nLineDirection, pointOnPlane, popDelta);
//project gap_ to line by readin
vec2 line = s-pointOnPlane;
float lineLen = length(line)+length(popDelta)/2.;
//gap between two lines = distance of intersection points with two neighboring lines, where one line was offset with gap
float gapInLine = length(intersection(lineOrigin+gap, nLineDirection, pointOnPlane, popDelta)-s);
//new line length*normalized line
s = pointOnPlane+(lineLen-floor(lineLen/gapInLine)*gapInLine)*normalize(line);
//t is used for the projection of the relocated intersection point
t = gl_ModelViewProjectionMatrix*vec4(s, 0, 1);
return abs(pop2Dy-t.y/t.z) < lineWidth*abs(pop2D2y-pop2Dy); //right side: pixel line width
}
else
{
//horizontal (x) scanline
//determine width of line intersecting scanline
vec2 popDelta = dFdx(pointOnPlane);
//pop2D is pointOnPlane in 2D screen space
vec4 t = gl_ModelViewProjectionMatrix*vec4(pointOnPlane, 0, 1);
float pop2Dx = t.x/t.z;
//pop2D2 is for calculating the line width at the end
t = gl_ModelViewProjectionMatrix*vec4(pointOnPlane+popDelta, 0, 1);
float pop2D2x = t.x/t.z;
//find intersection point of line going through pointOnPlane with the direction delta and the first line in question, starting at lineOrigin
vec2 s = intersection(lineOrigin, nLineDirection, pointOnPlane, popDelta);
//project gap_ to line by readin
vec2 line = s-pointOnPlane;
float lineLen = length(line)+length(popDelta)/2.;
//gap between two lines = distance of intersection points with two neighboring lines, where one line was offset with gap
float gapInLine = length(intersection(lineOrigin+gap, nLineDirection, pointOnPlane, popDelta)-s);
//new line length*normalized line
s = pointOnPlane+(lineLen-floor(lineLen/gapInLine)*gapInLine)*normalize(line);
//t is used for the projection of the relocated intersection point
t = gl_ModelViewProjectionMatrix*vec4(s, 0, 1);
return abs(pop2Dx-t.x/t.z) < lineWidth*abs(pop2D2x-pop2Dx); //right side: pixel line width
}
}


//circleOrigin in world units, lineWidth in pixels, gap in world units
bool circles(vec2 circleOrigin, float lineWidth, float gap)
{
vec2 dn = normalize(pointOnPlane-circleOrigin);
return lines(circleOrigin, vec2(dn.y, -dn.x), lineWidth, dn*gap);
}










coder0xff wrote:I wonder if Gabe ever lies in bed at night, thinking about all the fat jokes, and just cries himself to sleep, wiping his tears away with one-thousand dollar bills.



coder0xff wrote:I wonder if Gabe ever lies in bed at night, thinking about all the fat jokes, and just cries himself to sleep, wiping his tears away with one-thousand dollar bills.

Users browsing this forum: Bing [Bot]