Saturday, April 17, 2004
What is Regulus?
Regulus is a 3D solid modeller that I'm writing.
Regulus works on solids, not on meshes, like many other modellers. It also supports boolean set operations on these solids, so you can do interesting things like drill a hole through a sphere by subtracting a cylinder from it. Or you can create a pretty good simulation of Swiss cheese by subtracting a bunch of spheres from a cube.
It's actually a complete rewrite of my final project from a graphics course I took in school, CS488: Introduction to Computer Graphics. The original version was written in TCL/Tk and C++. It also didn't completely work. Taking Operating Systems in the same term probably wasn't a bright idea.
Anyway, the new version of Regulus is written in C++ and Python. It actually started as 100% Python, not including the 3rd-party modules I'm using, wxPython, NumPy and PyOpenGL. This made it much easier to get things working than if I had started in C++. It also made it pretty easy to profile and refactor the code to optimize the algorithms. Prior to optimization, subtracting a sphere from a cube took about 2 minutes. After optimization it took a few seconds.
Now that the algorithms are optimized, I'm porting the slower bits to C++. I'm using SWIG for now, but I'm thinking about trying out Boost.Python. Once I finish porting the bits to C++ that I want to be ported, I probably won't be using NumPy or PyOpenGL anymore. They're both fine, but almost every place I'm using them happens to be in an inner loop.
Here are some screenshots:
All of these images consist of 4 sub-images: top, front, side and a "3/4". The first image is a cube (red) with various transformed cubes subtracted from it. In Regulus, if a solid is subtracted from another the "cut" surface inherits the surface properties of the solid that made the cut. So you can see that a blue cube and a long thin green rod (a stretched cube) were subtracted from the red cube. The second image is simply a wireframe version of this same scene.
The third image is what happens if you subtract a violet cube from a red cube, and then subtract that resulting shape from a green cube. And no, the lines aren't supposed to be parallel. There's a slight twist to each of the cubes to, err, make it interesting I guess. :-) Once again the fourth image is a wireframe version of the preceding image.
These screenshots are actually a little old. I'll try to put up some screenshots showing some operations on spheres soon.