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


Python WindowProperties.setOrigin方法代码示例

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


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

示例1: setupWindow

# 需要导入模块: from panda3d.core import WindowProperties [as 别名]
# 或者: from panda3d.core.WindowProperties import setOrigin [as 别名]
    def setupWindow(self, windowType, x, y, width, height,
                    parent):
        """ Applies the indicated window parameters to the prc
        settings, for future windows; or applies them directly to the
        main window if the window has already been opened.  This is
        called by the browser. """

        if self.started and base.win:
            # If we've already got a window, this must be a
            # resize/reposition request.
            wp = WindowProperties()
            if x or y or windowType == 'embedded':
                wp.setOrigin(x, y)
            if width or height:
                wp.setSize(width, height)
            if windowType == 'embedded':
                wp.setParentWindow(parent)
            wp.setFullscreen(False)
            base.win.requestProperties(wp)
            self.windowProperties = wp
            return

        # If we haven't got a window already, start 'er up.  Apply the
        # requested setting to the prc file, and to the default
        # WindowProperties structure.

        self.__clearWindowProperties()

        if windowType == 'hidden':
            data = 'window-type none\n'
        else:
            data = 'window-type onscreen\n'

        wp = WindowProperties.getDefault()

        wp.clearParentWindow()
        wp.clearOrigin()
        wp.clearSize()

        wp.setFullscreen(False)
        if windowType == 'fullscreen':
            wp.setFullscreen(True)

        if windowType == 'embedded':
            wp.setParentWindow(parent)

        if x or y or windowType == 'embedded':
            wp.setOrigin(x, y)

        if width or height:
            wp.setSize(width, height)

        self.windowProperties = wp
        self.windowPrc = loadPrcFileData("setupWindow", data)
        WindowProperties.setDefault(wp)

        self.gotWindow = True

        # Send this call to the main thread; don't call it directly.
        messenger.send('AppRunner_startIfReady', taskChain = 'default')
开发者ID:Just-D,项目名称:panda3d,代码行数:62,代码来源:AppRunner.py

示例2: __init__

# 需要导入模块: from panda3d.core import WindowProperties [as 别名]
# 或者: from panda3d.core.WindowProperties import setOrigin [as 别名]
 def __init__(self):
     DirectObject.__init__(self)
     self.base = ShowBase()
     resolution = (1024, 768)
     wp = WindowProperties()
     wp.setSize(int(resolution[0]), int(resolution[1]))
     wp.setOrigin(0, 0)
     self.base.win.requestProperties(wp)
     # depth completely doesn't matter for this, since just 2d, and no layers
     self.depth = 0
     self.base.setBackgroundColor(115 / 255, 115 / 255, 115 / 255)
     # set up a 2d camera
     camera = self.base.camList[0]
     lens = OrthographicLens()
     lens.setFilmSize(int(resolution[0]), int(resolution[1]))
     lens.setNearFar(-100, 100)
     camera.node().setLens(lens)
     camera.reparentTo(self.base.render)
     self.accept("escape", sys.exit)
     # spread out some positions
     self.positions = [(-200, 0, -200),
                       (0, 0, -200),
                       (200, 0, -200),
                       (-200, 0, 0),
                       (0, 0, 0),
                       (200, 0, 0),
                       (-200, 0, 200),
                       (0, 0, 200),
                       (200, 0, 200)]
     self.all_smiles()
开发者ID:codedragon,项目名称:play,代码行数:32,代码来源:test_panda3d_bug.py

示例3: main

# 需要导入模块: from panda3d.core import WindowProperties [as 别名]
# 或者: from panda3d.core.WindowProperties import setOrigin [as 别名]
def main():
    # Handles CLI arguments
    p = OptionParser()
    p.add_option('-m', '--nomusic', action="store_false", dest="music", default = True, help = u"Disable music")
    p.add_option('-e', '--editor-mode', action="store_true", dest="editor", default = False, help = u"Editor mode")
    options, args = p.parse_args()
    levelname = 'level1'
    if args:
        levelname = args[0]

    # Instantiate the ShowBase
    base = ShowBase()

    # Toggle events verbosity :
    #base.messenger.toggleVerbose()

    # Set window properties:
    # - Hide mouse cursor
    # - move the window (because of the pekwm bug)
    curProps = base.win.getProperties()
    props = WindowProperties()
    props.setOrigin(curProps.getXOrigin() + 1, curProps.getYOrigin() + 1)
    props.setCursorHidden(True)
    base.win.requestProperties(props)

    # Now instantiate Gate's own stuff
    fps = FPS(base, levelname, options)
    osd = OSD(base, fps)
    mplayer = MusicPlayer(base, osd)
    if options.music:
        mplayer.play_random_track()
    player = Player(base, fps, osd)

    # And run the ShowBase
    base.run()
