-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvmftool-test.py
More file actions
executable file
·64 lines (58 loc) · 2.87 KB
/
vmftool-test.py
File metadata and controls
executable file
·64 lines (58 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
import sys
from typing import Optional, Union
from math import hypot
import itertools
from vmftool import *
DEFAULT_WALL_THICKNESS : float = 16.0
def make_room(sides : int,
radius : float,
height : float,
wall_materials : Union[list[str], str],
floor_material : str,
ceiling_material : str,
wall_thickness : float = DEFAULT_WALL_THICKNESS,
make_wall : Optional[list[bool]] = None) -> PolygonShape:
half_thickness : float = wall_thickness / 2.0
polygon : list[Point2] = gen_polygon(sides, radius + half_thickness)
shape : PolygonShape = PolygonShape(polygon,
wall_thickness,
pos=Point3(0.0, 0.0, 0.0 - half_thickness),
materials=floor_material)
# add the whole wall thickness to compensate for the half thickness subtracted from the floor
shape.add_child_shape(PolygonShape(polygon,
wall_thickness,
pos=Point3(0.0, 0.0, height + wall_thickness),
materials=ceiling_material),
PolygonShape.SHAPE)
side_length : float = hypot(polygon[1].x - polygon[0].x, polygon[1].y - polygon[0].y)
wall : list[Point2] = [Point2(-side_length / 2.0 - half_thickness, height + wall_thickness),
Point2(side_length / 2.0 + half_thickness, height + wall_thickness),
Point2(side_length / 2.0 + half_thickness, 0.0),
Point2(-side_length / 2.0 - half_thickness, 0.0)]
for i in range(len(polygon)):
if make_wall is None or make_wall[i] is False:
continue
i2 : int = (i+1)%len(polygon)
shape.add_child_shape(PolygonShape(wall,
wall_thickness,
pos=Point3(0.0, 0.0, 0.0),
materials=wall_materials),
PolygonShape.SIDE + i)
return shape
def main(args : list[str]):
v : VMF = VMF()
shape : PolygonShape = make_room(8, 256.0, 128.0,
"brick/brickwall026f",
"concrete/concretefloor033a",
"concrete/concretefloor033a",
make_wall=[False, True, True, True, True, True, True, True])
shape.add_child_entity(Entity("info_player_start",
Point3(0.0, 0.0, 10.0),
{'angles': Point3(0.0, 0.0, 0.0)}),
PolygonShape.TOP)
v.add_shape(shape)
#v.generate()
print(v.generate())
if __name__ == '__main__':
main(sys.argv[1:])