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


Python CardMaker.setHpr方法代码示例

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


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

示例1: CameraApp

# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import setHpr [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.setHpr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。