当前位置: 首页>>代码示例>>Python>>正文


Python CardMaker.setUvRange方法代码示例

本文整理汇总了Python中panda3d.core.CardMaker.setUvRange方法的典型用法代码示例。如果您正苦于以下问题:Python CardMaker.setUvRange方法的具体用法?Python CardMaker.setUvRange怎么用?Python CardMaker.setUvRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在panda3d.core.CardMaker的用法示例。


在下文中一共展示了CardMaker.setUvRange方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: loadFlatQuad

# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setUvRange [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
开发者ID:RandomToon,项目名称:Toontown-2,代码行数:35,代码来源:IssueFrame.py

示例2: setupTexture

# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setUvRange [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()
开发者ID:nate97,项目名称:src,代码行数:29,代码来源:HtmlView.py

示例3: MatPlotLibDemo

# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setUvRange [as 别名]
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
开发者ID:TheCheapestPixels,项目名称:panda_examples,代码行数:37,代码来源:matplotlib_to_panda3d.py

示例4: playVideo

# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setUvRange [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)
开发者ID:grimfang,项目名称:rising_reloaded,代码行数:33,代码来源:movieManager.py

示例5: makeCube

# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setUvRange [as 别名]
def makeCube(geom, x, y, z, scale=1.0, texpos=None, colors=False):
    """
    Function that adds six cards to a GeomNode to form a cube
    
    geom: GeomNode to add cards to
    x, y, z: Position offset
    scale: Optional, Scale factor, cube is 1x1x1 by default
    texpos: Optional, Dictionary of tuples with texture co-ordinates
            Tuple has Point2 for top-left and Point2 for bottom-right
            Faces are "front", "back", "left", "right", "top", "bottom"
    colors: Optional, if True set different color for each face for debugging
            (see cardcolors)
    """
    cardmaker = CardMaker("cardmaker")
    
    mycards = deepcopy(CARDS)
    for k, i in mycards.iteritems():
        points = i
        for j in points:
            j += Point3(x, y, z)
            j *= scale
        cardmaker.setFrame(*points)
        
        if texpos:
            cardmaker.setUvRange(*texpos[k])
        if colors:
            cardmaker.setColor(*CARDCOLORS[k])
        geom.addGeomsFrom(cardmaker.generate())
开发者ID:TazeTSchnitzel,项目名称:BlockGame,代码行数:30,代码来源:render.py

示例6: FirstTry

# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setUvRange [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
开发者ID:indygfx,项目名称:opticfoo,代码行数:35,代码来源:firsttry.py

示例7: getRenderMapCam

# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setUvRange [as 别名]
    def getRenderMapCam(self, rawTile, inputMaps, shader, size):
        """
        Sets up scene and cam for rendering the map
        Returns the cam
        """
        margin=texMargin(size)
        
        altRender=NodePath("newRender")

        # setup square orthographic cam
        altCam=NodePath(Camera("renderMapCam"))
        altCam.reparentTo(altRender)   
        altCam.setPos(.5,-1,.5) 

        oLens = OrthographicLens()
        oLens.setFilmSize(1+margin*2, 1+margin*2)
        altCam.node().setLens(oLens)
        
         # Make a card on which the shader will render the map
        c=CardMaker("MapCardMaker")
        c.setUvRange(0-margin,1+margin,0-margin,1+margin)
        c.setFrame(0-margin,1+margin,0-margin,1+margin)
        mapCard=NodePath(c.generate())
        
        mapCard.setPos(0,0,0)   
        mapCard.setShader(shader.shader)
        mapCard.setShaderInput("offset",rawTile.x,rawTile.y,0,0)
        mapCard.setShaderInput("scale",rawTile.scale,0,0,0)

        for m in inputMaps:
            texStage=TextureStage(m.name+"stage")
            mapCard.setTexture(texStage,m.tex)
        
        for p in shader.shaderTex:
            mapCard.setTexture(*p)
        
        mapCard.reparentTo(altRender)
        
        # Comment out this line to cause the bug with multiple textures requireing an extra frame to work properly
        altRender.prepareScene(base.win.getGsg())
        
        return altCam
