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,
112 int* numberOfPointsPtr,
115 ASSERT(coordinatesPtrPtr != NULL,
116 "Cannot use null pointer while calculating coordinates");
119 int currentIndex = 0;
128 *coordinatesPtrPtr = (
float*) malloc(numberOfCubeTriangleCoordinates *
sizeof(
float));
131 ASSERT(*coordinatesPtrPtr != NULL,
132 "Could not allocate memory for result array.")
154 const Vec3f pointA = {-1.0f, 1.0f, 1.0f};
155 const Vec3f pointB = {-1.0f, 1.0f, -1.0f};
156 const Vec3f pointC = { 1.0f, 1.0f, -1.0f};
157 const Vec3f pointD = { 1.0f, 1.0f, 1.0f};
158 const Vec3f pointE = {-1.0f, -1.0f, 1.0f};
159 const Vec3f pointF = {-1.0f, -1.0f, -1.0f};
160 const Vec3f pointG = { 1.0f, -1.0f, -1.0f};
161 const Vec3f pointH = { 1.0f, -1.0f, 1.0f};
166 (*coordinatesPtrPtr)[currentIndex++] = pointA.x;
167 (*coordinatesPtrPtr)[currentIndex++] = pointA.y;
168 (*coordinatesPtrPtr)[currentIndex++] = pointA.z;
170 (*coordinatesPtrPtr)[currentIndex++] = pointB.x;
171 (*coordinatesPtrPtr)[currentIndex++] = pointB.y;
172 (*coordinatesPtrPtr)[currentIndex++] = pointB.z;
174 (*coordinatesPtrPtr)[currentIndex++] = pointC.x;
175 (*coordinatesPtrPtr)[currentIndex++] = pointC.y;
176 (*coordinatesPtrPtr)[currentIndex++] = pointC.z;
179 (*coordinatesPtrPtr)[currentIndex++] = pointA.x;
180 (*coordinatesPtrPtr)[currentIndex++] = pointA.y;
181 (*coordinatesPtrPtr)[currentIndex++] = pointA.z;
183 (*coordinatesPtrPtr)[currentIndex++] = pointC.x;
184 (*coordinatesPtrPtr)[currentIndex++] = pointC.y;
185 (*coordinatesPtrPtr)[currentIndex++] = pointC.z;
187 (*coordinatesPtrPtr)[currentIndex++] = pointD.x;
188 (*coordinatesPtrPtr)[currentIndex++] = pointD.y;
189 (*coordinatesPtrPtr)[currentIndex++] = pointD.z;
193 (*coordinatesPtrPtr)[currentIndex++] = pointF.x;;
194 (*coordinatesPtrPtr)[currentIndex++] = pointF.y;;
195 (*coordinatesPtrPtr)[currentIndex++] = pointF.z;;
197 (*coordinatesPtrPtr)[currentIndex++] = pointE.x;
198 (*coordinatesPtrPtr)[currentIndex++] = pointE.y;
199 (*coordinatesPtrPtr)[currentIndex++] = pointE.z;
201 (*coordinatesPtrPtr)[currentIndex++] = pointH.x;
202 (*coordinatesPtrPtr)[currentIndex++] = pointH.y;
203 (*coordinatesPtrPtr)[currentIndex++] = pointH.z;
206 (*coordinatesPtrPtr)[currentIndex++] = pointF.x;
207 (*coordinatesPtrPtr)[currentIndex++] = pointF.y;
208 (*coordinatesPtrPtr)[currentIndex++] = pointF.z;
210 (*coordinatesPtrPtr)[currentIndex++] = pointH.x;
211 (*coordinatesPtrPtr)[currentIndex++] = pointH.y;
212 (*coordinatesPtrPtr)[currentIndex++] = pointH.z;
214 (*coordinatesPtrPtr)[currentIndex++] = pointG.x;
215 (*coordinatesPtrPtr)[currentIndex++] = pointG.y;
216 (*coordinatesPtrPtr)[currentIndex++] = pointG.z;
220 (*coordinatesPtrPtr)[currentIndex++] = pointG.x;
221 (*coordinatesPtrPtr)[currentIndex++] = pointG.y;
222 (*coordinatesPtrPtr)[currentIndex++] = pointG.z;
224 (*coordinatesPtrPtr)[currentIndex++] = pointC.x;
225 (*coordinatesPtrPtr)[currentIndex++] = pointC.y;
226 (*coordinatesPtrPtr)[currentIndex++] = pointC.z;
228 (*coordinatesPtrPtr)[currentIndex++] = pointB.x;
229 (*coordinatesPtrPtr)[currentIndex++] = pointB.y;
230 (*coordinatesPtrPtr)[currentIndex++] = pointB.z;
233 (*coordinatesPtrPtr)[currentIndex++] = pointG.x;
234 (*coordinatesPtrPtr)[currentIndex++] = pointG.y;
235 (*coordinatesPtrPtr)[currentIndex++] = pointG.z;
237 (*coordinatesPtrPtr)[currentIndex++] = pointB.x;
238 (*coordinatesPtrPtr)[currentIndex++] = pointB.y;
239 (*coordinatesPtrPtr)[currentIndex++] = pointB.z;
241 (*coordinatesPtrPtr)[currentIndex++] = pointF.x;
242 (*coordinatesPtrPtr)[currentIndex++] = pointF.y;
243 (*coordinatesPtrPtr)[currentIndex++] = pointF.z;
247 (*coordinatesPtrPtr)[currentIndex++] = pointE.x;
248 (*coordinatesPtrPtr)[currentIndex++] = pointE.y;
249 (*coordinatesPtrPtr)[currentIndex++] = pointE.z;
251 (*coordinatesPtrPtr)[currentIndex++] = pointA.x;
252 (*coordinatesPtrPtr)[currentIndex++] = pointA.y;
253 (*coordinatesPtrPtr)[currentIndex++] = pointA.z;
255 (*coordinatesPtrPtr)[currentIndex++] = pointD.x;
256 (*coordinatesPtrPtr)[currentIndex++] = pointD.y;
257 (*coordinatesPtrPtr)[currentIndex++] = pointD.z;
260 (*coordinatesPtrPtr)[currentIndex++] = pointE.x;
261 (*coordinatesPtrPtr)[currentIndex++] = pointE.y;
262 (*coordinatesPtrPtr)[currentIndex++] = pointE.z;
264 (*coordinatesPtrPtr)[currentIndex++] = pointD.x;
265 (*coordinatesPtrPtr)[currentIndex++] = pointD.y;
266 (*coordinatesPtrPtr)[currentIndex++] = pointD.z;
268 (*coordinatesPtrPtr)[currentIndex++] = pointH.x;
269 (*coordinatesPtrPtr)[currentIndex++] = pointH.y;
270 (*coordinatesPtrPtr)[currentIndex++] = pointH.z;
274 (*coordinatesPtrPtr)[currentIndex++] = pointH.x;
275 (*coordinatesPtrPtr)[currentIndex++] = pointH.y;
276 (*coordinatesPtrPtr)[currentIndex++] = pointH.z;
278 (*coordinatesPtrPtr)[currentIndex++] = pointD.x;
279 (*coordinatesPtrPtr)[currentIndex++] = pointD.y;
280 (*coordinatesPtrPtr)[currentIndex++] = pointD.z;
282 (*coordinatesPtrPtr)[currentIndex++] = pointC.x;
283 (*coordinatesPtrPtr)[currentIndex++] = pointC.y;
284 (*coordinatesPtrPtr)[currentIndex++] = pointC.z;
287 (*coordinatesPtrPtr)[currentIndex++] = pointH.x;
288 (*coordinatesPtrPtr)[currentIndex++] = pointH.y;
289 (*coordinatesPtrPtr)[currentIndex++] = pointH.z;
291 (*coordinatesPtrPtr)[currentIndex++] = pointC.x;
292 (*coordinatesPtrPtr)[currentIndex++] = pointC.y;
293 (*coordinatesPtrPtr)[currentIndex++] = pointC.z;
295 (*coordinatesPtrPtr)[currentIndex++] = pointG.x;
296 (*coordinatesPtrPtr)[currentIndex++] = pointG.y;
297 (*coordinatesPtrPtr)[currentIndex++] = pointG.z;
301 (*coordinatesPtrPtr)[currentIndex++] = pointF.x;
302 (*coordinatesPtrPtr)[currentIndex++] = pointF.y;
303 (*coordinatesPtrPtr)[currentIndex++] = pointF.z;
305 (*coordinatesPtrPtr)[currentIndex++] = pointB.x;
306 (*coordinatesPtrPtr)[currentIndex++] = pointB.y;
307 (*coordinatesPtrPtr)[currentIndex++] = pointB.z;
309 (*coordinatesPtrPtr)[currentIndex++] = pointA.x;
310 (*coordinatesPtrPtr)[currentIndex++] = pointA.y;
311 (*coordinatesPtrPtr)[currentIndex++] = pointA.z;
314 (*coordinatesPtrPtr)[currentIndex++] = pointF.x;
315 (*coordinatesPtrPtr)[currentIndex++] = pointF.y;
316 (*coordinatesPtrPtr)[currentIndex++] = pointF.z;
318 (*coordinatesPtrPtr)[currentIndex++] = pointA.x;
319 (*coordinatesPtrPtr)[currentIndex++] = pointA.y;
320 (*coordinatesPtrPtr)[currentIndex++] = pointA.z;
322 (*coordinatesPtrPtr)[currentIndex++] = pointE.x;
323 (*coordinatesPtrPtr)[currentIndex++] = pointE.y;
324 (*coordinatesPtrPtr)[currentIndex++] = pointE.z;
327 if (scalingFactor != 1.0
f)
335 if (numberOfCoordinatesPtr != NULL)
340 if (numberOfPointsPtr != NULL)
342 *numberOfPointsPtr = numberOfCubeTrianglePoints;
#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.
#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.