summaryrefslogtreecommitdiff
path: root/geometry.py
diff options
context:
space:
mode:
Diffstat (limited to 'geometry.py')
-rw-r--r--geometry.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/geometry.py b/geometry.py
index fdc361c..5acbbc4 100644
--- a/geometry.py
+++ b/geometry.py
@@ -104,6 +104,8 @@ class Geometry(object):
for i, surface in enumerate(surface2[reorder]):
self.surface2_index[i] = self.surfaces.index(surface)
+ self.colors = np.concatenate([solid.color for solid in self.solids])
+
self.solid_id = np.concatenate([np.tile(solid.id, len(solid.mesh)) \
for solid in self.solids])[reorder]
@@ -179,7 +181,7 @@ class Geometry(object):
if unique_bit_shifted_zvalues.size == 1:
break
- def load(self, module):
+ def load(self, module, color=False):
"""
Load the bounding volume hierarchy onto the GPU module,
bind it to the appropriate textures, and return a list
@@ -196,6 +198,12 @@ class Geometry(object):
triangles['y'] = self.mesh.triangles[:,1]
triangles['z'] = self.mesh.triangles[:,2]
+ if color:
+ triangles['w'] = self.colors
+ else:
+ triangles['w'] = (self.material1 << 24) | \
+ (self.material2 << 16) | (self.surface1 << 8) | self.surface2
+
lower_bounds = np.empty(self.lower_bounds.shape[0], dtype=gpuarray.vec.float4)
lower_bounds['x'] = self.lower_bounds[:,0]
lower_bounds['y'] = self.lower_bounds[:,1]