當前位置: 首頁>>代碼示例>>Python>>正文


Python CommonFilters.setBlurSharpen方法代碼示例

本文整理匯總了Python中direct.filter.CommonFilters.CommonFilters.setBlurSharpen方法的典型用法代碼示例。如果您正苦於以下問題:Python CommonFilters.setBlurSharpen方法的具體用法?Python CommonFilters.setBlurSharpen怎麽用?Python CommonFilters.setBlurSharpen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在direct.filter.CommonFilters.CommonFilters的用法示例。


在下文中一共展示了CommonFilters.setBlurSharpen方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from direct.filter.CommonFilters import CommonFilters [as 別名]
# 或者: from direct.filter.CommonFilters.CommonFilters import setBlurSharpen [as 別名]
class ShadowCreator:

    def __init__(self):
        self.shadowBuffer = base.win.makeTextureBuffer('Shadow Buffer', 2048, 2048)
        self.shadowBuffer.setClearColorActive(True)
        self.shadowBuffer.setClearColor((0, 0, 0, 1))
        self.shadowCamera = base.makeCamera(self.shadowBuffer)
        self.shadowCamera.reparentTo(render)
        self.lens = base.camLens
        self.lens.setAspectRatio(1 / 1)
        self.shadowCamera.node().setLens(self.lens)
        self.shadowCamera.node().setCameraMask(BitMask32.bit(1))
        self.initial = NodePath('initial')
        self.initial.setColor(0.75, 0.75, 0.75, 1, 1)
        self.initial.setTextureOff(2)
        self.initial.setMaterialOff(2)
        self.initial.setLightOff(2)
        self.shadowCamera.node().setInitialState(self.initial.getState())
        self.shadowCamera.setPos(-10, 0, 20)
        self.shadowCamera.lookAt(0, 0, 0)
        self.filters = CommonFilters(self.shadowBuffer, self.shadowCamera)
        self.filters.setBlurSharpen(0.1)
        self.shadowTexture = self.shadowBuffer.getTexture()
        self.imageObject = OnscreenImage(image=self.shadowTexture, pos=(-0.75, 0, 0.75), scale=0.2)
開發者ID:coginvasion,項目名稱:src,代碼行數:26,代碼來源:ShadowCreator.py

示例2: Application

# 需要導入模塊: from direct.filter.CommonFilters import CommonFilters [as 別名]
# 或者: from direct.filter.CommonFilters.CommonFilters import setBlurSharpen [as 別名]