开发者ID:court-jus,项目名称:Gate_OpenPortal,代码行数:37,代码来源:main.py

示例4: __init__

# 需要导入模块: from panda3d.core import WindowProperties [as 别名]
# 或者: from panda3d.core.WindowProperties import setOrigin [as 别名]
    def __init__(self):
        self.base = ShowBase()
        config = {}
        execfile('cross_config.py', config)
        if not unittest:
            JoystickHandler.__init__(self)
        self.base.disableMouse()
        print('Subject is', config['subject'])
        # set up reward system
        if config['reward'] and PYDAQ_LOADED:
            self.reward = pydaq.GiveReward()
            print 'pydaq'
        else:
            self.reward = None
        self.frameTask = self.base.taskMgr.add(self.frame_loop, "frame_loop")
        if not unittest:
            wp = WindowProperties()
            wp.setSize(1280, 800)
            wp.setOrigin(0, 0)
            base.win.requestProperties(wp)
        self.crosshair = TextNode('crosshair')
        self.crosshair.setText('+')
        textNodePath = aspect2d.attachNewNode(self.crosshair)
        textNodePath.setScale(0.2)
        self.setup_inputs()
        # starting variables. "suppose" to be initiated here, which makes it silly
        # to then have them again, but kind of necessary to test. Making PyCharm happy ;-)
        self.x_mag = 0
        self.y_mag = 0
        # variables for counting how long to hold joystick
        self.js_count = 0
        # how much to push joystick before reward
        self.js_goal = config['goal']
        # (count increases before checking for goal match)
        # default is to reward for backward movement. May want
        # to make this a configuration option instead.
        # zero, all backward allowed
        # one, straight backward not rewarded
        # two, no backward rewarded
        self.backward = config['backward']
        self.forward = True
        self.right = True
        self.left = True
        # all kinds of start defaults
        self.delay_start = False
        self.reward_delay = False
        self.reward_time = config['pulseInterval']  # 200 ms
        self.reward_override = False
        self.reward_on = True
        self.current_dir = None
        self.frameTask.delay = 0

        print 'initialized'
开发者ID:codedragon,项目名称:goBananas,代码行数:55,代码来源:crossTraining.py

示例5: setup_display2

# 需要导入模块: from panda3d.core import WindowProperties [as 别名]
# 或者: from panda3d.core.WindowProperties import setOrigin [as 别名]
 def setup_display2(self, display_node):
     print 'setup display2'
     props = WindowProperties()
     props.set_cursor_hidden(True)
     props.set_foreground(False)
     if self.config.get('resolution'):
         props.setSize(700, 700)
         props.setOrigin(-int(self.config['resolution'][0] - 5), 5)
     else:
         props.setSize(300, 300)
         props.setOrigin(10, 10)
     window2 = self.base.openWindow(props=props, aspectRatio=1)
     lens = OrthographicLens()
     lens.set_film_size(2, 2)
     lens.setNearFar(-100, 100)
     self.render2d = NodePath('render2d')
     self.render2d.attach_new_node(display_node)
     camera2d = self.base.makeCamera(window2)
     camera2d.setPos(0, -10, 0)
     camera2d.node().setLens(lens)
     camera2d.reparentTo(self.render2d)
开发者ID:codedragon,项目名称:color_world,代码行数:23,代码来源:play_world.py

示例6: __init__

