-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#151) sketching out
extensions.geometry
- Loading branch information
1 parent
e1318a9
commit 705ac45
Showing
5 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from __future__ import annotations | ||
from typing import List | ||
|
||
from ..branches import vector | ||
|
||
|
||
# TODO: Mesh, Material, Model | ||
# -- Transform (matrix | position, rotation, scale) | ||
|
||
|
||
class Vertex: | ||
position: vector.vec3 | ||
normal: vector.vec3 # should be normalised | ||
uv: List[vector.vec2] | ||
# uv[0] = albedo | ||
# uv[1] = lightmap | ||
|
||
|
||
class Polygon: | ||
vertices: List[Vertex] | ||
normal: vector.vec3 | ||
|
||
def __init__(self, vertices: List[Vertex]): | ||
assert len(vertices) >= 3 | ||
self.vertices = vertices | ||
|
||
def __iter__(self): | ||
return iter(self.vertices) | ||
|
||
@property | ||
def normal(self) -> vector.vec3: | ||
return [v.normal for v in self.vertices] / len(self.vertices) | ||
|
||
@normal.setter | ||
def normal(self, new_normal: vector.vec3): | ||
for i, vertex in enumerate(self.vertices): | ||
self.vertices[i].normal = new_normal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from typing import List | ||
|
||
from ..branches import physics | ||
from . import base | ||
|
||
|
||
def polygons_of(brush: physics.Brush) -> List[base.Polygon]: | ||
# generate a Polygon for each Plane, such that they can be zipped | ||
# extensions.editor should have a Brush class w/ BrushSides | ||
raise NotImplementedError() | ||
# aabb quads | ||
# slice edges w/ each non-axial plane | ||
# only respect in-bounds intersections | ||
# slice edge by replacing A-B w/ A-S;S-B if A & B on opposite sides | ||
# find the lerp(t) via plane.test(A) * -plane.normal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# import json | ||
|
||
|
||
class GLTF: | ||
# vertex specification | ||
# buffers | ||
# "Mesh" -> Vertex & Index buffers | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Obj: | ||
# option: use rexx' magic negative indices | ||
... |