Stuff
[opengl.git] / assignment-4 / report.latex
diff --git a/assignment-4/report.latex b/assignment-4/report.latex
new file mode 100644 (file)
index 0000000..ebb6fd2
--- /dev/null
@@ -0,0 +1,39 @@
+\documentclass{article}
+\usepackage{fullpage}
+\usepackage{graphicx}
+\usepackage{minted}
+\begin{document}
+\title{Hierarchical animation}
+\author{Luke Lau 15336810}
+\maketitle
+
+\includegraphics[width=\textwidth]{chest0}
+\includegraphics[width=\textwidth]{chest1}
+
+\section{Loading models with AssImp}
+I created a Model class that handles loading in the model from AssImp.
+It has an internal class for each Node (\texttt{aiNode}) and a struct for Mesh (\texttt{aiMesh}).
+\inputminted{c++}{../model.hpp}
+
+Each mesh stores a vector of all its vertices, as well as a list of all the indices of these vertices that it needs to draw. By storing the vertices in a \texttt{GL\_ARRAY\_BUFFER} and the indices in a \texttt{GL\_ELEMENT\_ARRAY\_BUFFER}, this allows faces that reuse multiple vertices to be drawn with
+\mintinline{c++}{glDrawElements(GL\_TRIANGLES, mesh.numIndices, GL\_UNSIGNED\_INT, 0)}, rather than \mintinline{c++}{glDrawArray(..)}.
+The AssImp triangulation post-processing flag ensures that each face is a triangle, so that \texttt{GL\_TRIANGLES} can be used throughout.
+
+\inputminted[firstline=6,lastline=72]{c++}{../model.cpp}
+
+\section{Node hierarchy}
+
+The nodes are stored in an hierarchical structure. The pretransform-vertices post-processing flag had to be disabled to prevent AssImp from flattening out the hierarchy, but this then allows for hierarchical animation to be done at each individual mesh in a single loaded object.
+
+By naming each of the nodes (objects in blender) and setting them as parents, I was able to use \mintinline{cpp}{aiNode.FindNode(const char* name)} to access them from my program.
+
+       \includegraphics[width=\textwidth]{blender}
+
+Each node object has a model variable which is then used in conjunction with its parent's model (and blender transformation) to work out the global transformation.
+\inputminted[firstline=92,lastline=110]{c++}{../model.cpp}
+
+Together with the ability to access nodes by name and set an individual transformation, defining the hierarchical animation can be done like so.
+
+\inputminted[firstline=181,lastline=198,gobble=1]{c++}{../main.cpp}
+
+\end{document}