# 需要导入模块: from panda3d.core import WindowProperties [as 别名]
# 或者: from panda3d.core.WindowProperties import setOrigin [as 别名]
    def __init__(self):
        """
        Initialize the experiment
        """
        pydaq_loaded = PYDAQ_LOADED
        self.base = ShowBase()
        config = {}
        execfile('train_config.py', config)
        if not unittest:
            JoystickHandler.__init__(self)
        self.base.disableMouse()
        sys.stdout.write('Subject is ' + str(config['subject']) + '\n')
        self.subject = config['subject']
        self.levels_available = [[2, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6], [3, 3.1], [4, 4.1, 4.2]]

        # set up reward system
        # if unit-testing, pretend like we couldn't
        # load the module
        if unittest:
            pydaq_loaded = False
        if config['reward'] and pydaq_loaded:
            self.reward = pydaq.GiveReward()
        else:
            self.reward = None
            sys.stdout.write('Warning: reward system not on \n')

        # setup windows
        if not unittest:
            # if doing unittests, there is no window
            wp = WindowProperties()
            # wp.setSize(1280, 800)
            wp.setSize(1024, 768)
            wp.setOrigin(0, 0)
            wp.setCursorHidden(True)
            self.base.win.requestProperties(wp)
            # base.setFrameRateMeter(True)
            # initialize training file name
            self.data_file_name = ''
            self.data_file = None
            self.open_data_file(config)

        # Get initial direction, only matters for manual, random will override later
        # for bananas, changing the angle from avatar to banana, so left is negative
        # right is positive.
        if config['trainingDirection'] == 'Right':
            self.multiplier = 1
        elif config['trainingDirection'] == 'Left':
            self.multiplier = -1
        # print config['trainingDirection']
        self.last_multiplier = self.multiplier

        # get more variables from configuration
        self.side_bias = config['random_bias']
        # bring some configuration parameters into memory, so we don't need to
        # reload the config file multiple times, also allows us to change these
        # variables dynamically
        self.num_beeps = config['numBeeps']
        # not changing now, but may eventually...
        self.x_alpha = config['xHairAlpha']
        self.reward_time = config['pulseInterval']  # usually 200ms
        # amount need to hold crosshair on banana to get reward (2.3)
        # must be more than zero. At 1.5 distance, must be greater than
        # 0.5 to require stopping
        self.hold_aim = config['hold_aim']
        self.initial_speed = config['initial_turn_speed']
        self.initial_forward_speed = config['initial_forward_speed']
        self.forward_limit = config['forward_limit']
        self.training = config['training']
        if not unittest:
            sys.stdout.write('training level: ' + str(self.training) + '\n')
            if self.training < 2.2:
                sys.stdout.write('starting direction: ' + str(config['trainingDirection']) + '\n')
        # random selection used for training 2.3 and above
        self.all_random_selections = config['random_lists']
        self.current_choice = config['random_selection'] - 1
        self.random_choices = self.all_random_selections[self.current_choice]

        # Setup Graphics
        # bitmasks for collisions
        ray_mask = BitMask32(0x1)
        sphere_mask = BitMask32(0x2)
        self.mask_list = [ray_mask, sphere_mask, ray_mask | sphere_mask]
        if config['background']:
            field = self.base.loader.loadModel("models/play_space/field.bam")
            field.setPos(Point3(0, 0, 0))
            field.reparentTo(self.base.render)
            field_node_path = field.find('**/+CollisionNode')
            field_node_path.node().setIntoCollideMask(0)
            sky = self.base.loader.loadModel("models/sky/sky.bam")
            sky.setPos(Point3(0, 0, 0))
            sky.reparentTo(self.base.render)

        # set up banana
        self.banana = None
        self.banana_mask = None
        self.banana_node_path = None
        self.banana_coll_node = None
        self.load_fruit(config.get('fruit', 'banana'))

        # set up collision system and collision ray to camera
#.........这里部分代码省略.........
开发者ID:codedragon,项目名称:goBananas,代码行数:103,代码来源:trainingBananas.py

示例7: __init__

# 需要导入模块: from panda3d.core import WindowProperties [as 别名]
# 或者: from panda3d.core.WindowProperties import setOrigin [as 别名]
    def __init__(self):
        ShowBase.__init__(self)
