Omgifol

From DoomWiki.org

Revision as of 06:50, 30 April 2016 by Xymph (talk | contribs) (Drawing maps: Add variant)


Omgifol is a Python library for WAD files. It is open source software written by Fredrik Johansson and released under the terms of the MIT License. The most recent version, 0.2, was released May 12, 2005. Since then a few more updates were added to the repository[1] that are not bundled in the v0.2 package.

In September 2015 the author confirmed that the original library is no longer being maintained[2], and recommended to use one of the available forks.

Features

Code example

mirror.py, a demo script that mirrors maps in a WAD, which is included in the 0.2 release:

from sys import argv
from omg import *
from omg.mapedit import *

def mirror(map):
    ed = MapEditor(map)
    for v in ed.vertexes:
        v.x = -v.x
    for l in ed.linedefs:
        l.vx_a, l.vx_b = l.vx_b, l.vx_a
    for t in ed.things:
        t.x = -t.x
        t.angle = (180 - t.angle) % 360
    ed.nodes.data = ""
    return ed.to_lumps()

def main(args):
    if (len(args) < 2):
        print "    Omgifol script: mirror maps\n"
        print "    Usage:"
        print "    mirror.py input.wad output.wad [pattern]\n"
        print "    Mirror all maps or those whose name match the given pattern"
        print "    (eg E?M4 or MAP*)."
        print "    Note: nodes will have to be rebuilt externally.\n"
    else:
        print "Loading %s..." % args[0]
        inwad = WAD()
        outwad = WAD()
        inwad.from_file(args[0])
        pattern = "*"
        if (len(args) == 3):
            pattern = args[2]
        for name in inwad.maps.find(pattern):
            print "Mirroring %s" % name
            outwad.maps[name] = mirror(inwad.maps[name])
        print "Saving %s..." % args[1]
        outwad.to_file(args[1])

if __name__ == "__main__": main(argv[1:])

Drawing maps

Another included demo script is drawmaps.py to save map preview images. This script is one of the tools most suitable for creating map views on Doom Wiki. After the initial v0.2 release, Fredrik made further improvements to its handling of the specified image dimensions[3].

In April 2016, Frans P. de Vries added support for a scale parameter that is applied to all requested map images, and for optional verbose logging. The following example command renders all DOOM2.WAD maps at the same scale (with only the largest maps sized down to fit within 1600 pixels) so the viewer gets a good impression of the size differences between them:

python drawmaps.py DOOM2.WAD MAP* 1600 4.0

Another variant[4] in the fork by Alex Mayfield adds drawing small squares for all things.

Trivia

"OMGIFOL" stands for "Oh My God! It's Full Of Lumps!"

See also

External links

References

  1. fredrik_j (4 April 2007). "Omgifol Python WAD Library Code Log." Sourceforge. Retrieved 20 April 2016.
  2. Fredrik (30 September 2015). "A faster way to generate PLAYPAL / COLORMAP." Doomworld Forums. Retrieved 20 April 2016.
  3. fredrik_j (11 December 2006). "Omgifol Python WAD Library Code demo / drawmaps.py." Sourceforge. Retrieved 20 April 2016.
  4. Alex Mayfield (11 September 2006). "Alex Mayfield omgifol demo / drawmaps.py." Bitbucket. Retrieved 30 April 2016.