示例#1
0
 def updateShadowAmount(self, amount):
     grayLevel = amount
     if self.shadowColor != grayLevel:
         self.shadowColor = grayLevel
         ShadowCaster.setGlobalDropShadowGrayLevel(1.0 - grayLevel)
         if self.shadowsEnabled:
             self.casterState.setColor(grayLevel, grayLevel, grayLevel, 1, 10)
             self.shadowCam.node().setInitialState(self.casterState.getState())
示例#2
0
 def disable(self):
     if not self.shadowsEnabled:
         return
     self.shadowsEnabled = 0
     taskName = 'shadowCamCompass'
     taskMgr.remove(taskName)
     self.shadowCamArm.removeNode()
     self.shadowCam.removeNode()
     if base.main_rtt:
         cam = base.main_rtt.camera_node_path.node()
         if cam:
             cam.clearTagState('caster')
     else:
         base.camNode.clearTagState('caster')
     self.turnOffShadows()
     self.shadowTex = None
     self.shadowStage = None
     ShadowCaster.setGlobalDropShadowFlag(1)
     return
示例#3
0
 def updateShadows(self, h):
     while h < TODGlobals.ShadowColorTable[self.shadowColorIndex][0]:
         self.shadowColorIndex -= 1
     while h > TODGlobals.ShadowColorTable[self.shadowColorIndex + 1][0]:
         self.shadowColorIndex += 1
     (prevH, prevColor) = TODGlobals.ShadowColorTable[self.shadowColorIndex]
     (nextH, nextColor) = TODGlobals.ShadowColorTable[self.shadowColorIndex + 1]
     dt = (h - prevH) / (nextH - prevH)
     grayLevel = dt * (nextColor - prevColor) + prevColor
     if h == 0:
         self.hideShadows()
     else:
         self.showShadows()
     if self.shadowColor != grayLevel:
         self.shadowColor = grayLevel
         ShadowCaster.setGlobalDropShadowGrayLevel(1.0 - grayLevel)
         if self.shadowsEnabled:
             self.casterState.setColor(grayLevel, grayLevel, grayLevel, 1, 10)
             self.shadowCam.node().setInitialState(self.casterState.getState())
示例#4
0
    def enable(self, fMoreShadows=False):
        self.fMoreShadows = fMoreShadows
        self.disable()
        self.shadowsEnabled = 1
        ShadowCaster.setGlobalDropShadowFlag(0)
        camNode = Camera('shadowCam')
        camNode.setCameraMask(OTPRender.ShadowCameraBitmask)
        self.shadowLens = OrthographicLens()
        if fMoreShadows:
            self.shadowLens.setFilmSize(60 * 4, 60 * 4)
        else:
            self.shadowLens.setFilmSize(60, 60)
        camNode.setLens(self.shadowLens)
        self.shadowCamArm = base.camera.attachNewNode('shadowCamArm')
        self.shadowCam = self.shadowCamArm.attachNewNode(camNode)
        self.shadowCamArm.setPos(0, 40, 0)
        self.shadowCam.setPos(0, -40, 0)
        taskName = 'shadowCamCompass'
        taskMgr.remove(taskName)

        def applyCompassEffect(task, self=self):
            self.shadowCamArm.setHpr(self.lightSrc, 0, 0, 0)
            self.shadowCamArm.setScale(1)
            return Task.cont

        taskMgr.add(applyCompassEffect, taskName, priority=46)
        self.shadowTex = Texture('shadow')
        self.shadowTex.setBorderColor(self.clearColor)
        self.shadowTex.setWrapU(Texture.WMBorderColor)
        self.shadowTex.setWrapV(Texture.WMBorderColor)
        self.casterState = NodePath('temp')
        self.casterState.setColorScaleOff(10)
        self.casterState.setColor(self.shadowColor, self.shadowColor,
                                  self.shadowColor, 1, 10)
        self.casterState.setTextureOff(10)
        self.casterState.setLightOff(10)
        self.casterState.setFogOff(10)
        camNode.setInitialState(self.casterState.getState())
        render.hide(OTPRender.ShadowCameraBitmask)
        self.shadowStage = TextureStage('shadow')
        self.shadowStage.setSort(1000)
        self.turnOnShadows()
 def disable(self):
     if not self.shadowsEnabled:
         return None
     
     self.shadowsEnabled = 0
     taskName = 'shadowCamCompass'
     taskMgr.remove(taskName)
     self.shadowCamArm.removeNode()
     self.shadowCam.removeNode()
     if base.main_rtt:
         cam = base.main_rtt.camera_node_path.node()
         if cam:
             cam.clearTagState('caster')
         
     else:
         base.camNode.clearTagState('caster')
     self.turnOffShadows()
     self.shadowTex = None
     self.shadowStage = None
     ShadowCaster.setGlobalDropShadowFlag(1)
    def enable(self, fMoreShadows = False):
        self.fMoreShadows = fMoreShadows
        self.disable()
        self.shadowsEnabled = 1
        ShadowCaster.setGlobalDropShadowFlag(0)
        camNode = Camera('shadowCam')
        camNode.setCameraMask(OTPRender.ShadowCameraBitmask)
        self.shadowLens = OrthographicLens()
        if fMoreShadows:
            self.shadowLens.setFilmSize(60 * 4, 60 * 4)
        else:
            self.shadowLens.setFilmSize(60, 60)
        camNode.setLens(self.shadowLens)
        self.shadowCamArm = base.camera.attachNewNode('shadowCamArm')
        self.shadowCam = self.shadowCamArm.attachNewNode(camNode)
        self.shadowCamArm.setPos(0, 40, 0)
        self.shadowCam.setPos(0, -40, 0)
        taskName = 'shadowCamCompass'
        taskMgr.remove(taskName)
        
        def applyCompassEffect(task, self = self):
            self.shadowCamArm.setHpr(self.lightSrc, 0, 0, 0)
            self.shadowCamArm.setScale(1)
            return Task.cont

        taskMgr.add(applyCompassEffect, taskName, priority = 46)
        self.shadowTex = Texture('shadow')
        self.shadowTex.setBorderColor(self.clearColor)
        self.shadowTex.setWrapU(Texture.WMBorderColor)
        self.shadowTex.setWrapV(Texture.WMBorderColor)
        self.casterState = NodePath('temp')
        self.casterState.setColorScaleOff(10)
        self.casterState.setColor(self.shadowColor, self.shadowColor, self.shadowColor, 1, 10)
        self.casterState.setTextureOff(10)
        self.casterState.setLightOff(10)
        self.casterState.setFogOff(10)
        camNode.setInitialState(self.casterState.getState())
        render.hide(OTPRender.ShadowCameraBitmask)
        self.shadowStage = TextureStage('shadow')
        self.shadowStage.setSort(1000)
        self.turnOnShadows()