Functions - ZackWilde27/Z3dPy GitHub Wiki

Table of Contents:

  • Object Functions
    • Universal
    • Triangles
    • Meshes
    • Things
    • Lights
    • Rays
    • Emitters
    • Particles
    • Cameras
    • Hits
  • Vector Functions
  • VectorUV Functions
  • Triangle Functions
  • Matrix Functions
  • Mesh Functions
  • Thing Functions
  • Collisions and Physics Functions
  • Train Functions
  • Raster Functions
  • Drawing and Shader Functions
    • PyGame
    • Tkinter
    • Lighting
    • "Rastering"
  • Custom Pipeline Functions
  • Misc. Functions



Legend:

Arguments marked with a * are optional

Unless it returns void, functions that change an input (such as VectorAdd) will return a new object without updating the originals.

Quite a few parameters specify the type of variable expected, with a starting letter:
f for float, i for integer, v for vector, msh for mesh.

Normalized parameters use capital letters, like F or V, expecting an input between 0-1 or -1 to 1


Object Functions

These functions are for setting and accessing variables inside "objects"


Universal


GetPos(any) -> vector

returns the position of a Thing, Mesh/AnimMesh, Cam, Ray, Light, Particle, or Emitter


SetPos(any, vector) -> void

sets the position of a Thing, Mesh/AnimMesh, Cam, Ray, Light, Particle, or Emitter


GetRot(any) -> vector

returns the rotation of a Thing, Cam, or Mesh/AnimMesh


SetRot(any, vector) -> void

sets the rotation of a Thing, Cam, or Mesh/AnimMesh


GetList(any) -> list or tuple

returns the list from a Thing, Emitter, Mesh/AnimMesh, or Frame.


For Things it's a list of meshes
For Emitters it's a tuple of active particles
For Meshes/Frames it's a tuple of tris
For AnimMeshes it's a list of frames

SetList(any, list) -> void

sets the list of a Thing, Emitter, Mesh/AnimMesh, or Frame.


Triangles


TriGetP1(tri)

returns the first point of a triangle.


TriGetP2(tri)

returns the second point of a triangle.


TriGetP3(tri)

returns the third point of a triangle.


TriGetNormal(tri) -> vector

returns the normal of the triangle.

TriGetNormal() will retrieve the stored normal, wheras GetNormal() will calculate a new one.


TriSetNormal(tri, vector) -> void

sets the normal of the triangle (set automatically during rasterization)


TriGetColour(tri) -> vector

returns the colour of the triangle.


TriSetColour(tri, vector) -> void

sets the colour of the triangle (set automatically during rasterization)


TriGetWPos(tri) -> vector

returns the world position of the triangle


TriSetWPos(tri, vector) -> void

sets the world position of a triangle (set automatically during rasterization)


TriGetShade(tri) -> vector

returns the baked lighting colour of the triangle


TriSetShade(tri, VColour) -> void

sets the baked lighting colour of a triangle


TriGetId(tri) -> int

returns the id of the triangle


TriSetId(tri, id) -> void

sets the id of a triangle (set automatically during rasterization)


Meshes


MeshGetTris(mesh)

returns the mesh's list of triangles


MeshSetTris(mesh, tris) -> void

Sets the tris of the given mesh


MeshGetPos(mesh) -> vector

returns the position of the given mesh


MeshSetPos(mesh, vector) -> void

Sets the position of the given mesh


MeshGetRot(mesh) -> vector

returns the rotation of the mesh


MeshSetRot(mesh, vector) -> void

Sets the rotation of the mesh


MeshAddRot(mesh, vector) -> void

Adds rotation to the mesh by the x, y, and z separately


MeshSubRot(mesh, vector) -> void

Subtracts the rotation of the mesh by the x, y, and z separately


MeshMulRot(mesh, vector) -> void

Multiplies the rotation of the mesh by the x, y, and z separately


MeshDivRot(mesh, vector) -> void

Divides mesh rotation by the x, y and z separately


MeshGetColour(mesh) -> vector