#        self.base.enableParticles()

        # load operation map which holds state of operations
        self.operationmap = operationMap
        self.op = operationMap
        self.mode = self.op['mode']

        # sound analyzer
        self.snd = SoundAnalyzer()
        self.snd.start()


        # set up another camera to view stuff in other window
        self.disableMouse()
        props = WindowProperties()
        props.setSize(1600, 900)
        props.setUndecorated(True)
        props.setOrigin(0,0)
        self.otherWin = self.openWindow(props, makeCamera = 0)
        props = WindowProperties()
        props.setCursorHidden(True)
        self.win.requestProperties(props)
        self.win.setClearColor((0,0,0,1))
        self.otherWin.setClearColor((0,0,0,1))
        self.gridCard = CardMaker("grid")
        self.gridCard.setFrame(-10,10,-10,10)
        self.grid = self.render.attachNewNode(self.gridCard.generate())
        self.grid.setP(90)
        self.grid.setZ(-50)
        self.grid.setTwoSided(1)
        tex = self.loader.loadTexture("grid.png")
        self.grid.setTexture(tex)
        self.grid.setTransparency(TransparencyAttrib.MAlpha, 1)
        self.grid.setScale(100)
        self.grid.setAlphaScale(0.15)

        # mouse shit
        # Set the current viewing target
        self.heading = 180
        self.pitch = 0

        # allocate visuals
        self.visuals = {}
        self.factory = VisualFactory(
            loader,
            self.render,
            self.snd,
            [self.win, self.otherWin]
        )
        #self.activeVisual = visual(loader, self.render, self.snd)

        # refactor this
        self.activeVisual = self.factory.visuals['placeholder']
        self.visuals['placeholder'] = self.activeVisual
        self.otherCam = self.makeCamera(self.otherWin)
        self.camSpeed = 1.0
        self.cam.setPos(0,-100,0)
        self.camAfterMath()

        self.cam.node().setCameraMask(BitMask32.bit(0))
        self.otherCam.node().setCameraMask(BitMask32.bit(1))
        self.grid.hide(BitMask32.bit(1))

        self.hud = HUD(self)
        self.hudToggle = 1
        self.setFrameRateMeter(True)

        # movement keys
        self.accept('a', self.setOperation, ['a'])
        self.accept('a-up', self.setOperation, ['a-up'])
        self.accept('d', self.setOperation, ['d'])
        self.accept('d-up', self.setOperation, ['d-up'])
        self.accept('w', self.setOperation, ['w'])
        self.accept('w-up', self.setOperation, ['w-up'])
        self.accept('s', self.setOperation, ['s'])
        self.accept('s-up', self.setOperation, ['s-up'])
        self.accept('d', self.setOperation, ['d'])
        self.accept('d-up', self.setOperation, ['d-up'])
        self.accept('h', self.setOperation, ['h'])
        self.accept('h-up', self.setOperation, ['h-up'])
        self.accept('j', self.setOperation, ['j'])
        self.accept('j-up', self.setOperation, ['j-up'])
        self.accept('k', self.setOperation, ['k'])
        self.accept('k-up', self.setOperation, ['k-up'])
        self.accept('l', self.setOperation, ['l'])
        self.accept('l-up', self.setOperation, ['l-up'])
        self.accept('i', self.setOperation, ['i'])
        self.accept('i-up', self.setOperation, ['i-up'])
        self.accept('u', self.setOperation, ['u'])
        self.accept('u-up', self.setOperation, ['u-up'])
        self.accept('shift', self.setOperation, ['shift'])
        self.accept('shift-up', self.setOperation, ['shift-up'])
        self.accept('space', self.setOperation, ['space'])
        self.accept('space-up', self.setOperation, ['space-up'])
        self.accept('arrow_up', self.setOperation, ['arrow_up'])
        self.accept('arrow_up-up', self.setOperation, ['arrow_up-up'])
        self.accept('arrow_down', self.setOperation, ['arrow_down'])
        self.accept('arrow_down-up', self.setOperation, ['arrow_down-up'])
#.........这里部分代码省略.........
开发者ID:indygfx,项目名称:opticfoo,代码行数:103,代码来源:vrc.py

示例8: __init__

