If anyone runs Linux, I posted the source code to a 3D pool simulator. I am sure it is easy to modiify to work on Windows, Mac, or even Pi, but I am not too concerned about anything other than Linux for 3D related applications.
A prebuilt version is available here:
https://github.com/sysrpl/Raylib.4.0.Pascal/blob/master/examples/table/README.md
Press C while running to change the camera modes. Arrow keys and space to shoot, or you can use the mouse in overhead mode. Of note is a smoothing implementation I came up with to draw nice antialiased vector lines and edges in 3D using this bit of fragment shader code.
float floatblend(float position, float edge)
{
float dist = distance(eye, vertex);
float m = dist / 1000;
vec3 n = normalize(normal);
vec3 v = normalize(eye - vertex);
float d = dot(n, v);
if (d < 0.0001)
return 0.0;
m = m * (1 + 1 / d);
if (position + m < edge)
return 1.0;
if (position - m > edge)
return 0.0;
return smoothstep(position - m, position + m, edge);
}What this does is look at an edge you are drawing (for example the stripe on a ball, the shot line on the table, or the diamonds on the wood top and so on), and accounts for the distance from your eye along with the angle you are viewing the line to apply some smoothing. Press E to cycle between a few smoothing modes to see the difference.
Oh and finally, I did write glsl syntax highlighter if anyone wants to add it to the ones that TSynEdit supports in the official Lazarus distribution.
If anyone wants to modify it to add multiplayer support, feel free to do so or add anything else you like.
Cheers
Anthony
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20250221/d0565bf1/attachment.htm>