returns the colour of the mesh


MeshSetColour(mesh, vector) -> void

sets the colour of the mesh


MeshGetId(mesh) -> int

returns the id of the mesh


MeshSetId(mesh, id) -> void

sets the id of the mesh


MeshGetCull(mesh) -> bool

returns wether or not back-faces are culled for this mesh


MeshSetCull(mesh, bCull) -> void

sets wether or not back-faces are culled for this mesh


MeshGetFrame(mesh) -> int

returns the frame counter, or -1 for regular mesh


MeshSetFrame(mesh, iFrame) -> void

sets the frame counter


MeshIncFrame(animMesh) -> void

increments the frame counter


MeshDecFrame(animMesh) -> void

decrements the frame counter


Things


ThingGetPos(thing) -> vector

returns the position of the mesh


ThingGetPosX(thing) -> float

returns the x position of a thing


ThingGetPosY(thing) -> float

returns the y position of a thing


ThingGetPosZ(thing) -> float

returns the z position of a thing


ThingSetPos(thing, vector) -> void

sets the position of a thing


ThingSetPosX(thing, x) -> void

sets the x position of a thing


ThingSetPosY(thing, y) -> void

sets the y position of a thing


ThingSetPosZ(thing, z) -> void

sets the z position of a thing


ThingAddPosX(thing, x) -> void

adds to the x position of a thing


ThingAddPosY(thing, y) -> void

adds to the y position of a thing


ThingAddPosZ(thing, z) -> void

adds to the z position of a thing


ThingGetRot(thing) -> vector

returns the rotation of a thing


ThingSetRot(thing, vector) -> void

sets the rotation of a thing


ThingAddRot(thing, vector) -> void

adds rotation to a thing


ThingSubRot(thing, vector) -> void

subtracts rotation from a thing


ThingMulRot(thing, vector) -> void

multiplies a thing's rotation by a vector


ThingDivRot(thing, vector) -> void

divides a thing's rotation by a vector


ThingGetPitch(thing) -> float

returns the pitch of a thing


ThingGetRoll(thing) -> float

returns the roll of a thing


ThingGetYaw(thing) -> float

returns the yaw of a thing


ThingSetPitch(thing, deg) -> void

sets the pitch of a thing


ThingSetRoll(thing, deg) -> void

sets the roll of a thing


ThingSetYaw(thing, deg) -> void

sets the yaw of a thing


ThingGetId(thing) -> int

returns the id of a thing


ThingSetId(thing, id) -> void

sets the id of a thing


ThingGetMovable(thing) -> bool

returns wether or not a thing is movable


ThingSetMovable(thing, bMovable) -> void

sets wether or not a thing is movable


ThingGetUserVar(thing) -> any

returns the user variable of a thing


ThingSetUserVar(thing, any) -> void

sets the user variable of a thing


ThingIncFrames(thing) -> void

increments the frame counter of all animMeshes in a thing


ThingSetupHitbox(thing, *type, *id, *radius, *height)

gives the thing a hitbox


ThingSetCollision(thing, type, id, radius, height)

changes the collision data of a thing and replaces the hitbox mesh.


ThingGetHitboxMesh(thing) -> mesh

returns the hitbox mesh of a thing


ThingGetHitboxHeight(thing) -> float

returns the height of a thing's hitbox


ThingGetHitboxRadius(thing) -> float

returns the hitbox radius of a thing


ThingGetHitboxId(thing) -> int

returns the collision id of a thing


ThingGetHitboxType(thing) -> int

returns the type of hitbox (0 = sphere, 1 = cylinder, 2 = cube)


ThingSetupPhysics(thing) -> void

gives the thing a physics body


ThingGetPhysics(thing) -> PhysicsBody

returns the physics body of a thing


ThingGetVelocity(thing, vector) -> void

sets the velocity of a thing


ThingSetVelocityX(thing, x) -> void

sets the x velocity of a thing


ThingSetVelocityY(thing, y) -> void

sets the y velocity of a thing


ThingSetVelocityZ(thing, z) -> void

