本文整理汇总了Python中panda3d.core.CardMaker类的典型用法代码示例。如果您正苦于以下问题:Python CardMaker类的具体用法?Python CardMaker怎么用?Python CardMaker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CardMaker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _createMapTextureCard
def _createMapTextureCard(self):
mapImage = PNMImage(MAP_RESOLUTION, MAP_RESOLUTION)
mapImage.fill(*self._bgColor)
fgColor = VBase4D(*self._fgColor)
for x in xrange(self._mazeHeight):
for y in xrange(self._mazeWidth):
if self._mazeCollTable[y][x] == 1:
ax = float(x) / self._mazeWidth * MAP_RESOLUTION
invertedY = self._mazeHeight - 1 - y
ay = float(invertedY) / self._mazeHeight * MAP_RESOLUTION
self._drawSquare(mapImage, int(ax), int(ay), 10, fgColor)
mapTexture = Texture('mapTexture')
mapTexture.setupTexture(Texture.TT2dTexture, self._maskResolution, self._maskResolution, 1, Texture.TUnsignedByte, Texture.FRgba)
mapTexture.setMinfilter(Texture.FTLinear)
mapTexture.load(mapImage)
mapTexture.setWrapU(Texture.WMClamp)
mapTexture.setWrapV(Texture.WMClamp)
mapImage.clear()
del mapImage
cm = CardMaker('map_cardMaker')
cm.setFrame(-1.0, 1.0, -1.0, 1.0)
map = self.attachNewNode(cm.generate())
map.setTexture(mapTexture, 1)
return map
示例2: MatPlotLibDemo
class MatPlotLibDemo(ShowBase):
def __init__(self):
ShowBase.__init__(self)
base.setFrameRateMeter(True)
m = loader.loadModel("models/smiley")
m.reparent_to(render)
m.set_pos(0, 5, 0)
x_size, y_size = 640, 480
xy_ratio = float(y_size) / float(x_size)
self.plot = Plot(x_size, y_size)
self.input_img = PNMImage(x_size, y_size)
self.input_tex = Texture()
self.input_tex.load(self.input_img)
self.card = CardMaker('pygame_card')
self.card.setUvRange(Point2(0, 1), # ll
Point2(1, 1), # lr
Point2(1, 0), # ur
Point2(0, 0)) # ul
self.screen = render.attach_new_node(self.card.generate())
self.screen.set_scale(1, 1, xy_ratio)
self.screen.set_pos(-0.5, 2, -0.5 * xy_ratio)
self.screen.setTexture(self.input_tex)
# FIXME: Apparently mpl's print_to_buffer() doesn't write
# alpha values properly.
self.screen.setTransparency(TransparencyAttrib.MAlpha)
taskMgr.add(self.update, "update plot")
def update(self, task):
self.input_tex.set_ram_image_as(self.plot.draw(), "RGBA")
return task.cont
示例3: __init__
def __init__(self):
ShowBase.__init__(self)
cm = CardMaker('grass')
cm.setFrame(-1, 1, -1, 1)
grass1 = render.attachNewNode(cm.generate())
grass2 = render.attachNewNode(cm.generate())
grass1.setTexture(loader.loadTexture("data/env/grass1.png"), 1)
grass2.setTexture(loader.loadTexture("data/env/grass2.png"), 1)
grass1.setTransparency(True)
grass2.setTransparency(True)
grass1.setBillboardPointEye()
grass2.setBillboardPointEye()
grass1.setHpr(0, -40, 0)
grass2.setHpr(0, -40, 0)
grass1.setPos(0, 1, -0.4)
grass2.setPos(0, 1, -0.3)
self.taskMgr.add(self.panCameraTask, "PanCameraTask")
示例4: __createAnimationSequence__
def __createAnimationSequence__(self,name,sprite_images,sprites_time,is_left = False):
"""
Creates the sequence node that plays these images
"""
seq = SpriteSequencePlayer(name)
for i in range(0,len(sprite_images)):
txtr = sprite_images[i]
w = txtr.getXSize()
h = txtr.getYSize()
# creating CardMaker to hold the texture
cm = CardMaker(name + str(i))
cm.setFrame(0,w,-h,0 ) # This configuration places the image's topleft corner at the origin
card = NodePath(cm.generate())
card.setTexture(txtr)
seq.addChild(card.node(),i)
seq.addFrame(card.node(),i,sprites_time[i])
# offseting image
xoffset = float(txtr.axisx + (-w if is_left else 0))
yoffset = float(txtr.axisy)
card.setPos(Vec3(xoffset,0,yoffset))
AnimationActor.LOGGER.debug("Animation %s Sprite [%i] image size %s and offset %s."%( name,i, str((w,h)), str((txtr.axisx,txtr.axisy)) ) )
return seq
示例5: setup
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)
示例6: __init__
def __init__(self, world, attach, name = '', position = Vec3(0,0,0), orientation = Vec3(0,0,0), size = (32, 32)):
cm=CardMaker('')
cm.setFrame(0,1,0,1)
floor = render.attachNewNode(PandaNode("floor"))
tex = loader.loadTexture('media/'+'ground.png')
tex.setMagfilter(Texture.FTNearest)
tex.setMinfilter(Texture.FTNearest)
for y in range(size[0]):
for x in range(size[1]):
nn = floor.attachNewNode(cm.generate())
nn.setP(-90)
nn.setPos((x), (y), 0)
floor.setTexture(tex)
floor.flattenStrong()
myMaterial = Material()
myMaterial.setShininess(0) #Make this material shiny
myMaterial.setAmbient(VBase4(0.5,.5,.5,1)) #Make this material blue
myMaterial.setDiffuse(VBase4(.5,.5,.5,1))
nn.setMaterial(myMaterial)
shape = BulletPlaneShape(Vec3(0, 0, 1), 0)
StaticWorldObject.__init__(self, world, attach, name, position, shape, orientation) ##Mass must be zero.
self._nodePath.node().setFriction(1)
示例7: register
def register(self, render, camera, keys):
State.register(self, render, camera, keys)
cm = CardMaker('CardMaker-Title')
tex = loadTexture('titlescreen.png')
cm.setFrame(-1, 1, -1, 1)
self.bg = self.node.attachNewNode(cm.generate())
self.bg.setPos(0, 0, 0)
self.bg.setTexture(tex)
menuActions = {'up': (Menu.previousOpt, self.menu),
'down': (Menu.nextOpt, self.menu),
'action': (self.selectOption, None)
}
self.menu.registerKeys(keys, menuActions)
self.title = OnscreenText(text="", mayChange = True , style=2,
fg=(1,1,1,1), pos=(0, 0.75), scale = 0.2) # is this used??
self.text = {}
id=0
for opt in self.menu.options:
self.text[opt] = OnscreenText(text=opt, mayChange = True , style=2, fg=(1,1,1,1), pos=(0, -0.3 - 0.15*id), scale = .1)
id+=1
self.title.reparentTo(self.node)
for opt in self.text.keys():
self.text[opt].reparentTo(self.node)
State.register(self, render, camera, keys)
示例8: renderQuadInto
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
示例9: setupBackgroundImage
def setupBackgroundImage(self):
image_file = Filename(TestGameBase.__BACKGROUND_IMAGE_PATH__)
# check if image can be loaded
img_head = PNMImageHeader()
if not img_head.readHeader(image_file ):
raise IOError("PNMImageHeader could not read file %s. Try using absolute filepaths"%(image_file.c_str()))
sys.exit()
# Load the image with a PNMImage
w = img_head.getXSize()
h = img_head.getYSize()
img = PNMImage(w,h)
#img.alphaFill(0)
img.read(image_file)
texture = Texture()
texture.setXSize(w)
texture.setYSize(h)
texture.setZSize(1)
texture.load(img)
texture.setWrapU(Texture.WM_border_color) # gets rid of odd black edges around image
texture.setWrapV(Texture.WM_border_color)
texture.setBorderColor(LColor(0,0,0,0))
# creating CardMaker to hold the texture
cm = CardMaker('background')
cm.setFrame(-0.5*w,0.5*w,-0.5*h,0.5*h) # This configuration places the image's topleft corner at the origin (left, right, bottom, top)
background_np = NodePath(cm.generate())
background_np.setTexture(texture)
background_np.reparentTo(self.render)
background_np.setPos(TestGameBase.__BACKGROUND_POSITION__)
background_np.setScale(TestGameBase.__BACKGROUND_SCALE__)
示例10: draw_image
def draw_image(self, image, box, identifier="", parameters=None):
cm = CardMaker(identifier)
tex = self.get_loader().loadTexture(image.value)
if box.mode == "pixels":
parent2d = self.get_parent_pixel2d()
elif box.mode == "standard":
parent2d = self.get_parent_render2d()
elif box.mode == "aspect":
parent2d = self.get_parent_aspect2d()
node = NodePath(cm.generate())
node.setTexture(tex)
if parameters is not None:
if hasattr(parameters, "transparency") and parameters.transparency == True:
node.setTransparency(TransparencyAttrib.MAlpha)
node.setPos(box.x, 0, box.y + box.sizey)
node.setScale(box.sizex, 1, -box.sizey)
node.setBin("fixed", self.get_next_sortid())
node.setDepthTest(False)
node.setDepthWrite(False)
node.reparentTo(parent2d)
return (node, image, box, parameters)
示例11: __init__
def __init__(self, battleGraphics, matrixContainer):
self.battleGraphics = battleGraphics
self.matrixContainer = matrixContainer
self.curtex = loader.loadTexture(GAME+'/textures/cursor.png')
self.curtex.setMagfilter(Texture.FTNearest)
self.curtex.setMinfilter(Texture.FTNearest)
self.x = False
self.y = False
self.z = False
self.cursor = loader.loadModel(GAME+'/models/slopes/flat')
self.cursor.reparentTo( self.matrixContainer )
self.cursor.setScale(3.7)
self.cursor.setTransparency(TransparencyAttrib.MAlpha)
self.cursor.setColor( 1, 1, 1, 1 )
self.cursor.setTexture(self.curtex)
pointertex = loader.loadTexture(GAME+'/textures/pointer.png')
pointertex.setMagfilter(Texture.FTNearest)
pointertex.setMinfilter(Texture.FTNearest)
cm = CardMaker('card')
cm.setFrame(-2, 2, -2, 2)
self.pointer = render.attachNewNode(cm.generate())
self.pointer.setTexture(pointertex)
self.pointer.setTransparency(True)
self.pointer.setBillboardPointEye()
self.pointer.reparentTo(render)
self.pointer.setScale(256.0/240.0)
示例12: genArrow
def genArrow(self, pos, hpr, id):
factory = CardMaker('factory')
factory.setFrame(-.5, 0.5, -.5, 0.5)
arrowNode = factory.generate()
arrowRoot = NodePath('root')
baseArrow = NodePath(arrowNode)
baseArrow.setTransparency(1)
baseArrow.setTexture(self.boostArrowTexture)
baseArrow.reparentTo(arrowRoot)
arrow2 = baseArrow.copyTo(baseArrow)
arrow2.setPos(0, 0, 1)
arrow3 = arrow2.copyTo(arrow2)
arrowRoot.setPos(*pos)
arrowRoot.setHpr(*hpr)
baseArrow.setHpr(0, -90, 0)
baseArrow.setScale(24)
arrowRoot.reparentTo(self.geom)
trigger = 'boostArrow' + str(id)
cs = CollisionTube(Point3(0.6, -6, 0), Point3(0.6, 54, 0), 4.8)
cs.setTangible(0)
triggerEvent = 'imIn-' + trigger
cn = CollisionNode(trigger)
cn.addSolid(cs)
cn.setIntoCollideMask(BitMask32(32768))
cn.setFromCollideMask(BitMask32(32768))
cnp = NodePath(cn)
cnp.reparentTo(arrowRoot)
self.accept(triggerEvent, self.hitBoostArrow)
arrowVec = arrow2.getPos(self.geom) - baseArrow.getPos(self.geom)
arrowVec.normalize()
idStr = str(id)
cnp.setTag('boostId', idStr)
self.boostDir[idStr] = arrowVec
base.arrows.append(arrowRoot)
示例13: _createSimpleMarker
def _createSimpleMarker(self, size, color = (1, 1, 1)):
halfSize = size * 0.5
cm = CardMaker('mazemap_simple_marker')
cm.setFrame(-halfSize, halfSize, -halfSize, halfSize)
markerNP = self.maskedLayer.attachNewNode(cm.generate())
markerNP.setColor(*color)
return markerNP
示例14: add_ground
def add_ground(self):
cm = CardMaker("ground")
cm.setFrame(-1, 1, -1, 1)
ground = render.attachNewNode(cm.generate())
ground.setColor(0.5, 0.7, 0.8)
ground.lookAt(0, 0, -1)
groundGeom = OdePlaneGeom(self.space, Vec4(0, 0, 1, 0))
示例15: constructModel
def constructModel(self):
self.obstacles = []
self.blocks = []
self.liftables = []
if self.nodePath != None:
self.nodePath.removeNode()
self.cards = []
self.nodePath = NodePath("Map")
#the ground
cm = CardMaker('CardMaker')
cm.setFrame(-2,2,-2,2)
card = self.nodePath.attachNewNode(cm.generate())
card.setTexture(tex)
for y in range(self.height):
for x in range(self.width):
# TO DO: MUDAR NOME
a = {"block": self.blocks,
"obstacle": self.obstacles,
"tree": self.obstacles,
"bush" : self.obstacles,
"liftable": self.liftables}
tType = self.tileType(Map.COLLISION, (x,y))
if tType != 'free':
a[tType].append(self.makeObject(tType, x,y))