| 1 |
#!/usr/bin/env python |
|---|
| 2 |
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 3 |
##~ License |
|---|
| 4 |
##~ |
|---|
| 5 |
##- The RuneBlade Foundation library is intended to ease some |
|---|
| 6 |
##- aspects of writing intricate Jabber, XML, and User Interface (wxPython, etc.) |
|---|
| 7 |
##- applications, while providing the flexibility to modularly change the |
|---|
| 8 |
##- architecture. Enjoy. |
|---|
| 9 |
##~ |
|---|
| 10 |
##~ Copyright (C) 2002 TechGame Networks, LLC. |
|---|
| 11 |
##~ |
|---|
| 12 |
##~ This library is free software; you can redistribute it and/or |
|---|
| 13 |
##~ modify it under the terms of the BSD style License as found in the |
|---|
| 14 |
##~ LICENSE file included with this distribution. |
|---|
| 15 |
##~ |
|---|
| 16 |
##~ TechGame Networks, LLC can be reached at: |
|---|
| 17 |
##~ 3578 E. Hartsel Drive #211 |
|---|
| 18 |
##~ Colorado Springs, Colorado, USA, 80920 |
|---|
| 19 |
##~ |
|---|
| 20 |
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 21 |
|
|---|
| 22 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 23 |
#~ Imports |
|---|
| 24 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 25 |
|
|---|
| 26 |
import Numeric |
|---|
| 27 |
from OpenGL import GL |
|---|
| 28 |
import NumericVertexArray |
|---|
| 29 |
|
|---|
| 30 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 31 |
#~ Constants / Variables / Etc. |
|---|
| 32 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 33 |
|
|---|
| 34 |
_DefautNumericType = Numeric.Float32 |
|---|
| 35 |
|
|---|
| 36 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 37 |
#~ Definitions |
|---|
| 38 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 39 |
|
|---|
| 40 |
class ArrayBase(object): |
|---|
| 41 |
"""VertexArray extension objects.""" |
|---|
| 42 |
|
|---|
| 43 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 44 |
#~ Constants / Variables / Etc. |
|---|
| 45 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 46 |
|
|---|
| 47 |
_DefaultFormat = _DefautNumericType |
|---|
| 48 |
|
|---|
| 49 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 50 |
#~ Public Methods |
|---|
| 51 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 52 |
|
|---|
| 53 |
def __init__(self, data, format=None): |
|---|
| 54 |
if format is None: format = self._DefaultFormat |
|---|
| 55 |
if isinstance(data, Numeric.ArrayType): |
|---|
| 56 |
self.data = data |
|---|
| 57 |
else: |
|---|
| 58 |
self.data = Numeric.asarray(data, format) |
|---|
| 59 |
|
|---|
| 60 |
def GLSelect(self, context): |
|---|
| 61 |
context.ClientStateMgr.Enable(self._glArrayType) |
|---|
| 62 |
self._glArrayCall(self.data) |
|---|
| 63 |
GLExecute = GLSelect |
|---|
| 64 |
|
|---|
| 65 |
def GLDeselect(self, context): |
|---|
| 66 |
context.ClientStateMgr.Disable(self._glArrayType) |
|---|
| 67 |
|
|---|
| 68 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 69 |
|
|---|
| 70 |
class VertexArray(ArrayBase): |
|---|
| 71 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 72 |
#~ Constants / Variables / Etc. |
|---|
| 73 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 74 |
|
|---|
| 75 |
_glArrayType = GL.GL_VERTEX_ARRAY |
|---|
| 76 |
_glArrayCall = NumericVertexArray.VertexArray |
|---|
| 77 |
|
|---|
| 78 |
class NormalArray(ArrayBase): |
|---|
| 79 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 80 |
#~ Constants / Variables / Etc. |
|---|
| 81 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 82 |
|
|---|
| 83 |
_glArrayType = GL.GL_NORMAL_ARRAY |
|---|
| 84 |
_glArrayCall = NumericVertexArray.NormalArray |
|---|
| 85 |
|
|---|
| 86 |
class TexCoordArray(ArrayBase): |
|---|
| 87 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 88 |
#~ Constants / Variables / Etc. |
|---|
| 89 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 90 |
|
|---|
| 91 |
_glArrayType = GL.GL_TEXTURE_COORD_ARRAY |
|---|
| 92 |
_glArrayCall = NumericVertexArray.TexCoordArray |
|---|
| 93 |
|
|---|
| 94 |
class ColorArray(ArrayBase): |
|---|
| 95 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 96 |
#~ Constants / Variables / Etc. |
|---|
| 97 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 98 |
|
|---|
| 99 |
_glArrayType = GL.GL_COLOR_ARRAY |
|---|
| 100 |
_glArrayCall = NumericVertexArray.ColorArray |
|---|
| 101 |
|
|---|
| 102 |
class EdgeFlagArray(ArrayBase): |
|---|
| 103 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 104 |
#~ Constants / Variables / Etc. |
|---|
| 105 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 106 |
|
|---|
| 107 |
_DefaultFormat = Numeric.UInt8 |
|---|
| 108 |
_glArrayType = GL.GL_EDGE_FLAG_ARRAY |
|---|
| 109 |
#_glArrayCall = NumericVertexArray.EdgeFlagArray |
|---|
| 110 |
|
|---|