aboutsummaryrefslogtreecommitdiff
path: root/boltzgas/visual
diff options
context:
space:
mode:
Diffstat (limited to 'boltzgas/visual')
-rw-r--r--boltzgas/visual/box.py23
-rw-r--r--boltzgas/visual/histogram.py4
-rw-r--r--boltzgas/visual/view.py36
3 files changed, 38 insertions, 25 deletions
diff --git a/boltzgas/visual/box.py b/boltzgas/visual/box.py
index 0b4bd82..3069387 100644
--- a/boltzgas/visual/box.py
+++ b/boltzgas/visual/box.py
@@ -6,7 +6,13 @@ class ColoredBox:
self.extend = extend
self.color = color
- def display(self, uniform):
+ def setup(self):
+ pass
+
+ def update(self):
+ pass
+
+ def display_decoration(self, uniform):
glUniform3f(uniform['face_color'], *self.color)
glBegin(GL_TRIANGLE_STRIP)
glVertex(self.origin[0], self.origin[1] , 0.)
@@ -15,6 +21,9 @@ class ColoredBox:
glVertex(self.origin[0] + self.extend[1], self.origin[1] + self.extend[1], 0.)
glEnd()
+ def display_window(self, uniform):
+ pass
+
class WireBox:
def __init__(self, x0, x1, y0, y1, z0, z1):
self.x0 = x0
@@ -24,7 +33,13 @@ class WireBox:
self.z0 = z0
self.z1 = z1
- def display(self, uniform):
+ def setup(self):
+ pass
+
+ def update(self):
+ pass
+
+ def display_decoration(self, uniform):
glBegin(GL_LINE_STRIP)
glVertex(self.x0, self.y0, self.z0)
glVertex(self.x0, self.y1, self.z0)
@@ -68,5 +83,5 @@ class WireBox:
glVertex(self.x0,self.y1,self.z0)
glEnd()
-
-
+ def display_window(self, uniform):
+ pass
diff --git a/boltzgas/visual/histogram.py b/boltzgas/visual/histogram.py
index 84bba34..27e0508 100644
--- a/boltzgas/visual/histogram.py
+++ b/boltzgas/visual/histogram.py
@@ -111,8 +111,10 @@ class VelocityHistogram:
self.plotter = None
+ def display_decoration(self, uniform):
+ pass
- def display(self, uniform):
+ def display_window(self, uniform):
if self.tick:
self.mixing = min(self.mixing+0.05, 1.0);
else:
diff --git a/boltzgas/visual/view.py b/boltzgas/visual/view.py
index 300092f..b4c1acd 100644
--- a/boltzgas/visual/view.py
+++ b/boltzgas/visual/view.py
@@ -52,7 +52,7 @@ particle_shader = (
particle_pos = gl_Position.xyz;
}
""",
- ['projection', 'rotation', 'face_color', 'trace_color', 'trace_id', 'camera_pos']
+ ['projection', 'rotation', 'camera_pos']
)
decoration_shader = (
@@ -60,7 +60,7 @@ decoration_shader = (
#version 430
void main(){
- gl_FragColor = vec4(1.,1.,1., 1.0);
+ gl_FragColor = vec4(1.);
}
""",
"""
@@ -117,10 +117,9 @@ texture_shader = (
class View:
- def __init__(self, gas, decorations, windows):
+ def __init__(self, gas, instruments):
self.gas = gas
- self.decorations = decorations
- self.windows = windows
+ self.instruments = instruments
self.texture_shader = Shader(*texture_shader)
self.particle_shader = Shader(*particle_shader)
@@ -136,8 +135,8 @@ class View:
MouseScrollMonitor(lambda zoom: self.camera_projection.update_distance(0.1*zoom))
]
- self.show_histogram = False
-
+ self.show_windows = False
+ self.show_decorations = True
def reshape(self, width, height):
glViewport(0,0,width,height)
@@ -169,10 +168,6 @@ class View:
self.particle_shader.use()
glUniformMatrix4fv(self.particle_shader.uniform['projection'], 1, False, np.ascontiguousarray(self.camera_projection.get()))
glUniformMatrix4fv(self.particle_shader.uniform['rotation'], 1, False, np.ascontiguousarray(self.camera_rotation.get()))
-
- glUniform3f(self.particle_shader.uniform['face_color'], 1., 1., 1.)
- glUniform3f(self.particle_shader.uniform['trace_color'], 1., 0., 0.)
- glUniform1ui(self.particle_shader.uniform['trace_id'], -1)
glUniform4fv(self.particle_shader.uniform['camera_pos'], 1, self.camera_pos)
glEnable(GL_POINT_SPRITE)
@@ -180,17 +175,18 @@ class View:
self.gas.gl_draw_particles()
glBindVertexArray(0)
- self.decoration_shader.use()
- glUniformMatrix4fv(self.decoration_shader.uniform['projection'], 1, False, np.ascontiguousarray(self.camera_projection.get()))
- glUniformMatrix4fv(self.decoration_shader.uniform['rotation'], 1, False, np.ascontiguousarray(self.camera_rotation.get()))
- glLineWidth(2)
- for decoration in self.decorations:
- decoration.display(self.decoration_shader.uniform)
+ if self.show_decorations:
+ self.decoration_shader.use()
+ glUniformMatrix4fv(self.decoration_shader.uniform['projection'], 1, False, np.ascontiguousarray(self.camera_projection.get()))
+ glUniformMatrix4fv(self.decoration_shader.uniform['rotation'], 1, False, np.ascontiguousarray(self.camera_rotation.get()))
+ glLineWidth(2)
+ for instrument in self.instruments:
+ instrument.display_decoration(self.decoration_shader.uniform)
- if self.show_histogram:
+ if self.show_windows:
self.texture_shader.use()
glUniformMatrix4fv(self.texture_shader.uniform['projection'], 1, False, np.asfortranarray(self.projection))
- for window in self.windows:
- window.display(self.texture_shader.uniform)
+ for instrument in self.instruments:
+ instrument.display_window(self.texture_shader.uniform)
glutSwapBuffers()