roc/enums.py

107 lines
2.9 KiB
Python
Executable file

class enum(object):
def __init__(self, names=[]):
for i, name in enumerate(names):
setattr(self, name, i)
def __len__(self):
return len([x for x in dir(self) if x[0] != '_'])
def __iter__(self):
for name in sequence(self):
yield getattr(self, name)
def index(enumobj, name):
return getattr(enumobj, name)
def reverse(enumobj, value):
for name in dir(enumobj):
if name[0] == '_':
continue
if value == getattr(enumobj, name):
return name
return None
def sequence(enumobj):
retlist = []
for name in dir(enumobj):
if name[0] == '_':
continue
retlist.append((getattr(enumobj, name), name))
return [x[1] for x in sorted(retlist)]
# render types (for model.renderable_layer)
rt = enum()
rt.model = 0 # a 3d model made out of triangles, go figure!
rt.sprite = 1 # a 2d texture applied to a 2d plane.
rt.beam = 2 # a 2d plane between two points, similar to a sprite
# rendering billboard modes (for model.renderable_layer)
rtbb = enum()
rtbb.none = 0 # not billboarded, has its own independent rotation
rtbb.full = 1 # the sprite always squarely faces the camera with no rotation, only its position is relevant
rtbb.yaxis = 2 # pitch and yaw axes are available for rotation, but rotation around the roll axis is always fixed to face the camera.
# coordinate mode
cm = enum()
cm.universe = 0
cm.camera = 1
cm.relative = 2
cm.aa_relative = 3
# log level
logl = enum()
logl.debug = 9
logl.info = 8
logl.warn = 4
logl.err = 2
logl.crit = 0
# pipelines
pl = enum()
pl.camera = 0
pl.player = 1
pl.model = 2
pl.shadow = 3
pl.particle = 4
pl.sprite = 5
pl.composite1 = 6
pl.composite2 = 7
# phases
phase = enum()
phase.handle_input = 0
phase.ai = 1
phase.animate = 2
phase.move = 3
phase.collide = 4
phase.prerender = 5
phase.render = 6
# texture types
tt = enum()
tt.diffuse = 0 # the diffuse texture sets the colors and general brightness of the texture. if the same texture is used as the emissive texture, the model is effectively "fullbright"
tt.emissive = 1 # this texture is blended with the diffuse texture as the light level drops (this can be used to add running lights or glow to a ship, or light up the dark side of a planet, otherwise pure "black" is a good choice)
tt.specular = 2 # adding a specular map allows you to add areas of low or high reflectivity to your texture
tt.normal = 3 # normal maps allow bump mapping and other tweaks, with each channel representing the direction of the normal (red = -1x to 1x, green = -1y to 1y, blue = 0z to 1z)
tt.noaa = 4 # this replaces the diffuse texture, and is used for sprites that dont want to be antialiased
# UI stuff
ui_frametype = enum()
ui_frametype.grid = 0
ui_frametype.composite = 1
ui_frametype.model = 2
ui_postype = enum()
ui_postype.center = 0
ui_postype.relative = 1
ui_postype.absolute = 2
ui_filltype = enum()
ui_filltype.none = 0
ui_filltype.tile = 1
ui_filltype.stretch = 2