sets the z velocity of a thing


ThingGetVelocity(thing) -> vector

returns the velocity of a thing


ThingGetVelocityX(thing) -> float

returns the x velocity of a thing


ThingGetVelocityY(thing) -> float

returns the y velocity of a thing


ThingGetVelocityZ(thing) -> float

returns the z velocity of a thing


ThingAddVelocity(thing, vector) -> void

adds velocity to a thing


ThingSubVelocity(thing, vector) -> void

subtracts velocity from a thing


ThingSetAcceleration(thing, vector) -> void

sets the acceleration of a thing


ThingGetAcceleration(thing) -> vector

returns the acceleration of a thing


ThingSetMass(thing, mass) -> void

sets the mass of a thing


ThingGetMass(thing) -> float

returns the mass of a thing


ThingSetFriction(thing, frc) -> void

sets the friction of a thing


ThingGetFriction(thing) -> float

returns the friction of a thing


ThingSetBounciness(thing, bnc) -> void

sets the bounciness of a thing


ThingGetBounciness(thing) -> float

returns the bounciness of a thing


ThingGetRotVelocity(thing) -> vector

returns the rotational velocity of a thing


ThingSetRotVelocity(thing, vector) -> void

sets the rotational velocity of a thing


ThingAddRotVelocity(thing, vector) -> void

adds to the rotational velocity of a thing


ThingGetRotAccel(thing) -> vector

returns the rotational acceleration of a thing


ThingSetRotAccel(thing, vector) -> void

sets the rotational acceleration of a thing


ThingAddRotAccel(thing, vector) -> void

adds to the rotational acceleration of a thing


ThingStop(thing) -> void

sets velocity and acceleration of a thing to 0


Lights


LightGetType(light) -> int

returns the type of light. (0 for point, 1 for sun)


LightGetPos(light) -> vector

returns the position of a light


LightSetPos(light, vector) -> void

sets the position of a light


LightSetPosX(light, x) -> void

sets the x position of a light


LightSetPosY(light, y) -> void

sets the y position of a light


LightSetPosZ(light, z) -> void

sets the z position of a light


LightGetStrength(light) -> float

returns the strength of a light


LightSetStrength(light, f) -> void

sets the strength of a light (0 - 1)


LightGetRadius(light) -> float

returns the radius of a light


LightSetRadius(light, f) -> void

sets the radius of a thing


LightGetColour(light) -> vector

returns the colour of a light


LightSetColour(light, vColour) -> void

sets the colour of a light.


LightGetUserVar(light) -> any

returns the user variable of a light


LightSetUserVar(light, any) -> void

sets the user variable of a light


Rays


RayGetStart(ray) -> vector

returns the start position of a ray


RaySetStart(ray, vector) -> void

sets the start position of a ray


RayGetEnd(ray) -> vector

returns the end position of a ray


RaySetEnd(ray, vector) -> void

sets the end position of a ray


RayGetDirection(ray) -> vector

returns the direction of a ray


RayGetLength(ray) -> float

returns the length of a ray


RayGetIsArrow(ray) -> bool

returns wether or not the ray is an arrow


RaySetIsArrow(ray, bIsArrow) -> void

sets wether or not the ray is an arrow


Emitters


EmitterGetPos(emitter) -> vector

returns the position of an emitter


EmitterSetPos(emitter, vector) -> void

sets the position of an emitter


EmitterGetTemplate(emitter) -> mesh

returns the template mesh of an emitter


EmitterSetTemplate(emitter, mesh) -> void

sets the template mesh of an emitter


EmitterGetVelocity(emitter) -> vector

returns the starting velocity of an emitter


EmitterSetVelocity(emitter, vector) -> void

sets the starting velocity of an emitter


EmitterGetMax(emitter) -> int

returns the max number of particles for an emitter


EmitterSetMax(emitter, iMax) -> void

sets the max number of particles for an emitter


EmitterGetLifetime(emitter) -> float

returns the particle lifetime of an emitter


EmitterSetLifetime(emitter, float) -> void

