summaryrefslogtreecommitdiffstats
path: root/Smoke/report/chapter7.tex
blob: fef2fbb7599772e45bb0514e3ef1fbc10b3147f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
\chapter{Height plots}

Height plots are a very neat visualization technique. What are height plots, what are they used for and how did we implement them? \\

\section{Description}

All the previous discussed methods are implemented on a 2D grid. But sometimes it's also useful to see the value not by its color but by the height of the surface. This is exactly what a height plot does, it maps the values onto the Z-axis. Since the simulation uses a top down view, not much can be seen. Even with lightening and shadows it still left to be desired. \\

By rotating the field the height plots become much more visible. Rotation is achieved by dragging the mouse over the screen while holding the middle mouse button or scroll wheel, this however only controlls the yaw and the pitch. Rolling can easily be done by using the shift key in addition to the mouse button. The shift key can also be used on the left mouse button to move the field up and down, left and right. This all becomes helpfull when using the scroll wheen to zoom in and out. \\

\section{Implementation}

Realizing height plots would not be very visible from the default view, rotation, zoom and movement was implemented first. After having the ability we costructed the height plots as follows. \\

Since vertex allready had x and y-coordinates, all that was needed was to add a z-coordinate. An extra array to track the height of each vertex was used, as the original simulation and its datastructers should not be disturbed. As value for the height any of the primary datasets can be choosen. When drawing a vertex the stored height from the array is then rendered using that value for the z-coordinate. \\

To see improve the preception of depth in the simulation some ambient and diffuse light was added. In order to let the light have effect on the surface also the normal vector was being calculated and stored for each vertex. \\

\begin {center}
  \includegraphics[width=\textwidth]{height_plot.png} \\
  Figure 9: A height plot of the density \\
\end {center}

The above image (figure 9) shows a height plot of a fluid where the height translates to the density of the fluid. The colormap is also mapped to the density but this does not necessarily have to be the case. In figure 10, the height is visualizing the velocity of the fluid while the colormap shows differences in the density. \\

It can be seen in the second height plot, the bright yellow colors are not on the highest point of the height map. This means the density is not always the largest where the velocity is high. \\

\begin {center}
  \includegraphics[width=\textwidth]{height_plot2.png} \\
  Figure 10: Velocity height plot \\
\end {center}

\subsection{Normal vector}

To calculate the normal vector for a given vertex, say $ v_0 $, firstly the two neighboring vertices in that cell are taken, $ v_{1} $ and $ v_{2} $. Then the difference of $ v_0 $ with $ v_1 $ and of $ v_1 $ with $ v_2 $ is taken. Lastly the cross product of these two differences is normalized to yield the result. This gives the normal vector at $ v_0 $. \\

OpenGL uses this vector to calculate the angle between the normal and the light source that is shining on the vertex. This angle is then used to shade a vertex, and with that an entire surface. \\

\section{Difficulties}

Some small issues throughout the implementation of this assignment arose, but eventually where implement correctly. \\

\subsection{Rotation}

The first problem encountered was due to the rotation of the field. Rotating around one axis was not to difficult. When trying to rotate the field around two or three axes, the simulation would not rotate around its center any more.\\

As it turns out the translation and rotation was in the opposite order. After changing the order of rotation and translation the simlation turned properly around the center. \\

\subsection{Height strips}

When first implementing the height plots a third dimension was simply added when rendering the triangle strips for the smoke visualization. This had as an effect that the different rows of each of the triangle strips in the simulation where not connected. In stead of a height plots we implemented height strips. \\

This problem was countered first calculating the height for each vertex and storing it in an array. When rendering a vertex, the correct value is then retrieved from the array to correctly display the height. \\

\subsection{Calculating the normal vector}

When enabling the light in our program and adding the normal to each vertex there where some strange result. Because of the fact thatthe left lower neightbor was not concistently evaluated to calculate the normal vector. As a result each vertex was randomly pointing up or downwards, resulting in something that could be best explained as a checkers board. \\

When rendering the normal vectors the cause of the problem became immediatly visiable and it was quickly resolved. \\