diff --git a/professorTests/models/cone_1_2_4_3.3d b/professorTests/models/cone_1_2_4_3.3d
index bb2848e1..d541ba46 100644
--- a/professorTests/models/cone_1_2_4_3.3d
+++ b/professorTests/models/cone_1_2_4_3.3d
@@ -1,38 +1,86 @@
+# cone 1.000000 2.000000 4 3
v 0 0 0
v 1 0 0
v -4.37114e-08 0 1
v -1 0 -8.74228e-08
v 1.19249e-08 0 -1
+v 1 0 1.74846e-07
+v 1 0 0
+v -4.37114e-08 0 1
+v -1 0 -8.74228e-08
+v 1.19249e-08 0 -1
+v 1 0 1.74846e-07
v 0.666667 0.666667 0
v -2.91409e-08 0.666667 0.666667
v -0.666667 0.666667 -5.82818e-08
v 7.94992e-09 0.666667 -0.666667
+v 0.666667 0.666667 1.16564e-07
v 0.333333 1.33333 0
v -1.45705e-08 1.33333 0.333333
v -0.333333 1.33333 -2.91409e-08
v 3.97496e-09 1.33333 -0.333333
+v 0.333333 1.33333 5.82818e-08
+v 0 2 0
+v -0 2 0
+v -0 2 -0
+v 0 2 -0
v 0 2 0
-f 1 2 3
-f 1 3 4
-f 1 4 5
-f 1 5 2
-f 2 6 7
-f 2 7 3
-f 3 7 8
-f 3 8 4
-f 4 8 9
-f 4 9 5
-f 5 9 6
-f 5 6 2
-f 6 10 11
-f 6 11 7
-f 7 11 12
-f 7 12 8
-f 8 12 13
-f 8 13 9
-f 9 13 10
-f 9 10 6
-f 10 14 11
-f 11 14 12
-f 12 14 13
-f 13 14 10
+vt 0.5 0.5
+vt 1 0.5
+vt 0.5 1
+vt 0 0.5
+vt 0.5 0
+vt 1 0.5
+vt 0 0
+vt 0.25 0
+vt 0.5 0
+vt 0.75 0
+vt 1 0
+vt 0 0.333333
+vt 0.25 0.333333
+vt 0.5 0.333333
+vt 0.75 0.333333
+vt 1 0.333333
+vt 0 0.666667
+vt 0.25 0.666667
+vt 0.5 0.666667
+vt 0.75 0.666667
+vt 1 0.666667
+vt 0 1
+vt 0.25 1
+vt 0.5 1
+vt 0.75 1
+vt 1 1
+vn 0 -1 0
+vn 0.894427 0.447214 0
+vn -3.90967e-08 0.447214 0.894427
+vn -0.894427 0.447214 -7.81933e-08
+vn 1.06659e-08 0.447214 -0.894427
+f 1/1/1 2/2/1 3/3/1
+f 1/1/1 3/3/1 4/4/1
+f 1/1/1 4/4/1 5/5/1
+f 1/1/1 5/5/1 6/6/1
+f 7/7/2 12/12/2 13/13/3
+f 7/7/2 13/13/3 8/8/3
+f 8/8/3 13/13/3 14/14/4
+f 8/8/3 14/14/4 9/9/4
+f 9/9/4 14/14/4 15/15/5
+f 9/9/4 15/15/5 10/10/5
+f 10/10/5 15/15/5 16/16/2
+f 10/10/5 16/16/2 11/11/2
+f 12/12/2 17/17/2 18/18/3
+f 12/12/2 18/18/3 13/13/3
+f 13/13/3 18/18/3 19/19/4
+f 13/13/3 19/19/4 14/14/4
+f 14/14/4 19/19/4 20/20/5
+f 14/14/4 20/20/5 15/15/5
+f 15/15/5 20/20/5 21/21/2
+f 15/15/5 21/21/2 16/16/2
+f 17/17/2 22/22/2 23/23/3
+f 17/17/2 23/23/3 18/18/3
+f 18/18/3 23/23/3 24/24/4
+f 18/18/3 24/24/4 19/19/4
+f 19/19/4 24/24/4 25/25/5
+f 19/19/4 25/25/5 20/20/5
+f 20/20/5 25/25/5 26/26/2
+f 20/20/5 26/26/2 21/21/2
diff --git a/reports/RelatorioFase4.tex b/reports/RelatorioFase4.tex
index 80f374e6..be298da9 100644
--- a/reports/RelatorioFase4.tex
+++ b/reports/RelatorioFase4.tex
@@ -138,6 +138,24 @@ \section{Resultados Obtidos}
{\color{red} TODO - cada faz as suas prints, sem borda de janela, no tamanho especificado pela cena,
com a UI escondida (U), Humberto escreve}
+\begin{figure}[H]
+ \centering
+ \includegraphics[width=\textwidth]{res/phase4/Cone.png}
+ \caption{Cone.}
+\end{figure}
+
+\begin{figure}[H]
+ \centering
+ \includegraphics[width=\textwidth]{res/phase4/IceCream.png}
+ \caption{Gelado.}
+\end{figure}
+
+\begin{figure}[H]
+ \centering
+ \includegraphics[width=\textwidth]{res/phase4/IceCreamXYZ.png}
+ \caption{Gelado.}
+\end{figure}
+
\section{Conclusão}
{\color{red} TODO - Humberto}
diff --git a/reports/res/phase4/Cone.png b/reports/res/phase4/Cone.png
new file mode 100644
index 00000000..4d2fca6e
Binary files /dev/null and b/reports/res/phase4/Cone.png differ
diff --git a/reports/res/phase4/IceCream.png b/reports/res/phase4/IceCream.png
new file mode 100644
index 00000000..552aa886
Binary files /dev/null and b/reports/res/phase4/IceCream.png differ
diff --git a/reports/res/phase4/IceCreamXYZ.png b/reports/res/phase4/IceCreamXYZ.png
new file mode 100644
index 00000000..b45bf600
Binary files /dev/null and b/reports/res/phase4/IceCreamXYZ.png differ
diff --git a/res/models/cone.3d b/res/models/cone.3d
index 5268c5c9..7f1ff1f9 100644
--- a/res/models/cone.3d
+++ b/res/models/cone.3d
@@ -1,29 +1,302 @@
-# cone 1.000000 2.000000 4 2
+# cone 1.000000 2.000000 16 3
v 0 0 0
v 1 0 0
+v 0.92388 0 0.382683
+v 0.707107 0 0.707107
+v 0.382683 0 0.92388
v -4.37114e-08 0 1
+v -0.382684 0 0.92388
+v -0.707107 0 0.707107
+v -0.92388 0 0.382683
v -1 0 -8.74228e-08
+v -0.92388 0 -0.382683
+v -0.707107 0 -0.707107
+v -0.382683 0 -0.92388
v 1.19249e-08 0 -1
+v 0.382684 0 -0.923879
+v 0.707107 0 -0.707107
+v 0.92388 0 -0.382683
v 1 0 1.74846e-07
-v 0.5 1 0
-v -2.18557e-08 1 0.5
-v -0.5 1 -4.37114e-08
-v 5.96244e-09 1 -0.5
-v 0.5 1 8.74228e-08
+v 1 0 0
+v 0.92388 0 0.382683
+v 0.707107 0 0.707107
+v 0.382683 0 0.92388
+v -4.37114e-08 0 1
+v -0.382684 0 0.92388
+v -0.707107 0 0.707107
+v -0.92388 0 0.382683
+v -1 0 -8.74228e-08
+v -0.92388 0 -0.382683
+v -0.707107 0 -0.707107
+v -0.382683 0 -0.92388
+v 1.19249e-08 0 -1
+v 0.382684 0 -0.923879
+v 0.707107 0 -0.707107
+v 0.92388 0 -0.382683
+v 1 0 1.74846e-07
+v 0.666667 0.666667 0
+v 0.61592 0.666667 0.255122
+v 0.471404 0.666667 0.471404
+v 0.255122 0.666667 0.61592
+v -2.91409e-08 0.666667 0.666667
+v -0.255122 0.666667 0.61592
+v -0.471404 0.666667 0.471404
+v -0.61592 0.666667 0.255122
+v -0.666667 0.666667 -5.82818e-08
+v -0.61592 0.666667 -0.255122
+v -0.471404 0.666667 -0.471405
+v -0.255122 0.666667 -0.61592
+v 7.94992e-09 0.666667 -0.666667
+v 0.255122 0.666667 -0.61592
+v 0.471405 0.666667 -0.471404
+v 0.61592 0.666667 -0.255122
+v 0.666667 0.666667 1.16564e-07
+v 0.333333 1.33333 0
+v 0.30796 1.33333 0.127561
+v 0.235702 1.33333 0.235702
+v 0.127561 1.33333 0.30796
+v -1.45705e-08 1.33333 0.333333
+v -0.127561 1.33333 0.30796
+v -0.235702 1.33333 0.235702
+v -0.30796 1.33333 0.127561
+v -0.333333 1.33333 -2.91409e-08
+v -0.30796 1.33333 -0.127561
+v -0.235702 1.33333 -0.235702
+v -0.127561 1.33333 -0.30796
+v 3.97496e-09 1.33333 -0.333333
+v 0.127561 1.33333 -0.30796
+v 0.235702 1.33333 -0.235702
+v 0.30796 1.33333 -0.127561
+v 0.333333 1.33333 5.82818e-08
+v 0 2 0
+v 0 2 0
+v 0 2 0
+v 0 2 0
+v -0 2 0
+v -0 2 0
+v -0 2 0
+v -0 2 0
+v -0 2 -0
+v -0 2 -0
+v -0 2 -0
+v -0 2 -0
+v 0 2 -0
+v 0 2 -0
+v 0 2 -0
+v 0 2 -0
v 0 2 0
-f 1 2 3
-f 1 3 4
-f 1 4 5
-f 1 5 6
-f 2 7 8
-f 2 8 3
-f 3 8 9
-f 3 9 4
-f 4 9 10
-f 4 10 5
-f 5 10 11
-f 5 11 6
-f 7 12 8
-f 8 12 9
-f 9 12 10
-f 10 12 11
+vt 0.5 0.5
+vt 1 0.5
+vt 0.96194 0.691342
+vt 0.853553 0.853553
+vt 0.691342 0.96194
+vt 0.5 1
+vt 0.308658 0.96194
+vt 0.146447 0.853553
+vt 0.0380602 0.691342
+vt 0 0.5
+vt 0.0380602 0.308658
+vt 0.146447 0.146447
+vt 0.308658 0.0380602
+vt 0.5 0
+vt 0.691342 0.0380603
+vt 0.853554 0.146447
+vt 0.96194 0.308658
+vt 1 0.5
+vt 0 0
+vt 0.0625 0
+vt 0.125 0
+vt 0.1875 0
+vt 0.25 0
+vt 0.3125 0
+vt 0.375 0
+vt 0.4375 0
+vt 0.5 0
+vt 0.5625 0
+vt 0.625 0
+vt 0.6875 0
+vt 0.75 0
+vt 0.8125 0
+vt 0.875 0
+vt 0.9375 0
+vt 1 0
+vt 0 0.333333
+vt 0.0625 0.333333
+vt 0.125 0.333333
+vt 0.1875 0.333333
+vt 0.25 0.333333
+vt 0.3125 0.333333
+vt 0.375 0.333333
+vt 0.4375 0.333333
+vt 0.5 0.333333
+vt 0.5625 0.333333
+vt 0.625 0.333333
+vt 0.6875 0.333333
+vt 0.75 0.333333
+vt 0.8125 0.333333
+vt 0.875 0.333333
+vt 0.9375 0.333333
+vt 1 0.333333
+vt 0 0.666667
+vt 0.0625 0.666667
+vt 0.125 0.666667
+vt 0.1875 0.666667
+vt 0.25 0.666667
+vt 0.3125 0.666667
+vt 0.375 0.666667
+vt 0.4375 0.666667
+vt 0.5 0.666667
+vt 0.5625 0.666667
+vt 0.625 0.666667
+vt 0.6875 0.666667
+vt 0.75 0.666667
+vt 0.8125 0.666667
+vt 0.875 0.666667
+vt 0.9375 0.666667
+vt 1 0.666667
+vt 0 1
+vt 0.0625 1
+vt 0.125 1
+vt 0.1875 1
+vt 0.25 1
+vt 0.3125 1
+vt 0.375 1
+vt 0.4375 1
+vt 0.5 1
+vt 0.5625 1
+vt 0.625 1
+vt 0.6875 1
+vt 0.75 1
+vt 0.8125 1
+vt 0.875 1
+vt 0.9375 1
+vt 1 1
+vn 0 -1 0
+vn 0.894427 0.447214 0
+vn 0.826343 0.447214 0.342283
+vn 0.632456 0.447214 0.632456
+vn 0.342282 0.447214 0.826343
+vn -3.90967e-08 0.447214 0.894427
+vn -0.342283 0.447214 0.826343
+vn -0.632456 0.447214 0.632456
+vn -0.826343 0.447214 0.342282
+vn -0.894427 0.447214 -7.81933e-08
+vn -0.826343 0.447214 -0.342283
+vn -0.632455 0.447214 -0.632456
+vn -0.342282 0.447214 -0.826343
+vn 1.06659e-08 0.447214 -0.894427
+vn 0.342283 0.447214 -0.826343
+vn 0.632456 0.447214 -0.632455
+vn 0.826343 0.447214 -0.342282
+f 1/1/1 2/2/1 3/3/1
+f 1/1/1 3/3/1 4/4/1
+f 1/1/1 4/4/1 5/5/1
+f 1/1/1 5/5/1 6/6/1
+f 1/1/1 6/6/1 7/7/1
+f 1/1/1 7/7/1 8/8/1
+f 1/1/1 8/8/1 9/9/1
+f 1/1/1 9/9/1 10/10/1
+f 1/1/1 10/10/1 11/11/1
+f 1/1/1 11/11/1 12/12/1
+f 1/1/1 12/12/1 13/13/1
+f 1/1/1 13/13/1 14/14/1
+f 1/1/1 14/14/1 15/15/1
+f 1/1/1 15/15/1 16/16/1
+f 1/1/1 16/16/1 17/17/1
+f 1/1/1 17/17/1 18/18/1
+f 19/19/2 36/36/2 37/37/3
+f 19/19/2 37/37/3 20/20/3
+f 20/20/3 37/37/3 38/38/4
+f 20/20/3 38/38/4 21/21/4
+f 21/21/4 38/38/4 39/39/5
+f 21/21/4 39/39/5 22/22/5
+f 22/22/5 39/39/5 40/40/6
+f 22/22/5 40/40/6 23/23/6
+f 23/23/6 40/40/6 41/41/7
+f 23/23/6 41/41/7 24/24/7
+f 24/24/7 41/41/7 42/42/8
+f 24/24/7 42/42/8 25/25/8
+f 25/25/8 42/42/8 43/43/9
+f 25/25/8 43/43/9 26/26/9
+f 26/26/9 43/43/9 44/44/10
+f 26/26/9 44/44/10 27/27/10
+f 27/27/10 44/44/10 45/45/11
+f 27/27/10 45/45/11 28/28/11
+f 28/28/11 45/45/11 46/46/12
+f 28/28/11 46/46/12 29/29/12
+f 29/29/12 46/46/12 47/47/13
+f 29/29/12 47/47/13 30/30/13
+f 30/30/13 47/47/13 48/48/14
+f 30/30/13 48/48/14 31/31/14
+f 31/31/14 48/48/14 49/49/15
+f 31/31/14 49/49/15 32/32/15
+f 32/32/15 49/49/15 50/50/16
+f 32/32/15 50/50/16 33/33/16
+f 33/33/16 50/50/16 51/51/17
+f 33/33/16 51/51/17 34/34/17
+f 34/34/17 51/51/17 52/52/2
+f 34/34/17 52/52/2 35/35/2
+f 36/36/2 53/53/2 54/54/3
+f 36/36/2 54/54/3 37/37/3
+f 37/37/3 54/54/3 55/55/4
+f 37/37/3 55/55/4 38/38/4
+f 38/38/4 55/55/4 56/56/5
+f 38/38/4 56/56/5 39/39/5
+f 39/39/5 56/56/5 57/57/6
+f 39/39/5 57/57/6 40/40/6
+f 40/40/6 57/57/6 58/58/7
+f 40/40/6 58/58/7 41/41/7
+f 41/41/7 58/58/7 59/59/8
+f 41/41/7 59/59/8 42/42/8
+f 42/42/8 59/59/8 60/60/9
+f 42/42/8 60/60/9 43/43/9
+f 43/43/9 60/60/9 61/61/10
+f 43/43/9 61/61/10 44/44/10
+f 44/44/10 61/61/10 62/62/11
+f 44/44/10 62/62/11 45/45/11
+f 45/45/11 62/62/11 63/63/12
+f 45/45/11 63/63/12 46/46/12
+f 46/46/12 63/63/12 64/64/13
+f 46/46/12 64/64/13 47/47/13
+f 47/47/13 64/64/13 65/65/14
+f 47/47/13 65/65/14 48/48/14
+f 48/48/14 65/65/14 66/66/15
+f 48/48/14 66/66/15 49/49/15
+f 49/49/15 66/66/15 67/67/16
+f 49/49/15 67/67/16 50/50/16
+f 50/50/16 67/67/16 68/68/17
+f 50/50/16 68/68/17 51/51/17
+f 51/51/17 68/68/17 69/69/2
+f 51/51/17 69/69/2 52/52/2
+f 53/53/2 70/70/2 71/71/3
+f 53/53/2 71/71/3 54/54/3
+f 54/54/3 71/71/3 72/72/4
+f 54/54/3 72/72/4 55/55/4
+f 55/55/4 72/72/4 73/73/5
+f 55/55/4 73/73/5 56/56/5
+f 56/56/5 73/73/5 74/74/6
+f 56/56/5 74/74/6 57/57/6
+f 57/57/6 74/74/6 75/75/7
+f 57/57/6 75/75/7 58/58/7
+f 58/58/7 75/75/7 76/76/8
+f 58/58/7 76/76/8 59/59/8
+f 59/59/8 76/76/8 77/77/9
+f 59/59/8 77/77/9 60/60/9
+f 60/60/9 77/77/9 78/78/10
+f 60/60/9 78/78/10 61/61/10
+f 61/61/10 78/78/10 79/79/11
+f 61/61/10 79/79/11 62/62/11
+f 62/62/11 79/79/11 80/80/12
+f 62/62/11 80/80/12 63/63/12
+f 63/63/12 80/80/12 81/81/13
+f 63/63/12 81/81/13 64/64/13
+f 64/64/13 81/81/13 82/82/14
+f 64/64/13 82/82/14 65/65/14
+f 65/65/14 82/82/14 83/83/15
+f 65/65/14 83/83/15 66/66/15
+f 66/66/15 83/83/15 84/84/16
+f 66/66/15 84/84/16 67/67/16
+f 67/67/16 84/84/16 85/85/17
+f 67/67/16 85/85/17 68/68/17
+f 68/68/17 85/85/17 86/86/2
+f 68/68/17 86/86/2 69/69/2
diff --git a/res/scenes/cone.xml b/res/scenes/cone.xml
index 3fb4998a..8c2a1aaf 100644
--- a/res/scenes/cone.xml
+++ b/res/scenes/cone.xml
@@ -6,9 +6,14 @@
+
+
+
-
+
+
+
\ No newline at end of file
diff --git a/res/scenes/ice_cream.xml b/res/scenes/ice_cream.xml
new file mode 100644
index 00000000..9b49e295
--- /dev/null
+++ b/res/scenes/ice_cream.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/textures/ice_cream.jpg b/res/textures/ice_cream.jpg
new file mode 100644
index 00000000..741ed8fe
Binary files /dev/null and b/res/textures/ice_cream.jpg differ
diff --git a/res/textures/ice_cream_cone.jpg b/res/textures/ice_cream_cone.jpg
new file mode 100644
index 00000000..05802909
Binary files /dev/null and b/res/textures/ice_cream_cone.jpg differ
diff --git a/src/generator/figures/Cone.cpp b/src/generator/figures/Cone.cpp
index 80fd1810..8753b9be 100644
--- a/src/generator/figures/Cone.cpp
+++ b/src/generator/figures/Cone.cpp
@@ -30,44 +30,83 @@ Cone::Cone(float radius, float height, int slices, int stacks) {
const float stackStep = height / stacks;
const float sliceStep = glm::two_pi() / slices;
+ // Generate base
this->positions.push_back(glm::vec4(0.0f, 0.0f, 0.0f, 1.0f));
+ this->textureCoordinates.push_back(glm::vec2(0.5f, 0.5f));
+ this->normals.push_back(glm::vec3(0.0f, -1.0f, 0.0f));
+ for (int jSlice = 0; jSlice <= slices; jSlice++) {
+ const float angle = jSlice * sliceStep;
+ const float x = radius * cosf(angle);
+ const float z = radius * sinf(angle);
+ this->positions.push_back(glm::vec4(x, 0.0f, z, 1.0f));
- for (int iStack = 0; iStack < stacks; iStack++) {
+ const float s = 0.5 + 0.5 * cosf(angle);
+ const float t = 0.5 + 0.5 * sinf(angle);
+ this->textureCoordinates.push_back(glm::vec2(s, t));
+ }
+
+ // Generate stacks
+ for (int iStack = 0; iStack <= stacks; iStack++) {
const float y = iStack * stackStep;
const float stackRadius = ((height - y) * radius) / height;
+ const float v = static_cast(iStack) / stacks;
for (int jSlice = 0; jSlice <= slices; jSlice++) {
const float angle = jSlice * sliceStep;
const float x = stackRadius * cosf(angle);
const float z = stackRadius * sinf(angle);
this->positions.push_back(glm::vec4(x, y, z, 1.0f));
+
+ const float u = static_cast(jSlice) / slices;
+ this->textureCoordinates.push_back(glm::vec2(u, v));
}
}
- const int topVertexIndex = this->positions.size();
- this->positions.push_back(glm::vec4(0.0f, height, 0.0f, 1.0f));
+ // Generate side normals
+ for (int jSlice = 0; jSlice < slices; ++jSlice) {
+ const float angle = jSlice * sliceStep;
+ const float nx = cosf(angle);
+ const float ny = radius / height;
+ const float nz = sinf(angle);
+ this->normals.push_back(glm::normalize(glm::vec3(nx, ny, nz)));
+ }
+ // Triangulate base
for (int jSlice = 0; jSlice < slices; jSlice++) {
- this->faces.push_back(utils::TriangleFace(0, jSlice + 1, jSlice + 2));
+ this->faces.push_back(
+ utils::TriangleFace(0, 0, 0, jSlice + 1, jSlice + 1, 0, jSlice + 2, jSlice + 2, 0));
}
- for (int iStack = 0; iStack < stacks - 1; iStack++) {
+ // Triangulate stacks
+ for (int iStack = 0; iStack < stacks; iStack++) {
for (int jSlice = 0; jSlice < slices; jSlice++) {
- const int currentBottom = iStack * (slices + 1) + jSlice + 1;
+ const int currentBottom = iStack * (slices + 1) + jSlice + slices + 2;
const int nextBottom = currentBottom + 1;
const int currentTop = currentBottom + slices + 1;
const int nextTop = currentTop + 1;
- this->faces.push_back(utils::TriangleFace(currentBottom, currentTop, nextTop));
- this->faces.push_back(utils::TriangleFace(currentBottom, nextTop, nextBottom));
- }
- }
+ const int currentFaceNormal = (jSlice) % slices + 1;
+ const int nextFaceNormal = (jSlice + 1) % slices + 1;
- const int topStackStart = topVertexIndex - slices - 1;
- for (int jSlice = 0; jSlice < slices; jSlice++) {
- const int current = topStackStart + jSlice;
- const int next = current + 1;
- this->faces.push_back(utils::TriangleFace(current, topVertexIndex, next));
+ this->faces.push_back(utils::TriangleFace(currentBottom,
+ currentBottom,
+ currentFaceNormal,
+ currentTop,
+ currentTop,
+ currentFaceNormal,
+ nextTop,
+ nextTop,
+ nextFaceNormal));
+ this->faces.push_back(utils::TriangleFace(currentBottom,
+ currentBottom,
+ currentFaceNormal,
+ nextTop,
+ nextTop,
+ nextFaceNormal,
+ nextBottom,
+ nextBottom,
+ nextFaceNormal));
+ }
}
}