Implemented the first version of the 3D engine. Added support for loading 'obj' files as a mesh.

This commit is contained in:
2020-07-14 16:53:06 -05:00
parent b318076f05
commit 05d2beb8ac
4 changed files with 75 additions and 49 deletions
+15
View File
@@ -11,6 +11,21 @@ class Vector3d:
self.y = y
self.z = z
def cross_product(self, vector3d):
# Returns a line that is perpendicular to the parameter
# and self.
# Returns the 'normal'.
x = self.y * vector3d.z - self.z * vector3d.y
y = self.z * vector3d.x - self.x * vector3d.z
z = self.x * vectored.y - self.y * vector3d.x
return Vector3d(x, y, z)
def dot_product(self, vector3d):
# Returns a scalar that defines how similar two
# vectors are to one another.
return self.x * vector3d.x + self.y * vector3d.y + self.z * vector3d.z
class Vector2d:
def __init__(self, x, y):
self.x = x