def __init__(self, index=0): SoSeparator.__init__(self) self.normal = (0, 0, 1) ## ========================= color = SoMaterial() color.diffuseColor.setValue(0, 1, 0) ## ========================= ## el punto de simetría self.origen = creaPunto(radio=.03, color=(0,1,0)) self.eje = tubo((0,0, -2), (0,0, 2), .005, .99, color) self.plano = lee(""" Separator { Complexity { value 1.0 } Material { transparency 0.6 } Cube { depth 3 width 3 height .001 } } """) self.plano[1].emissiveColor.setValue(0, 1, 0) self.plano.insertChild(self.anillo(60), 2) self.switch = SoSwitch() self.switch.addChild(self.origen) self.switch.addChild(self.eje) self.switch.addChild(self.plano) self.switch.whichChild = 0 self.addChild(self.switch) self.setTipo(index)
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 creaPunto(radio, color=(.5, .5, .5), emissive = (0, 0, 0)): colorStr = " ".join(map(str,color)) emissiveStr = " ".join(map(str,emissive)) sep = lee(""" Separator { Translation {} Material { diffuseColor %(colorStr)s specularColor .7 .7 .7 emissiveColor %(emissiveStr)s shininess 0.1 } Sphere { radius %(radio)f } } """ % vars()) sep.translation = sep[0].translation sep.esfera = sep[2] return sep