Changeset 602 in main for branches


Ignore:
Timestamp:
12/21/11 15:56:39 (9 years ago)
Author:
agalech
Message:

Read color from STEP

Location:
branches/3D/openPLM/document3D
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3D/openPLM/document3D/aficher.py

    r601 r602  
    55from kjbuckets import kjGraph 
    66from OCC.TopLoc import TopLoc_Location 
    7    
     7 
    88 
    99import time 
     
    2222    my_shapes_arbre = my_step_importer.get_shapes_arbre() 
    2323    my_shapes_simples = my_step_importer.get_shapes_simples() 
    24      
     24    color_tool=my_step_importer.get_color_tool() 
    2525    init_time = time.time() 
     26     
     27    ColorLabels = TDF_LabelSequence() 
     28    color_tool.GetColors(ColorLabels) 
     29    print 'Number of colors fuera sigue siendo=%i'%ColorLabels.Length() 
    2630     
    2731    for i in range(len(my_shapes_simples)): 
     
    3034            new_stp_jss.save() 
    3135            print "processing mesh " ,my_shapes_simples[i].nom ,   " " , i+1 , "/" ,len(my_shapes_simples) 
    32             my_mesh = mesh_shape(my_shapes_simples[i].shape) 
     36            my_mesh = mesh_shape(my_shapes_simples[i].shape,color_tool) 
    3337  
    3438            name = new_stp_jss.js.storage.get_available_name(fileName+".js") 
     
    206210             
    207211    else: #is instance of feuille_nom_shapes 
    208         menu_generate_objects[0]+="var object%s=new THREE.Mesh( new _%s(), new THREE.MeshNormalMaterial({opacity:0.5,shading:THREE.SmoothShading}) );\n"%(objects_numeration[0],my_shapes_arbre.reference) 
     212    #var mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { color: 0xffffff } )  ); 
     213        menu_generate_objects[0]+="var NewMaterial=new THREE.MeshBasicMaterial({opacity:1.0,shading:THREE.SmoothShading});\n" 
     214        menu_generate_objects[0]+="NewMaterial.color.setRGB(%f,%f,%f);\n"%(my_shapes_arbre.red,my_shapes_arbre.green,my_shapes_arbre.blue) 
     215        menu_generate_objects[0]+="var object%s=new THREE.Mesh( new _%s(),NewMaterial );\n"%(objects_numeration[0],my_shapes_arbre.reference) 
     216        #menu_generate_objects[0]+="var object%s=new THREE.Mesh( new _%s(), new THREE.MeshBasicMaterial( { color: 0xffffff , opacity:0.2,shading:THREE.SmoothShading} ) );\n"%(objects_numeration[0],my_shapes_arbre.reference) 
     217        #menu_generate_objects[0]+="object%s.materials.color.setRGB( 1 , 0, 0 );\n"%objects_numeration[0] 
    209218        #menu_generate_objects[0]+="var object%s=new THREE.Mesh( new _%s(), new THREE.MeshBasicMaterial({opacity:0.5}) );\n"%(objects_numeration[0],my_shapes_arbre.reference) 
    210219        menu_generate_objects[0]+="object3D.add(object%s);\n"%objects_numeration[0] 
     
    240249 
    241250     
    242 def mesh_shape(shape): 
     251def mesh_shape(shape,color_tool): 
    243252    """ Take a topods_shape instance, returns the tesselated object""" 
    244253    ''' Connect a ode.Trimesh to this body. The mesh is generated from the MSH subpackage. vertices lits 
     
    254263    a_mesh.set_shape(shape) 
    255264    a_mesh.set_precision(a_mesh.get_precision()/quality_factor) 
    256     a_mesh.compute() 
     265    a_mesh.compute(color_tool) 
    257266    return a_mesh        
    258267 
  • branches/3D/openPLM/document3D/models.py

    r601 r602  
    7171    loc=TopLoc_Location() 
    7272    reference='' 
    73     def __init__(self, nom,location,ref): 
     73    red=0 
     74    green=0 
     75    blue=0 
     76    def __init__(self, nom,location,colour,ref): 
    7477        self.nom = nom 
    7578        self.loc = location 
    7679        self.reference=ref 
    77          
     80        if colour: 
     81            self.red=colour.Red() 
     82            self.green=colour.Green() 
     83            self.blue=colour.Blue() 
    7884         
    7985 
Note: See TracChangeset for help on using the changeset viewer.