sets the particle lifetime of an emitter


EmitterGetActive(emitter) -> bool

returns wether or not an emitter is active


EmitterSetActive(emitter, bActive) -> void

sets wether or not an emitter is active


EmitterGetGravity(emitter) -> vector

returns the emitter's gravity


EmitterSetGravity(emitter, vector) -> void

sets the emitter's gravity


Particles


PartGetTime(particle) -> float

returns the time left of a particle


PartSetTime(particle, float) -> void

sets the time left of a particle. I made a mistake and it says iLayer, but it's a float.


PartGetPos(particle) -> vector

returns the position of a particle


PartSetPos(particle, vector) -> void

sets the position of a particle


PartGetVelocity(particle) -> vector

returns the velocity of a particle


PartSetVelocity(particle, vector) -> void

sets the velocity of a particle


Cameras


CamGetPos(cam) -> vector

returns the position of a camera


CamGetPosX(camera) -> float

returns the x position of a camera


CamGetPosY(camera) -> float

returns the y position of a camera


CamGetPosZ(camera) -> float

returns the z position of a camera


CamSetPos(cam, vector) -> void

sets the position of a camera


CamSetPosX(cam, x) -> void

sets the x position of a camera


CamSetPosY(cam, y) -> void

sets the y position of a camera


CamSetPosZ(cam, z) -> void

sets the z position of a camera


CamAddPos(cam, vector) -> void

adds the vector to the camera's position


CamSubPos(cam, vector) -> void

subtracts position from the camera


CamMulPos(cam, vector) -> void

multiplies the camera's position by a vector


CamDivPos(cam, vector) -> void

divides the camera's position by a vector


CamDivPosF(cam, f) -> void

divides the camera's position by a float


CamChase(cam, vLocation, *fSpeed)

causes a camera to "chase" a location rather than directly setting.


CamGetPitch(cam) -> float

returns the pitch of a camera


CamGetRoll(cam) -> float

returns the roll of a camera


CamGetYaw(cam) -> float

returns the yaw of a camera


CamSetPitch(cam, deg) -> void

sets the pitch of a camera


CamSetRoll(cam, deg) -> void

sets the roll of a camera


CamSetYaw(cam, deg) -> void

sets the yaw of a camera


CamGetRot(cam) -> vector

returns the rotation of a camera


CamSetRot(cam, vector) -> void

sets the rotation of a camera


CamAddRot(cam, vector) -> void

adds rotation to a camera


CamSubRot(cam, vector) -> void

subtracts rotation from a camera


CamMulRot(cam, vector) -> void

multiplies the rotation of a camera by a vector


CamDivRot(cam, vector) -> void

divides the rotation of a camera by a vector


CamDivRotF(cam, f) -> void

divides the rotation of a camera by a float


CamGetNCl(cam) -> float

returns the near clip of a camera


CamSetNCl(cam, f) -> void

sets the near clip of a camera


CamGetFCl(cam) -> float

returns the far clip of a camera


CamSetFCl(cam, f) -> void

sets the far clip of a camera


CamGetTargetLoc(cam) -> vector

returns the location a camera is looking at.


CamSetTargetLoc(cam, vector) -> void

sets the location a camera will look at


CamGetTargetDir(cam) -> vector

returns the direction a camera is looking


CamSetTargetDir(cam, vector) -> void

sets the direction a camera will look


CamSetTargetFP(cam) -> void

uses the camera's rotation to determine target direction, for an easy first person camera.


CamGetRightVector(cam) -> vector

returns the direction to the right of the camera.


CamGetUserVar(camera) -> any

returns the user variable


CamSetUserVar(camera, any) -> void

sets the user variable of a camera


Hits


HitCheck(hit) -> bool

returns wether or not it hit.

and if so...


HitPos(hit) -> vector

returns the position of the hit


HitDistance(hit) -> float

returns the distance between the ray start and the hit


HitNormal(hit) -> vector

returns the normal of the triangle that was hit


HitTriPos(hit) -> vector

