Functions OOP - ZackWilde27/Z3dPy GitHub Wiki
OOP Functions
Docs for function version can be found here
Raster Functions
RasterThings(thingList, camera) -> triangle list
returns a list of triangles to draw to the screen, given a list of things, and a camera to render from.
RasterMeshList(meshList, camera) -> triangle list
returns a list of triangles to draw to the screen, given a list of meshes, and a camera to render from.
Drawing Functions can be found here
Vector Functions
VectorAdd(vector1, vector2) -> vector
returns the sum of the vectors
VectorSub(vector1, vector2) -> vector
returns the first vector subtracted by the second vector
VectorMul(vector1, vector2) -> vector
returns the first vector multiplied by the second
VectorMulF(vector, float) -> vector
returns the vector multiplied by the float
VectorDivF(vector, float) -> vector
returns the vector, divided by the float
VectorCrP(vector1, vector2) -> vector
returns the cross product of 2 vectors. A.K.A the direction apposing 2 vectors
VectorDoP(vector1, vector2) -> float
returns the dot product of 2 directions. A.K.A how much is vector1 facing vector2 (-1 to 1)
VectorRotateX(vector, degrees) -> vector
returns the vector rotated around the x axis
VectorRotateY(vector, degrees) -> vector
returns the vector rotated around the y axis
VectorRotateZ(vector, degrees) -> vector
returns the vector rotated around the z axis
VectorEqual(vector1, vector2) -> bool
returns true if the vectors are equal
VectorNegate(vector) -> vector
returns the negated vector
DistanceBetweenVectors(vector1, vector2) -> float
returns the distance between the two vectors
DirectionBetweenVectors(vector1, vector2) -> vector
returns the direction from the first vector towards the second
VectorIntersectPlane(planePos, planeNrm, lineStart, lineEnd) -> vector
returns the point where a line intersects a plane
ShortestPointToPlane(startPoint, planeNrm, planePos) -> vector
returns the closest point on the plane to the startPoint
VectorGetLength(vector) -> float
returns the length of a vector
VectorToList(vector) -> list
returns the vector as a list
VectorNormalize(vector) -> vector
returns the normalized vector
Triangle Functions
TriangleAdd(triangle, vector) -> triangle
Shortcut instead of VectorAdd-ing each point
TriangleSub(triangle, vector) -> triangle
Shortcut instead of VectorSub-ing each point
TriangleMul(triangle, vector) -> triangle
You probably get the point
TriangleMulF(triangle, float) -> triangle
TriangleDivF(triangle, float) -> triangle
GetNormal(triangle) -> vector
returns the normal vector of a given triangle
TriangleAverage(triangle) -> vector
returns the center point of the triangle
triSort(triangle) -> float
returns the inverse of the distance from the camera, after averaging each point of the triangle. Used when sorting triangles but you might have some other use for it
Matrix Functions
My version of a matrix is just a list of lists, so to set or retrive a value it's myMatrix[x][y]
GetTranslationMatrix(x, y, z) -> matrix
returns a translation matrix given a camera x, y, and z
MatrixMul(vector, matrix) -> vector4
multiplies the vector by the matrix and returns the vector4
TriMatrixMul(triangle, matrix) -> triangle
Shortcut for multiplying a matrix by each point of a triangle
PointAtMatrix(position, target, up) -> matrix
returns a rotation matrix given a start position, target direction, and up direction
MatrixMakeRotX(angle) -> matrix
returns an X rotation matrix given an angle value in degrees
MatrixMakeRotY(angle) -> matrix
returns an Y rotation matrix given an angle value in degrees
MatrixMakeRotZ(angle) -> matrix
returns an Z rotation matrix given an angle value in degrees
Mesh Functions
LoadMesh(filename, x, y, z) -> mesh
returns a mesh, using the filename, with a scale of 1
LoadMeshScl(filename, x, y, z, sclX, sclY, sclZ) -> mesh
returns a mesh, using the filename, with custom scale
NewCube(scale, x, y, z) -> mesh
returns a basic cube mesh, used for debugging
Custom Render Pipeline Functions
RasterMeshList() and RasterThings() does pretty much everything in one function. Does all the matrix math for camera positioning and object rotation, projects them to the camera coordinates, and sorts based on depth. But what if you want more control?
SetInternalCamera(camera) -> void
sets the internal camera, and computes a bunch of constants needed for rendering. Do this before everything else
TransformTriangles(triangleList, rotation) -> triangle list
returns a list of rotated triangles. given a list of triangles, the new rotation, and camera object.
TranslateTriangles(triangleList, position) -> triangle list
returns a list of translated triangles, given a list of triangles, the new position, and camera object.
ViewTriangles(triangleList) -> triangle list
returns the list of viewed triangles, given a list of triangles, and camera object.
ProjectTriangles(triangleList) -> triangle list
returns the list of projected triangles, given a list of triangles, and camera object.
These functions should be done in order, so first Transform, then Translate, then View, then Project.