本文整理汇总了Python中pandac.PandaModules.CardMaker.setColor方法的典型用法代码示例。如果您正苦于以下问题:Python CardMaker.setColor方法的具体用法?Python CardMaker.setColor怎么用?Python CardMaker.setColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandac.PandaModules.CardMaker
的用法示例。
在下文中一共展示了CardMaker.setColor方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setupTexture
# 需要导入模块: from pandac.PandaModules import CardMaker [as 别名]
# 或者: from pandac.PandaModules.CardMaker import setColor [as 别名]
def setupTexture(self):
cm = CardMaker('quadMaker')
cm.setColor(1.0, 1.0, 1.0, 1.0)
aspect = base.camLens.getAspectRatio()
htmlWidth = 2.0 * aspect * WEB_WIDTH_PIXELS / float(WIN_WIDTH)
htmlHeight = 2.0 * float(WEB_HEIGHT_PIXELS) / float(WIN_HEIGHT)
cm.setFrame(-htmlWidth / 2.0, htmlWidth / 2.0, -htmlHeight / 2.0, htmlHeight / 2.0)
bottomRightX = WEB_WIDTH_PIXELS / float(WEB_WIDTH + 1)
bottomRightY = WEB_HEIGHT_PIXELS / float(WEB_HEIGHT + 1)
cm.setUvRange(Point2(0, 1 - bottomRightY), Point2(bottomRightX, 1))
card = cm.generate()
self.quad = NodePath(card)
self.quad.reparentTo(self.parent)
self.guiTex = Texture('guiTex')
self.guiTex.setupTexture(Texture.TT2dTexture, WEB_WIDTH, WEB_HEIGHT, 1, Texture.TUnsignedByte, Texture.FRgba)
self.guiTex.setMinfilter(Texture.FTLinear)
self.guiTex.setKeepRamImage(True)
self.guiTex.makeRamImage()
self.guiTex.setWrapU(Texture.WMRepeat)
self.guiTex.setWrapV(Texture.WMRepeat)
ts = TextureStage('webTS')
self.quad.setTexture(ts, self.guiTex)
self.quad.setTexScale(ts, 1.0, -1.0)
self.quad.setTransparency(0)
self.quad.setTwoSided(True)
self.quad.setColor(1.0, 1.0, 1.0, 1.0)
self.calcMouseLimits()
示例2: loadFlatQuad
# 需要导入模块: from pandac.PandaModules import CardMaker [as 别名]
# 或者: from pandac.PandaModules.CardMaker import setColor [as 别名]
def loadFlatQuad(self, fullFilename):
cm = CardMaker("cm-%s" % fullFilename)
cm.setColor(1.0, 1.0, 1.0, 1.0)
aspect = base.camLens.getAspectRatio()
htmlWidth = 2.0 * aspect * WEB_WIDTH_PIXELS / float(WIN_WIDTH)
htmlHeight = 2.0 * float(WEB_HEIGHT_PIXELS) / float(WIN_HEIGHT)
cm.setFrame(-htmlWidth / 2.0, htmlWidth / 2.0, -htmlHeight / 2.0, htmlHeight / 2.0)
bottomRightX = WEB_WIDTH_PIXELS / float(WEB_WIDTH + 1)
bottomRightY = WEB_HEIGHT_PIXELS / float(WEB_HEIGHT + 1)
cm.setUvRange(Point2(0, 1 - bottomRightY), Point2(bottomRightX, 1))
card = cm.generate()
quad = NodePath(card)
jpgFile = PNMImage(WEB_WIDTH, WEB_HEIGHT)
smallerJpgFile = PNMImage()
readFile = smallerJpgFile.read(Filename(fullFilename))
if readFile:
jpgFile.copySubImage(smallerJpgFile, 0, 0)
guiTex = Texture("guiTex")
guiTex.setupTexture(Texture.TT2dTexture, WEB_WIDTH, WEB_HEIGHT, 1, Texture.TUnsignedByte, Texture.FRgba)
guiTex.setMinfilter(Texture.FTLinear)
guiTex.load(jpgFile)
guiTex.setWrapU(Texture.WMClamp)
guiTex.setWrapV(Texture.WMClamp)
ts = TextureStage("webTS")
quad.setTexture(ts, guiTex)
quad.setTransparency(0)
quad.setTwoSided(True)
quad.setColor(1.0, 1.0, 1.0, 1.0)
result = quad
else:
result = None
Texture.setTexturesPower2(1)
return result
示例3: _initGUI
# 需要导入模块: from pandac.PandaModules import CardMaker [as 别名]
# 或者: from pandac.PandaModules.CardMaker import setColor [as 别名]
def _initGUI(self):
base.loadingScreen.beginStep('init Gui', 4, 55)
cm = CardMaker('PotionBackground')
cm.setFrame(-10, 10, -10, 10)
cm.setColor(0, 0, 0, 1)
self.background = NodePath(cm.generate())
self.background.reparentTo(aspect2d)
self.background.setBin('background', -100)
self.xpBackground = NodePath('PotionXPBackground')
self.xpBackground.reparentTo(aspect2d)
self.xpBackground.setBin('background', -95)
base.loadingScreen.tick()
self.dialogs = NodePath('DialogBackground')
self.dialogs.reparentTo(aspect2d)
self.dialogs.setBin('background', -70)
self.buttonsBackground = NodePath('PotionButtonBackground')
self.buttonsBackground.reparentTo(base.a2dBottomRight)
self.buttonsBackground.setBin('background', -90)
textureCard = loader.loadModel('models/minigames/pir_m_gui_pot_textureCard')
self.stretchedBackgroundTextureCard = textureCard.find('**/pir_t_gui_pot_background')
self.stretchedBackgroundTextureCard.reparentTo(self.background)
self.stretchedBackgroundTextureCard.setScale(3.3999999999999999, 1.0, 3.3999999999999999)
self.stretchedBackgroundTextureCard.setPos(0.0, 20.0, 0.0)
fadecm = CardMaker('card')
fadecm.setFrameFullscreenQuad()
self.fadeIn = render2d.attachNewNode(fadecm.generate())
self.fadeIn.setBin('background', -50)
self.fadeIn.setPos(0.0, -30.0, 0.0)
self.fadeIn.setColor(0, 0, 0, 1.0)
self.fadeIn.setTransparency(True)
base.loadingScreen.tick()
cm = CardMaker('card')
cm.setFrame(0, 1, 0.01, 0.01)
self.foregroundLayer = aspect2d.attachNewNode(cm.generate())
self.foregroundTextureCard = textureCard.find('**/pir_t_gui_pot_foreground')
self.foregroundTextureCard.setScale(0.80000000000000004, 1.0, 0.40000000000000002)
self.foregroundTextureCard.setPos(-0.69999999999999996, -20.0, 0.80000000000000004)
self.foregroundTextureCard.setBin('background', -80)
self.foregroundTextureCard.copyTo(self.foregroundLayer)
self.repMeter = ReputationMeter.ReputationMeter(InventoryType.PotionsRep, width = 0.56000000000000005)
inv = localAvatar.getInventory()
self.repMeter.reparentTo(self.xpBackground)
self.repMeter.setPos(0, 0, -0.94999999999999996)
self.repMeter.update(inv.getAccumulator(InventoryType.PotionsRep))
localAvatar.guiMgr.registerReputationHandler(self.updateRepMeter)
base.loadingScreen.tick()
self.closeButton = GuiButton.GuiButton(image = (textureCard.find('**/pir_t_gui_pot_escape'), textureCard.find('**/pir_t_gui_pot_escapeOn'), textureCard.find('**/pir_t_gui_pot_escapeOn'), textureCard.find('**/pir_t_gui_pot_escape')), image_scale = (0.10000000000000001, 0.10000000000000001, 0.10000000000000001), image_pos = (0.074999999999999997, 0, 0.080000000000000002), hotkeys = [
'Escape'], hotkeyLabel = PLocalizer.PotionGui['ExitButton'], pos = (-0.40000000000000002, 0.0, 0.01), text0_fg = PotionGlobals.TextColor, text1_fg = PiratesGuiGlobals.TextFG0, text2_fg = PiratesGuiGlobals.TextFG15, text3_fg = PotionGlobals.TextColorDisabled, parent = self.buttonsBackground, command = self.confirmQuit)
self.returnButton = GuiButton.GuiButton(text = (PLocalizer.PotionGui['SwitchRecipe'], PLocalizer.PotionGui['SwitchRecipe'], PLocalizer.PotionGui['SwitchRecipe'], PLocalizer.PotionGui['SwitchRecipe']), pos = (-0.57999999999999996, 0.0, -0.62), text_scale = PiratesGuiGlobals.TextScaleExtraLarge, text_shadow = None, image = (None, None, None, None), text0_fg = PotionGlobals.TextColor, text1_fg = PiratesGuiGlobals.TextFG0, text2_fg = PiratesGuiGlobals.TextFG15, text3_fg = PotionGlobals.TextColorDisabled, parent = self.background, command = self.confirmReturn)
self.returnButton.stash()
self.hintsButton = GuiButton.GuiButton(text = (PLocalizer.PotionGui['ShowTutorial'], PLocalizer.PotionGui['ShowTutorial'], PLocalizer.PotionGui['ShowTutorial'], PLocalizer.PotionGui['ShowTutorial']), text_scale = PiratesGuiGlobals.TextScaleSmall, image_scale = (0.25, 0.10000000000000001, 0.17999999999999999), image_pos = (0, 0, 0), pos = (-0.53000000000000003, 0.0, 0.074999999999999997), parent = self.buttonsBackground, command = self.showLastHint)
self.InfoButton = GuiButton.GuiButton(text = (PLocalizer.PotionGui['IngredientList'], PLocalizer.PotionGui['IngredientList'], PLocalizer.PotionGui['IngredientList'], PLocalizer.PotionGui['IngredientList']), text_scale = PiratesGuiGlobals.TextScaleSmall, image_scale = (0.29999999999999999, 0.10000000000000001, 0.17999999999999999), image_pos = (0, 0, 0), pos = (-0.83999999999999997, 0.0, 0.074999999999999997), parent = self.buttonsBackground, command = self.showInfo)
textureCard.removeNode()
base.loadingScreen.endStep('init Gui')
示例4: makeCard
# 需要导入模块: from pandac.PandaModules import CardMaker [as 别名]
# 或者: from pandac.PandaModules.CardMaker import setColor [as 别名]
def makeCard(self, color, width, height, i, j, divisions):
divisions = float(divisions)
x = i / divisions
y = j / divisions
d = 1 / divisions
card = CardMaker("wall")
card.setColor(*color)
card.setFrame(width*(x*2-1), width*((x+d)*2-1), height*(y*2-1), height*((y+d)*2-1))
card.setUvRange(Point2(width*x, height*y), Point2(width*(x+d), height*(y+d)))
card.setHasUvs(True)
card.setHasNormals(True)
node = self.node.attachNewNode(card.generate())
示例5: setupRightTexture
# 需要导入模块: from pandac.PandaModules import CardMaker [as 别名]
# 或者: from pandac.PandaModules.CardMaker import setColor [as 别名]
def setupRightTexture(self):
cm = CardMaker('quadMaker')
cm.setColor(1.0, 1.0, 1.0, 1.0)
aspect = base.camLens.getAspectRatio()
htmlWidth = 2.0 * aspect * WEB_WIDTH / float(WIN_WIDTH)
htmlHeight = 2.0 * float(WEB_HEIGHT) / float(WIN_HEIGHT)
cm.setFrame(0, htmlWidth / 2.0, -htmlHeight / 2.0, htmlHeight / 2.0)
card = cm.generate()
self.rightQuad = NodePath(card)
self.rightQuad.reparentTo(self.parent)
self.rightGuiTex = Texture('guiTex')
self.rightGuiTex.setupTexture(Texture.TT2dTexture, WEB_HALF_WIDTH, WEB_HEIGHT, 1, Texture.TUnsignedByte, Texture.FRgba)
self.rightGuiTex.setKeepRamImage(True)
self.rightGuiTex.makeRamImage()
self.rightGuiTex.setWrapU(Texture.WMClamp)
self.rightGuiTex.setWrapV(Texture.WMClamp)
ts = TextureStage('rightWebTS')
self.rightQuad.setTexture(ts, self.rightGuiTex)
self.rightQuad.setTexScale(ts, 1.0, -1.0)
self.rightQuad.setTransparency(0)
self.rightQuad.setTwoSided(True)
self.rightQuad.setColor(1.0, 1.0, 1.0, 1.0)
示例6: __init__
# 需要导入模块: from pandac.PandaModules import CardMaker [as 别名]
# 或者: from pandac.PandaModules.CardMaker import setColor [as 别名]
class RaceGUI:
GagPie = 0
gagRoot = 'phase_3.5/maps/inventory_'
class RacerInfo:
def __init__(self, face, mapSpot):
self.curvetime = 0
self.maxlaphit = 0
self.face = face
self.mapspot = mapSpot
self.place = 1
self.enabled = True
self.finished = False
self.gag = None
return
def update(self, curvetime = None, maxlaphit = None, faceX = None, mapspotPt = None, place = None, finished = None):
if self.enabled:
if not curvetime == None:
self.curvetime = curvetime
if not maxlaphit == None:
self.maxlaphit = maxlaphit
if not faceX == None:
self.face.setX(faceX)
if not mapspotPt == None:
self.mapspot.setPos(mapspotPt)
if not place == None:
self.place = place
if not finished == None:
self.finished = finished
return
def disable(self):
self.enabled = False
if not self.finished:
self.face.hide()
self.mapspot.hide()
def enable(self):
self.enabled = True
self.face.show()
self.mapspot.show()
def __init__(self, distRace):
self.race = distRace
self.timerEnabled = False
self.maxLapHit = 0
self.photoFinish = False
toonInteriorTextures = loader.loadModel('phase_3.5/models/modules/toon_interior_textures')
invTextures = loader.loadModel('phase_3.5/models/gui/inventory_icons')
racingTextures = loader.loadModel('phase_6/models/karting/racing_textures')
self.gagTextures = [toonInteriorTextures.find('**/couch'),
invTextures.find('**/inventory_bannana_peel'),
racingTextures.find('**/boost_arrow'),
invTextures.find('**/inventory_anvil'),
invTextures.find('**/inventory_creampie')]
self.gagTextures[1].setScale(7.5)
self.gagTextures[3].setScale(7.5)
self.gagTextures[4].setScale(7.5)
self.cardMaker = CardMaker('card')
self.racerDict = {}
self.render2dRoot = render2d.attachNewNode('RaceGuiRender2dRoot')
self.render2dRoot.setDepthWrite(1)
self.directObjList = []
self.aspect2dRoot = aspect2d.attachNewNode('RaceGuiAspect2dRoot')
self.aspect2dRoot.setDepthWrite(1)
self.raceModeRoot = self.aspect2dRoot.attachNewNode('RaceModeRoot')
gui = loader.loadModel('phase_3.5/models/gui/avatar_panel_gui')
self.closeButton = DirectButton(image=(gui.find('**/CloseBtn_UP'),
gui.find('**/CloseBtn_DN'),
gui.find('**/CloseBtn_Rllvr'),
gui.find('**/CloseBtn_UP')), relief=None, scale=1.05, text=TTLocalizer.KartRace_Leave, text_scale=0.04, text_pos=(0, -0.07), text_fg=VBase4(1, 1, 1, 1), pos=(-0.99, 0, 0.925), command=self.race.leaveRace)
self.closeButton.reparentTo(self.aspect2dRoot)
self.directObjList.append(self.closeButton)
self.raceTimeDelta = 0
self.raceModeReady = False
self.resultModeReady = False
self.gagCycleSound = base.loadSfx('phase_3.5/audio/sfx/tick_counter.ogg')
if hasattr(self.gagCycleSound, 'setPlayRate'):
self.gagCycleSound.setPlayRate(0.2)
self.gagCycleSound.setLoop(1)
self.gagAcquireSound = base.loadSfx('phase_6/audio/sfx/SZ_MM_gliss.ogg')
self.disable()
return
def initRaceMode(self):
self.mapScene = base.a2dTopRight.attachNewNode('MapScene')
self.mapScene.setPos(-0.2, 0, -0.2)
self.mapScene.setScale(0.25, 0.001, 0.25)
maxT = self.race.curve.getMaxT()
pt = Vec3(0, 0, 0)
ls = LineSegs('MapLines')
ls.setColor(1, 1, 1, 1)
ls.setThickness(2)
for x in xrange(101):
self.race.curve.getPoint(x / 100.0 * maxT, pt)
if x == 0:
ls.moveTo(pt[0], pt[1], pt[2])
else:
#.........这里部分代码省略.........
示例7: Shooter
# 需要导入模块: from pandac.PandaModules import CardMaker [as 别名]
# 或者: from pandac.PandaModules.CardMaker import setColor [as 别名]
class Shooter(FSM):
def __init__(self, character):
FSM.__init__(self, "ShooterFSM")
self.character = character
self.world = self.character.world
# Set firing control handlers.
base.accept("mouse1", self.request, ["Shooting"])
base.accept("mouse1-up", self.request, ["Waiting"])
# Create power meter.
self.meter = base.render2d.attachNewNode("powerMeter")
self.meter.setPos(-0.2, 0.0, 0.0)
self.meter.hide()
self.meterBGCard = CardMaker("powerMeterBG")
self.meterBGCard.setFrame(0.0, 0.4, -0.9, -0.95)
self.meterBGCard.setColor(0.5, 0.0, 0.0, 1.0)
self.meterBG = self.meter.attachNewNode(self.meterBGCard.generate())
self.meterFGCard = CardMaker("powerMeterFG")
self.meterFGCard.setFrame(0.0, 0.4, -0.9, -0.95)
self.meterFGCard.setColor(1.0, 0.0, 0.0, 1.0)
self.meterFG = self.meter.attachNewNode(self.meterFGCard.generate())
# Create gun.
self.gun = loader.loadModel("models/ak47.egg")
self.gun.reparentTo(base.camera)
self.gun.setHpr(60, 104, 232)
self.gun.setPos(4.0, 14.0, -3.5)
self.gun.setScale(1.75)
self.gunRecoil = None
# Make gun get drawn on top.
self.gun.setBin("fixed", 40)
self.gun.setDepthTest(False)
self.gun.setDepthWrite(False)
# Load gunshot sound
self.gunSfx = base.loader.loadSfx("media/gun.wav")
self.gunSfx.setVolume(0.6)
def exitShooting(self):
angSpeed = 20.0 + (40.0 * self.powerLevel)
linSpeed = 80.0 + (320.0 * self.powerLevel)
color = (0.7 + 0.1*random(), 0.7 + 0.1*random(), 0.7 + 0.1*random())
dir = self.character.getDir()
bullet = Bullet(self.world, base.render, color, (0.0, 0.0, 0.0), dir, 0.3, 80, self.character.node)
bullet.body.setLinearVel(dir * linSpeed)
bullet.body.setAngularVel(dir * angSpeed)
self.gunSfx.play()
self.meter.hide()
base.taskMgr.remove("powerMeterGauge")
# Recoil and camera flash
self.recoil()
self.character.recoil(12)
self.world.game.cameraHandler.flash((1,1,1,0.5), 0.2)
def enterShooting(self):
self.powerLevel = 0.5
self.powerDir = 1
self.meter.show()
self.refreshMeter()
base.taskMgr.add(self.gaugeTask, "powerMeterGauge")
def gaugeTask(self, task):
self.powerLevel += globalClock.getDt() * self.powerDir
if self.powerLevel > 1:
self.powerLevel = 1
self.powerDir = -1
elif self.powerLevel < 0:
self.powerLevel = 0
self.powerDir = 1
self.refreshMeter()
return task.cont
def refreshMeter(self):
self.meterFG.setSx(self.powerLevel)
def recoil(self):
if self.gunRecoil != None:
self.gunRecoil.finish()
self.gunRecoil = Sequence(LerpPosInterval(self.gun, 0.1, Point3(4.0, 12.0, -3.5)),
LerpPosInterval(self.gun, 0.6, Point3(4.0, 14.0, -3.5), Point3(4.0, 12.0, -3.5)))
self.gunRecoil.start()