-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
blocky: generates flat color patches and textures
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
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,42 @@ | ||
#!/usr/bin/python | ||
# generates a PWAD with 256 64x64-sized flat color patches and textures named | ||
# COLORXXX and 256 flats named FOLORXXX where XXX is a decimal index into the | ||
# palette | ||
|
||
from omg import * | ||
from omg.txdef import * | ||
import struct | ||
|
||
out = WAD() | ||
editor = omg.txdef.Textures() | ||
|
||
for i in range(0,256): | ||
|
||
# generate raw patch data for palette index i | ||
topdelta = 0 | ||
length = 64 | ||
unused = 0 | ||
data = i | ||
post = struct.pack('<BBB64sB', topdelta, length, unused, bytes([data])*64, unused) | ||
width = height = 64 | ||
leftoffs = topoffs = 0 | ||
postoffs = 264 | ||
patch = struct.pack('<HHhh', width, height, leftoffs, topoffs) \ | ||
+ struct.pack('<L', postoffs) * 64 \ | ||
+ post | ||
gr = Graphic() | ||
gr.data = patch | ||
name = "COLOR{:03d}".format(i) | ||
out.patches[name] = gr | ||
|
||
# generate a texture entry | ||
editor.simple(name, out.patches[name]) | ||
|
||
# generate a flat | ||
name = "FOLOR{:03d}".format(i) | ||
flat = Flat() | ||
flat.load_raw(bytes([i])*4096) | ||
out.flats[name] = flat | ||
|
||
out.txdefs = editor.to_lumps() | ||
out.to_file('out.wad') |