forked from pchalas1/libWall
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgl_material.py
More file actions
106 lines (82 loc) · 2.26 KB
/
gl_material.py
File metadata and controls
106 lines (82 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
from OpenGL.GL import *
class Material(object):
""" @author Preetham Chalasani
@brief This refers to the properties of an object that determine how it interacts with light.
Material properties like shininess, specularity etc have to binded with the objects."""
def __init__(self):
self.__ambient = [0.2, 0.2, 0.2, 1]
self.__diffuse = [0.8, 0.8, 0.8, 1]
self.__specular = [0, 0, 0, 1]
self.__emission = [0, 0, 0, 1]
self.__shininess = 100
pass
def setShineness(self, value):
"""Set shininess of the material
@param value : int, float or long
"""
if type(value)__name__ in ['float', 'long', 'int'] && len(value) == 1:
self.__shininess = value
else:
# print Error
pass
pass
def setAmbient(self, value):
"""Set ambient of the material
@param value : int, float or long
"""
if type(value).__name__ == 'list' && len(value) == 4:
self.__ambient = value
else:
# print Error
pass
pass
def setDiffuse(self, value):
"""Set diffuse of the material
@param value : int, float or long
"""
if type(value).__name__ == 'list' && len(value) == 4:
self.__diffuse = value
else:
# print Error
pass
pass
def setAmbientDiffuse(self, value):
"""Set ambient and diffuse of the material with the same value
@param value : int, float or long
"""
if type(value).__name__ == 'list' && len(value) == 4:
self.__ambient = value
self.__diffuse = value
else:
# print Error
pass
pass
def setSpecular(self, value):
"""Set specular of the material
@param value : int, float or long
"""
if type(value).__name__ == 'list' && len(value) == 4:
self.__specular = value
else:
# print Error
pass
pass
def setEmission(self, value):
"""Set emission of the material
@param value : int, float or long
"""
if type(value).__name__ == 'list' && len(value) == 4:
self.__emission = value
else:
# print Error
pass
pass
def render(self):
"""Render the material with the property values assigned
"""
glMaterialfv(GL_FRONT, GL_SHININESS, self.__shininess)
glMaterialfv(GL_FRONT, GL_SPECULAR, self.__specular)
glMaterialfv(GL_FRONT, GL_AMBIENT, self.__ambient)
glMaterialfv(GL_FRONT, GL_DIFFUSE, self.__diffuse)
glMaterialfv(GL_FRONT, GL_EMISSION, self.__emission)
pass