#.........這裏部分代碼省略.........
			self.sunLight.node().setShadowCaster(True, 256, 256)
			self.render.setShaderAuto()

		self.ambientLight = self.render.attachNewNode(AmbientLight("ambientLight"))
		self.ambientLight.node().setColor(Vec4(0.2, 0.2, 0.2, 1))
		self.render.setLight(self.ambientLight)

	def setupModels(self):
		self.city = self.loader.loadModel("models/city")
		self.city.reparentTo(self.render)
		self.phoneState.setupPhone()
		self.cityOutline = self.loader.loadModel("models/city_outline")
		self.cityOutline.reparentTo(self.phoneState.minimap)

	def setupLighting(self):
		self.ambientLight = self.render.attachNewNode(AmbientLight("ambientLight"))
		self.ambientLight.node().setColor(Vec4(1, 1, 1, 1))
		self.render.setLight(self.ambientLight)

	def setMouseBtn(self, btn, value):
		self.mousebtn[btn] = value

		if (btn == 0 and value == 1 and self.phoneState.state == "Center"):
			phoneDisplayRegionCenterX = self.win.getXSize() * (self.phoneState.phoneDisplayRegion.getLeft() + self.phoneState.phoneDisplayRegion.getRight()) / 2.0
			phoneDisplayRegionCenterY = self.win.getYSize() * (1.0 - (self.phoneState.phoneDisplayRegion.getBottom() + self.phoneState.phoneDisplayRegion.getTop()) / 2.0)
			mouse = self.win.getPointer(0)
			s = 2 ** self.phoneState.minimapZoom
			x = clamp(self.camera.getX() + (mouse.getX() - phoneDisplayRegionCenterX) / s, -self.maxX, self.maxX)
			y = clamp(self.camera.getY() + (phoneDisplayRegionCenterY - mouse.getY()) / s, -self.maxY, self.maxY)
			previousHeading = self.camera.getH() % 360.0
			heading = (rad2Deg(atan2(y - self.camera.getY(), x - camera.getX())) - 90.0) % 360.0

			if (180.0 < abs(heading - previousHeading)):
				if (previousHeading < heading):
					heading -= 360.0
				else:
					heading += 360.0

			self.camera.setH(previousHeading)
			self.phoneState.orientationTriangle.setH(previousHeading)

			Parallel(
				self.camera.posInterval(0.5, Vec3(x, y, self.camera.getZ())),
				self.phoneState.minimapCamera.posInterval(0.5, Vec3(x, y, self.phoneState.minimapCamera.getZ())),
				self.phoneState.orientationTriangle.posInterval(0.5, Vec3(x, y, self.phoneState.orientationTriangle.getZ())),
				self.camera.hprInterval(0.5, Vec3(heading, self.camera.getP(), self.camera.getR())),
				self.phoneState.orientationTriangle.hprInterval(0.5, Vec3(heading, self.phoneState.orientationTriangle.getP(), self.phoneState.orientationTriangle.getR()))
			).start()
	
	def setBlurSharpen(self, amount):
		if (not self.useAdvancedVisualEffects):
			return

		if (amount == 1.0):
			self.filters.delBlurSharpen()
		else:
			self.filters.setBlurSharpen(amount=amount)

	def controlCamera(self, task):
		if (self.phoneState.state == "Center"):
			return Task.cont

		# figure out how much the mouse has moved (in pixels)
		mouse = self.win.getPointer(0)
		x = mouse.getX()
		y = mouse.getY()
		windowCenterX = self.win.getXSize() / 2
		windowCenterY = self.win.getYSize() / 2
		heading = self.camera.getH()
		pitch = self.camera.getP()

		if self.win.movePointer(0, windowCenterX, windowCenterY):
			heading -= (x - windowCenterX) * 0.2
			pitch = clamp(pitch - (y - windowCenterY) * 0.2, -45, 45)

		self.camera.setHpr(heading, pitch, 0)

		elapsed = task.time - self.last

		if (self.last == 0):
			elapsed = 0

		if (self.mousebtn[0]):
			direction = self.camera.getMat().getRow3(1)
			self.camera.setPos(self.camera.getPos() + direction * elapsed*30)

		clampX(self.camera, -self.maxX, self.maxX)
		clampY(self.camera, -self.maxY, self.maxY)
		self.camera.setZ(2)

		self.phoneState.minimapCamera.setX(self.camera.getX())
		self.phoneState.minimapCamera.setY(self.camera.getY())

		self.phoneState.orientationTriangle.setX(self.camera.getX())
		self.phoneState.orientationTriangle.setY(self.camera.getY())
		self.phoneState.orientationTriangle.setHpr(heading, -90, 0)

		self.last = task.time

		return Task.cont
開發者ID:codistmonk,項目名稱:burdenofproof,代碼行數:104,代碼來源:application.py

示例3: Engine

# 需要導入模塊: from direct.filter.CommonFilters import CommonFilters [as 別名]
# 或者: from direct.filter.CommonFilters.CommonFilters import setBlurSharpen [as 別名]
class Engine(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)
        self.disableMouse()

        props = WindowProperties()
        props.setTitle('Test')
        self.win.requestProperties(props)

        # self.render.setAntiAlias(AntialiasAttrib.MAuto)

        self.transitions = Transitions(self.loader)
        self.transitions.setFadeColor(0, 0, 0)

        self.filters = CommonFilters(self.win, self.cam)
        # self.filters.setCartoonInk()
        self.filters.setBlurSharpen(1)
        # self.filters.setVolumetricLighting(self.render)

        # self.buffer = self.win.makeTextureBuffer("Post-processing buffer", self.win.getXSize(), self.win.getXSize())
        # print self.buffer.getYSize()
        # self.texture = self.buffer.getTexture()
        # self.buffer.setSort(-100)
        #
        # self.originalCamera = self.camera
        # self.offScreenCamera = self.makeCamera(self.buffer)
        # self.camera = self.offScreenCamera
        #
        # self.img = OnscreenImage(image=self.texture, pos=(0, 0, 0.5))

        self.scene = None
        self.channel = Channel()

    def set_scene(self, scene_module):
        # self.transitions.fadeOut(0.2)
        args = []

        if self.scene:
            args.append(Parallel(Func(self.fade_out), LerpFunc(self.blur_out, duration=0.2)))
            args.append(Wait(0.2))

        args.append(Func(self._set_scene, scene_module))
        args.append(Parallel(Func(self.fade_in), LerpFunc(self.blur_in, duration=0.4)))

        Sequence(*args).start()

    def blur_out(self, t):
        # index = int(t)
        # self.filters.delBlurSharpen()
        self.filters.setBlurSharpen(1 - t)
        self.filters.setBloom(intensity=t)

    def blur_in(self, t):
        # index = int(t)
        # self.filters.delBlurSharpen()
        self.filters.setBlurSharpen(t)
        self.filters.setBloom(intensity=-t)

    def fade_out(self):
        self.transitions.fadeOut(0.2)

    def fade_in(self):
        self.transitions.fadeIn(0.2)

    def _set_scene(self, scene_module):
        group, class_ = scene_module.split('.')
        module = importlib.import_module('game.scenes.{}'.format(group))
        scene_class = getattr(module, class_)
        if self.scene:
            self.scene.destroy()
            del self.scene
        self.scene = scene_class(self)
        # self.transitions.fadeIn(0.2)

    def start(self):
        self.channel = Channel()
        self.channel.connect()

        self.set_scene('auth.AuthScene')

        while True:
            self.taskMgr.step()
            if self.channel.can_read():
                for packet in self.channel.read_packets():
                    self.scene.on_packet(packet)