# 需要导入模块: from panda3d.core import WindowProperties [as 别名]
# 或者: from panda3d.core.WindowProperties import setOrigin [as 别名]

#.........这里部分代码省略.........
        
        # Load PDB structures
        receptor = PDBReader.read_pdb_from_file(pdb_file1)
        ligand = PDBReader.read_pdb_from_file(pdb_file2)
        receptor.move_to_origin()
        ligand.move_to_origin()
        
        # Background
        base.setBackgroundColor(0.7, 0.7, 0.7, 1.0)
        
        # Load Color maps
        color_map_cpk = CPK()
        color_map_bfactor = BFactor(min_value=-14.0, max_value=8.0, middle_value=0.0)
        
        # Load 3D model
        self.receptor_node = render.attachNewNode("Receptor")
        if full_atom:
            self.load_protein_full_atom(receptor, self.receptor_node, color_map_bfactor)
        else:
            self.load_protein_residue(receptor, self.receptor_node)
        self.receptor_node.reparentTo(render)
        
        self.ligand_node = render.attachNewNode("Ligand")
        if full_atom:
            self.load_protein_full_atom(ligand, self.ligand_node, color_map_cpk)
        else:
            self.load_protein_residue(ligand, self.ligand_node)
        self.ligand_node.reparentTo(render)
        
        # Ambient lights
        self.alight = AmbientLight('alight')
        self.alight.setColor(LVecBase4f(0.162679, 0.162679, 0.169059, 1.0))
        self.alnp = render.attachNewNode(self.alight)
        render.setLight(self.alnp)
        
        # Center receptor and ligand
        self.center_proteins()
        
        # Center camera on complexes
        self.center = loader.loadModel("models/atom_sphere")
        self.center.setColor(0.0, 0.53, 0.0, 1.0)
        self.center_camera()
        
        # DirectionalLight
        self.dlight = DirectionalLight('dlight')
        self.dlight.setColor(LVecBase4f(0.797448, 0.660287, 0.743222, 1.0))
        self.dlight.setShadowCaster(True, 512, 512)
        render.setShaderAuto()
        self.dlnp = render.attachNewNode(self.dlight)
        self.dlnp.setPos(0,-50,0)
        render.setLight(self.dlnp)
        self.dlnp.lookAt(self.center)
        l1 = loader.loadModel("models/Dirlight")
        l1.setColor(1.0, 1.0, 0.0, 1.0)
        l1.setPos(0, -50, 0)
        l1.setScale(1)
        self.lights = [l1]
        
        # Post processing        
        render.setAntialias(AntialiasAttrib.MAuto)
        
        # Show control structures if required
        if self.structures:
            for light in self.lights:
                light.reparentTo(render)
            self.center.reparentTo(render)
            
        # Movement functions
        taskMgr.add(self.ligand_movement, 'ligand_movement') 

        # Key mapping
        self.key_bindings()
        
        # Show frame rate
        if debug:
            base.setFrameRateMeter(True)
    
        # Create two windows from cameras pointing to each molecule
        wx = base.win.getProperties().getXOrigin()
        wy = base.win.getProperties().getYOrigin() 
        
        # Ligand window
        wp = WindowProperties()
        wp.setSize(300,300)
        wp.setOrigin(self.width + wx + 10, wy - 50)
        wp.setTitle('From Ligand')
        self.ligand_view = base.openWindow(props=wp)
        self.cam_ligand = base.camList[1]
        self.cam_ligand.setPos(self.center.getX(), self.center.getY(), self.center.getZ())
        self.cam_ligand.lookAt(self.receptor_node)
        
        # Receptor window
        wp = WindowProperties()
        wp.setSize(300,300)
        wp.setOrigin(self.width + wx + 10, wy + 300)
        wp.setTitle('From Receptor')
        self.receptor_view = base.openWindow(props=wp)
        self.cam_receptor = base.camList[2]
        self.cam_receptor.setPos(self.center.getX(), self.center.getY(), self.center.getZ())
        self.cam_receptor.lookAt(self.ligand_node)
开发者ID:brianjimenez,项目名称:dockit,代码行数:104,代码来源:dockit.py


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