-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathoutdoor.py
executable file
·84 lines (71 loc) · 2.38 KB
/
outdoor.py
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#! /usr/bin/env python3
"""Example map generator: Outdoor
This script demonstrates vmflib by generating a map with a 2D skybox and
some terrain (a displacement map).
"""
from vmflib import *
from vmflib.types import Vertex
from vmflib.tools import Block
from vmflib.brush import DispInfo
import vmflib.games.source as source
m = vmf.ValveMap()
# Environment and lighting
# Sun angle S Pitch Brightness Ambience
# 0 225 0 -25 254 242 160 400 172 196 204 80
m.world.skyname = 'sky_day02_01'
light = source.LightEnvironment()
light.set_all("0 225 0", -25, "254 242 160 400", "172 196 204 80")
# Displacement map for the floor
# do cool stuff
norms = []
for i in range(17):
row = []
for j in range(17):
row.append(Vertex(0, 0, 1))
norms.append(row)
dists = []
for i in range(17):
row = []
for j in range(17):
row.append(((i % 2) + ((j+1) % 2)) * 6) # funky pattern
dists.append(row)
d = DispInfo(4, norms, dists)
# Floor
floor = Block(Vertex(0, 0, -480), (2048, 2048, 64), 'nature/dirtfloor003a')
floor.top().lightmapscale = 32
floor.top().children.append(d) # Add disp map to the ground
# Ceiling
ceiling = Block(Vertex(0, 0, 512), (2048+128, 2048+128, 64))
ceiling.set_material('tools/toolsskybox2d')
# Prepare some upper walls for the skybox
skywalls = []
# Left upper wall
skywalls.append(Block(Vertex(-1024-64, 0, 128), (64, 2048+128, 768)))
# Right upper wall
skywalls.append(Block(Vertex(1024+64, 0, 128), (64, 2048+128, 768)))
# Forward upper wall
skywalls.append(Block(Vertex(0, 1024+64, 128), (2048+128, 64, 768)))
# Rear upper wall
skywalls.append(Block(Vertex(0, -1024-64, 128), (2048+128, 64, 768)))
for wall in skywalls:
wall.set_material('tools/toolsskybox2d')
# Prepare some lower walls to be basic walls
walls = []
# Left wall
walls.append(Block(Vertex(-1024, 0, -384), (64, 2048+64, 256)))
# Right wall
walls.append(Block(Vertex(1024, 0, -384), (64, 2048+64, 256)))
# Forward wall
walls.append(Block(Vertex(0, 1024, -384), (2048+64, 64, 256)))
# Rear wall
walls.append(Block(Vertex(0, -1024, -384), (2048+64, 64, 256)))
# Set each wall's material
for wall in walls:
wall.set_material('brick/brickwall003a')
# Add everything we prepared to the world geometry
m.world.children.extend(walls)
m.world.children.extend(skywalls)
m.world.children.extend([floor, ceiling])
# TODO: Define a playerspawn entity
# Write the map to a file
m.write_vmf('outdoor.vmf')