returns the world pos of the triangle that was hit



Vector Functions

Almost all of these return new vectors, does not modify the original



VectorAdd(vector1, vector2) -> vector

returns the sum of the vectors


VectorAddF(vector, float) -> vector

returns a vector with the float added to each axis


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


VectorDiv(vector, vector) -> vector

returns the first vector divided by the second


VectorDivF(vector, float) -> vector

returns a vector, divided by the float


VectorMod(vector1, vector2) -> vector

returns a vector with each axis modulo'd individually


VectorModF(vector, float) -> void

returns a vector with each axis modulo'd by the float.


VectorCrP(vector1, vector2) -> vector

returns the cross product of 2 vectors


VectorDoP(vector1, vector2) -> vector

returns the dot product of 2 vectors


VectorFloor(vector) -> vector

returns a vector with each axis math.floor()'d


VectorABS(vector) -> vector

returns a vector with each axis abs()'d


VectorComb(vector) -> float

returns the axis of a vector added together


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


VectorCompare(vector1, vector2) -> bool

returns wether or not vector1 is greater than vector2, in terms of absolute magnitude


VectorNegate(vector) -> vector

returns the negated vector


VectorPureDirection(vector) -> vector

returns a vector with the strongest axis being 1, others are 0


VectorZero(vector, fThreshold) -> vector

returns a vector where all axis below the threshold are 0


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


VectorNormalize(vector) -> vector

returns the normalized vector


VectorMax(v1, v2) -> vector

shortcut for using a max() on each axis individually.


VectorMin(v1, v2) -> vector

shortcut for using a min() on each axis individually.


VectorMaxF(v, f) -> vector

shortcut for using a max() on each axis.


VectorMinF(v, f) -> vector

shortcut for using a min() on each axis.


WrapRot(vRot) -> vector

returns a rot with each axis wrapped to 0-359


RotTo(vRot, VTarget) -> vector

returns the target direction rotated, used to get anything's up, forward, right, or anything-in-between vector



VectorUV Functions

The second vector does not have to be a vectorUV. The first vector's normal and UV are carried.



VectorUVAdd(v1, v2) -> VectorUV

adds the second vector to the first.


VectorUVSub(v1, v2) -> VectorUV

subtracts the second vector from the first.


VectorUVMul(v1, v2) -> VectorUV

multiplies the first vector by the second.


VectorUVMulF(v, f) -> VectorUV

multiplies the vectorUV by a float


VectorUVDiv(v1, v2) -> VectorUV

divides the first vector by the second


VectorUVDivF(v, f) -> VectorUV

divides the vectorUV by a float



Triangle Functions

Most of these return new triangles, does not modify the original



TriAdd(triangle, vector) -> triangle

Shortcut instead of VectorAdd-ing each point


TriSub(triangle, vector) -> triangle

Shortcut instead of VectorSub-ing each point


TriMul(triangle, vector) -> triangle

You get the point


TriMulF(triangle, float) -> triangle


TriDivF(triangle, float) -> triangle


GetNormal(triangle) -> vector

Calculates the normal of a triangle. (TriangleGetNormal() will return the currently stored normal)


TriAverage(triangle) -> vector

returns the center point of the triangle


TriClipAgainstPlane(planePosition, planeNormal, tri)

returns a list of triangles, either containing the original triangle if it's in front of the plane, split up triangles that clip the plane, or no triangles if it's behind the plane.


TriClipAgainstZ(tri, camera)

does a TriClipAgainstPlane(), for the camera's near clip plane


TriClipAgainstScreenEdges(tri, camera)

does a TriClipAgainstPlane(), for all 4 edges of the screen.


triSortAverage(triangle) -> float

returns the average point's distance from the camera. A key for sorting triangles.


triSortFurthest(triangle) -> float

returns the furthest point from the camera. A key for sorting triangles.


triSortClosest(triangle) -> float

returns the closest point from the camera. A key for sorting triangles.


Matrix Functions

My version of a matrix is just a list of lists, to set or retrive a value it's myMatrix[x][y]

