Assignment 057: Construction of 3D mesh - Generalized Lissajous curve

The task is to construct a 3D representation of a generalized Lissajous curve. The curve is represented by simple equations given in the parametric form. Your task is to "wrap" the curve into a triangle mesh. You will be given an environment with implemented boundary model of the scene (that is, a triangle mesh) enriched by the "Corner-table". Your result should be a correct representation of the 3D geometry in memory, which the application can render on the screen or save to a file.

3D Lissajous

Basics

You will build on the project 086shaders from the grcis repository (make sure to always SVN update just before you start working on a new project). The application can load up a 3D scene from a file (Wavefront OBJ) or generate it through an algorithm (this is where your code comes in). The scene is then rendered using the GPU. Should your generated geometry contain per-vertex normal vectors, the GPU renderer will also be able to use smooth shading. The resulting rendering (bitmap) as well as the 3D scene can be saved to a disk.
To construct your geometry, you will modify the prepared class Construction in the source file Construction.cs. The construction method is called Construction.AddMesh(). Smooth shading is optional, but if you want to use it, make sure to generate the normal vectors at the mesh vertices.
You will have to respect the given transformation matrix m, by which you will transform all the generated vertices (Vector3.TransformPosition()) and their normal vectors (Vector3.TransformVector()).

Curve representation

You will have to "wrap" the curve by a triangle mesh so that its shape is nicely visible. An ideal solution is to use a cylindrical tube with a circular or similar cross-section - that's up to you. (If you want to be creative, the cross-section could gradually change along the curve.) A smooth appearance of the tube can be improved by shading, for which you will have to set per-vertex normals (which the GPU will interpolate across the triangles).
The Lissajous curve is defined in a parametric form using goniometric functions. For this reason, its tangent vector can be easily calculated by taking the first derivative of the defining equaltions. Having the tangent vector, one can find a plane perpendicular to the tangent (and therefore also to the curve at a given point). In this plane you may calculate several vertices "wrapping" the curve. The respective vertices of the neigboring cross-sections should then be connected to create a smooth mesh approximating the tube.

Theory

The Wikipedia page on Lissajous curve. A 3D generalization is simple, you simply add another coordinate Z, see Lissajous knot. We recommend to reorganize the formulas so that they only contain the cosine function (with an appropriate phase shift, just like on the Lissajous knot page).
Another possible extension would be adding another term (another cosine with a different frequency and phase shift) into all the equations, such as for the Rose curve.
Calculation of the domain: Lissajous (and "Rose") curve is cyclic (i.e. periodic), that is, the parameter t should run from zero to a multiple of PI. It is not entirely trivial to find out this interval, but your task is to try. Hint: work with frequency coefficient as rational numbers.

Technical details

You will be given a 3D object SceneBrep, into which you will add the created geometry. You will be given a transformation matrix of the instance Matrix4 and a text string that can be used to parametrize the geometry construction (e.g. the kind of cross-section, should you implement more of them, etc.). Remember that your function Construction.AddMesh() can be called repeatedly. Do not, in any case, initialize a scene object. Instead, upon every call, simply add a new instance of your geometry (transformed through the given matrix of the instance).

For simpler debugging, you may enter an initial value of the text parameter param - use the function InitParams() for this.

After you have created 1 to 8 instances of your geometry, the procedure CheckCornerTable() will be run, which will check the consistency of the topology (i.e. mesh connectivity) of your geometry. If you see a non-zero number of errors, you should open the "Output" window in Visual Studio an check the detected inconsistencies.

Construction method

  • geometry vertices are added using the method SceneBrep.AddVertex(). Remember to first transform the vertices thorough a given transformation matrix (using e.g. Vector3.TransformPosition()).
  • normal vectors are set using the method SceneBrep.SetNormal(). Remember to first transform the vertices thorough a given transformation matrix (using e.g. Vector3.TransformVector()).
  • triangles are initialized using the method SceneBrep.AddTriangle(i,j,k). Use indices of three previously added vertices (the vertex index is the return value of SceneBrep.AddVertex()).

Beuty render in 3ds Max / Corona renderer

As an optional part of the assignment, you may load up your exported geometry into 3d Max and achieve an artistic-quality abstract rendering. For that, you will need to assign material to your geometry (experiment with materials from the Corona material library), set up illumination (experiment with the sun/sky model, Corona lights, or HDRI maps). You may also apply some interesting post-processing effects such as glare etc.

Deadline

The due date is: 30. 12. 2018

Points

Base: 6 pts - implementation of a generalized Lissajous curve wrapped in at least some trivial way by triangles.
Bonus up to 4 pts for a nice wrapping by a "tube" and for setting colors (Hhow about using that cyclic mandala palette you once created...)
Bonus up to 2 pts for an automatic calculation of the domain of the curve.
Bonus up to 3 pts for generation of normal vectors (will be seen when shading is on and after importing the geometry in 3ds Max).
Bonus up to 3 pts for further extensions (e.g. the "Rose" curve).
Bonus up to 5 pts: for a "beauty" render of your geometry in 3ds Max / Corona rendrer. The actual number of points will depend on the complexity of your setup and the aesthetic quality of the output.

Project

Visual Studio project: 086shader
Make sure to always SVN update just before you start working on a new project.

Source file

Modify and hand in the file: Construction.cs Remember to put your name in the function InitParams()!
Should you decide to implement the optional 3ds Max beauty render, please include up to three different, high-resolution (around 2K) rendered images. Image framing / aspect ratio is entirely up to you.


Copyright (C) 2010-2018 J.Pelikán and J.Krivánek, last change: 2019-05-09 17:52:59 +0200 (Thu, 09 May 2019)