X-Git-Url: http://git.lukelau.me/?p=opengl.git;a=blobdiff_plain;f=assignment-4%2Freport.latex;fp=assignment-4%2Freport.latex;h=ebb6fd26b0b5416b25951122de155faf69154ddc;hp=0000000000000000000000000000000000000000;hb=85f8f7278f24fe73fef1a19174376b155319072f;hpb=1043b5b05e00f830da26624eee8b25fb4dc4e4fc diff --git a/assignment-4/report.latex b/assignment-4/report.latex new file mode 100644 index 0000000..ebb6fd2 --- /dev/null +++ b/assignment-4/report.latex @@ -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}