sculpto
cube.cpp
Go to the documentation of this file.
1/*!****************************************************************//*!*
2 * \file cube.cpp
3 * \brief Cube topology object class imlementation module.
4 *
5 * \author Sabitov Kirill
6 * \date 29 June 2022
7 *********************************************************************/
8
9#include "sclpch.h"
10#include "cube.h"
11
13{
14 float ax = A.GetX(), ay = A.GetY(), az = A.GetZ();
15 float bx = B.GetX(), by = B.GetY(), bz = B.GetZ();
16
17 // Front
18 Vertices.push_back(vertex( A, { 0, 0, -1 }, { ax, ay }));
19 Vertices.push_back(vertex({ ax, by, az }, { 0, 0, -1 }, { ax, by }));
20 Vertices.push_back(vertex({ bx, ay, az }, { 0, 0, -1 }, { bx, ay }));
21 Vertices.push_back(vertex({ bx, by, az }, { 0, 0, -1 }, { bx, by }));
22
23 Indices.push_back(0);
24 Indices.push_back(1);
25 Indices.push_back(2);
26 Indices.push_back(1);
27 Indices.push_back(2);
28 Indices.push_back(3);
29
30 // Right
31 Vertices.push_back(vertex({ bx, ay, az}, { 1, 0, 0 }, { ay, az }));
32 Vertices.push_back(vertex({ bx, by, az}, { 1, 0, 0 }, { by, az }));
33 Vertices.push_back(vertex({ bx, ay, bz}, { 1, 0, 0 }, { ay, bz }));
34 Vertices.push_back(vertex( B, { 1, 0, 0 }, { by, bz }));
35
36 Indices.push_back(4);
37 Indices.push_back(5);
38 Indices.push_back(6);
39 Indices.push_back(5);
40 Indices.push_back(6);
41 Indices.push_back(7);
42
43 // Back
44 Vertices.push_back(vertex({ bx, ay, bz }, { 0, 0, 1 }, { bx, ay }));
45 Vertices.push_back(vertex( B, { 0, 0, 1 }, { bx, by }));
46 Vertices.push_back(vertex({ ax, ay, bz }, { 0, 0, 1 }, { ax, ay }));
47 Vertices.push_back(vertex({ ax, by, bz }, { 0, 0, 1 }, { ax, by }));
48
49 Indices.push_back(8);
50 Indices.push_back(9);
51 Indices.push_back(10);
52 Indices.push_back(9);
53 Indices.push_back(10);
54 Indices.push_back(11);
55
56 // Left
57 Vertices.push_back(vertex({ ax, ay, bz }, { -1, 0, 0 }, { ay, bz }));
58 Vertices.push_back(vertex({ ax, by, bz }, { -1, 0, 0 }, { by, bz }));
59 Vertices.push_back(vertex( A, { -1, 0, 0 }, { ay, az }));
60 Vertices.push_back(vertex({ ax, by, az }, { -1, 0, 0 }, { by, az }));
61
62 Indices.push_back(12);
63 Indices.push_back(13);
64 Indices.push_back(14);
65 Indices.push_back(13);
66 Indices.push_back(14);
67 Indices.push_back(15);
68
69 // Top
70 Vertices.push_back(vertex({ ax, by, az }, { 0, 1, 0 }, { ax, az }));
71 Vertices.push_back(vertex({ ax, by, bz }, { 0, 1, 0 }, { ax, bz }));
72 Vertices.push_back(vertex({ bx, by, az }, { 0, 1, 0 }, { bx, az }));
73 Vertices.push_back(vertex( B, { 0, 1, 0 }, { bx, bz }));
74
75 Indices.push_back(16);
76 Indices.push_back(17);
77 Indices.push_back(18);
78 Indices.push_back(17);
79 Indices.push_back(18);
80 Indices.push_back(19);
81
82 // Bottom
83 Vertices.push_back(vertex( A, { 0, -1, 0 }, { ax, az }));
84 Vertices.push_back(vertex({ ax, ay, bz }, { 0, -1, 0 }, { ax, bz }));
85 Vertices.push_back(vertex({ bx, ay, az }, { 0, -1, 0 }, { bx, az }));
86 Vertices.push_back(vertex({ bx, ay, bz }, { 0, -1, 0 }, { bx, bz }));
87
88 Indices.push_back(20);
89 Indices.push_back(21);
90 Indices.push_back(22);
91 Indices.push_back(21);
92 Indices.push_back(22);
93 Indices.push_back(23);
94
95 Min = vec3::Min(A, B), Max = vec3::Max(A, B);
97}
static vec3 Max(const vec3 &A, const vec3 &B)
Definition: vec3.h:148
static vec3 Min(const vec3 &A, const vec3 &B)
Definition: vec3.h:140
std::vector< vertex > Vertices
Definition: basis.h:22
std::vector< u32 > Indices
Definition: basis.h:23
cube(const vec3 &A, const vec3 &B)
Definition: cube.cpp:12
virtual void EvaluateTangentSpace()
Definition: trimesh.cpp:47
Topology cube object class declaration function.
Sculpto library prehompiled header. Defines common definitions, includes commonly used modules.