Skip to content

Commit

Permalink
(titanfall.respawn) added Bounds.as_model()
Browse files Browse the repository at this point in the history
  • Loading branch information
snake-biscuits committed Sep 22, 2024
1 parent 05dd30e commit 90c09fd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bsp_tool/branches/respawn/titanfall.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import annotations
import enum
import io
import math
import struct
from typing import Dict, List, Union

Expand Down Expand Up @@ -408,6 +409,19 @@ class Bounds(base.Struct): # LUMP 88 & 90 (0058 & 005A)
_arrays = {"origin": [*"xyz"], "extents": [*"xyz"]}
_classes = {"origin": vector.vec3, "extents": vector.vec3}

@property
def yaw(self) -> float:
# NOTE: could be backwards
# -- rotation in Blender is inverted from top orthographic view if I specify Z-axis
return math.degrees(math.atan2(self.positive_sin / 0x8000, -self.negative_cos / 0x8000))

def as_model(self) -> geometry.Model:
aabb = physics.AABB.from_origin_extents(self.origin, self.extents)
return geometry.Model(
meshes=aabb.as_model().meshes,
origin=self.origin,
angles=vector.vec3(z=self.yaw))


class Brush(base.Struct): # LUMP 92 (005C)
"""A bounding box sliced down into a convex hull by multiple planes"""
Expand Down

0 comments on commit 90c09fd

Please sign in to comment.