GrooveStomp's 3D Software Renderer
0.1.0
|
Go to the source code of this file.
Classes | |
struct | vec2 |
Homogenous 2D coordinates. More... | |
struct | vec3 |
Homogenous 3D coordinates. More... | |
struct | triangle |
Triangular mesh face. More... | |
struct | mesh |
A collection of triangles representing some kind of 3D model. More... | |
struct | mat4x4 |
A 3D matrix using homogenous coordinates. More... | |
Macros | |
#define | MATH_VERSION "0.1.0" |
include guard | |
Functions | |
void | Vec3Debug (struct vec3 vec3, char *name) |
Prints debug information about the homogenous 3D vector. | |
struct vec3 | Vec3Init (float x, float y, float z) |
float | Vec3DotProduct (struct vec3 left, struct vec3 right) |
struct vec3 | Vec3CrossProduct (struct vec3 left, struct vec3 right) |
struct vec3 | Vec3Normalize (struct vec3 vec3) |
struct vec3 | Vec3Add (struct vec3 left, struct vec3 right) |
struct vec3 | Vec3Subtract (struct vec3 minuend, struct vec3 subtrahend) |
struct vec3 | Vec3Multiply (struct vec3 vec3, float f) |
struct vec3 | Vec3Divide (struct vec3 vec3, float f) |
struct vec3 | Vec3IntersectPlane (struct vec3 plane, struct vec3 normal, struct vec3 lineStart, struct vec3 lineEnd, float *t) |
Return the 3d point where a line intersects a plane. More... | |
struct triangle | TriangleInit (float x1, float y1, float z1, float u1, float v1, float x2, float y2, float z2, float u2, float v2, float x3, float y3, float z3, float u3, float v3) |
Create a new triangle with the given params. | |
int | TriangleClipAgainstPlane (struct vec3 plane, struct vec3 normal, struct triangle in, struct triangle *out1, struct triangle *out2) |
Clip a triangle against a plane. More... | |
void | TriangleDebug (struct triangle triangle, char *name) |
Prints debug information about the triangle face. | |
struct mesh * | MeshInit (int numTris) |
Initialize a new mesh object. More... | |
struct mesh * | MeshInitFromObj (char *objFile) |
Initialize a new mesh object from an obj file. More... | |
void | MeshDeinit (struct mesh *mesh) |
De-initializes the mesh object. More... | |
struct vec3 | Mat4x4MultiplyVec3 (struct mat4x4 mat, struct vec3 vec) |
struct mat4x4 | Mat4x4Identity () |
struct mat4x4 | Mat4x4RotateX (float rad) |
struct mat4x4 | Mat4x4RotateY (float rad) |
struct mat4x4 | Mat4x4RotateZ (float rad) |
struct mat4x4 | Mat4x4Translate (float x, float y, float z) |
struct mat4x4 | Mat4x4Project (float fovDegrees, float aspect, float near, float far) |
struct mat4x4 | Mat4x4Multiply (struct mat4x4 left, struct mat4x4 right) |
struct mat4x4 | Mat4x4InvertFast (struct mat4x4 matrix) |
Fast matrix inverse. Doesn't work if matrix does scaling. | |
struct mat4x4 | Mat4x4PointAt (struct vec3 pos, struct vec3 target, struct vec3 up) |
void | Mat4x4Debug (struct mat4x4 mat, char *name) |
Prints debug information about the 4x4 matrix. | |
A collection of vector and matrix types and associated functions.
void MeshDeinit | ( | struct mesh * | mesh | ) |
De-initializes the mesh object.
Frees any memory allocated by the object and frees the pointer to the object itself.
[in,out] | mesh | The mesh to be de-initialized |
struct mesh* MeshInit | ( | int | numTris | ) |
Initialize a new mesh object.
This function is useful if a mesh needs to be explicitly, manually defined. Initialization here only refers to setting a valid "zero" state.
[in] | numTris | the number of triangular faces the mesh will hold. |
struct mesh* MeshInitFromObj | ( | char * | objFile | ) |
Initialize a new mesh object from an obj file.
Loads the specified obj file and constructs a new mesh object representation of it.
Note: This doesn't read material definitions properly, instead explicitly loading a predefined texture out-of-band and applying it if there are texture coordinates in the obj file.
[in] | objFile | path to the obj file to read |
int TriangleClipAgainstPlane | ( | struct vec3 | plane, |
struct vec3 | normal, | ||
struct triangle | in, | ||
struct triangle * | out1, | ||
struct triangle * | out2 | ||
) |
Clip a triangle against a plane.
Given a triangle and a plane, if some of the points lie on one side of the plane and some on the other, then split the triangle into 1 or 2 smaller triangles that do not pass through the plane.
[in] | plane | point on the plane to clip against |
[in] | normal | normal of the plane to clip against |
[in] | in | the triangle to clip |
[out] | out1 | one of the smaller triangles resulting from the clipping, if necessary |
[out] | out2 | one of the smaller triangles resulting from the clipping, if necessary |
struct vec3 Vec3IntersectPlane | ( | struct vec3 | plane, |
struct vec3 | normal, | ||
struct vec3 | lineStart, | ||
struct vec3 | lineEnd, | ||
float * | t | ||
) |
Return the 3d point where a line intersects a plane.
[in] | plane | 3d point on the plane to intersect against |
[in] | normal | normal of the plane to intersect against |
[in] | lineStart | |
[in] | lineEnd | |
[out] | t | where on the line the intersection occurs. |