--- /dev/null
+\documentclass{article}
+\usepackage{fullpage}
+\usepackage{graphicx}
+\usepackage{minted}
+\begin{document}
+\title{Assignment 2}
+\author{Luke Lau 16336810}
+\maketitle
+
+\setminted[c++]{stripall,linenos,breaklines,tabsize=4}
+
+\section{3D}
+For 3D, I first had to add an additional number of vertices to create a square pyramid model:
+
+\inputminted[firstline=181,lastline=198,gobble=1]{c++}{../main.cpp}
+
+The vertex shader then got 3 new matrices: the model, view and projection matrices.
+
+\inputminted{glsl}{../vertex.glsl}
+
+These matrices are computed and bound during the display function:
+
+\inputminted[firstline=36,lastline=45,gobble=2]{c++}{../main.cpp}
+\inputminted[firstline=62,lastline=62,gobble=2]{c++}{../main.cpp}
+
+\texttt{GL\_DEPTH\_TEST} also needed to be enabled so that each side of pyramid was drawn in the correct order (lower Z values first, higher Z values last).
+
+\section{Transformations and Animations}
+
+Various scale, rotation and translation transformations can be performed by manipulating the model matrix.
+To animate it, the amount that the model is transformed by can be multiplied with the elapsed time at the time of drawing.
+\inputminted[firstline=47,lastline=59,gobble=2]{c++}{../main.cpp}
+It was important to translate the model into its position in the world first, before performing any of the rotation or scaling, otherwise the rotation/scaling ended up affecting its position.
+
+\section{Multiple Pyramids}
+Originally I planned on duplicating the vertices stored in the vertex buffer, but as it turns out is sufficient enough to redraw the same 12 vertices and just translate them beforehand.
+
+\begin{figure}[!htb]
+\minipage{0.32\textwidth}
+ \includegraphics[width=\linewidth]{plain}
+ \caption{The pyramids with no transformations}
+\endminipage\hfill
+\minipage{0.32\textwidth}
+ \includegraphics[width=\linewidth]{rotateAndScale}
+ \caption{Scaling and rotation applied}
+\endminipage\hfill
+\minipage{0.32\textwidth}
+ \includegraphics[width=\linewidth]{translate}
+ \caption{Sinusoidal translations, individual to each pyramid}
+\endminipage
+\end{figure}
+
+\section{Camera and movement}
+
+I handle keyboard input by storing a map of which keys are currently pressed down, and then updating the position on a timer.
+\inputminted[firstline=210,lastline=246]{c++}{../main.cpp}
+
+The yaw used above is calculated alongside the pitch based on mouse movement.
+\inputminted[firstline=248,lastline=271]{c++}{../main.cpp}
+
+By working on the pitch and yaw of the camera, we can calculate the direction the camera should be facing. This is stored in the \texttt{camFront} vector.
+This is combined with \texttt{camUp}, which defines the roll of the camera, and is used to calculate the view matrix with \mintinline{c++}{glm::lookAt}.
+Since we don't want the camera to be angled on its side, \texttt{camUp} is left as just the $y$ normal vector.
+
+
+
+\end{document}
+++ /dev/null
-This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) (preloaded format=pdflatex 2018.9.19) 22 SEP 2018 16:52
-entering extended mode
- restricted \write18 enabled.
- %&-line parsing enabled.
-**report.latex
-(./report.latex
-LaTeX2e <2018-04-01> patch level 2
-Babel <3.18> and hyphenation patterns for 22 language(s) loaded.
-(/usr/local/texlive/2018basic/texmf-dist/tex/latex/base/article.cls
-Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
-(/usr/local/texlive/2018basic/texmf-dist/tex/latex/base/size10.clo
-File: size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
-)
-\c@part=\count80
-\c@section=\count81
-\c@subsection=\count82
-\c@subsubsection=\count83
-\c@paragraph=\count84
-\c@subparagraph=\count85
-\c@figure=\count86
-\c@table=\count87
-\abovecaptionskip=\skip41
-\belowcaptionskip=\skip42
-\bibindent=\dimen102
-)
-(/usr/local/texlive/2018basic/texmf-dist/tex/latex/preprint/fullpage.sty
-Package: fullpage 1999/02/23 1.1 (PWD)
-\FP@margin=\skip43
-)
-(/usr/local/texlive/2018basic/texmf-dist/tex/latex/listings/listings.sty
-(/usr/local/texlive/2018basic/texmf-dist/tex/latex/graphics/keyval.sty
-Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
-\KV@toks@=\toks14
-)
-\lst@mode=\count88
-\lst@gtempboxa=\box26
-\lst@token=\toks15
-\lst@length=\count89
-\lst@currlwidth=\dimen103
-\lst@column=\count90
-\lst@pos=\count91
-\lst@lostspace=\dimen104
-\lst@width=\dimen105
-\lst@newlines=\count92
-\lst@lineno=\count93
-\lst@maxwidth=\dimen106
-
-(/usr/local/texlive/2018basic/texmf-dist/tex/latex/listings/lstmisc.sty
-File: lstmisc.sty 2015/06/04 1.6 (Carsten Heinz)
-\c@lstnumber=\count94
-\lst@skipnumbers=\count95
-\lst@framebox=\box27
-)
-(/usr/local/texlive/2018basic/texmf-dist/tex/latex/listings/listings.cfg
-File: listings.cfg 2015/06/04 1.6 listings configuration
-))
-Package: listings 2015/06/04 1.6 (Carsten Heinz)
-
-(/usr/local/texlive/2018basic/texmf-dist/tex/latex/graphics/graphicx.sty
-Package: graphicx 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)
-
-(/usr/local/texlive/2018basic/texmf-dist/tex/latex/graphics/graphics.sty
-Package: graphics 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
-
-(/usr/local/texlive/2018basic/texmf-dist/tex/latex/graphics/trig.sty
-Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
-)
-(/usr/local/texlive/2018basic/texmf-dist/tex/latex/graphics-cfg/graphics.cfg
-File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
-)
-Package graphics Info: Driver file: pdftex.def on input line 99.
-
-(/usr/local/texlive/2018basic/texmf-dist/tex/latex/graphics-def/pdftex.def
-File: pdftex.def 2018/01/08 v1.0l Graphics/color driver for pdftex
-))
-\Gin@req@height=\dimen107
-\Gin@req@width=\dimen108
-)
-(./report.aux)
-\openout1 = `report.aux'.
-
-LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 5.
-LaTeX Font Info: ... okay on input line 5.
-LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 5.
-LaTeX Font Info: ... okay on input line 5.
-LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 5.
-LaTeX Font Info: ... okay on input line 5.
-LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 5.
-LaTeX Font Info: ... okay on input line 5.
-LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 5.
-LaTeX Font Info: ... okay on input line 5.
-LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 5.
-LaTeX Font Info: ... okay on input line 5.
-\c@lstlisting=\count96
-
-(/usr/local/texlive/2018basic/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
-[Loading MPS to PDF converter (version 2006.09.02).]
-\scratchcounter=\count97
-\scratchdimen=\dimen109
-\scratchbox=\box28
-\nofMPsegments=\count98
-\nofMParguments=\count99
-\everyMPshowfont=\toks16
-\MPscratchCnt=\count100
-\MPscratchDim=\dimen110
-\MPnumerator=\count101
-\makeMPintoPDFobject=\count102
-\everyMPtoPDFconversion=\toks17
-) (/usr/local/texlive/2018basic/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
-Package: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf
-(/usr/local/texlive/2018basic/texmf-dist/tex/generic/oberdiek/infwarerr.sty
-Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO)
-)
-(/usr/local/texlive/2018basic/texmf-dist/tex/latex/oberdiek/grfext.sty
-Package: grfext 2016/05/16 v1.2 Manage graphics extensions (HO)
-
-(/usr/local/texlive/2018basic/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty
-Package: kvdefinekeys 2016/05/16 v1.4 Define keys (HO)
-
-(/usr/local/texlive/2018basic/texmf-dist/tex/generic/oberdiek/ltxcmds.sty
-Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
-)))
-(/usr/local/texlive/2018basic/texmf-dist/tex/latex/oberdiek/kvoptions.sty
-Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO)
-
-(/usr/local/texlive/2018basic/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
-Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO)
-
-(/usr/local/texlive/2018basic/texmf-dist/tex/generic/oberdiek/etexcmds.sty
-Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
-
-(/usr/local/texlive/2018basic/texmf-dist/tex/generic/oberdiek/ifluatex.sty
-Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO)
-Package ifluatex Info: LuaTeX not detected.
-)
-Package etexcmds Info: Could not find \expanded.
-(etexcmds) That can mean that you are not using pdfTeX 1.50 or
-(etexcmds) that some package has redefined \expanded.
-(etexcmds) In the latter case, load this package earlier.
-)))
-(/usr/local/texlive/2018basic/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
-Package: pdftexcmds 2018/01/30 v0.27 Utility functions of pdfTeX for LuaTeX (HO
-)
-
-(/usr/local/texlive/2018basic/texmf-dist/tex/generic/oberdiek/ifpdf.sty
-Package: ifpdf 2017/03/15 v3.2 Provides the ifpdf switch
-)
-Package pdftexcmds Info: LuaTeX not detected.
-Package pdftexcmds Info: \pdf@primitive is available.
-Package pdftexcmds Info: \pdf@ifprimitive is available.
-Package pdftexcmds Info: \pdfdraftmode found.
-)
-Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4
-38.
-Package grfext Info: Graphics extension search list:
-(grfext) [.pdf,.png,.jpg,.mps,.jpeg,.jbig2,.jb2,.PDF,.PNG,.JPG,.JPE
-G,.JBIG2,.JB2,.eps]
-(grfext) \AppendGraphicsExtensions on input line 456.
-
-(/usr/local/texlive/2018basic/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg
-File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Liv
-e
-))
-LaTeX Font Info: External font `cmex10' loaded for size
-(Font) <12> on input line 9.
-LaTeX Font Info: External font `cmex10' loaded for size
-(Font) <8> on input line 9.
-LaTeX Font Info: External font `cmex10' loaded for size
-(Font) <6> on input line 9.
- (/usr/local/texlive/2018basic/texmf-dist/tex/latex/listings/lstlang1.sty
-File: lstlang1.sty 2015/06/04 1.6 listings language file
-)
-(/usr/local/texlive/2018basic/texmf-dist/tex/latex/listings/lstlang1.sty
-File: lstlang1.sty 2015/06/04 1.6 listings language file
-)
-(/usr/local/texlive/2018basic/texmf-dist/tex/latex/listings/lstmisc.sty
-File: lstmisc.sty 2015/06/04 1.6 (Carsten Heinz)
-)
-(./fragment.glsl
-LaTeX Font Info: Font shape `OT1/cmtt/bx/n' in size <10> not available
-(Font) Font shape `OT1/cmtt/m/n' tried instead on input line 1.
-)
-<part1.png, id=1, 915.42pt x 736.7525pt>
-File: part1.png Graphic file (type png)
-<use part1.png>
-Package pdftex.def Info: part1.png used on input line 20.
-(pdftex.def) Requested size: 375.80544pt x 302.4527pt.
- [1
-
-{/usr/local/texlive/2018basic/texmf-var/fonts/map/pdftex/updmap/pdftex.map} <./
-part1.png>]
-<part2.png, id=14, 915.42pt x 736.7525pt>
-File: part2.png Graphic file (type png)
-<use part2.png>
-Package pdftex.def Info: part2.png used on input line 54.
-(pdftex.def) Requested size: 375.80544pt x 302.4527pt.
- [2 <./part2.png>]
-Overfull \hbox (46.84398pt too wide) in paragraph at lines 90--92
-[][][][][][][][][][][][][][][][][][][][]
- []
-
-
-Overfull \hbox (235.84361pt too wide) in paragraph at lines 101--103
-[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
- []
-
-[3]
-Overfull \hbox (21.64403pt too wide) in paragraph at lines 169--170
-[][][][][][][][][][][][][][][][][][][][][][][][][][][][]
- []
-
-[4]
-Overfull \hbox (9.04405pt too wide) in paragraph at lines 174--175
-[][][][][][][][][][][][][][][][][][][][][][][][][][][][]
- []
-
-(./yellow.glsl)
-<part4.png, id=25, 915.42pt x 736.7525pt>
-File: part4.png Graphic file (type png)
-<use part4.png>
-Package pdftex.def Info: part4.png used on input line 199.
-(pdftex.def) Requested size: 375.80544pt x 302.4527pt.
- [5 <./part4.png>] (./report.aux) )
-Here is how much of TeX's memory you used:
- 3356 strings out of 494091
- 46707 string characters out of 6163523
- 147119 words of memory out of 5000000
- 7005 multiletter control sequences out of 15000+600000
- 7448 words of font info for 27 fonts, out of 8000000 for 9000
- 319 hyphenation exceptions out of 8191
- 41i,6n,61p,275b,1582s stack positions out of 5000i,500n,10000p,200000b,80000s
-</usr/local/texlive/2018basic/texmf-dist/fon
-ts/type1/public/amsfonts/cm/cmbx12.pfb></usr/local/texlive/2018basic/texmf-dist
-/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr/local/texlive/2018basic/texmf-d
-ist/fonts/type1/public/amsfonts/cm/cmr12.pfb></usr/local/texlive/2018basic/texm
-f-dist/fonts/type1/public/amsfonts/cm/cmr17.pfb></usr/local/texlive/2018basic/t
-exmf-dist/fonts/type1/public/amsfonts/cm/cmtt10.pfb>
-Output written on report.pdf (5 pages, 843858 bytes).
-PDF statistics:
- 47 PDF objects out of 1000 (max. 8388607)
- 28 compressed objects within 1 object stream
- 0 named destinations out of 1000 (max. 500000)
- 16 words of extra memory for PDF output out of 10000 (max. 10000000)
-