開發者ID:and3rson,項目名稱:gs,代碼行數:87,代碼來源:engine.py

示例4: ToonBase

# 需要導入模塊: from direct.filter.CommonFilters import CommonFilters [as 別名]
# 或者: from direct.filter.CommonFilters.CommonFilters import setBlurSharpen [as 別名]

#.........這裏部分代碼省略.........
        if cogdoGameDifficulty != -1:
            self.cogdoGameDifficulty = cogdoGameDifficulty
        if cogdoGameSafezoneId != -1:
            self.cogdoGameSafezoneId = cogdoGameSafezoneId
        ToontownBattleGlobals.SkipMovie = self.config.GetBool('skip-battle-movies', 0)
        self.housingEnabled = self.config.GetBool('want-housing', 1)
        self.cannonsEnabled = self.config.GetBool('estate-cannons', 0)
        self.fireworksEnabled = self.config.GetBool('estate-fireworks', 0)
        self.dayNightEnabled = self.config.GetBool('estate-day-night', 0)
        self.cloudPlatformsEnabled = self.config.GetBool('estate-clouds', 0)
        self.greySpacing = self.config.GetBool('allow-greyspacing', 0)
        self.slowQuietZone = self.config.GetBool('slow-quiet-zone', 0)
        self.slowQuietZoneDelay = self.config.GetFloat('slow-quiet-zone-delay', 5)
        self.killInterestResponse = self.config.GetBool('kill-interest-response', 0)
        tpMgr = TextPropertiesManager.getGlobalPtr()
        WLDisplay = TextProperties()
        WLDisplay.setSlant(0.3)
        tpMgr.setProperties('WLDisplay', WLDisplay)
        WLRed = tpMgr.getProperties('red')
        WLRed.setTextColor(1.0, 0.0, 0.0, 1)
        tpMgr.setProperties('WLRed', WLRed)
        del tpMgr
        self.lastScreenShotTime = globalClock.getRealTime()
        self.accept('InputState-forward', self.__walking)
        self.canScreenShot = 1
        self.glitchCount = 0
        self.walking = 0
        self.oldX = max(1, base.win.getXSize())
        self.oldY = max(1, base.win.getYSize())
        self.aspectRatio = float(self.oldX) / self.oldY
        self.localAvatarStyle = None

        self.filters = CommonFilters(self.win, self.cam)
        self.filters.setBlurSharpen(1.1)

        self.wantCogInterface = settings.get('cogInterface', True)
        self.wantWASD = settings.get('want-WASD', False)
        self.wantNews = settings.get('want-News', True)

        self.Move_Up = 'arrow_up'
        self.Move_Left = 'arrow_left'       
        self.Move_Down = 'arrow_down'
        self.Move_Right = 'arrow_right'
        self.JUMP = 'control'
        
        if self.wantWASD:
            self.Move_Up = 'w'
            self.Move_Left = 'a'            
            self.Move_Down = 's'
            self.Move_Right = 'd'
            self.JUMP = 'shift'

    def openMainWindow(self, *args, **kw):
        result = OTPBase.OTPBase.openMainWindow(self, *args, **kw)
        self.setCursorAndIcon()
        return result

    def setCursorAndIcon(self):
        atexit.register(shutil.rmtree, tempdir)

        wp = WindowProperties()
        wp.setCursorFilename(Filename.fromOsSpecific(os.path.join(tempdir, 'toonmono.cur')))
        wp.setIconFilename(Filename.fromOsSpecific(os.path.join(tempdir, 'icon.ico')))
        self.win.requestProperties(wp)

    def addCullBins(self):
開發者ID:RandomToon,項目名稱:Toontown-2,代碼行數:70,代碼來源:ToonBase.py

示例5: MyApp

# 需要導入模塊: from direct.filter.CommonFilters import CommonFilters [as 別名]
# 或者: from direct.filter.CommonFilters.CommonFilters import setBlurSharpen [as 別名]

