OpenGLContext.loaders.twitch
index
/home/mcfletch/pylive/OpenGLContext/loaders/twitch.py

Quake3 BSP file loading module (lowest abstraction layer)
 
Written directly from the following:
 
    http://www.mralligator.com/q3/
 
Basically just uses numpy record declarations to parse the bsp files
into structured data-arrays...

 
Modules
       
logging
numpy
sys
OpenGL.arrays.vbo

 
Classes
       
object
Twitch

 
class Twitch(object)
     Methods defined here:
__init__(self, model)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
patch_faces
Create another pair of VBOs for our patch faces
 
TODO: do the bezier position adjustment (currently just renders 
the control points)
 
a, -> [a,b,c],[d,e,f]
    a blend
        b = 1-a
            x = a**2 * cp[0].x + 2*a*b * cp[1].x + b**2 * cp[2].x
            y = ...
            z = ...
    For the second blend, blend the control points...
simple_faces
Create an index VBO for the indices to render faces of type 1 and 3

Data and other attributes defined here:
patch_indices_vbo = None
simple_indices_vbo = None
texture_set = None

 
Functions
       
load(filename)
load_visdata(visdata)
main()
parse_bsp(array)
Parse a BSP structure for the array 
 
array -- numpy array with the data to parse...
 
returns {
    <lump>: <lump_array>,
    for lump,dtype in LUMP_ORDER
}

 
Data
        BRUSHSIDE_RECORD = [('plane', '<i4'), ('texture', '<i4')]
BRUSH_RECORD = [('brushside', '<i4'), ('n_brushsides', '<i4'), ('texture', '<i4')]
EFFECT_RECORD = [('name', 'c', 64), ('brush', '<i4'), ('unknown', '<i4')]
FACE_RECORD = [('texture', '<i4'), ('effect', '<i4'), ('type', '<i4'), ('vertex', '<i4'), ('n_vertices', '<i4'), ('meshvert', '<i4'), ('n_meshverts', '<i4'), ('lm_index', '<i4'), ('lm_start', '<i4', 2), ('lm_size', '<i4', 2), ('lm_origin', '<f4', 3), ('lm_vecs_s', '<f4', 3), ('lm_vecs_t', '<f4', 3), ('normal', '<f4', 3), ('size', '<i4', 2)]
LEAF_RECORD = dtype([('cluster', '<i4'), ('area', '<i4'), ('mi... ('leafbrush', '<i4'), ('n_leafbrushes', '<i4')])
LIGHTMAP_RECORD = [('texture', 'i1', (128, 128, 3))]
LIGHTVOL_RECORD = [('ambient', 'i1', 3), ('directional', 'i1', 3), ('dir', 'i1', 2)]
LUMP_ORDER = [('entities', 'c'), ('textures', dtype([('filename', '|S1', (64,)), ('flags', '<i4'), ('contents', '<i4')])), ('planes', dtype([('normal', '<f4', (3,)), ('distance', '<f4')])), ('nodes', dtype([('plane', '<i4'), ('children', '<i4', (2,)), ('mins', '<i4', (3,)), ('maxs', '<i4', (3,))])), ('leafs', dtype([('cluster', '<i4'), ('area', '<i4'), ('mi... ('leafbrush', '<i4'), ('n_leafbrushes', '<i4')])), ('leaffaces', '<i4'), ('leafbrushes', '<i4'), ('models', [('mins', '<f4', 3), ('maxs', '<f4', 3), ('face', '<i4'), ('n_faces', '<i4'), ('brush', '<i4'), ('n_brushes', '<i4')]), ('brushes', [('brushside', '<i4'), ('n_brushsides', '<i4'), ('texture', '<i4')]), ('brushsides', [('plane', '<i4'), ('texture', '<i4')]), ('vertices', [('position', '<f4', 3), ('texcoord_surface', '<f4', 2), ('texcoord_lightmap', '<f4', 2), ('normal', '<f4', 3), ('color', 'B', 4)]), ('meshverts', '<i4'), ('effects', [('name', 'c', 64), ('brush', '<i4'), ('unknown', '<i4')]), ('faces', [('texture', '<i4'), ('effect', '<i4'), ('type', '<i4'), ('vertex', '<i4'), ('n_vertices', '<i4'), ('meshvert', '<i4'), ('n_meshverts', '<i4'), ('lm_index', '<i4'), ('lm_start', '<i4', 2), ('lm_size', '<i4', 2), ('lm_origin', '<f4', 3), ('lm_vecs_s', '<f4', 3), ('lm_vecs_t', '<f4', 3), ('normal', '<f4', 3), ('size', '<i4', 2)]), ('lightmaps', [('texture', 'i1', (128, 128, 3))]), ('lightvols', [('ambient', 'i1', 3), ('directional', 'i1', 3), ('dir', 'i1', 2)]), ('visdata', 'iio')]
MODEL_RECORD = [('mins', '<f4', 3), ('maxs', '<f4', 3), ('face', '<i4'), ('n_faces', '<i4'), ('brush', '<i4'), ('n_brushes', '<i4')]
NODE_RECORD = dtype([('plane', '<i4'), ('children', '<i4', (2,)), ('mins', '<i4', (3,)), ('maxs', '<i4', (3,))])
PLANE_RECORD = dtype([('normal', '<f4', (3,)), ('distance', '<f4')])
TEXTURE_RECORD = dtype([('filename', '|S1', (64,)), ('flags', '<i4'), ('contents', '<i4')])
VERTEX_RECORD = [('position', '<f4', 3), ('texcoord_surface', '<f4', 2), ('texcoord_lightmap', '<f4', 2), ('normal', '<f4', 3), ('color', 'B', 4)]
VISDATA_RECORD_HEADER = [('n_vecs', '<i4'), ('sz_vecs', '<i4')]
__file__ = '/home/mcfletch/pylive/OpenGLContext/loaders/twitch.py'
__name__ = 'OpenGLContext.loaders.twitch'
__package__ = 'OpenGLContext.loaders'
f4 = '<f4'
filename = 'maps/focal_p132.bsp'
i4 = '<i4'
log = <logging.Logger object>