Changeset 8555:ca938ba8650b in orange


Ignore:
Timestamp:
08/01/11 13:18:22 (3 years ago)
Author:
matejd <matejd@…>
Branch:
default
Convert:
9f7f13563713f37ca61b8f37b3604da7cd7aed0e
Message:

Added higher quality sphere for radviz3d

Location:
orange/OrangeWidgets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Prototypes/OWRadviz3D.py

    r8544 r8555  
    55""" 
    66 
     7import os 
     8 
    79from plot.owplot3d import * 
    8 from plot.owprimitives3d import get_symbol_data 
     10from plot.owprimitives3d import parse_obj 
    911from plot.owplotgui import OWPlotGUI 
    1012from OWLinProjQt import * 
     
    2426        self.gui = OWPlotGUI(self) 
    2527 
    26         self.sphere_data = get_symbol_data(Symbol.CIRCLE) 
     28        self.sphere_data = parse_obj(os.path.join(os.path.dirname(__file__), '../plot/primitives/sphere_hq.obj')) 
    2729        self.show_axes = self.show_chassis = self.show_grid = False 
    2830 
     
    3638        glDisable(GL_DEPTH_TEST) 
    3739        glDisable(GL_BLEND) 
    38         glColor4f(1,0,0,1) 
     40        glColor4f(1,0,0,0.5) 
    3941 
     42        # TODO: vaos 
    4043        glScalef(5, 5, 5) 
    4144        glBegin(GL_TRIANGLES) 
  • orange/OrangeWidgets/plot/owprimitives3d.py

    r8505 r8555  
    1616} 
    1717 
    18 symbol_data = {} # Cache: contains triangles + their normals for each needed symbol. 
     18_symbol_data = {} # Cache: contains triangles + their normals for each needed symbol. 
    1919 
    20 def get_symbol_data(symbol): 
    21     if not Symbol.is_valid(symbol): 
    22         return [] 
    23     if symbol in symbol_data: 
    24         return symbol_data[symbol] 
    25     file_name = symbol_map[symbol] 
    26     lines = open(os.path.join(os.path.dirname(__file__), file_name)).readlines() 
     20def parse_obj(file_name): 
     21    lines = open(file_name).readlines() 
    2722    normals_lines =  filter(lambda line: line.startswith('vn'), lines) 
    2823    vertices_lines = filter(lambda line: line.startswith('v'), lines) 
     
    3126    vertices = [map(float, line.split()[1:]) for line in vertices_lines] 
    3227    if len(normals) > 0: 
    33         pattern = 'f (\d+)//(\d+) (\d+)//(\d+) (\d+)//(\d+)' 
     28        pattern = r'f (\d+)//(\d+) (\d+)//(\d+) (\d+)//(\d+)' 
    3429        faces = [map(int, re.match(pattern, line).groups()) for line in faces_lines] 
    3530        triangles = [[vertices[face[0]-1], 
     
    4843            normal = normal_from_points(v0, v1, v2) 
    4944            triangles.append([v0, v1, v2, normal, normal, normal]) 
    50     symbol_data[symbol] = triangles 
    5145    return triangles 
     46 
     47def get_symbol_data(symbol): 
     48    if not Symbol.is_valid(symbol): 
     49        return [] 
     50    if symbol in _symbol_data: 
     51        return _symbol_data[symbol] 
     52    file_name = symbol_map[symbol] 
     53    file_name = os.path.join(os.path.dirname(__file__), file_name) 
     54    triangles = parse_obj(file_name) 
     55    _symbol_data[symbol] = triangles 
     56    return triangles 
Note: See TracChangeset for help on using the changeset viewer.