21 #include "PlaneModel.h"
23 #include "Mathematics.h"
42 if (uvCoordinates == NULL)
44 LOGE(
"Cannot use null pointer while calculating coordinates.");
50 const int numberOfUVCoordinates = 2 * 3 * 2;
53 *uvCoordinates = (
float*) malloc (numberOfUVCoordinates *
sizeof(
float));
56 if (*uvCoordinates == NULL)
58 LOGE(
"Could not allocate memory for result array.");
68 (*uvCoordinates)[currentIndex] = 0.0f;
71 (*uvCoordinates)[currentIndex] = 0.0f;
75 (*uvCoordinates)[currentIndex] = 1.0f;
78 (*uvCoordinates)[currentIndex] = 0.0f;
82 (*uvCoordinates)[currentIndex] = 1.0f;
85 (*uvCoordinates)[currentIndex] = 1.0f;
91 (*uvCoordinates)[currentIndex] = 0.0f;
94 (*uvCoordinates)[currentIndex] = 0.0f;
98 (*uvCoordinates)[currentIndex] = 1.0f;
101 (*uvCoordinates)[currentIndex] = 1.0f;
105 (*uvCoordinates)[currentIndex] = 0.0f;
108 (*uvCoordinates)[currentIndex] = 1.0f;
111 if (numberOfCoordinates != NULL)
113 *numberOfCoordinates = numberOfUVCoordinates;
129 if (coordinates == NULL)
131 LOGE(
"Cannot use null pointer while calculating coordinates.");
137 const int numberOfSquareCoordinates = 2 * 3 * 4;
140 *coordinates = (
float*) malloc (numberOfSquareCoordinates *
sizeof(
float));
143 if (*coordinates == NULL)
145 LOGE(
"Could not allocate memory for result array.");
150 int currentIndex = 0;
155 (*coordinates)[currentIndex] = -1.0f;
158 (*coordinates)[currentIndex] = 0.0f;
161 (*coordinates)[currentIndex] = -1.0f;
164 (*coordinates)[currentIndex] = 1.0f;
168 (*coordinates)[currentIndex] = 1.0f;
171 (*coordinates)[currentIndex] = 0.0f;
174 (*coordinates)[currentIndex] = -1.0f;
177 (*coordinates)[currentIndex] = 1.0f;
181 (*coordinates)[currentIndex] = 1.0f;
184 (*coordinates)[currentIndex] = 0.0f;
187 (*coordinates)[currentIndex] = 1.0f;
190 (*coordinates)[currentIndex] = 1.0f;
196 (*coordinates)[currentIndex] = -1.0f;
199 (*coordinates)[currentIndex] = 0.0f;
202 (*coordinates)[currentIndex] = -1.0f;
205 (*coordinates)[currentIndex] = 1.0f;
209 (*coordinates)[currentIndex] = 1.0f;
212 (*coordinates)[currentIndex] = 0.0f;
215 (*coordinates)[currentIndex] = 1.0f;
218 (*coordinates)[currentIndex] = 1.0f;
222 (*coordinates)[currentIndex] = -1.0f;
225 (*coordinates)[currentIndex] = 0.0f;
228 (*coordinates)[currentIndex] = 1.0f;
231 (*coordinates)[currentIndex] = 1.0f;
234 if (numberOfCoordinates != NULL)
236 *numberOfCoordinates = numberOfSquareCoordinates;
244 LOGE(
"Cannot use null pointer while calculating coordinates.");
250 const int numberOfNormalsCoordinates = 2 * 3 * 3;
252 int currentIndex = 0;
255 *normals = (
float*) malloc (numberOfNormalsCoordinates *
sizeof(
float));
258 if (*normals == NULL)
260 LOGE(
"Could not allocate memory for result array.");
265 for (
int i = 0; i < numberOfNormalsCoordinates; i+=3)
267 (*normals)[currentIndex] = 0.0f;
269 (*normals)[currentIndex] = 1.0f;
271 (*normals)[currentIndex] = 0.0f;
275 if (numberOfCoordinates != NULL)
277 *numberOfCoordinates = numberOfNormalsCoordinates;
284 for (
int allCoordinates = 0; allCoordinates < numberOfCoordinates; allCoordinates +=4)
286 Vec4f currentVertex = {(*squareCoordinates)[allCoordinates], (*squareCoordinates)[allCoordinates + 1], (*squareCoordinates)[allCoordinates + 2], (*squareCoordinates)[allCoordinates + 3]};
290 (*squareCoordinates)[allCoordinates] = rotatedVertex.
x;
291 (*squareCoordinates)[allCoordinates + 1] = rotatedVertex.
y;
292 (*squareCoordinates)[allCoordinates + 2] = rotatedVertex.
z;
293 (*squareCoordinates)[allCoordinates + 3] = rotatedVertex.
w;
static void getTriangleRepresentation(int *numberOfCoordinates, float **coordinates)
Get coordinates of points which make up a plane. The plane is located in XZ space.
Functions for manipulating matrices.
static void transform(Matrix transform, int numberOfCoordinates, float **coordinates)
Transform a plane by a matrix.
static void getTriangleRepresentationUVCoordinates(int *numberOfCoordinates, float **uvCoordinates)
Get U/V 2D texture coordinates that can be mapped onto a plane generated from this class...
static Vec4f vertexTransform(Vec4f *vector, Matrix *matrix)
Transform a 4D vertex by a matrix.
static void getNormals(int *numberOfCoordinates, float **normals)
Get normals for plane placed in XZ space.
A 4D floating point vector.