#.........這裏部分代碼省略.........
					# Create building
					buildingInstance = self.render.attachNewNode(buildingInstanceName)
					buildingInstance.setPos(buildingX, buildingY, buildingZ)
					buildingPrototype.instanceTo(buildingInstance)

					# Create building outline in minimap
					buildingOutlineInstance = self.phoneState.minimap.attachNewNode("buildingOutline")
					buildingOutlineInstance.setPos(buildingX, buildingY, buildingZ)
					buildingOutlinePrototype.instanceTo(buildingOutlineInstance)

	def setMouseBtn(self, btn, value):
		self.mousebtn[btn] = value

		if (btn == 0 and value == 1 and self.phoneState.state == "Center"):
			phoneDisplayRegionCenterX = self.win.getXSize() * (self.phoneState.phoneDisplayRegion.getLeft() + self.phoneState.phoneDisplayRegion.getRight()) / 2.0
			phoneDisplayRegionCenterY = self.win.getYSize() * (1.0 - (self.phoneState.phoneDisplayRegion.getBottom() + self.phoneState.phoneDisplayRegion.getTop()) / 2.0)
			mouse = self.win.getPointer(0)
			s = 2 ** self.phoneState.minimapZoom
			x = clamp(self.camera.getX() + (mouse.getX() - phoneDisplayRegionCenterX) / s, -self.maxX, self.maxX)
			y = clamp(self.camera.getY() + (phoneDisplayRegionCenterY - mouse.getY()) / s, -self.maxY, self.maxY)
			previousHeading = self.camera.getH() % 360.0
			heading = (rad2Deg(atan2(y - self.camera.getY(), x - camera.getX())) - 90.0) % 360.0

			if (180.0 < abs(heading - previousHeading)):
				if (previousHeading < heading):
					heading -= 360.0
				else:
					heading += 360.0

			self.camera.setH(previousHeading)
			self.phoneState.orientationTriangle.setH(previousHeading)

			Parallel(
				self.camera.posInterval(0.5, Vec3(x, y, self.camera.getZ())),
				self.phoneState.minimapCamera.posInterval(0.5, Vec3(x, y, self.phoneState.minimapCamera.getZ())),
				self.phoneState.orientationTriangle.posInterval(0.5, Vec3(x, y, self.phoneState.orientationTriangle.getZ())),
				self.camera.hprInterval(0.5, Vec3(heading, self.camera.getP(), self.camera.getR())),
				self.phoneState.orientationTriangle.hprInterval(0.5, Vec3(heading, self.phoneState.orientationTriangle.getP(), self.phoneState.orientationTriangle.getR()))
			).start()

	def buildingInstanceNameAndPrototypeFromType(self, buildingType):
		return {
			'S' : ( None, None ),
			'P' : ( "policeBuildingInstance", self.policeBuildingPrototype ),
			'T' : ( "tribunalInstance", self.tribunalPrototype ),
			'O' : ( "officeBuildingInstance", self.officeBuildingPrototype ),
			'H' : ( "houseInstance", self.housePrototype ),
		}.get(buildingType, ( None, None ))
	
	def setBlurSharpen(self, amount):
		if (not self.useAdvancedVisualEffects):
			return

		if (amount == 1.0):
			self.filters.delBlurSharpen()
		else:
			self.filters.setBlurSharpen(amount=amount)

	def controlCamera(self, task):
		if (self.phoneState.state == "Center"):
			return Task.cont

		# figure out how much the mouse has moved (in pixels)
		mouse = self.win.getPointer(0)
		x = mouse.getX()
		y = mouse.getY()
		windowCenterX = self.win.getXSize() / 2
		windowCenterY = self.win.getYSize() / 2
		heading = self.camera.getH()
		pitch = self.camera.getP()

		if self.win.movePointer(0, windowCenterX, windowCenterY):
			heading -= (x - windowCenterX) * 0.2
			pitch = clamp(pitch - (y - windowCenterY) * 0.2, -45, 45)

		self.camera.setHpr(heading, pitch, 0)

		elapsed = task.time - self.last

		if (self.last == 0):
			elapsed = 0

		if (self.mousebtn[0]):
			direction = self.camera.getMat().getRow3(1)
			self.camera.setPos(self.camera.getPos() + direction * elapsed*30)

		clampX(self.camera, -self.maxX, self.maxX)
		clampY(self.camera, -self.maxY, self.maxY)
		self.camera.setZ(2)

		self.phoneState.minimapCamera.setX(self.camera.getX())
		self.phoneState.minimapCamera.setY(self.camera.getY())

		self.phoneState.orientationTriangle.setX(self.camera.getX())
		self.phoneState.orientationTriangle.setY(self.camera.getY())
		self.phoneState.orientationTriangle.setHpr(heading, -90, 0)

		self.last = task.time

		return Task.cont
開發者ID:codistmonk,項目名稱:burdenofproof,代碼行數:104,代碼來源:city.py


注:本文中的direct.filter.CommonFilters.CommonFilters.setBlurSharpen方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。