A set of material properties describing how an object will look.
| 1 | import numpy as np |
| 2 | |
| 3 | class MaterialProperties(object): |
| 4 | """A set of material properties describing how an object will look. |
| 5 | """ |
| 6 | |
| 7 | def __init__(self, color=np.array([0.5, 0.5, 0.5]), |
| 8 | k_a=1.0, k_d=1.0, k_s = 1.0, alpha=1.0, |
| 9 | smooth=False, wireframe=False): |
| 10 | """Initialize a set of material properties. |
| 11 | |
| 12 | Parameters |
| 13 | ---------- |
| 14 | color : (3,) float |
| 15 | The RGB color of the object in (0,1). |
| 16 | k_a : float |
| 17 | A multiplier for ambient lighting. |
| 18 | k_d : float |
| 19 | A multiplier for diffuse lighting. |
| 20 | k_s : float |
| 21 | A multiplier for specular lighting. |
| 22 | alpha : float |
| 23 | A multiplier for shininess (higher values indicate |
| 24 | more reflectivity and smaller highlights). |
| 25 | smooth : bool |
| 26 | If True, normals will be interpolated to smooth the mesh. |
| 27 | wireframe : bool |
| 28 | If True, the mesh will be rendered as a wireframe. |
| 29 | """ |
| 30 | self._color = color |
| 31 | self._k_a = k_a |
| 32 | self._k_d = k_d |
| 33 | self._k_s = k_s |
| 34 | self._alpha = alpha |
| 35 | self._smooth = smooth |
| 36 | self._wireframe = wireframe |
| 37 | |
| 38 | @property |
| 39 | def color(self): |
| 40 | """(3,) float: The RGB color of the object in (0,1). |
| 41 | """ |
| 42 | return self._color |
| 43 | |
| 44 | @property |
| 45 | def k_a(self): |
| 46 | """float: A multiplier for ambient lighting. |
| 47 | """ |
| 48 | return self._k_a |
| 49 | |
| 50 | @property |
| 51 | def k_d(self): |
| 52 | """float: A multiplier for diffuse lighting. |
| 53 | """ |
| 54 | return self._k_d |
| 55 | |
| 56 | @property |
| 57 | def k_s(self): |
| 58 | """float: A multiplier for specular lighting. |
| 59 | """ |
| 60 | return self._k_s |
no outgoing calls
no test coverage detected