Graphics Project
An interactive OpenGL tool that lets users sketch points on a 2D plane, generate a ruled-surface mesh with adjustable subdivisions, and export the result as a watertight .OBJ for 3D printing.
Click points on a 2D plane → the tool lofts a ruled surface into a triangle mesh (controlled by steps) → export as .OBJ for printing.
I built this project to explore interactive geometry modeling: how to go from a minimal user input (a few points on a plane) to a structured 3D surface that is:
steps) to control surface smoothness / triangle densitygeometry.objTrackBallC trackball) provides intuitive orbit/rotate viewing.mouseLeft, mouseMid, mouseRight) and cursor positions (mouseX, mouseY) support point placement and navigation.objectPoints (a list of glm::vec3), while a simple XY reference plane is drawn from planePoints.The core mesh is built as triangles:
vvector<TriangleC> tri) so the geometry can be exported reliablyKey idea: the tool generates triangles as it builds the surface, then converts every 3 vertices into a TriangleC:
tri for later .obj writingThis keeps the rendering representation (GPU buffer) and the export representation (triangle list) consistent.
The surface resolution is controlled by:
steps = number of subdivisions per segment (default 12)There are two generation cases:
If the user provides a single point, the tool generates a circular ring using:
OpCreateRuledCircle(vv, n)circle(y, x, n) mapping into 3D via sin/cos around 2πThis makes a simple “lathe-like” surface primitive.
For multiple points, the tool builds a surface strip between each consecutive pair:
OpCreateRuled(vv, n, u) iterates through point pairsn3, n4)Each quad-like patch is tessellated into two triangles (“lower” and “upper”), producing a consistent triangle mesh.
Once vertices are generated:
glBufferDataThis happens for:
BuildObject)BuildPlane)So the user gets immediate visual feedback as they add points / adjust subdivisions.
Because every triangle is stored in tri, export becomes straightforward:
v entriesf indices for each trianglegeometry.objThis is intentionally separated from GPU buffers so the exported mesh matches what’s on screen.
steps) let users trade off speed vs smoothness.obj for slicers / 3D printingsteps: subdivision level (mesh resolution)pointSize, lineWidth: visualization settingsaddVertices: toggle between editing and viewing modessteps produces faceting)