本文整理汇总了Python中panda3d.core.CardMaker.setFrameFullscreenQuad方法的典型用法代码示例。如果您正苦于以下问题:Python CardMaker.setFrameFullscreenQuad方法的具体用法?Python CardMaker.setFrameFullscreenQuad怎么用?Python CardMaker.setFrameFullscreenQuad使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.CardMaker
的用法示例。
在下文中一共展示了CardMaker.setFrameFullscreenQuad方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FirstTry
# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setFrameFullscreenQuad [as 别名]
class FirstTry(visual):
def setup(self):
self.tex1 = MovieTexture('videos/saturn5_apollo_launch.mp4')
assert self.tex1.read('videos/saturn5_apollo_launch.mp4')
self.tex2 = MovieTexture('videos/boards_eye_view.mp4')
assert self.tex2.read('videos/boards_eye_view.mp4')
self.cm1 = CardMaker('saturn')
self.cm1.setFrameFullscreenQuad()
self.cm1.setUvRange(self.tex1)
self.card1 = NodePath(self.cm1.generate())
self.card1.reparentTo(self.path)
self.card1.setPos(0,0,10)
self.card1.setP(50)
self.cm2 = CardMaker('board')
self.cm2.setFrameFullscreenQuad()
self.cm2.setUvRange(self.tex2)
self.card2 = NodePath(self.cm2.generate())
self.card2.reparentTo(self.path)
self.card2.setPos(0,0,-10)
self.card2.setP(-50)
self.card1.setTexture(self.tex1)
self.card1.setTexScale(TextureStage.getDefault(), self.tex1.getTexScale())
self.card2.setTexture(self.tex2)
self.card2.setTexScale(TextureStage.getDefault(), self.tex2.getTexScale())
self.card1.setScale(10)
self.card2.setScale(10)
def getBeat(self):
pass
示例2: playVideo
# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setFrameFullscreenQuad [as 别名]
def playVideo(self, video):
# check if it is loadable
try:
# load the video texture
self.tex = MovieTexture("MovieTexture")
#print video
self.tex.read(video)
# Set up a fullscreen card to set the video texture on it.
cm = CardMaker("Movie Card")
cm.setFrameFullscreenQuad()
cm.setUvRange(self.tex)
self.card = NodePath(cm.generate())
self.card.reparentTo(base.render2d)
self.card.setTexture(self.tex)
self.card.setTexScale(TextureStage.getDefault(),
self.tex.getTexScale())
# load the video
self.sound = loader.loadSfx(video)
# Synchronize the video to the sound.
self.tex.synchronizeTo(self.sound)
# play the video and audio
self.sound.play()
# start the task which checks if the video is finished
taskMgr.add(self.isVideoFinish, "task_isVideoFinised")
except:
logging.error("Failed to load video: %s %s", video, sys.exc_info())
self.stopVideo()
base.messenger.send(self.vidFinEvt)
示例3: __initSceneGraph
# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setFrameFullscreenQuad [as 别名]
def __initSceneGraph(self):
self.point_path = self.host_planet.point_path.attachNewNode("unit_center_node")
self.model_path = self.point_path.attachNewNode("unit_node")
self.model_path.reparentTo(self.point_path)
self.model_path.setPos(Vec3(0,6,0))
self.model_path.setPythonTag('pyUnit', self)
rad = 1
cnode = CollisionNode("coll_sphere_node")
cnode.addSolid(CollisionBox(Point3(-rad,-rad,-rad),Point3(rad,rad,rad)))
cnode.setIntoCollideMask(BitMask32.bit(1))
cnode.setTag('unit', str(id(self)))
self.cnode_path = self.model_path.attachNewNode(cnode)
#self.cnode_path.show()
tex = loader.loadTexture("models/billboards/flare.png")
cm = CardMaker('quad')
cm.setFrameFullscreenQuad()
self.quad_path = self.model_path.attachNewNode(cm.generate())
self.quad_path.setTexture(tex)
self.quad_path.setTransparency(TransparencyAttrib.MAlpha)
self.quad_path.setBillboardPointEye()
self.quad_path.setColor(self.player.color)
示例4: renderQuadInto
# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setFrameFullscreenQuad [as 别名]
def renderQuadInto(self, xsize, ysize, colortex=None, cmode = GraphicsOutput.RTMBindOrCopy, auxtex = None):
buffer = self.createBuffer("filter-stage", xsize, ysize, colortex, cmode, auxtex)
if (buffer == None):
return None
cm = CardMaker("filter-stage-quad")
cm.setFrameFullscreenQuad()
quad = NodePath(cm.generate())
quad.setDepthTest(0)
quad.setDepthWrite(0)
quad.setColor(Vec4(1,0.5,0.5,1))
quadcamnode = Camera("filter-quad-cam")
lens = OrthographicLens()
lens.setFilmSize(2, 2)
lens.setFilmOffset(0, 0)
lens.setNearFar(-1000, 1000)
quadcamnode.setLens(lens)
quadcam = quad.attachNewNode(quadcamnode)
buffer.getDisplayRegion(0).setCamera(quadcam)
buffer.getDisplayRegion(0).setActive(1)
return quad, buffer
示例5: _activateSunflare
# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setFrameFullscreenQuad [as 别名]
def _activateSunflare(self):
self.deactivateHighlight()
flare_tex = base.loader.loadTexture("models/billboards/sunflare.png")
cm = CardMaker('flare')
cm.setFrameFullscreenQuad() # so that the center acts as the origin (from -1 to 1)
self.flare_path = self.point_path.attachNewNode(cm.generate())
self.flare_path.setTransparency(TransparencyAttrib.MAlpha)
self.flare_path.setTexture(self.flare_ts,flare_tex)
self.flare_path.setColor(Vec4(1.0, 1.0, 1.0, 1))
self.flare_path.setScale(50)
self.flare_path.setPos(Vec3(0,0,0))
self.flare_path.setBillboardPointEye()
self.flare_path.setLightOff()
示例6: renderQuadInto
# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setFrameFullscreenQuad [as 别名]
def renderQuadInto(self, mul=1, div=1, align=1, depthtex=None, colortex=None, auxtex0=None, auxtex1=None):
""" Creates an offscreen buffer for an intermediate
computation. Installs a quad into the buffer. Returns
the fullscreen quad. The size of the buffer is initially
equal to the size of the main window. The parameters 'mul',
'div', and 'align' can be used to adjust that size. """
texgroup = (depthtex, colortex, auxtex0, auxtex1)
winx, winy = self.getScaledSize(mul, div, align)
depthbits = bool(depthtex != None)
buffer = self.createBuffer("filter-stage", winx, winy, texgroup, depthbits)
if (buffer == None):
return None
cm = CardMaker("filter-stage-quad")
cm.setFrameFullscreenQuad()
quad = NodePath(cm.generate())
quad.setDepthTest(0)
quad.setDepthWrite(0)
quad.setColor(1, 0.5, 0.5, 1)
quadcamnode = Camera("filter-quad-cam")
lens = OrthographicLens()
lens.setFilmSize(2, 2)
lens.setFilmOffset(0, 0)
lens.setNearFar(-1000, 1000)
quadcamnode.setLens(lens)
quadcam = quad.attachNewNode(quadcamnode)
dr = buffer.makeDisplayRegion((0, 1, 0, 1))
dr.disableClears()
dr.setCamera(quadcam)
dr.setActive(True)
dr.setScissorEnabled(False)
# This clear stage is important if the buffer is padded, so that
# any pixels accidentally sampled in the padded region won't
# be reading from unititialised memory.
buffer.setClearColor((0, 0, 0, 1))
buffer.setClearColorActive(True)
self.buffers.append(buffer)
self.sizes.append((mul, div, align))
return quad
示例7: _makeFullscreenQuad
# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setFrameFullscreenQuad [as 别名]
def _makeFullscreenQuad(self):
""" Create a quad which fills the full screen """
cm = CardMaker("BufferQuad")
cm.setFrameFullscreenQuad()
quad = NodePath(cm.generate())
quad.setDepthTest(0)
quad.setDepthWrite(0)
quad.setAttrib(TransparencyAttrib.make(TransparencyAttrib.MNone), 1000)
quad.setColor(Vec4(1, 0.5, 0.5, 1))
# No culling check
quad.node().setFinal(True)
quad.node().setBounds(OmniBoundingVolume())
quad.setBin("unsorted", 10)
return quad
示例8: activateHighlight
# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setFrameFullscreenQuad [as 别名]
def activateHighlight(self, thin):
if thin:
flare_tex = base.loader.loadTexture("models/billboards/thin_ring.png")
else:
flare_tex = base.loader.loadTexture("models/billboards/ring.png")
cm = CardMaker('quad')
cm.setFrameFullscreenQuad() # so that the center acts as the origin (from -1 to 1)
self.quad_path = self.point_path.attachNewNode(cm.generate())
self.quad_path.setTransparency(TransparencyAttrib.MAlpha)
self.quad_path.setTexture(flare_tex)
if thin:
self.quad_path.setColor(Vec4(1,1,1, 1))
else:
self.quad_path.setColor(Vec4(0.2, 0.3, 1.0, 1))
self.quad_path.setScale(5)
self.quad_path.setPos(Vec3(0,0,0))
self.quad_path.setBillboardPointEye()
示例9: _updateDebugNode
# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setFrameFullscreenQuad [as 别名]
def _updateDebugNode(self):
""" Internal method to generate new debug geometry. """
debugNode = NodePath("PointLightDebugNode")
debugNode.setPos(self.position)
# Create the inner image
cm = CardMaker("PointLightDebug")
cm.setFrameFullscreenQuad()
innerNode = NodePath(cm.generate())
innerNode.setTexture(Globals.loader.loadTexture("Data/GUI/Visualization/PointLight.png"))
innerNode.setBillboardPointEye()
innerNode.reparentTo(debugNode)
# Create the outer lines
lineNode = debugNode.attachNewNode("lines")
# Generate outer circles
points1 = []
points2 = []
points3 = []
for i in range(self.visualizationNumSteps + 1):
angle = float(
i) / float(self.visualizationNumSteps) * math.pi * 2.0
points1.append(Vec3(0, math.sin(angle), math.cos(angle)))
points2.append(Vec3(math.sin(angle), math.cos(angle), 0))
points3.append(Vec3(math.sin(angle), 0, math.cos(angle)))
self._createDebugLine(points1, False).reparentTo(lineNode)
self._createDebugLine(points2, False).reparentTo(lineNode)
self._createDebugLine(points3, False).reparentTo(lineNode)
lineNode.setScale(self.radius)
# Remove the old debug node
self.debugNode.node().removeAllChildren()
# Attach the new debug node
debugNode.reparentTo(self.debugNode)
示例10: attackAnimation
# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setFrameFullscreenQuad [as 别名]
def attackAnimation(self, time, task):
try:
if self.shockwave_path != None:
self.shock_scale += 0.1
self.shockwave_path.setScale(self.shock_scale)
except AttributeError:
cm = CardMaker('quad')
cm.setFrameFullscreenQuad()
tex = loader.loadTexture("models/billboards/attack.png")
self.shockwave_path = self.model_path.attachNewNode(cm.generate())
self.shockwave_path.setTexture(tex)
self.shockwave_path.setTransparency(TransparencyAttrib.MAlpha)
self.shock_scale = 0.2
self.shockwave_path.setScale(self.shock_scale)
self.shockwave_path.setPos(Vec3(0, 0, -0.5))
self.shockwave_path.setP(-90)
self.shockwave_path.setColor(Vec4(1.0, 0.65, 0, 0.6))
if task.time > time:
self.shockwave_path.removeNode()
self.shockwave_path = None
del self.shock_scale
del self.shockwave_path
return task.done
return task.cont
示例11: _updateDebugNode
# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setFrameFullscreenQuad [as 别名]
def _updateDebugNode(self):
""" Internal method to generate new debug geometry. """
debugNode = NodePath("SpotLightDebugNode")
# Create the inner image
cm = CardMaker("SpotLightDebug")
cm.setFrameFullscreenQuad()
innerNode = NodePath(cm.generate())
innerNode.setTexture(Globals.loader.loadTexture("Data/GUI/Visualization/SpotLight.png"))
innerNode.setBillboardPointEye()
innerNode.reparentTo(debugNode)
innerNode.setPos(self.position)
innerNode.setColorScale(1,1,0,1)
# Create the outer lines
lineNode = debugNode.attachNewNode("lines")
currentNodeTransform = render.getTransform(self.ghostCameraNode).getMat()
currentCamTransform = self.ghostLens.getProjectionMat()
currentRelativeCamPos = self.ghostCameraNode.getPos(render)
currentCamBounds = self.ghostLens.makeBounds()
currentCamBounds.xform(self.ghostCameraNode.getMat(render))
p = lambda index: currentCamBounds.getPoint(index)
# Make a circle at the bottom
frustumBottomCenter = (p(0) + p(1) + p(2) + p(3)) * 0.25
upVector = (p(0) + p(1)) / 2 - frustumBottomCenter
rightVector = (p(1) + p(2)) / 2 - frustumBottomCenter
points = []
for idx in xrange(64):
rad = idx / 64.0 * math.pi * 2.0
pos = upVector * math.sin(rad) + rightVector * math.cos(rad)
pos += frustumBottomCenter
points.append(pos)
frustumLine = self._createDebugLine(points, True)
frustumLine.setColorScale(1,1,0,1)
frustumLine.reparentTo(lineNode)
# Create frustum lines which connect the origin to the bottom circle
pointArrays = [
[self.position, frustumBottomCenter + upVector],
[self.position, frustumBottomCenter - upVector],
[self.position, frustumBottomCenter + rightVector],
[self.position, frustumBottomCenter - rightVector],
]
for pointArray in pointArrays:
frustumLine = self._createDebugLine(pointArray, False)
frustumLine.setColorScale(1,1,0,1)
frustumLine.reparentTo(lineNode)
# Create line which is in the direction of the spot light
startPoint = (p(0) + p(1) + p(2) + p(3)) * 0.25
endPoint = (p(4) + p(5) + p(6) + p(7)) * 0.25
line = self._createDebugLine([startPoint, endPoint], False)
line.setColorScale(1,1,1,1)
line.reparentTo(lineNode)
# Remove the old debug node
self.debugNode.node().removeAllChildren()
# Attach the new debug node
debugNode.reparentTo(self.debugNode)
示例12: enterIntro
# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setFrameFullscreenQuad [as 别名]
def enterIntro(self):
helper.hide_cursor()
cm = CardMaker("fade")
cm.setFrameFullscreenQuad()
self.gfLogo = NodePath(cm.generate())
self.gfLogo.setTransparency(TransparencyAttrib.MAlpha)
gfLogotex = loader.loadTexture('GrimFangLogo.png')
gfLogots = TextureStage('gfLogoTS')
gfLogots.setMode(TextureStage.MReplace)
self.gfLogo.setTexture(gfLogots, gfLogotex)
self.gfLogo.setY(-50)
self.gfLogo.reparentTo(render2d)
self.gfLogo.hide()
self.pandaLogo = NodePath(cm.generate())
self.pandaLogo.setTransparency(TransparencyAttrib.MAlpha)
pandaLogotex = loader.loadTexture('Panda3DLogo.png')
pandaLogots = TextureStage('pandaLogoTS')
pandaLogots.setMode(TextureStage.MReplace)
self.pandaLogo.setTexture(pandaLogots, pandaLogotex)
self.pandaLogo.setY(-50)
self.pandaLogo.reparentTo(render2d)
self.pandaLogo.hide()
gfFadeInInterval = LerpColorScaleInterval(
self.gfLogo,
2,
LVecBase4f(0.0,0.0,0.0,1.0),
LVecBase4f(0.0,0.0,0.0,0.0))
gfFadeOutInterval = LerpColorScaleInterval(
self.gfLogo,
2,
LVecBase4f(0.0,0.0,0.0,0.0),
LVecBase4f(0.0,0.0,0.0,1.0))
p3dFadeInInterval = LerpColorScaleInterval(
self.pandaLogo,
2,
LVecBase4f(0.0,0.0,0.0,1.0),
LVecBase4f(0.0,0.0,0.0,0.0))
p3dFadeOutInterval = LerpColorScaleInterval(
self.pandaLogo,
2,
LVecBase4f(0.0,0.0,0.0,0.0),
LVecBase4f(0.0,0.0,0.0,1.0))
self.fadeInOut = Sequence(
Func(self.pandaLogo.show),
p3dFadeInInterval,
Wait(1.0),
p3dFadeOutInterval,
Wait(0.5),
Func(self.pandaLogo.hide),
Func(self.gfLogo.show),
gfFadeInInterval,
Wait(1.0),
gfFadeOutInterval,
Wait(0.5),
Func(self.gfLogo.hide),
Func(self.request, "Menu"),
Func(helper.show_cursor),
name="fadeInOut")
self.fadeInOut.start()
示例13: __init__
# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setFrameFullscreenQuad [as 别名]
def __init__(self):
ShowBase.__init__(self)
FSM.__init__(self, "FSM-Game")
#
# BASIC APPLICATION CONFIGURATIONS
#
self.disableMouse()
self.setBackgroundColor(0, 0, 0)
self.camLens.setFov(75)
self.camLens.setNear(0.8)
# check if the config file hasn't been created
base.textWriteSpeed = 0.05
mute = ConfigVariableBool("audio-mute", False).getValue()
if mute:
self.disableAllAudio()
else:
self.enableAllAudio()
particles = ConfigVariableBool("particles-enabled", True).getValue()
if particles:
self.enableParticles()
base.textWriteSpeed = ConfigVariableDouble("text-write-speed",0.05).getValue()
base.controlType = ConfigVariableString("control-type", "Gamepad").getValue()
base.mouseSensitivity = ConfigVariableDouble("mouse-sensitivity",1.0).getValue()
if not os.path.exists(prcFile):
self.__writeConfig()
# set window properties
# clear all properties not previously set
self.win.clearRejectedProperties()
# setup new window properties
props = WindowProperties()
# Fullscreen
props.setFullscreen(True)
# window icon
print props.hasIconFilename()
props.setIconFilename(windowicon)
# get the displays width and height
w = self.pipe.getDisplayWidth()
h = self.pipe.getDisplayHeight()
# set the window size to the screen resolution
props.setSize(w, h)
# request the new properties
self.win.requestProperties(props)
atexit.register(self.__writeConfig)
# enable collision handling
base.cTrav = CollisionTraverser("base collision traverser")
base.pusher = CollisionHandlerPusher()
base.pusher.addInPattern('%fn-in-%in')
base.pusher.addOutPattern('%fn-out-%in')
self.menu = Menu()
self.options = OptionsMenu()
self.musicMenu = loader.loadMusic("MayanJingle6_Menu.ogg")
self.musicMenu.setLoop(True)
cm = CardMaker("menuFade")
cm.setFrameFullscreenQuad()
self.menuCoverFade = NodePath(cm.generate())
self.menuCoverFade.setTransparency(TransparencyAttrib.MAlpha)
self.menuCoverFade.setBin("fixed", 1000)
self.menuCoverFade.reparentTo(render2d)
self.menuCoverFade.hide()
self.menuCoverFadeOutInterval = Sequence(
Func(self.menuCoverFade.show),
LerpColorScaleInterval(
self.menuCoverFade,
1,
LVecBase4f(0.0,0.0,0.0,1.0),
LVecBase4f(0.0,0.0,0.0,0.0)),
Func(self.menuCoverFade.hide))
self.menuCoverFadeInInterval = Sequence(
Func(self.menuCoverFade.show),
LerpColorScaleInterval(
self.menuCoverFade,
1,
LVecBase4f(0.0,0.0,0.0,0.0),
LVecBase4f(0.0,0.0,0.0,1.0)),
Func(self.menuCoverFade.hide))
self.lerpAudioFadeOut = LerpFunc(
self.audioFade,
fromData=1.0,
toData=0.0,
duration=0.25,
extraArgs=[self.musicMenu])
self.fadeMusicOut = Sequence(
self.lerpAudioFadeOut,
Func(self.musicMenu.stop))
self.lerpAudioFadeIn = LerpFunc(
self.audioFade,
fromData=0.0,
toData=1.0,
duration=1,
extraArgs=[self.musicMenu])
self.fadeMusicIn = Sequence(
Func(self.musicMenu.play),
self.lerpAudioFadeIn)
#.........这里部分代码省略.........
示例14: __init__
# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setFrameFullscreenQuad [as 别名]
def __init__(self,
parent = None,
pos = (0,0,0),
fading = False,
fading_position_offset = (0,0,0),
fading_duration = 0.5,
backgroundImage = None,
backgroundColor = None,
enableMask = False,
noFocus = False,
shownFunc = None,
hiddenFunc = None,
funcExtraArgs = [],
sort = None
):
'''if fading enabled, it will apply a fading effect on show()&hide()
Important Attributes:
enableMask: This creates a big transparent plane (DirectButton) off screen so the directGui below won't be
clicked (However due to this trick we won't be able to accept mouse events (I have paid back 'mouse3' by
self.__maskClick))
noFocus: if it is true, it doesn't need SogalBase to manage its focus state (it will not affect
other Sogalforms' focus state
'''
self.__fading = fading
self.__fadingPositionOffset = fading_position_offset
self.__fadingDuration = fading_duration
self.__originPos = pos
self.__currentInterval = None
self.__maskEnabled = enableMask
self.__noFocus = noFocus
self.__shownFunc = shownFunc
self.__hiddenFunc = hiddenFunc
self.__eventExtraArgs = funcExtraArgs
self.__mask = None
if self.__maskEnabled:
self.__mask = DialogMask()
#self.__mask = DirectButton(parent = aspect2d, frameColor =(1,1,1,0.1), relief = DGG.FLAT,commandButtons = [DGG.RMB],command = self.__maskClick)
self.__mask.hide()
self.__backgroundImage = backgroundImage
self.__backgroundColor = backgroundColor
self.__bgPath = None
self.__imagePath = None
self.__hidden = True
NodePath.__init__(self,self.__class__.__name__)
parent = parent or aspect2d
if sort:
self.reparentTo(parent, sort = sort)
else:
self.reparentTo(parent)
self.setPos(pos)
if self.__backgroundColor:
self.__bgPath = NodePath('bgPath')
self.__bgPath.setTransparency(TransparencyAttrib.MAlpha)
cm = CardMaker('cm')
cm.setFrameFullscreenQuad()
cm.setColor(self.__backgroundColor)
self.__bgPath.attachNewNode(cm.generate())
self.__bgPath.reparentTo(aspect2d,self.getSort())
self.__bgPath.hide()
#TODO: backgroundImage
self.setTransparency(TransparencyAttrib.MAlpha)
self.accept('window-event', self.windowResize)
self.windowResize(None)
NodePath.hide(self)
示例15: renderSceneInto
# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setFrameFullscreenQuad [as 别名]
def renderSceneInto(self, depthtex=None, colortex=None, auxtex=None, auxbits=0, textures=None):
""" Causes the scene to be rendered into the supplied textures
instead of into the original window. Puts a fullscreen quad
into the original window to show the render-to-texture results.
Returns the quad. Normally, the caller would then apply a
shader to the quad.
To elaborate on how this all works:
* An offscreen buffer is created. It is set up to mimic
the original display region - it is the same size,
uses the same clear colors, and contains a DisplayRegion
that uses the original camera.
* A fullscreen quad and an orthographic camera to render
that quad are both created. The original camera is
removed from the original window, and in its place, the
orthographic quad-camera is installed.
* The fullscreen quad is textured with the data from the
offscreen buffer. A shader is applied that tints the
results pink.
* Automatic shader generation NOT enabled.
If you have a filter that depends on a render target from
the auto-shader, you either need to set an auto-shader
attrib on the main camera or scene, or, you need to provide
these outputs in your own shader.
* All clears are disabled on the original display region.
If the display region fills the whole window, then clears
are disabled on the original window as well. It is
assumed that rendering the full-screen quad eliminates
the need to do clears.
Hence, the original window which used to contain the actual
scene, now contains a pink-tinted quad with a texture of the
scene. It is assumed that the user will replace the shader
on the quad with a more interesting filter. """
if (textures):
colortex = textures.get("color", None)
depthtex = textures.get("depth", None)
auxtex = textures.get("aux", None)
auxtex0 = textures.get("aux0", auxtex)
auxtex1 = textures.get("aux1", None)
else:
auxtex0 = auxtex
auxtex1 = None
if (colortex == None):
colortex = Texture("filter-base-color")
colortex.setWrapU(Texture.WMClamp)
colortex.setWrapV(Texture.WMClamp)
texgroup = (depthtex, colortex, auxtex0, auxtex1)
# Choose the size of the offscreen buffer.
(winx, winy) = self.getScaledSize(1,1,1)
buffer = self.createBuffer("filter-base", winx, winy, texgroup)
if (buffer == None):
return None
cm = CardMaker("filter-base-quad")
cm.setFrameFullscreenQuad()
quad = NodePath(cm.generate())
quad.setDepthTest(0)
quad.setDepthWrite(0)
quad.setTexture(colortex)
quad.setColor(1, 0.5, 0.5, 1)
cs = NodePath("dummy")
cs.setState(self.camstate)
# Do we really need to turn on the Shader Generator?
#cs.setShaderAuto()
if (auxbits):
cs.setAttrib(AuxBitplaneAttrib.make(auxbits))
self.camera.node().setInitialState(cs.getState())
quadcamnode = Camera("filter-quad-cam")
lens = OrthographicLens()
lens.setFilmSize(2, 2)
lens.setFilmOffset(0, 0)
lens.setNearFar(-1000, 1000)
quadcamnode.setLens(lens)
quadcam = quad.attachNewNode(quadcamnode)
self.region.setCamera(quadcam)
self.setStackedClears(buffer, self.rclears, self.wclears)
if (auxtex0):
buffer.setClearActive(GraphicsOutput.RTPAuxRgba0, 1)
buffer.setClearValue(GraphicsOutput.RTPAuxRgba0, (0.5, 0.5, 1.0, 0.0))
if (auxtex1):
buffer.setClearActive(GraphicsOutput.RTPAuxRgba1, 1)
self.region.disableClears()
if (self.isFullscreen()):
#.........这里部分代码省略.........