VecMatrixMul(vectorUV, matrix) -> vectorUV

multiplies the vector by the matrix and returns the vectorUV


Vec3MatrixMul(vector, matrix) -> vector4

multiplies the vector by the matrix and returns the vector4


MatrixMatrixMul(matrix1, matrix2) -> matrix

returns the multiplied matrixes


TriMatrixMul(triangle, matrix) -> triangle

Shortcut for multiplying a matrix by each point of a triangle


PointAtMatrix(pos, target, up) -> matrix

returns a point at matrix, given a position, target location, and up direction


LookAtMatrix(pos, target, up) -> matrix

returns a look at matrix given a position, target location, and up direction. used during the ViewTriangles() stage of rastering


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

MatrixMakeProjection(camera) -> matrix

returns the projection matrix, given a camera. Not used



Mesh Functions



LoadMesh(filename, *vPos, *VScale) -> mesh

loads the mesh from filename and returns it. If the filename is not found, loads the NOPE mesh


LoadAnimMesh(filename, *vPos, *VScale) -> mesh

loads the animMesh from filename and returns it.




Thing Functions



AddThing(thing, *iLayer) -> void

adds a thing to the specified layer (third layer by default)


AddThings(thingList, *iLayer) -> void

adds a list of things to the specified layer (third layer by default)


RemoveThing(thing, *iLayer) -> void

removes a thing from the specified layer (third layer by default)


GatherThings() -> list

returns a list of all things in all layers.


AddDupe(thing, position, rotation, *iLayer) -> dupe

Adds a dupe to the global list in the iLayer, and returns it.
If iLayer is -1, doesn't add to global list.



Collisions and Physics Functions



GatherCollisions(thingList) -> collisionList

returns a list of things that are colliding


BasicHandleCollisions(collision) -> void

takes the list from GatherCollisions() and sets the position of things to try and separate them.


HandlePhysicsFloor(thingList, *floorHeight) -> void

sets the position of things based on their physics calculations. Gravity is included, so there's a floor that things won't fall past. (0 unless specified.)


HandlePhysicsTrain(thingList, train) -> void

same as HandlePhysicsFloor() except uses a train to determine height.


PhysicsCollisions(thingList) -> void

will GatherCollisions(), then applies velocity to separate any collisions. Will only push objects that have a physics body.




Train Functions



BakeTrain(train, *iPasses, *FStrength, *fAmplitude) -> void

blurs terrain into smooth hills. overwrites the original.


TrainInterpolate(train, x, y) -> float

returns the height at a certain location, interpolating between values.




Raster Functions



SetInternalCamera(camera) -> void

computes the view matrix for the ViewTriangles stage of rendering. This needs to be done when the camera moves or otherwise changes.


RasterMeshList(meshList, *sortingMethod, *reverseSort) -> triangle list

returns a list of triangles to draw to the screen, given a list of meshes, and a camera to render from.

sorting method has 3 options: triSortAverage, triSortFurthest, and triSortClosest.

reverseSort is wether or not to reverse sorting. Should be True, except when using the PgPixelShader


RasterThings(thingList, *emittersList, *sortingMethod, *reverseSort) -> triangle list

returns a list of triangles to draw to the screen, given a list of things. sorts using z3dpy.triSortAverage by default


Raster(*sortingMethod, *reverseSort) -> triangle list

same thing as RasterThings() but uses the internal list


DebugRaster(*train, *sortingMethod, *reverseSort) -> triangle list

returns a list of triangles to draw to the screen, including hitboxes, lights, rays, and other debug things.


CRaster(*sortingMethod, *reverseSort) -> triangle list

returns a list of triangles to draw to the screen, rendered with the C++ extension


CRasterThings(*sortingMethod, *reverseSort) -> triangle list

same as RasterThings(), but using the C++ extension




Drawing and Shader Functions



PyGame


PgDrawTriFL(tri, surface, pygame) -> void

draws a triangle to a PyGame surface, with dynamic flat lighting


