本文整理汇总了Python中pandac.PandaModules.TextNode.generate方法的典型用法代码示例。如果您正苦于以下问题:Python TextNode.generate方法的具体用法?Python TextNode.generate怎么用?Python TextNode.generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandac.PandaModules.TextNode
的用法示例。
在下文中一共展示了TextNode.generate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addball
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import generate [as 别名]
def addball(self, NUM):
# pos = Vec3(random.uniform(-7, 7), random.uniform(-7, 7), random.uniform(-7, 7))
if self.model == True and self.text == True:
self.f.remove()
self.newTextNodePath2.remove()
a = random.uniform(-7, 7)
b = random.uniform(-7, 7)
c = random.uniform(-7, 7)
pos = Vec3(a, b, c)
tex = loader.loadTexture("cra/textures/e.jpeg")
self.f = loader.loadModel("cra/models/ball1.egg")
self.f.setTexGen(TextureStage.getDefault(), TexGenAttrib.MEyeSphereMap)
self.f.setTexture(tex, 1)
self.f.setPos(pos)
self.f.setScale(1.5)
self.f.reparentTo(render)
self.f.setCollideMask(0)
text = NUM
newTextNode = TextNode("text") # Create a new TextNode
newTextNode.setText(text) # Set the TextNode text
newTextNode.setAlign(TextNode.ACenter) # Set the text align
newTextNode.setWordwrap(6.0) # Set the word wrap
text_generate = newTextNode.generate() # Generate a NodePath
self.newTextNodePath2 = render.attachNewNode(text_generate) # Attach the NodePath to the render tree
self.newTextNodePath2.setPos(a, b, (c + 0.3))
self.newTextNodePath2.setColor(255, 0, 0, 1)
self.newTextNodePath2.setScale(0.6)
return pos
示例2: addball
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import generate [as 别名]
def addball(self, NUM):
X = "Person_pics/" + NUM + '.jpeg'
tex = loader.loadTexture(X)
f = loader.loadModel("models/ball1.egg")
f.setTexGen(TextureStage.getDefault(), TexGenAttrib.MEyeSphereMap)
a = random.uniform((-8 + (self.addx)), (8 + self.addx))
b = random.uniform((-8 + (self.addy)), (8 + self.addy))
c = random.uniform((-8 + (self.addz)), (8 + self.addz))
pos = Vec3(a,b,c)
f.setTexture(tex, 1)
f.setPos(pos)
f.setScale(.8)
f.reparentTo(render)
f.setCollideMask(0)
text = NUM
newTextNode = TextNode('text') # Create a new TextNode
newTextNode.setText(text) # Set the TextNode text
newTextNode.setAlign(TextNode.ACenter) # Set the text align
newTextNode.setWordwrap(6.0) # Set the word wrap
text_generate = newTextNode.generate() # Generate a NodePath
newTextNodePath = render.attachNewNode(text_generate) # Attach the NodePath to the render tree
newTextNodePath.setPos(a,b,(c + 0.6))
newTextNodePath.setColor(255, 0, 0,1)
newTextNodePath.setScale(.5)
return pos
示例3: addball
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import generate [as 别名]
def addball(self, NUM):
#pos = Vec3(random.uniform(-7, 7), random.uniform(-7, 7), random.uniform(-7, 7))
a = random.uniform((-8 + (self.addx)), (8 + self.addx))
b = random.uniform((-8 + (self.addy)), (8 + self.addy))
c = random.uniform((-8 + (self.addz)), (8 + self.addz))
pos = Vec3(a,b,c)
f = loader.loadModel("models/ball")
f.setPos(pos)
f.setScale(.8)
f.reparentTo(render)
f.setCollideMask(0)
text = NUM
newTextNode = TextNode('text') # Create a new TextNode
newTextNode.setText(text) # Set the TextNode text
newTextNode.setAlign(TextNode.ACenter) # Set the text align
newTextNode.setWordwrap(6.0) # Set the word wrap
text_generate = newTextNode.generate() # Generate a NodePath
newTextNodePath = render.attachNewNode(text_generate) # Attach the NodePath to the render tree
newTextNodePath.setPos(a,b,(c + 0.6))
newTextNodePath.setColor(255, 0, 0,1)
newTextNodePath.setScale(2)
#self.V = self.V + 1
#self.negy = (10%(self.V))*(-7)
#self.posy = (10%(self.V)+3)*(-7)
return pos
示例4: center
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import generate [as 别名]
def center(self, prsn_name , m):
if (m < 5):
self.i = self.i + 1
X = 'Person_pics/' + prsn_name + '.jpeg'
tex = loader.loadTexture(X)
self.sphere = loader.loadModel("models/ball1")
self.sphere.setTexGen(TextureStage.getDefault(), TexGenAttrib.MEyeSphereMap)
self.sphere.setTexture(tex, 1)
self.sphere.reparentTo(render)
gx = self.sx
y = self.sy
z = self.sz
pos = (gx,y,z)
self.addx =gx
self.addy =y
self.addz =z
self.sphere.setPos(1, self.sy, 1)
self.sphere.setScale(.9)
self.sy = -14*(self.i)
else :
x = m/5
j = m%5
if ( j == 0):
self.sy = 1
self.i = 1
else :
self.sy = -14*(self.i)
self.sx = 40*(x)
self.sphere = loader.loadModel("models/ball1")
self.sphere.reparentTo(render)
gx = self.sx
y = self.sy
z = self.sz
self.addx =gx
self.addy =y
self.addz =z
pos = (gx, y, 1)
self.sphere.setPos(pos)
#self.sphere.setScale(.9)
self.i = self.i + 1
self.sphere.setScale(.9)
text = prsn_name
newTextNode = TextNode('text') # Create a new TextNode
newTextNode.setText(text) # Set the TextNode text
newTextNode.setAlign(TextNode.ACenter) # Set the text align
newTextNode.setWordwrap(6.0) # Set the word wrap
text_generate = newTextNode.generate() # Generate a NodePath
newTextNodePath = render.attachNewNode(text_generate) # Attach the NodePath to the render tree
newTextNodePath.setPos(gx, y, (z + 2))
newTextNodePath.setColor(0, 0, 255,1)
newTextNodePath.setScale(.5)
return pos
示例5: center
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import generate [as 别名]
def center(self, prsn_name):
self.sphere = loader.loadModel("models/ball")
self.sphere.reparentTo(render)
self.sphere.setPos(1, 1, 1)
self.sphere.setScale(.9)
text = prsn_name
newTextNode = TextNode('text') # Create a new TextNode
newTextNode.setText(text) # Set the TextNode text
newTextNode.setAlign(TextNode.ACenter) # Set the text align
newTextNode.setWordwrap(6.0) # Set the word wrap
text_generate = newTextNode.generate() # Generate a NodePath
newTextNodePath = render.attachNewNode(text_generate) # Attach the NodePath to the render tree
newTextNodePath.setPos(1, 1, 2)
newTextNodePath.setColor(255, 0, 0,1)
newTextNodePath.setScale(.8)
示例6: createText
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import generate [as 别名]
def createText(self, text, pos=(0.0, 0.0), align=TextNode.ACenter, scale=None, colour=None):
if colour is None:
colour = self.colour
if scale is None:
scale = self.default_element_scale
text_node = TextNode("text")
text_node.setText(text)
text_node.setGlyphScale(scale)
text_node.setAlign(align)
text_node.setFont(self.unicodefont)
text_node.setTextColor(colour[0], colour[1], colour[2], colour[3])
generated_text = text_node.generate()
text_node_path = render2d.attachNewNode(generated_text)
text_node_path.setPos(pos[0], 0.0, pos[1])
return text_node, text_node_path
示例7: centerF
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import generate [as 别名]
def centerF(self, prsn_name):
if self.model == True and self.text == True:
self.sphere.remove()
self.newTextNodePath1.remove()
X = "cra/textures/" + prsn_name + ".jpeg"
tex = loader.loadTexture(X)
self.sphere = loader.loadModel("cra/models/ball1.egg")
self.sphere.setTexGen(TextureStage.getDefault(), TexGenAttrib.MEyeSphereMap)
self.sphere.setTexture(tex, 1)
self.sphere.reparentTo(render)
self.sphere.setPos(1, 1, 1)
self.sphere.setScale(2.5)
text = prsn_name
newTextNode = TextNode("text") # Create a new TextNode
newTextNode.setText(text) # Set the TextNode text
newTextNode.setAlign(TextNode.ACenter) # Set the text align
newTextNode.setWordwrap(6.0) # Set the word wrap
text_generate = newTextNode.generate() # Generate a NodePath
self.newTextNodePath1 = render.attachNewNode(text_generate) # Attach the NodePath to the render tree
self.newTextNodePath1.setPos(1, 1, 2)
self.newTextNodePath1.setColor(255, 0, 0, 1)
self.newTextNodePath1.setScale(0.8)
示例8: DistributedPartyCatchActivity
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import generate [as 别名]
class DistributedPartyCatchActivity(DistributedPartyActivity, DistributedPartyCatchActivityBase):
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedPartyCatchActivity')
DropTaskName = 'dropSomething'
DropObjectPlurals = {'apple': TTLocalizer.PartyCatchActivityApples,
'orange': TTLocalizer.PartyCatchActivityOranges,
'pear': TTLocalizer.PartyCatchActivityPears,
'coconut': TTLocalizer.PartyCatchActivityCoconuts,
'watermelon': TTLocalizer.PartyCatchActivityWatermelons,
'pineapple': TTLocalizer.PartyCatchActivityPineapples,
'anvil': TTLocalizer.PartyCatchActivityAnvils}
class Generation:
def __init__(self, generation, startTime, startNetworkTime, numPlayers):
self.generation = generation
self.startTime = startTime
self.startNetworkTime = startNetworkTime
self.numPlayers = numPlayers
self.hasBeenScheduled = False
self.droppedObjNames = []
self.dropSchedule = []
self.numItemsDropped = 0
self.droppedObjCaught = {}
def __init__(self, cr):
DistributedPartyActivity.__init__(self, cr, PartyGlobals.ActivityIds.PartyCatch, PartyGlobals.ActivityTypes.HostInitiated, wantRewardGui=True)
self.setUsesSmoothing()
self.setUsesLookAround()
self._sNumGen = SerialNumGen()
def getTitle(self):
return TTLocalizer.PartyCatchActivityTitle
def getInstructions(self):
return TTLocalizer.PartyCatchActivityInstructions % {'badThing': self.DropObjectPlurals['anvil']}
def generate(self):
DistributedPartyActivity.generate(self)
self.notify.info('localAvatar doId: %s' % base.localAvatar.doId)
self.notify.info('generate()')
self._generateFrame = globalClock.getFrameCount()
self._id2gen = {}
self._orderedGenerations = []
self._orderedGenerationIndex = None
rng = RandomNumGen(self.doId)
self._generationSeedBase = rng.randrange(1000)
self._lastDropTime = 0.0
return
def getCurGeneration(self):
if self._orderedGenerationIndex is None:
return
return self._orderedGenerations[self._orderedGenerationIndex]
def _addGeneration(self, generation, startTime, startNetworkTime, numPlayers):
self._id2gen[generation] = self.Generation(generation, startTime, startNetworkTime, numPlayers)
i = 0
while 1:
if i >= len(self._orderedGenerations):
break
gen = self._orderedGenerations[i]
startNetT = self._id2gen[gen].startTime
genId = self._id2gen[gen].generation
if startNetT > startNetworkTime:
break
if startNetT == startNetworkTime and genId > generation:
break
i += 1
self._orderedGenerations = self._orderedGenerations[:i] + [generation] + self._orderedGenerations[i:]
if self._orderedGenerationIndex is not None:
if self._orderedGenerationIndex >= i:
self._orderedGenerationIndex += 1
def _removeGeneration(self, generation):
del self._id2gen[generation]
i = self._orderedGenerations.index(generation)
self._orderedGenerations = self._orderedGenerations[:i] + self._orderedGenerations[i + 1:]
if self._orderedGenerationIndex is not None:
if len(self._orderedGenerations):
if self._orderedGenerationIndex >= i:
self._orderedGenerationIndex -= 1
else:
self._orderedGenerationIndex = None
return
def announceGenerate(self):
self.notify.info('announceGenerate()')
self.catchTreeZoneEvent = 'fence_floor'
DistributedPartyActivity.announceGenerate(self)
def load(self, loadModels = 1, arenaModel = 'partyCatchTree'):
self.notify.info('load()')
DistributedPartyCatchActivity.notify.debug('PartyCatch: load')
self.activityFSM = CatchActivityFSM(self)
if __dev__:
for o in xrange(3):
print {0: 'SPOTS PER PLAYER',
1: 'DROPS PER MINUTE PER SPOT DURING NORMAL DROP PERIOD',
2: 'DROPS PER MINUTE PER PLAYER DURING NORMAL DROP PERIOD'}[o]
for i in xrange(1, self.FallRateCap_Players + 10):
#.........这里部分代码省略.........
示例9: DistributedCogThiefGame
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import generate [as 别名]
#.........这里部分代码省略.........
result = Task.cont
if hasattr(self, 'rewardPanel'):
self.rewardPanel['text'] = str(score)
if task.curScore != score:
if hasattr(self, 'jarIval'):
self.jarIval.finish()
s = self.rewardPanel.getScale()
self.jarIval = Parallel(Sequence(self.rewardPanel.scaleInterval(0.15, s * 3.0 / 4.0, blendType='easeOut'), self.rewardPanel.scaleInterval(0.15, s, blendType='easeIn')), SoundInterval(self.sndRewardTick), name='cogThiefGameRewardJarThrob')
self.jarIval.start()
task.curScore = score
else:
result = Task.done
return result
def startGameWalk(self):
self.gameWalk.start()
def stopGameWalk(self):
self.gameWalk.stop()
def getCogThief(self, cogIndex):
return self.cogInfo[cogIndex]['suit']
def isToonPlayingHitTrack(self, avId):
if avId in self.toonHitTracks:
track = self.toonHitTracks[avId]
if track.isPlaying():
return True
return False
def getNumCogs(self):
result = base.config.GetInt('cog-thief-num-cogs', 0)
if not result:
safezone = self.getSafezoneId()
result = CTGG.calculateCogs(self.numPlayers, safezone)
return result
def getCogSpeed(self):
result = 6.0
safezone = self.getSafezoneId()
result = CTGG.calculateCogSpeed(self.numPlayers, safezone)
return result
def showResults(self):
if not self.gameIsEnding:
self.gameIsEnding = True
for barrel in self.barrels:
barrel.wrtReparentTo(render)
for key in self.cogInfo:
thief = self.cogInfo[key]['suit']
thief.suit.setPos(100, 0, 0)
thief.suit.hide()
self.__killRewardCountdown()
self.stopGameWalk()
numBarrelsSaved = len(self.barrels) - len(self.stolenBarrels)
resultStr = ''
if numBarrelsSaved == len(self.barrels):
resultStr = TTLocalizer.CogThiefPerfect
elif numBarrelsSaved > 1:
resultStr = TTLocalizer.CogThiefBarrelsSaved % {'num': numBarrelsSaved}
elif numBarrelsSaved == 1:
resultStr = TTLocalizer.CogThiefBarrelSaved % {'num': numBarrelsSaved}
else:
resultStr = TTLocalizer.CogThiefNoBarrelsSaved
perfectTextSubnode = hidden.attachNewNode(self.__genText(resultStr))
perfectText = hidden.attachNewNode('perfectText')
perfectTextSubnode.reparentTo(perfectText)
frame = self.__textGen.getCardActual()
offsetY = -abs(frame[2] + frame[3]) / 2.0
perfectTextSubnode.setPos(0, 0, offsetY)
perfectText.setColor(1, 0.1, 0.1, 1)
def fadeFunc(t, text = perfectText):
text.setColorScale(1, 1, 1, t)
def destroyText(text = perfectText):
text.removeNode()
def safeGameOver(self = self):
if not self.frameworkFSM.isInternalStateInFlux():
self.gameOver()
textTrack = Sequence(Func(perfectText.reparentTo, aspect2d), Parallel(LerpScaleInterval(perfectText, duration=0.5, scale=0.3, startScale=0.0), LerpFunctionInterval(fadeFunc, fromData=0.0, toData=1.0, duration=0.5)), Wait(2.0), Parallel(LerpScaleInterval(perfectText, duration=0.5, scale=1.0), LerpFunctionInterval(fadeFunc, fromData=1.0, toData=0.0, duration=0.5, blendType='easeIn')), Func(destroyText), WaitInterval(0.5), Func(safeGameOver))
if numBarrelsSaved == len(self.barrels):
soundTrack = SoundInterval(self.sndPerfect)
else:
soundTrack = Sequence()
self.resultIval = Parallel(textTrack, soundTrack)
self.resultIval.start()
def __genText(self, text):
self.__textGen.setText(text)
return self.__textGen.generate()
def getIntroTrack(self):
base.camera.setPosHpr(0, -13.66, 13.59, 0, -51.6, 0)
result = Sequence(Wait(2), LerpPosHprInterval(base.camera, 13, Point3(self.cameraTopView[0], self.cameraTopView[1], self.cameraTopView[2]), Point3(self.cameraTopView[3], self.cameraTopView[4], self.cameraTopView[5]), blendType='easeIn'))
return result
示例10: center
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import generate [as 别名]
def center(self, prsn_name , m):
if (m < 5):
#creating the card without glow map
cardMaker = CardMaker("cubemaker")
card = render.attachNewNode(cardMaker.generate())
#base.saveSphereMap('k.jpeg', size = 256)
#tex = loader.loadTexture('k.jpeg')
#card.setTexture(tex)
card.setDepthWrite(True)
card.setTransparency(True)
self.sphere = loader.loadModel("models/ball")
self.sphere.setTexGen(TextureStage.getDefault(), TexGenAttrib.MEyeSphereMap)
#self.sphere.setTexture(tex, 1)
self.sphere.reparentTo(render)
self.sphere.setPos(1, 1, 1)
self.sphere.setScale(2.5)
self.i = self.i + 1
gx = self.sx
y = self.sy
z = self.sz
pos = (gx,y,z)
self.addx =gx
self.addy =y
self.addz =z
self.sphere.setPos(1, self.sy, 1)
self.sphere.setScale(1)
self.sy = -14*(self.i)
else :
x = m/5
j = m%5
if ( j == 0):
self.sy = 1
self.i = 1
else :
self.sy = -14*(self.i)
self.sx = 40*(x)
self.sphere = loader.loadModel("models/ball")
self.sphere.reparentTo(render)
gx = self.sx
y = self.sy
z = self.sz
self.addx =gx
self.addy =y
self.addz =z
pos = (gx, y, 1)
self.sphere.setPos(pos)
#self.sphere.setScale(.9)
self.i = self.i + 1
self.sphere.setScale(1)
text = prsn_name
newTextNode = TextNode('text') # Create a new TextNode
newTextNode.setText(text) # Set the TextNode text
newTextNode.setAlign(TextNode.ACenter) # Set the text align
newTextNode.setWordwrap(6.0) # Set the word wrap
text_generate = newTextNode.generate() # Generate a NodePath
newTextNodePath = render.attachNewNode(text_generate) # Attach the NodePath to the render tree
newTextNodePath.setPos(gx, y, (z + 2))
newTextNodePath.setColor(0, 0, 255,1)
newTextNodePath.setScale(2)
return pos