| 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 RBRapier.Renderer.AttributeMgr import AttributeChangeElement |
|---|
| 27 |
from RBRapier.Tools import Vector |
|---|
| 28 |
from OpenGL import GL |
|---|
| 29 |
|
|---|
| 30 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 31 |
#~ Definitions |
|---|
| 32 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 33 |
|
|---|
| 34 |
class Material(object): |
|---|
| 35 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 36 |
#~ Constants / Variables / Etc. |
|---|
| 37 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 38 |
|
|---|
| 39 |
AttributeChange = AttributeChangeElement(GL.GL_LIGHTING_BIT) |
|---|
| 40 |
|
|---|
| 41 |
Face = GL.GL_FRONT_AND_BACK |
|---|
| 42 |
Shininess = None # 0. |
|---|
| 43 |
Ambient = Vector.ColorVectorProperty('Ambient', lazy=1) |
|---|
| 44 |
Diffuse = Vector.ColorVectorProperty('Diffuse', lazy=1) |
|---|
| 45 |
Specular = Vector.ColorVectorProperty('Specular', lazy=1) |
|---|
| 46 |
Emission = Vector.ColorVectorProperty('Emission', lazy=1) |
|---|
| 47 |
|
|---|
| 48 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 49 |
#~ Public Methods |
|---|
| 50 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 51 |
|
|---|
| 52 |
def GLSelect(self, context): |
|---|
| 53 |
Face = self.Face |
|---|
| 54 |
value = self.Shininess |
|---|
| 55 |
if value is not None: |
|---|
| 56 |
GL.glMaterialf(Face, GL.GL_SHININESS, value) |
|---|
| 57 |
value = self.Ambient |
|---|
| 58 |
if value is not None: |
|---|
| 59 |
GL.glMaterialfv(Face, GL.GL_AMBIENT, value) |
|---|
| 60 |
value = self.Diffuse |
|---|
| 61 |
if value is not None: |
|---|
| 62 |
GL.glMaterialfv(Face, GL.GL_DIFFUSE, value) |
|---|
| 63 |
value = self.Specular |
|---|
| 64 |
if value is not None: |
|---|
| 65 |
GL.glMaterialfv(Face, GL.GL_SPECULAR, value) |
|---|
| 66 |
value = self.Emission |
|---|
| 67 |
if value is not None: |
|---|
| 68 |
GL.glMaterialfv(Face, GL.GL_EMISSION, value) |
|---|
| 69 |
|
|---|
| 70 |
def GLDeselect(self, context): |
|---|
| 71 |
pass # Ah, what to do here? |
|---|
| 72 |
|
|---|
| 73 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 74 |
|
|---|
| 75 |
class ColorMaterial(object): |
|---|
| 76 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 77 |
#~ Constants / Variables / Etc. |
|---|
| 78 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 79 |
|
|---|
| 80 |
AttributeChange = AttributeChangeElement(GL.GL_LIGHTING_BIT) |
|---|
| 81 |
|
|---|
| 82 |
Parameter = GL.GL_AMBIENT_AND_DIFFUSE |
|---|
| 83 |
Face = GL.GL_FRONT_AND_BACK |
|---|
| 84 |
|
|---|
| 85 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 86 |
#~ Public Methods |
|---|
| 87 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 88 |
|
|---|
| 89 |
def GLSelect(self, context): |
|---|
| 90 |
GL.glColorMaterial(self.Face, self.Parameter) |
|---|
| 91 |
context.StateMgr.Enable(GL.GL_COLOR_MATERIAL) |
|---|
| 92 |
|
|---|
| 93 |
def GLDeselect(self, context): |
|---|
| 94 |
context.StateMgr.Disable(GL.GL_COLOR_MATERIAL) |
|---|
| 95 |
|
|---|