Task 095: Building a 3D Scene - Space Filling Curves

Your task is to construct a space filling 3D curve, but built as a surface model composed of triangles. The structure must be created via algorithmic means, i.e. the 3D point locations, and the assmebly of individual points into triangles, must be the result of your algorithm (that is, no hard-coding of 3D structures is allowed). You have to come up with a representation of the object that allows you to control drawing, shading, and possibly also to save it to disk in PLY format.

3D Hilbert
© Michael Bader


The template application 086shader from the repository grcis serves as the basis of this project. This is a complete template application which can load a 3D scene from file in OBJ format, or generate geometry via an algorithm (this is the part you have to fill in). You can then choose from several drawing modes for the stored geometry. The 3D scene can be saved as Stanford PLY file.
Your task is to modify the class Construction located in the file Construction.cs. There, you will have to fill in the method Construction.AddMesh(). Do not forget to set the vertex normal vectors, and take the current transformation matrix m into account.

Alternative Project

As an easier alternative, you can also work with the base project 038trackball, which uses comparatively simple OpenGL rendering instead of advanced shading. The class file Construction.cs is 1:1 interchangeable between both projects.


You can draw from the following sources: Space-Filling Curves in 3D (lecture by Michael Bader) or the reference pages of Aubrey Jaffer (with lots of links to articles about individual curves).
Google search (3D SFC images).

Technical Details

Within the application, there following resources exist: a 3D object SceneBrep to which you can add your vertices and triangles, a transformation matrix Matrix4, and a text parameter that can contain construction parameters that are specific to your chosen algorithm.
Remember that your method Construction.AddMesh() can be invoked repeatedly. Never return an empty object, and always return a new instance of the solid you are creating (with the given transformation matrix applied).

The 3D curve should have a cylindrical cross-section, for a nice appearance and shading results. The curve joints that connect each cylindrical section should be modelled as torus sections. You will need to find a suitable tessellation resolution for the cylindrical and toroidal sections, so that the result is not too complex, but still looks nice. Optimally, the user should be able to control this via parameters.

It is also possible to use a rectangular cross-section, i.e. to create square pipes. In this case, you should not share the vertices of adjacent walls, but rather duplicate them, so that every wall had its own normal vectors.

To allow users to manipulate pre-existing parameters that are specific to your solution (i.e. to save them typing work), you can specify the initial value of the text parameter param via the function InitParams().

After creating instances of your object, the method CheckCornerTable() runs, which checks the topology of the created model. You should check the text console ("Output" in Visual Studio) to see whether inconsistencies were found.

Methods Available for Mesh Construction

  • Vertices can be added via SceneBrep.AddVertex(). Don't forget to transform the points, if needed! (e.g. Vector3.TransformPosition())
  • Normal vectors can be set via SceneBrep.SetNormal(). Again, transform them first, if this is needed! (e.g. Vector3.TransformVector() - note the different method from the previous example: vectors and points transform differently!)
  • Triangles can be defined via SceneBrep.AddTriangle(i,j,k). For this, you have to use the vertex indices you defined earlier: the return value of SceneBrep.AddVertex() is the index of the vertex you just created.


Hand in until: 10. 1. 2017


Basis: 10 points (if a simple shape is successfully generated).
Bonus: up to 6 additional points for parameterisation options, and possibly shadows


Visual Studio projects: 038trackball or 068shader
The modified source file can be used interchangeably for both applications!

Source file

Modify and hand in the source file: Construction.cs
As a comment in the first line, please include your name!

Copyright (C) 2016 J. Pelikán & A. Wilkie, last change: 2015-10-26 01:59:27 +0100 (Mo, 26 Okt 2015)