Пример #1
0
 def setValue(self, coor):
     "modifica las coordenadas del punto, la linea y el reflejado"
     simCoords = self.creaSimetrico(coor)
     self.p1.translation.setValue(coor)
     self.p2.translation.setValue(simCoords)
     self.segmento = Segmento(coor,simCoords)
     self.p3.translation.setValue(self.segmento.eval(.5))
     self.animaLinea(1.0)
Пример #2
0
 def __init__(self, p1, tipoSimetria):
     SoSeparator.__init__(self)
     ## tipoSimetria es un objeto de tipo 'Simetria'
     self.enlace = None
     ## el tipo de simetria
     self.creaSimetrico = tipoSimetria
     ## compatibilidad
     self.root = self
     ## el punto original
     self.p1 = creaPunto(radio=.03, color=(1, .3, .3))
     self.addChild(self.p1)
     ## el reflejado
     self.p2 = creaPunto(radio=.03, color=(.2,.2, 1))
     ## la proyección
     self.p3 = creaPunto(radio=.02, color=(.2,1,.2))
     sep = SoSeparator()
     sep.addChild(self.p2)
     sep.addChild(self.p3)
     self.switch = SoSwitch()
     self.switch.addChild(sep)
     self.addChild(self.switch)
     ## =========================
     ## la linea
     sep = lee("""
         Separator {
             Coordinate3 { }
             Normal { vector 1 1 1 }
             Material {
                 diffuseColor  1 0 0
                 ambientColor  1 0 0
                 emissiveColor  1 0 0
             }
             LineSet {  }
       }
     """)
     self.addChild(sep)
     self.linea = sep[0]
     ## ============================    
     self.segmento = Segmento(self.getValue(), self.getValueReflex())
     ## ============================
     ## esto inicializa todas las coordenadas
     self.setValue(p1)
     ## ============================
     self.oneshot = OneShot(1.0)
     conectaParcial(self.oneshot, "ramp(float)", self.animaLinea)
     conectaParcial(self.oneshot, "finished(bool)", self.reflexOn)
Пример #3
0
class PuntoReflejado(SoSeparator):
    def __init__(self, p1, tipoSimetria):
        SoSeparator.__init__(self)
        ## tipoSimetria es un objeto de tipo 'Simetria'
        self.enlace = None
        ## el tipo de simetria
        self.creaSimetrico = tipoSimetria
        ## compatibilidad
        self.root = self
        ## el punto original
        self.p1 = creaPunto(radio=.03, color=(1, .3, .3))
        self.addChild(self.p1)
        ## el reflejado
        self.p2 = creaPunto(radio=.03, color=(.2,.2, 1))
        ## la proyección
        self.p3 = creaPunto(radio=.02, color=(.2,1,.2))
        sep = SoSeparator()
        sep.addChild(self.p2)
        sep.addChild(self.p3)
        self.switch = SoSwitch()
        self.switch.addChild(sep)
        self.addChild(self.switch)
        ## =========================
        ## la linea
        sep = lee("""
            Separator {
                Coordinate3 { }
                Normal { vector 1 1 1 }
                Material {
                    diffuseColor  1 0 0
                    ambientColor  1 0 0
                    emissiveColor  1 0 0
                }
                LineSet {  }
          }
        """)
        self.addChild(sep)
        self.linea = sep[0]
        ## ============================    
        self.segmento = Segmento(self.getValue(), self.getValueReflex())
        ## ============================
        ## esto inicializa todas las coordenadas
        self.setValue(p1)
        ## ============================
        self.oneshot = OneShot(1.0)
        conectaParcial(self.oneshot, "ramp(float)", self.animaLinea)
        conectaParcial(self.oneshot, "finished(bool)", self.reflexOn)
    
    def start(self):
        self.oneshot.start()
        
    def update(self):
        "actualizamos el punto reflejado y la linea"
        self.setValue(self.getValue().getValue())
        
    def animaLinea(self, t):
        p1p2 = (self.segmento.p1(),self.segmento.eval(t))
        self.linea.point.setValues(0,len(p1p2), p1p2)
        
    def reflexOn(self, val):
        self.switch.whichChild = 0
    
    def setValue(self, coor):
        "modifica las coordenadas del punto, la linea y el reflejado"
        simCoords = self.creaSimetrico(coor)
        self.p1.translation.setValue(coor)
        self.p2.translation.setValue(simCoords)
        self.segmento = Segmento(coor,simCoords)
        self.p3.translation.setValue(self.segmento.eval(.5))
        self.animaLinea(1.0)
        
    def getValue(self):
        return self.p1.translation.getValue()

    def getValueReflex(self):
        return self.p2.translation.getValue()