39 ASSERT(uvCoordinates != NULL,
"Cannot use null pointer while calculating coordinates.");
47 *uvCoordinates = (
float*) malloc (numberOfUVCoordinates *
sizeof(
float));
50 ASSERT(*uvCoordinates != NULL,
"Could not allocate memory for result array.");
58 (*uvCoordinates)[currentIndex++] = 0.0f;
60 (*uvCoordinates)[currentIndex++] = 0.0f;
63 (*uvCoordinates)[currentIndex++] = 1.0f;
65 (*uvCoordinates)[currentIndex++] = 0.0f;
68 (*uvCoordinates)[currentIndex++] = 1.0f;
70 (*uvCoordinates)[currentIndex++] = 1.0f;
75 (*uvCoordinates)[currentIndex++] = 0.0f;
77 (*uvCoordinates)[currentIndex++] = 0.0f;
80 (*uvCoordinates)[currentIndex++] = 1.0f;
82 (*uvCoordinates)[currentIndex++] = 1.0f;
85 (*uvCoordinates)[currentIndex++] = 0.0f;
87 (*uvCoordinates)[currentIndex++] = 1.0f;
89 if (numberOfCoordinates != NULL)
91 *numberOfCoordinates = numberOfUVCoordinates;
107 ASSERT(coordinates != NULL,
"Cannot use null pointer while calculating coordinates.");
110 const Vec4f pointA = {-1.0f, 0.0f, -1.0f, 1.0f};
111 const Vec4f pointB = { 1.0f, 0.0f, -1.0f, 1.0f};
112 const Vec4f pointC = { 1.0f, 0.0f, 1.0f, 1.0f};
113 const Vec4f pointD = {-1.0f, 0.0f, 1.0f, 1.0f};
118 const int numberOfSquareCoordinates = numberOfSquarePoints *
122 *coordinates = (
float*) malloc (numberOfSquareCoordinates *
sizeof(
float));
125 ASSERT(*coordinates != NULL,
"Could not allocate memory for result array.");
128 int currentIndex = 0;
132 (*coordinates)[currentIndex++] = pointA.
x;
133 (*coordinates)[currentIndex++] = pointA.
y;
134 (*coordinates)[currentIndex++] = pointA.
z;
135 (*coordinates)[currentIndex++] = pointA.
w;
137 (*coordinates)[currentIndex++] = pointB.
x;
138 (*coordinates)[currentIndex++] = pointB.
y;
139 (*coordinates)[currentIndex++] = pointB.
z;
140 (*coordinates)[currentIndex++] = pointB.
w;
142 (*coordinates)[currentIndex++] = pointC.
x;
143 (*coordinates)[currentIndex++] = pointC.
y;
144 (*coordinates)[currentIndex++] = pointC.
z;
145 (*coordinates)[currentIndex++] = pointC.
w;
149 (*coordinates)[currentIndex++] = pointA.
x;
150 (*coordinates)[currentIndex++] = pointA.
y;
151 (*coordinates)[currentIndex++] = pointA.
z;
152 (*coordinates)[currentIndex++] = pointA.
w;
154 (*coordinates)[currentIndex++] = pointC.
x;
155 (*coordinates)[currentIndex++] = pointC.
y;
156 (*coordinates)[currentIndex++] = pointC.
z;
157 (*coordinates)[currentIndex++] = pointC.
w;
159 (*coordinates)[currentIndex++] = pointD.
x;
160 (*coordinates)[currentIndex++] = pointD.
y;
161 (*coordinates)[currentIndex++] = pointD.
z;
162 (*coordinates)[currentIndex++] = pointD.
w;
164 if (numberOfPoints != NULL)
166 *numberOfPoints = numberOfSquarePoints;
169 if (numberOfCoordinates != NULL)
171 *numberOfCoordinates = numberOfSquareCoordinates;
179 ASSERT(normals != NULL,
"Cannot use null pointer while calculating coordinates.");
187 int currentIndex = 0;
190 *normals = (
float*) malloc (numberOfNormalsCoordinates *
sizeof(
float));
193 ASSERT(*normals != NULL,
"Could not allocate memory for result array.");
197 (*normals)[currentIndex++] = 0.0f;
198 (*normals)[currentIndex++] = 1.0f;
199 (*normals)[currentIndex++] = 0.0f;
200 (*normals)[currentIndex++] = 1.0f;
203 if (numberOfCoordinates != NULL)
205 *numberOfCoordinates = numberOfNormalsCoordinates;
215 Vec4f currentVertex = {(*squareCoordinates)[allCoordinates],
216 (*squareCoordinates)[allCoordinates + 1],
217 (*squareCoordinates)[allCoordinates + 2],
218 (*squareCoordinates)[allCoordinates + 3]};
222 (*squareCoordinates)[allCoordinates] = rotatedVertex.x;
223 (*squareCoordinates)[allCoordinates + 1] = rotatedVertex.y;
224 (*squareCoordinates)[allCoordinates + 2] = rotatedVertex.z;
225 (*squareCoordinates)[allCoordinates + 3] = rotatedVertex.w;
static const int numberOfSquareTriangles
Number of triangles which make up a square.
static void getTriangleRepresentation(int *numberOfCoordinates, float **coordinates)
Get coordinates of points which make up a plane. The plane is located in XZ space.
static const int numberOfPointCoordinates
Number of coordinates for a point in 3D space.
static const int numberOfPointUvCoordinates
Number of coordinates for point UVs.
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 const int numberOfTrianglePoints
number of points that make up a shape of a triangle.
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.