PgDrawTriFLB(tri, surface, pygame) -> void

draws a triangle to a PyGame surface, with baked flat lighting.


PgDrawTriRGB(tri, vector, surface, pygame) -> void

draws a triangle to a PyGame surface. it's a vector so xyz is rgb


PgDrawTriRGBF(tri, vector, surface, pygame) -> void

draws a triangle to a PyGame surface. converts 0-1 to 0-255


PgDrawTriF(tri, f, surface, pygame) -> void

draws a triangle to a PyGame surface. uses the float for all channels, so it's grayscale


PgDrawTriS(tri, f, surface, pygame) -> void

draws a triangle to a PyGame surface. multiplies the float by the triangle's colour to produce shading


PgDrawTriOutl(tri, vector, surface, pygame) -> void

draws a triangle to a PyGame surface. only draws the outline and converts 0-1 to 0-255


PgPixelShader(tri, pixelArray, pygame) -> void

draws a textured triangle to a PyGame pixel array. Still early on and definitely not the fastest.


Tkinter


TkDrawTriFL(tri, canvas) -> void

draws a triangle to a Tkinter canvas, with dynamic flat lighting


TkDrawTriFLB(tri, canvas) -> void

draws a triangle to a Tkinter canvas, with baked flat lighting


TkDrawTriRGB(tri, vector, canvas) -> void

draws a triangle to a Tkinter canvas. it's a vector so xyz is rgb


TkDrawTriRGBF(tri, vector, surface, pygame) -> void

draws a triangle to a Tkinter canvas. converts 0-1 to 0-255


TkDrawTriF(tri, f, surface, pygame) -> void

draws a triangle to a Tkinter canvas. uses the float for all channels, so it's grayscale


TkDrawTriS(tri, f, surface, pygame) -> void

draws a triangle to a Tkinter canvas. multiplies the float by the triangle's colour to produce shading


TkDrawTriOutl(tri, vector, surface, pygame) -> void

draws a triangle to a Tkinter canvas. only draws the outline and converts 0-1 to 0-255


Lighting


CheapLightingCalc(tri, *drawRay) -> float

returns the shade of a triangle, using cheap direction based lighting. optionally you can specify whether or not to add to the global rays list for drawing. (False by default)


ExpensiveLightingCalc(tri) -> float

returns the shade of a triangle, using an expensive technique that checks for shadows.


FlatLightingBaked(tri) -> float

returns the shade of a triangle, cheaply retrived from it's shade variable


BakeLighting(thingList, *bExpensive, *lightList, *shadowcasterList) -> void

saves the lighting calculations to each triangle's shade variable. optional parameter to specify expensive lighting. Shadowcasters is the list of Things to check for collisions.


"Rastering"

technically Rastering is converting triangles to lines or pixels, so here are those functions.


TriToLines(tri) -> tuple

returns a tuple of lines to draw, given a triangle. Each line is a ray, with a start position and end position.


TriToPixels(tri) -> tuple

returns a tuple of pixels to draw, given a triangle. Each line is a Vector2, with an x and y




Custom Render Pipeline Functions




TransformTris(triangleList, pos, target, up) -> triangle list

rotates triangles in world space, given a position, target location, and up direction.


WTransformTris(triangleList, rot) -> triangle list

the old method of transforming triangles


TranslateTris(triangleList, pos) -> triangle list

the old method of translating triangles


ViewTris(triangleList) -> triangle list

moves and distorts triangles in front of [0, 0, 0] as if the camera was moving.


ProjectTris(triangleList) -> triangle list

projects a list of triangles to 2D


These functions should be done in order, so first Transform, then Translate, then View, then Project.





Misc. Functions



ListInterpolate(list, fIndex) -> float

interpolates between numbers in a list based on fIndex


ListExclude(list, index) -> list

returns the list, with the index removed, for temporary exclusion, or for replacing the list to act as a better remove()


Sign(float) -> 1, 0, or -1

returns the sign of the input, positive, negative, or 0

⚠️ **GitHub.com Fallback** ⚠️