开发者ID:jorjuato,项目名称:Panda3D-Terrain-System,代码行数:44,代码来源:gpuBakery.py

示例8: CameraApp

# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setUvRange [as 别名]
class CameraApp(GuiHandler):
    __ImageDir = "data/images"
    
    def __init__(self, device):
        GuiHandler.__init__(self)
        self.func3 = "Si"
        self.func2 = ""
        self.func1 = "No"
        self.title = "Guardar?"
        self.parent = device
        self.video_mode = False
        
        option = WebcamVideo.get_option(0)
        self.texture = MovieTexture(option)
        self.texture.setKeepRamImage(True)
    	#self.texture = OpenCVTexture()
    	#self.texture.fromCamera()
    	scale = self.texture.getTexScale()
    	print scale
    	#self.texture = OpenCVTexture()
    	self.card = CardMaker('webcam')
    	self.card.setFrame(-scale[0], scale[0], -scale[1], scale[1])
    	self.card.setUvRange(Point2(scale[0], 0), Point2(0, scale[1]))
    	
        self.card = render.attachNewNode(self.card.generate())
        
        screen = self.parent.get_screen()    
        self.card.reparentTo(screen.getParent())
        self.card.setTransform(screen.getTransform())
    	
        self.card.setSx(0.49)
        self.card.setSz(0.394)
        self.card.setHpr(0, 270, 0)
        self.card.setPos(0.004, 0.335, 0.1)
        self.card.hide()

    def activate(self, events):
        self.toggle_view(True)
        events.add_action("boton_izq1", self.quit)
        events.add_action("centro", self.shoot)
        events.add_action("boton_der", self.shoot)
        events.add_action("boton_izq", self.cancel)

    def shoot(self):
        if self.video_mode:
            max = self.texture.getXSize() * self.texture.getYSize()
            data = array.array('B')
            data.fromstring(self.texture.getRamImageAs("BGR1").getData())

            img = cairo.ImageSurface.create_for_data(data, cairo.FORMAT_ARGB32,
                       self.texture.getXSize(), self.texture.getYSize(),
                       self.texture.getXSize() * 4)

            self.cam_shot = cairo.ImageSurface(cairo.FORMAT_ARGB32,
                                               self.texture.getVideoWidth(),
                                               self.texture.getVideoHeight())

            ctx = cairo.Context(self.cam_shot)
            ctx.set_source_surface(img, 0 , 0)
            ctx.paint() 
            
            self.paint_background()
            self.cr.set_source_surface(self.draw_viewer(self.cam_shot), 30,
                                       self.top_margin + 5)
            self.cr.paint()
            self.paint_foreground()
            self.surface.write_to_png(self.get_output())
            self.parent.repaint()
            self.toggle_view(False)
        else:
            print "Saving..."
            pic_path = CameraApp.__ImageDir + "/p" + Util.generate_id() + ".png"
            print pic_path
            self.cam_shot.write_to_png(pic_path)
            self.toggle_view(True)

    def paint_scene(self):
        drawer_width = self.width - 60
        drawer_height = 2 * self.height / 3
        
        surface  = cairo.ImageSurface (cairo.FORMAT_ARGB32, self.width, self.height)
        context = cairo.Context(surface)
        
        scale_x = float(self.width) / float(self.cam_shot.get_width())
        scale_y = float(self.height) / float(self.cam_shot.get_height())
        
        
        context.scale(scale_x, scale_y)
        
        context.set_source_surface(self.cam_shot, 0, 0)
        context.paint()
        
        return surface
        
    def cancel(self):
        self.cam_shot = None
        self.toggle_view(True)
        
    def draw_viewer(self, image_surface):
        drawer_width = self.width - 60
#.........这里部分代码省略.........
开发者ID:Monolite,项目名称:evdp,代码行数:103,代码来源:CameraApp.py


注:本文中的panda3d.core.CardMaker.setUvRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。