| 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 RBFoundation.Objects.Properties import LazyProperty |
|---|
| 28 |
from RBRapier.Tools import Vector |
|---|
| 29 |
from RBRapier.Renderer.AttributeMgr import AttributeChangeElement |
|---|
| 30 |
|
|---|
| 31 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 32 |
#~ Definitions |
|---|
| 33 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 34 |
|
|---|
| 35 |
class PointSize(object): |
|---|
| 36 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 37 |
#~ Constants / Variables / Etc. |
|---|
| 38 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 39 |
|
|---|
| 40 |
AttributeChange = AttributeChangeElement(GL.GL_POINT_BIT) |
|---|
| 41 |
Size = 1. |
|---|
| 42 |
|
|---|
| 43 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 44 |
#~ Public Methods |
|---|
| 45 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 46 |
|
|---|
| 47 |
def __init__(self, Size=1.): |
|---|
| 48 |
self.Size = Size |
|---|
| 49 |
|
|---|
| 50 |
def GLSelect(self, context): |
|---|
| 51 |
GL.glPointSize(self.Size) |
|---|
| 52 |
|
|---|
| 53 |
def GLDeselect(self, context): |
|---|
| 54 |
GL.glPointSize(1.) |
|---|
| 55 |
|
|---|
| 56 |
class PointSmooth(object): |
|---|
| 57 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 58 |
#~ Constants / Variables / Etc. |
|---|
| 59 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 60 |
|
|---|
| 61 |
AttributeChange = AttributeChangeElement(GL.GL_POINT_BIT | GL.GL_HINT_BIT) |
|---|
| 62 |
SmoothHint = GL.GL_DONT_CARE |
|---|
| 63 |
|
|---|
| 64 |
def GLSelect(self, context): |
|---|
| 65 |
GL.glHint(GL.GL_POLYGON_SMOOTH_HINT, self.SmoothHint) |
|---|
| 66 |
context.StateMgr.Enable(GL.GL_POINT_SMOOTH) |
|---|
| 67 |
|
|---|
| 68 |
def GLDeselect(self, context): |
|---|
| 69 |
context.StateMgr.Disable(GL.GL_POINT_SMOOTH) |
|---|
| 70 |
|
|---|
| 71 |
class PointParameters(object): |
|---|
| 72 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 73 |
#~ Constants / Variables / Etc. |
|---|
| 74 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 75 |
|
|---|
| 76 |
AttributeChange = AttributeChangeElement(GL.GL_POINT_BIT) |
|---|
| 77 |
Attenuation = Vector.Vector3Property('Attenuation', (1., 0., 0.)) |
|---|
| 78 |
MinSize = 0. |
|---|
| 79 |
MaxSize = 64. |
|---|
| 80 |
FadeThreshold = 1. |
|---|
| 81 |
|
|---|
| 82 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 83 |
#~ Definitions |
|---|
| 84 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 85 |
|
|---|
| 86 |
class _Extensions(object): |
|---|
| 87 |
def __init__(self): |
|---|
| 88 |
from OpenGL.GL.EXT import point_parameters |
|---|
| 89 |
self.point_parameters = point_parameters.glInitPointParametersEXT() and point_parameters or None |
|---|
| 90 |
_extensions = LazyProperty(_Extensions) |
|---|
| 91 |
|
|---|
| 92 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 93 |
#~ Public Methods |
|---|
| 94 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 95 |
|
|---|
| 96 |
def GLExecute(self, context): |
|---|
| 97 |
pp = self._extensions.point_parameters |
|---|
| 98 |
pp.glPointParameterfvEXT(pp.GL_POINT_DISTANCE_ATTENUATION_EXT, self.Attenuation) |
|---|
| 99 |
pp.glPointParameterfEXT(pp.GL_POINT_SIZE_MIN_EXT, self.MinSize) |
|---|
| 100 |
pp.glPointParameterfEXT(pp.GL_POINT_SIZE_MAX_EXT, self.MaxSize) |
|---|
| 101 |
pp.glPointParameterfEXT(pp.GL_POINT_FADE_THRESHOLD_SIZE_EXT, self.FadeThreshold) |
|---|
| 102 |
|
|---|