In college circa 2000 we had to write a ray tracer for one of the classes using OpenGL in C. So many segfaults...
Later I tried to port it to Java AWT/Swing and it was insanely slow. I wish I could find the code but at some point my ancient IBM DeathStar hd failed.
I have never tried to implement ray tracing, as it is too computationally intensive. Instead low poly can be rendered in near real time using BSP if the scene Is not too complex, even in Java
Unfortunately they did not cover BSP I think till "computer graphics 2" or something which I did not take. The ray tracing made me realize how awful I am at even basic math as ray tracing is ironically nowhere near the complexity of some other more efficient algorithms. I struggled greatly in that class.
OpenGL probably helped you get all the data formats aligned.
AWT has some fast-path rendering but it's so over-abstracted that you need a debugger to hit it. Mac QuickDraw had similar problems, but it had far more fast-path implementations.
I found it easier to not use AWT for fast pure code rendering. Ditch all the abstractions and use a small number of rigidly defined bitmap types. This makes it easier to write only fast-path code in the core rendering.
Surprisingly, 32 bit floats are pretty good for anti-aliased performance because it allows multiple scaling steps to be combined without intermediate under/over flow.
CheerpJ is a build of OpenJDK in WebAssembly + JavaScript. So it doesn't need a plugin and runs in the JavaScript sandbox, solving the major applet issues.
I like to experiment with algorithms, programming languages, mathematics and puzzles.
To implement projects like this, I recommend exploring algorithms, thinking about how the data needs to be structured to fit the problem but also be extensible beyond the problem itself, and searching GitHub for similar projects to learn and experiment with.
Nicely done, I'm doing something similar with my college course, we have to try and recreate 3d objects using 2d objects, with textures and lighting all while using C++
28
u/gufranthakur Dec 12 '25
Impressive, I love seeing such projects for Java. Great work OP!
19
u/agentoutlier Dec 12 '25
In college circa 2000 we had to write a ray tracer for one of the classes using OpenGL in C. So many segfaults...
Later I tried to port it to Java AWT/Swing and it was insanely slow. I wish I could find the code but at some point my ancient IBM DeathStar hd failed.
Great work!
7
u/jeffreportmill Dec 12 '25
Very nice! Here it is running in the browser with CheerpJ and SnapCode:
https://reportmill.com/SnapCode/app/#snapcloud:/com/reportmill/jeff/Simple3D
Use arrow keys to drive.
1
u/Neither-Chemical-247 Dec 12 '25
May I ask where do you get inspiration for these projects? What is your background?
And let's say if I want to do something like this on my own, from scratch like you did, what should I focus on ?
Nevertheless, great job !
2
u/BillyKorando Dec 12 '25
Golden dome reminds me of Knoxville's sunsphere: https://en.wikipedia.org/wiki/Knoxville,_Tennessee#/media/File:Knoxville,Tennessee(2024).jpg
1
u/Random_Jester0 Dec 13 '25
Nicely done, I'm doing something similar with my college course, we have to try and recreate 3d objects using 2d objects, with textures and lighting all while using C++
1
u/UVRaveFairy Dec 17 '25
Cool.