Changeset 8536:26812a0affff in orange
 Timestamp:
 07/30/11 01:08:02 (3 years ago)
 Branch:
 default
 Convert:
 13af4abd7e3c386911a631129e7552b6cccec171
 Location:
 orange/OrangeWidgets
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

orange/OrangeWidgets/Prototypes/OWScatterPlot3D.py
r8532 r8536 174 174 175 175 self.loadSettings() 176 self.plot.update_camera() 176 177 177 178 self.data = None 
orange/OrangeWidgets/plot/owplot3d.py
r8534 r8536 51 51 OpenGL.ERROR_LOGGING = False 52 52 OpenGL.FULL_LOGGING = False 53 #OpenGL.ERROR_ON_COPY = True # TODO: enable this to check for unwanted copying (wrappers) 53 54 from OpenGL.GL import * 54 55 from OpenGL.GLU import * … … 57 58 from OpenGL.GL.ARB.vertex_buffer_object import * 58 59 from ctypes import c_void_p 59 #OpenGL.ERROR_ON_COPY = True # TODO: enable this to check for unwanted copying (wrappers)60 60 61 61 import sys … … 72 72 73 73 def normalize(vec): 74 return vec / numpy.sqrt(numpy.sum(vec** 74 return vec / numpy.sqrt(numpy.sum(vec**2)) 75 75 76 76 def clamp(value, min, max): … … 392 392 self.activatePanning = void 393 393 self.activateSelection = void 394 self.removeLastSelection = void 394 395 395 396 self.commands = [] … … 401 402 self.yaw = self.pitch = pi / 4. 402 403 self.rotation_factor = 0.3 403 self.camera = [ 404 sin(self.pitch)*cos(self.yaw), 405 cos(self.pitch), 406 sin(self.pitch)*sin(self.yaw)] 404 self.update_camera() 407 405 408 406 self.ortho_scale = 100. … … 498 496 uniform bool encode_color; 499 497 uniform bool hide_outside; 500 uniform float symbol_scale; 501 uniform float transparency; 502 uniform float view_edge; 498 uniform vec2 transparency; // vec2 instead of float, fixing a bug on windows 499 // (setUniformValue with float crashes) 500 uniform vec2 symbol_scale; 501 uniform vec2 view_edge; 503 502 504 503 uniform vec3 scale; … … 509 508 void main(void) { 510 509 vec3 offset_rotated = offset; 511 offset_rotated.x *= symbol_scale ;512 offset_rotated.y *= symbol_scale ;513 offset_rotated.z *= symbol_scale ;510 offset_rotated.x *= symbol_scale.x; 511 offset_rotated.y *= symbol_scale.x; 512 offset_rotated.z *= symbol_scale.x; 514 513 515 514 if (use_2d_symbols) { … … 561 560 pos = abs(pos); 562 561 float manhattan_distance = max(max(pos.x, pos.y), pos.z)+5.; 563 float a = min(pow(min(1., view_edge / manhattan_distance), 5.), transparency);562 float a = min(pow(min(1., view_edge.x / manhattan_distance), 5.), transparency.x); 564 563 // Calculate the amount of lighting this triangle receives (diffuse component only). 565 564 vec3 light_direction = normalize(vec3(1., 1., 0.5)); … … 567 566 light_direction)); 568 567 var_color = vec4(color.rgb+diffuse*0.7, a); // Physically wrong, but looks better. 569 if (manhattan_distance > view_edge && hide_outside)568 if (manhattan_distance > view_edge.x && hide_outside) 570 569 var_color.a = 0.; 571 570 } … … 625 624 def resizeGL(self, width, height): 626 625 glViewport(0, 0, width, height) 626 627 def update_camera(self): 628 self.pitch = clamp(self.pitch, 3., 0.1) 629 self.camera = [ 630 sin(self.pitch)*cos(self.yaw), 631 cos(self.pitch), 632 sin(self.pitch)*sin(self.yaw)] 627 633 628 634 def paintGL(self): … … 669 675 self.symbol_shader.setUniformValue(self.symbol_shader_encode_color, False) 670 676 self.symbol_shader.setUniformValue(self.symbol_shader_hide_outside, self.hide_outside) 671 self.symbol_shader.setUniformValue(self.symbol_shader_view_edge, float(self.view_cube_edge)) 672 self.symbol_shader.setUniformValue(self.symbol_shader_symbol_scale, float(self.symbol_scale)) 673 self.symbol_shader.setUniformValue(self.symbol_shader_transparency, self.transparency / 255.) 677 # Specifying float uniforms with vec2 because of a weird bug in PyQt 678 self.symbol_shader.setUniformValue(self.symbol_shader_view_edge, self.view_cube_edge, self.view_cube_edge) 679 self.symbol_shader.setUniformValue(self.symbol_shader_symbol_scale, self.symbol_scale, self.symbol_scale) 680 self.symbol_shader.setUniformValue(self.symbol_shader_transparency, self.transparency / 255., self.transparency / 255.) 674 681 self.symbol_shader.setUniformValue(self.symbol_shader_scale, *scale) 675 682 self.symbol_shader.setUniformValue(self.symbol_shader_translation, *self.translation) … … 1387 1394 self.yaw += dx / (self.rotation_factor*self.width()) 1388 1395 self.pitch += dy / (self.rotation_factor*self.height()) 1389 self.pitch = clamp(self.pitch, 3., 0.1) 1390 self.camera = [ 1391 sin(self.pitch)*cos(self.yaw), 1392 cos(self.pitch), 1393 sin(self.pitch)*sin(self.yaw)] 1396 self.update_camera() 1394 1397 elif self.state == PlotState.SCALING: 1395 1398 dx = pos.x()  self.scaling_init_pos.x()
Note: See TracChangeset
for help on using the changeset viewer.