30 int* numberOfCoordinatesPtr)
34 ASSERT(normalsPtrPtr != NULL,
35 "Cannot use null pointer while calculating coordinates");
49 *normalsPtrPtr = (
float*) malloc(numberOfCubeNormalsCoordinates *
sizeof(
float));
52 ASSERT(*normalsPtrPtr != NULL,
53 "Could not allocate memory for result array");
56 for (
int i = 0; i < numberOfCoordinatesForOneFace; i++)
58 (*normalsPtrPtr)[currentIndex++] = 0;
59 (*normalsPtrPtr)[currentIndex++] = 1;
60 (*normalsPtrPtr)[currentIndex++] = 0;
64 for (
int i = 0; i < numberOfCoordinatesForOneFace; i++)
66 (*normalsPtrPtr)[currentIndex++] = 0;
67 (*normalsPtrPtr)[currentIndex++] = -1;
68 (*normalsPtrPtr)[currentIndex++] = 0;
72 for (
int i = 0; i < numberOfCoordinatesForOneFace; i++)
74 (*normalsPtrPtr)[currentIndex++] = 0;
75 (*normalsPtrPtr)[currentIndex++] = 0;
76 (*normalsPtrPtr)[currentIndex++] = -1;
80 for (
int i = 0; i < numberOfCoordinatesForOneFace; i++)
82 (*normalsPtrPtr)[currentIndex++] = 0;
83 (*normalsPtrPtr)[currentIndex++] = 0;
84 (*normalsPtrPtr)[currentIndex++] = 1;
88 for (
int i = 0; i < numberOfCoordinatesForOneFace; i++)
90 (*normalsPtrPtr)[currentIndex++] = 1;
91 (*normalsPtrPtr)[currentIndex++] = 0;
92 (*normalsPtrPtr)[currentIndex++] = 0;
96 for (
int i = 0; i < numberOfCoordinatesForOneFace; i++)
98 (*normalsPtrPtr)[currentIndex++] = -1;
99 (*normalsPtrPtr)[currentIndex++] = 0;
100 (*normalsPtrPtr)[currentIndex++] = 0;
103 if (numberOfCoordinatesPtr != NULL)
105 *numberOfCoordinatesPtr = numberOfCubeNormalsCoordinates;
111 int* numberOfCoordinatesPtr,
114 ASSERT(coordinatesPtrPtr != NULL,
115 "Cannot use null pointer while calculating coordinates");
118 int currentIndex = 0;
122 NUMBER_OF_TRIANGLE_VERTICES *
126 *coordinatesPtrPtr = (
float*) malloc(numberOfCubeTriangleCoordinates *
sizeof(
float));
129 ASSERT(*coordinatesPtrPtr != NULL,
130 "Could not allocate memory for result array.")
152 const Vec3f pointA = {-1.0f, 1.0f, 1.0f};
153 const Vec3f pointB = {-1.0f, 1.0f, -1.0f};
154 const Vec3f pointC = { 1.0f, 1.0f, -1.0f};
155 const Vec3f pointD = { 1.0f, 1.0f, 1.0f};
156 const Vec3f pointE = {-1.0f, -1.0f, 1.0f};
157 const Vec3f pointF = {-1.0f, -1.0f, -1.0f};
158 const Vec3f pointG = { 1.0f, -1.0f, -1.0f};
159 const Vec3f pointH = { 1.0f, -1.0f, 1.0f};
164 (*coordinatesPtrPtr)[currentIndex++] = pointA.
x;
165 (*coordinatesPtrPtr)[currentIndex++] = pointA.
y;
166 (*coordinatesPtrPtr)[currentIndex++] = pointA.
z;
168 (*coordinatesPtrPtr)[currentIndex++] = pointB.
x;
169 (*coordinatesPtrPtr)[currentIndex++] = pointB.
y;
170 (*coordinatesPtrPtr)[currentIndex++] = pointB.
z;
172 (*coordinatesPtrPtr)[currentIndex++] = pointC.
x;
173 (*coordinatesPtrPtr)[currentIndex++] = pointC.
y;
174 (*coordinatesPtrPtr)[currentIndex++] = pointC.
z;
177 (*coordinatesPtrPtr)[currentIndex++] = pointA.
x;
178 (*coordinatesPtrPtr)[currentIndex++] = pointA.
y;
179 (*coordinatesPtrPtr)[currentIndex++] = pointA.
z;
181 (*coordinatesPtrPtr)[currentIndex++] = pointC.
x;
182 (*coordinatesPtrPtr)[currentIndex++] = pointC.
y;
183 (*coordinatesPtrPtr)[currentIndex++] = pointC.
z;
185 (*coordinatesPtrPtr)[currentIndex++] = pointD.
x;
186 (*coordinatesPtrPtr)[currentIndex++] = pointD.
y;
187 (*coordinatesPtrPtr)[currentIndex++] = pointD.
z;
191 (*coordinatesPtrPtr)[currentIndex++] = pointF.
x;;
192 (*coordinatesPtrPtr)[currentIndex++] = pointF.
y;;
193 (*coordinatesPtrPtr)[currentIndex++] = pointF.
z;;
195 (*coordinatesPtrPtr)[currentIndex++] = pointE.
x;
196 (*coordinatesPtrPtr)[currentIndex++] = pointE.
y;
197 (*coordinatesPtrPtr)[currentIndex++] = pointE.
z;
199 (*coordinatesPtrPtr)[currentIndex++] = pointH.
x;
200 (*coordinatesPtrPtr)[currentIndex++] = pointH.
y;
201 (*coordinatesPtrPtr)[currentIndex++] = pointH.
z;
204 (*coordinatesPtrPtr)[currentIndex++] = pointF.
x;
205 (*coordinatesPtrPtr)[currentIndex++] = pointF.
y;
206 (*coordinatesPtrPtr)[currentIndex++] = pointF.
z;
208 (*coordinatesPtrPtr)[currentIndex++] = pointH.
x;
209 (*coordinatesPtrPtr)[currentIndex++] = pointH.
y;
210 (*coordinatesPtrPtr)[currentIndex++] = pointH.
z;
212 (*coordinatesPtrPtr)[currentIndex++] = pointG.
x;
213 (*coordinatesPtrPtr)[currentIndex++] = pointG.
y;
214 (*coordinatesPtrPtr)[currentIndex++] = pointG.
z;
218 (*coordinatesPtrPtr)[currentIndex++] = pointG.
x;
219 (*coordinatesPtrPtr)[currentIndex++] = pointG.
y;
220 (*coordinatesPtrPtr)[currentIndex++] = pointG.
z;
222 (*coordinatesPtrPtr)[currentIndex++] = pointC.
x;
223 (*coordinatesPtrPtr)[currentIndex++] = pointC.
y;
224 (*coordinatesPtrPtr)[currentIndex++] = pointC.
z;
226 (*coordinatesPtrPtr)[currentIndex++] = pointB.
x;
227 (*coordinatesPtrPtr)[currentIndex++] = pointB.
y;
228 (*coordinatesPtrPtr)[currentIndex++] = pointB.
z;
231 (*coordinatesPtrPtr)[currentIndex++] = pointG.
x;
232 (*coordinatesPtrPtr)[currentIndex++] = pointG.
y;
233 (*coordinatesPtrPtr)[currentIndex++] = pointG.
z;
235 (*coordinatesPtrPtr)[currentIndex++] = pointB.
x;
236 (*coordinatesPtrPtr)[currentIndex++] = pointB.
y;
237 (*coordinatesPtrPtr)[currentIndex++] = pointB.
z;
239 (*coordinatesPtrPtr)[currentIndex++] = pointF.
x;
240 (*coordinatesPtrPtr)[currentIndex++] = pointF.
y;
241 (*coordinatesPtrPtr)[currentIndex++] = pointF.
z;
245 (*coordinatesPtrPtr)[currentIndex++] = pointE.
x;
246 (*coordinatesPtrPtr)[currentIndex++] = pointE.
y;
247 (*coordinatesPtrPtr)[currentIndex++] = pointE.
z;
249 (*coordinatesPtrPtr)[currentIndex++] = pointA.
x;
250 (*coordinatesPtrPtr)[currentIndex++] = pointA.
y;
251 (*coordinatesPtrPtr)[currentIndex++] = pointA.
z;
253 (*coordinatesPtrPtr)[currentIndex++] = pointD.
x;
254 (*coordinatesPtrPtr)[currentIndex++] = pointD.
y;
255 (*coordinatesPtrPtr)[currentIndex++] = pointD.
z;
258 (*coordinatesPtrPtr)[currentIndex++] = pointE.
x;
259 (*coordinatesPtrPtr)[currentIndex++] = pointE.
y;
260 (*coordinatesPtrPtr)[currentIndex++] = pointE.
z;
262 (*coordinatesPtrPtr)[currentIndex++] = pointD.
x;
263 (*coordinatesPtrPtr)[currentIndex++] = pointD.
y;
264 (*coordinatesPtrPtr)[currentIndex++] = pointD.
z;
266 (*coordinatesPtrPtr)[currentIndex++] = pointH.
x;
267 (*coordinatesPtrPtr)[currentIndex++] = pointH.
y;
268 (*coordinatesPtrPtr)[currentIndex++] = pointH.
z;
272 (*coordinatesPtrPtr)[currentIndex++] = pointH.
x;
273 (*coordinatesPtrPtr)[currentIndex++] = pointH.
y;
274 (*coordinatesPtrPtr)[currentIndex++] = pointH.
z;
276 (*coordinatesPtrPtr)[currentIndex++] = pointD.
x;
277 (*coordinatesPtrPtr)[currentIndex++] = pointD.
y;
278 (*coordinatesPtrPtr)[currentIndex++] = pointD.
z;
280 (*coordinatesPtrPtr)[currentIndex++] = pointC.
x;
281 (*coordinatesPtrPtr)[currentIndex++] = pointC.
y;
282 (*coordinatesPtrPtr)[currentIndex++] = pointC.
z;
285 (*coordinatesPtrPtr)[currentIndex++] = pointH.
x;
286 (*coordinatesPtrPtr)[currentIndex++] = pointH.
y;
287 (*coordinatesPtrPtr)[currentIndex++] = pointH.
z;
289 (*coordinatesPtrPtr)[currentIndex++] = pointC.
x;
290 (*coordinatesPtrPtr)[currentIndex++] = pointC.
y;
291 (*coordinatesPtrPtr)[currentIndex++] = pointC.
z;
293 (*coordinatesPtrPtr)[currentIndex++] = pointG.
x;
294 (*coordinatesPtrPtr)[currentIndex++] = pointG.
y;
295 (*coordinatesPtrPtr)[currentIndex++] = pointG.
z;
299 (*coordinatesPtrPtr)[currentIndex++] = pointF.
x;
300 (*coordinatesPtrPtr)[currentIndex++] = pointF.
y;
301 (*coordinatesPtrPtr)[currentIndex++] = pointF.
z;
303 (*coordinatesPtrPtr)[currentIndex++] = pointB.
x;
304 (*coordinatesPtrPtr)[currentIndex++] = pointB.
y;
305 (*coordinatesPtrPtr)[currentIndex++] = pointB.
z;
307 (*coordinatesPtrPtr)[currentIndex++] = pointA.
x;
308 (*coordinatesPtrPtr)[currentIndex++] = pointA.
y;
309 (*coordinatesPtrPtr)[currentIndex++] = pointA.
z;
312 (*coordinatesPtrPtr)[currentIndex++] = pointF.
x;
313 (*coordinatesPtrPtr)[currentIndex++] = pointF.
y;
314 (*coordinatesPtrPtr)[currentIndex++] = pointF.
z;
316 (*coordinatesPtrPtr)[currentIndex++] = pointA.
x;
317 (*coordinatesPtrPtr)[currentIndex++] = pointA.
y;
318 (*coordinatesPtrPtr)[currentIndex++] = pointA.
z;
320 (*coordinatesPtrPtr)[currentIndex++] = pointE.
x;
321 (*coordinatesPtrPtr)[currentIndex++] = pointE.
y;
322 (*coordinatesPtrPtr)[currentIndex++] = pointE.
z;
325 if (scalingFactor != 1.0
f)
333 if (numberOfCoordinatesPtr != NULL)
#define NUMBER_OF_TRIANGLE_VERTICES
Number of vertices which make up a triangle shape.
static void getNormals(int *numberOfCoordinates, float **normals)
Create normals for a cube which was created with getTriangleRepresentation() function.
A 3D floating point vector.
#define NUMBER_OF_CUBE_FACES
Number of faces which make up a cubic shape.
int numberOfCubeTriangleCoordinates
static void getTriangleRepresentation(float scalingFactor, int *numberOfCoordinates, float **coordinates)
Compute coordinates of points which make up a cube.
#define NUMBER_OF_POINT_COORDINATES
Number of coordinates for a point in 3D space.
#define NUMBER_OF_TRIANGLES_IN_QUAD
Number of triangles which make up a quad.