30 ASSERT(coordinates != NULL,
"Cannot use null pointer while calculating coordinates.");
43 *coordinates = (
float*) malloc (numberOfCubeTriangleCoordinates *
sizeof(
float));
46 ASSERT(*coordinates != NULL,
"Could not allocate memory for result array.");
69 Vec3f pointA = {-1.0f, 1.0f, 1.0f};
70 Vec3f pointB = {-1.0f, 1.0f, -1.0f};
71 Vec3f pointC = { 1.0f, 1.0f, -1.0f};
72 Vec3f pointD = { 1.0f, 1.0f, 1.0f};
73 Vec3f pointE = {-1.0f, -1.0f, 1.0f};
74 Vec3f pointF = {-1.0f, -1.0f, -1.0f};
75 Vec3f pointG = { 1.0f, -1.0f, -1.0f};
76 Vec3f pointH = { 1.0f, -1.0f, 1.0f};
81 (*coordinates)[currentIndex++] = pointA.
x;
82 (*coordinates)[currentIndex++] = pointA.
y;
83 (*coordinates)[currentIndex++] = pointA.
z;
85 (*coordinates)[currentIndex++] = pointB.
x;
86 (*coordinates)[currentIndex++] = pointB.
y;
87 (*coordinates)[currentIndex++] = pointB.
z;
89 (*coordinates)[currentIndex++] = pointC.
x;
90 (*coordinates)[currentIndex++] = pointC.
y;
91 (*coordinates)[currentIndex++] = pointC.
z;
94 (*coordinates)[currentIndex++] = pointA.
x;
95 (*coordinates)[currentIndex++] = pointA.
y;
96 (*coordinates)[currentIndex++] = pointA.
z;
98 (*coordinates)[currentIndex++] = pointC.
x;
99 (*coordinates)[currentIndex++] = pointC.
y;
100 (*coordinates)[currentIndex++] = pointC.
z;
102 (*coordinates)[currentIndex++] = pointD.
x;
103 (*coordinates)[currentIndex++] = pointD.
y;
104 (*coordinates)[currentIndex++] = pointD.
z;
108 (*coordinates)[currentIndex++] = pointE.
x;
109 (*coordinates)[currentIndex++] = pointE.
y;
110 (*coordinates)[currentIndex++] = pointE.
z;
112 (*coordinates)[currentIndex++] = pointF.
x;
113 (*coordinates)[currentIndex++] = pointF.
y;
114 (*coordinates)[currentIndex++] = pointF.
z;
116 (*coordinates)[currentIndex++] = pointG.
x;
117 (*coordinates)[currentIndex++] = pointG.
y;
118 (*coordinates)[currentIndex++] = pointG.
z;
121 (*coordinates)[currentIndex++] = pointE.
x;
122 (*coordinates)[currentIndex++] = pointE.
y;
123 (*coordinates)[currentIndex++] = pointE.
z;
125 (*coordinates)[currentIndex++] = pointG.
x;
126 (*coordinates)[currentIndex++] = pointG.
y;
127 (*coordinates)[currentIndex++] = pointG.
z;
129 (*coordinates)[currentIndex++] = pointH.
x;
130 (*coordinates)[currentIndex++] = pointH.
y;
131 (*coordinates)[currentIndex++] = pointH.
z;
135 (*coordinates)[currentIndex++] = pointG.
x;
136 (*coordinates)[currentIndex++] = pointG.
y;
137 (*coordinates)[currentIndex++] = pointG.
z;
139 (*coordinates)[currentIndex++] = pointC.
x;
140 (*coordinates)[currentIndex++] = pointC.
y;
141 (*coordinates)[currentIndex++] = pointC.
z;
143 (*coordinates)[currentIndex++] = pointB.
x;
144 (*coordinates)[currentIndex++] = pointB.
y;
145 (*coordinates)[currentIndex++] = pointB.
z;
148 (*coordinates)[currentIndex++] = pointG.
x;
149 (*coordinates)[currentIndex++] = pointG.
y;
150 (*coordinates)[currentIndex++] = pointG.
z;
152 (*coordinates)[currentIndex++] = pointB.
x;
153 (*coordinates)[currentIndex++] = pointB.
y;
154 (*coordinates)[currentIndex++] = pointB.
z;
156 (*coordinates)[currentIndex++] = pointF.
x;
157 (*coordinates)[currentIndex++] = pointF.
y;
158 (*coordinates)[currentIndex++] = pointF.
z;
162 (*coordinates)[currentIndex++] = pointE.
x;
163 (*coordinates)[currentIndex++] = pointE.
y;
164 (*coordinates)[currentIndex++] = pointE.
z;
166 (*coordinates)[currentIndex++] = pointA.
x;
167 (*coordinates)[currentIndex++] = pointA.
y;
168 (*coordinates)[currentIndex++] = pointA.
z;
170 (*coordinates)[currentIndex++] = pointD.
x;
171 (*coordinates)[currentIndex++] = pointD.
y;
172 (*coordinates)[currentIndex++] = pointD.
z;
175 (*coordinates)[currentIndex++] = pointE.
x;
176 (*coordinates)[currentIndex++] = pointE.
y;
177 (*coordinates)[currentIndex++] = pointE.
z;
179 (*coordinates)[currentIndex++] = pointD.
x;
180 (*coordinates)[currentIndex++] = pointD.
y;
181 (*coordinates)[currentIndex++] = pointD.
z;
183 (*coordinates)[currentIndex++] = pointH.
x;
184 (*coordinates)[currentIndex++] = pointH.
y;
185 (*coordinates)[currentIndex++] = pointH.
z;
189 (*coordinates)[currentIndex++] = pointH.
x;
190 (*coordinates)[currentIndex++] = pointH.
y;
191 (*coordinates)[currentIndex++] = pointH.
z;
193 (*coordinates)[currentIndex++] = pointD.
x;
194 (*coordinates)[currentIndex++] = pointD.
y;
195 (*coordinates)[currentIndex++] = pointD.
z;
197 (*coordinates)[currentIndex++] = pointC.
x;
198 (*coordinates)[currentIndex++] = pointC.
y;
199 (*coordinates)[currentIndex++] = pointC.
z;
202 (*coordinates)[currentIndex++] = pointH.
x;
203 (*coordinates)[currentIndex++] = pointH.
y;
204 (*coordinates)[currentIndex++] = pointH.
z;
206 (*coordinates)[currentIndex++] = pointC.
x;
207 (*coordinates)[currentIndex++] = pointC.
y;
208 (*coordinates)[currentIndex++] = pointC.
z;
210 (*coordinates)[currentIndex++] = pointG.
x;
211 (*coordinates)[currentIndex++] = pointG.
y;
212 (*coordinates)[currentIndex++] = pointG.
z;
216 (*coordinates)[currentIndex++] = pointF.
x;
217 (*coordinates)[currentIndex++] = pointF.
y;
218 (*coordinates)[currentIndex++] = pointF.
z;
220 (*coordinates)[currentIndex++] = pointB.
x;
221 (*coordinates)[currentIndex++] = pointB.
y;
222 (*coordinates)[currentIndex++] = pointB.
z;
224 (*coordinates)[currentIndex++] = pointA.
x;
225 (*coordinates)[currentIndex++] = pointA.
y;
226 (*coordinates)[currentIndex++] = pointA.
z;
229 (*coordinates)[currentIndex++] = pointF.
x;
230 (*coordinates)[currentIndex++] = pointF.
y;
231 (*coordinates)[currentIndex++] = pointF.
z;
233 (*coordinates)[currentIndex++] = pointA.
x;
234 (*coordinates)[currentIndex++] = pointA.
y;
235 (*coordinates)[currentIndex++] = pointA.
z;
237 (*coordinates)[currentIndex++] = pointE.
x;
238 (*coordinates)[currentIndex++] = pointE.
y;
239 (*coordinates)[currentIndex++] = pointE.
z;
244 (*coordinates)[i] = scalingFactor * (*coordinates)[i];
247 if (numberOfCoordinates != NULL)
252 if (numberOfPoints != NULL)
254 *numberOfPoints = numberOfVerticesToGenerate;
262 ASSERT(normals != NULL,
"Cannot use null pointer while calculating coordinates.");
268 numberOfCoordinatesForOneFace *
272 int currentIndex = 0;
275 *normals = (
float*) malloc (numberOfCubeNormalsCoordinates *
sizeof(
float));
278 ASSERT(*normals != NULL,
"Could not allocate memory for result array.");
281 for (
int i = 0; i < numberOfCoordinatesForOneFace; i++)
283 (*normals)[currentIndex++] = 0;
284 (*normals)[currentIndex++] = 1;
285 (*normals)[currentIndex++] = 0;
289 for (
int i = 0; i < numberOfCoordinatesForOneFace; i++)
291 (*normals)[currentIndex++] = 0;
292 (*normals)[currentIndex++] = -1;
293 (*normals)[currentIndex++] = 0;
297 for (
int i = 0; i < numberOfCoordinatesForOneFace; i++)
299 (*normals)[currentIndex++] = 0;
300 (*normals)[currentIndex++] = 0;
301 (*normals)[currentIndex++] = -1;
305 for (
int i = 0; i < numberOfCoordinatesForOneFace; i++)
307 (*normals)[currentIndex++] = 0;
308 (*normals)[currentIndex++] = 0;
309 (*normals)[currentIndex++] = 1;
313 for (
int i = 0; i < numberOfCoordinatesForOneFace; i++)
315 (*normals)[currentIndex++] = 1;
316 (*normals)[currentIndex++] = 0;
317 (*normals)[currentIndex++] = 0;
321 for (
int i = 0; i < numberOfCoordinatesForOneFace; i++)
323 (*normals)[currentIndex++] = -1;
324 (*normals)[currentIndex++] = 0;
325 (*normals)[currentIndex++] = 0;
328 if (numberOfCoordinates != NULL)
330 *numberOfCoordinates = numberOfCubeNormalsCoordinates;
static const int numberOfSquareTriangles
Number of triangles which make up a square.
static void getNormals(int *numberOfCoordinates, float **normals)
Create normals for a cube which was created with getTriangleRepresentation() function.
static const int numberOfCubeFaces
Number of cube faces.
A 3D floating point vector.
static const int numberOfTrianglePoints
number of points that make up a shape of a triangle.
int numberOfCubeTriangleCoordinates
static void getTriangleRepresentation(float scalingFactor, int *numberOfCoordinates, float **coordinates)
Compute coordinates of points which make up a cube.
static const int numberOfPointCoordinates
Number of coordinates for a point in 3D space.