27 if (coordinates == NULL)
29 LOGE(
"Cannot use null pointer while calculating coordinates.");
39 *coordinates = (
float*) malloc (numberOfCubeTriangleCoordinates *
sizeof(
float));
42 if (*coordinates == NULL)
44 LOGE(
"Could not allocate memory for result array.");
72 (*coordinates)[currentIndex] = -1.0f;
74 (*coordinates)[currentIndex] = 1.0f;
76 (*coordinates)[currentIndex] = 1.0f;
79 (*coordinates)[currentIndex] = -1.0f;
81 (*coordinates)[currentIndex] = 1.0f;
83 (*coordinates)[currentIndex] = -1.0f;
86 (*coordinates)[currentIndex] = 1.0f;
88 (*coordinates)[currentIndex] = 1.0f;
90 (*coordinates)[currentIndex] = -1.0f;
94 (*coordinates)[currentIndex] = -1.0f;
96 (*coordinates)[currentIndex] = 1.0f;
98 (*coordinates)[currentIndex] = 1.0f;
101 (*coordinates)[currentIndex] = 1.0f;
103 (*coordinates)[currentIndex] = 1.0f;
105 (*coordinates)[currentIndex] = -1.0f;
108 (*coordinates)[currentIndex] = 1.0f;
110 (*coordinates)[currentIndex] = 1.0f;
112 (*coordinates)[currentIndex] = 1.0f;
117 (*coordinates)[currentIndex] = -1.0f;
119 (*coordinates)[currentIndex] = -1.0f;
121 (*coordinates)[currentIndex] = 1.0f;
124 (*coordinates)[currentIndex] = -1.0f;
126 (*coordinates)[currentIndex] = -1.0f;
128 (*coordinates)[currentIndex] = -1.0f;
131 (*coordinates)[currentIndex] = 1.0f;
133 (*coordinates)[currentIndex] = -1.0f;
135 (*coordinates)[currentIndex] = -1.0f;
139 (*coordinates)[currentIndex] = -1.0f;
141 (*coordinates)[currentIndex] = -1.0f;
143 (*coordinates)[currentIndex] = 1.0f;
146 (*coordinates)[currentIndex] = 1.0f;
148 (*coordinates)[currentIndex] = -1.0f;
150 (*coordinates)[currentIndex] = -1.0f;
153 (*coordinates)[currentIndex] = 1.0f;
155 (*coordinates)[currentIndex] = -1.0f;
157 (*coordinates)[currentIndex] = 1.0f;
162 (*coordinates)[currentIndex] = 1.0f;
164 (*coordinates)[currentIndex] = -1.0f;
166 (*coordinates)[currentIndex] = -1.0f;
169 (*coordinates)[currentIndex] = 1.0f;
171 (*coordinates)[currentIndex] = 1.0f;
173 (*coordinates)[currentIndex] = -1.0f;
176 (*coordinates)[currentIndex] = -1.0f;
178 (*coordinates)[currentIndex] = 1.0f;
180 (*coordinates)[currentIndex] = -1.0f;
184 (*coordinates)[currentIndex] = 1.0f;
186 (*coordinates)[currentIndex] = -1.0f;
188 (*coordinates)[currentIndex] = -1.0f;
191 (*coordinates)[currentIndex] = -1.0f;
193 (*coordinates)[currentIndex] = 1.0f;
195 (*coordinates)[currentIndex] = -1.0f;
198 (*coordinates)[currentIndex] = -1.0f;
200 (*coordinates)[currentIndex] = -1.0f;
202 (*coordinates)[currentIndex] = -1.0f;
207 (*coordinates)[currentIndex] = -1.0f;
209 (*coordinates)[currentIndex] = -1.0f;
211 (*coordinates)[currentIndex] = 1.0f;
214 (*coordinates)[currentIndex] = -1.0f;
216 (*coordinates)[currentIndex] = 1.0f;
218 (*coordinates)[currentIndex] = 1.0f;
221 (*coordinates)[currentIndex] = 1.0f;
223 (*coordinates)[currentIndex] = 1.0f;
225 (*coordinates)[currentIndex] = 1.0f;
229 (*coordinates)[currentIndex] = -1.0f;
231 (*coordinates)[currentIndex] = -1.0f;
233 (*coordinates)[currentIndex] = 1.0f;
236 (*coordinates)[currentIndex] = 1.0f;
238 (*coordinates)[currentIndex] = 1.0f;
240 (*coordinates)[currentIndex] = 1.0f;
243 (*coordinates)[currentIndex] = 1.0f;
245 (*coordinates)[currentIndex] = -1.0f;
247 (*coordinates)[currentIndex] = 1.0f;
252 (*coordinates)[currentIndex] = 1.0f;
254 (*coordinates)[currentIndex] = -1.0f;
256 (*coordinates)[currentIndex] = 1.0f;
259 (*coordinates)[currentIndex] = 1.0f;
261 (*coordinates)[currentIndex] = 1.0f;
263 (*coordinates)[currentIndex] = 1.0f;
266 (*coordinates)[currentIndex] = 1.0f;
268 (*coordinates)[currentIndex] = 1.0f;
270 (*coordinates)[currentIndex] = -1.0f;
274 (*coordinates)[currentIndex] = 1.0f;
276 (*coordinates)[currentIndex] = -1.0f;
278 (*coordinates)[currentIndex] = 1.0f;
281 (*coordinates)[currentIndex] = 1.0f;
283 (*coordinates)[currentIndex] = 1.0f;
285 (*coordinates)[currentIndex] = -1.0f;
288 (*coordinates)[currentIndex] = 1.0f;
290 (*coordinates)[currentIndex] = -1.0f;
292 (*coordinates)[currentIndex] = -1.0f;
297 (*coordinates)[currentIndex] = -1.0f;
299 (*coordinates)[currentIndex] = -1.0f;
301 (*coordinates)[currentIndex] = -1.0f;
304 (*coordinates)[currentIndex] = -1.0f;
306 (*coordinates)[currentIndex] = 1.0f;
308 (*coordinates)[currentIndex] = -1.0f;
311 (*coordinates)[currentIndex] = -1.0f;
313 (*coordinates)[currentIndex] = 1.0f;
315 (*coordinates)[currentIndex] = 1.0f;
319 (*coordinates)[currentIndex] = -1.0f;
321 (*coordinates)[currentIndex] = -1.0f;
323 (*coordinates)[currentIndex] = -1.0f;
326 (*coordinates)[currentIndex] = -1.0f;
328 (*coordinates)[currentIndex] = 1.0f;
330 (*coordinates)[currentIndex] = 1.0f;
333 (*coordinates)[currentIndex] = -1.0f;
335 (*coordinates)[currentIndex] = -1.0f;
337 (*coordinates)[currentIndex] = 1.0f;
343 (*coordinates)[i] = scalingFactor * (*coordinates)[i];
346 if (numberOfCoordinates != NULL)
360 LOGE(
"Cannot use null pointer while calculating coordinates.");
366 const int numberOfCubeNormalsCoordinates = 6 * 2 * 3 * 3;
368 int currentIndex = 0;
371 *normals = (
float*) malloc (numberOfCubeNormalsCoordinates *
sizeof(
float));
374 if (*normals == NULL)
376 LOGE(
"Could not allocate memory for result array.");
382 int numberOfCoordinatesForOneFace = 2 * 3;
385 for (
int i = 0; i < numberOfCoordinatesForOneFace; i++)
387 (*normals)[currentIndex] = 0;
389 (*normals)[currentIndex] = 1;
391 (*normals)[currentIndex] = 0;
396 for (
int i = 0; i < numberOfCoordinatesForOneFace; i++)
398 (*normals)[currentIndex] = 0;
400 (*normals)[currentIndex] = -1;
402 (*normals)[currentIndex] = 0;
407 for (
int i = 0; i < numberOfCoordinatesForOneFace; i++)
409 (*normals)[currentIndex] = 0;
411 (*normals)[currentIndex] = 0;
413 (*normals)[currentIndex] = -1;
418 for (
int i = 0; i < numberOfCoordinatesForOneFace; i++)
420 (*normals)[currentIndex] = 0;
422 (*normals)[currentIndex] = 0;
424 (*normals)[currentIndex] = 1;
429 for (
int i = 0; i < numberOfCoordinatesForOneFace; i++)
431 (*normals)[currentIndex] = 1;
433 (*normals)[currentIndex] = 0;
435 (*normals)[currentIndex] = 0;
440 for (
int i = 0; i < numberOfCoordinatesForOneFace; i++)
442 (*normals)[currentIndex] = -1;
444 (*normals)[currentIndex] = 0;
446 (*normals)[currentIndex] = 0;
450 if (numberOfCoordinates != NULL)
452 *numberOfCoordinates = numberOfCubeNormalsCoordinates;
static void getNormals(int *numberOfCoordinates, float **normals)
Create normals for a cube which was created with getTriangleRepresentation() function.
int numberOfCubeTriangleCoordinates
static void getTriangleRepresentation(float scalingFactor, int *numberOfCoordinates, float **coordinates)
Compute coordinates of points which make up a cube.