Skip to content

Commit

Permalink
(#151) sketching out extensions.geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
snake-biscuits committed Dec 8, 2023
1 parent e1318a9 commit 705ac45
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 0 deletions.
Empty file.
37 changes: 37 additions & 0 deletions bsp_tool/extensions/geometry/base.py
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
15 changes: 15 additions & 0 deletions bsp_tool/extensions/geometry/brushwork.py
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
8 changes: 8 additions & 0 deletions bsp_tool/extensions/geometry/gltf.py
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
...
3 changes: 3 additions & 0 deletions bsp_tool/extensions/geometry/obj.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Obj:
# option: use rexx' magic negative indices
...

0 comments on commit 705ac45

Please sign in to comment.