MCPcopy Create free account
hub / github.com/ICE27182/Python-3D-renderer / __init__

Method __init__

v1.0/renderer.py:4–19  ·  view source on GitHub ↗
(self, name, v=None, vn=None, vt=None, f=None,)

Source from the content-addressed store, hash-verified

2
3class Mesh:
4 def __init__(self, name, v=None, vn=None, vt=None, f=None,) -> None:
5 import math
6 self.sqrt = math.sqrt
7 self.sin = lambda x: math.sin(x * math.pi / 180)
8 self.cos = lambda x: math.cos(x * math.pi / 180)
9 self.name = name
10 self.v = [] if v == None else v
11 self.vn = [] if vn == None else vn
12 self.vt = [] if vt == None else vt
13 self.f = [] if f == None else f
14 if self.v != []:
15 def relative_v_calculation(v):
16 return (v[0] - self.center[0], v[1] - self.center[1], v[2] - self.center[2])
17 self.center = list(map(sum, (zip(*self.v))))
18 self.center = [self.center[i] / len(self.v) for i in range(3)]
19 self.relative_v = map(relative_v_calculation, self.v)
20
21
22 def load_obj(filename, meshes, directory=".") -> dict:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected