| 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 |
from OpenGL import GL |
|---|
| 27 |
from RBRapier.Renderer.AttributeMgr import AttributeChangeElement |
|---|
| 28 |
|
|---|
| 29 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 30 |
#~ Definitions |
|---|
| 31 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 32 |
|
|---|
| 33 |
class AxisLineSet(object): |
|---|
| 34 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 35 |
#~ Constants / Variables / Etc. |
|---|
| 36 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 37 |
|
|---|
| 38 |
AttributeChange = AttributeChangeElement(GL.GL_LINE_BIT) |
|---|
| 39 |
LineWidth = 4. |
|---|
| 40 |
AxisLength = 1. |
|---|
| 41 |
xColor = (1., 0., 0., 1.) |
|---|
| 42 |
yColor = (0., 1., 0., 1.) |
|---|
| 43 |
zColor = (0., 0., 1., 1.) |
|---|
| 44 |
|
|---|
| 45 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 46 |
#~ Public Methods |
|---|
| 47 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 48 |
|
|---|
| 49 |
def __init__(self, AxisLength=None, **kw): |
|---|
| 50 |
if AxisLength is not None: |
|---|
| 51 |
self.AxisLength = AxisLength |
|---|
| 52 |
for name, value in kw.iteritems(): |
|---|
| 53 |
setattr(self, name, value) |
|---|
| 54 |
|
|---|
| 55 |
def GLExecute(self, context): |
|---|
| 56 |
AxisLength = self.AxisLength |
|---|
| 57 |
|
|---|
| 58 |
GL.glLineWidth(self.LineWidth) |
|---|
| 59 |
GL.glNormal3f(0.577,0.577,0.577) |
|---|
| 60 |
GL.glBegin(GL.GL_LINES) |
|---|
| 61 |
|
|---|
| 62 |
# X Axis |
|---|
| 63 |
GL.glColor4f(*self.xColor) |
|---|
| 64 |
GL.glVertex3f(0., 0., 0.) |
|---|
| 65 |
GL.glVertex3f(AxisLength, 0., 0.) |
|---|
| 66 |
# Y Axis |
|---|
| 67 |
GL.glColor4f(*self.yColor) |
|---|
| 68 |
GL.glVertex3f(0., 0., 0.) |
|---|
| 69 |
GL.glVertex3f(0., AxisLength, 0.) |
|---|
| 70 |
# Z Axis |
|---|
| 71 |
GL.glColor4f(*self.zColor) |
|---|
| 72 |
GL.glVertex3f(0., 0., 0.) |
|---|
| 73 |
GL.glVertex3f(0., 0., AxisLength) |
|---|
| 74 |
|
|---|
| 75 |
GL.glEnd() |
|---|
| 76 |
GL.glLineWidth(1.) |
|---|
| 77 |
|
|---|
| 78 |
context.Statistics['lines'] = context.Statistics.get('lines', 0) + 3 |
|---|
| 79 |
|
|---|