當前位置: 首頁>>代碼示例>>Python>>正文


Python SmoothMover.setPos方法代碼示例

本文整理匯總了Python中pandac.PandaModules.SmoothMover.setPos方法的典型用法代碼示例。如果您正苦於以下問題:Python SmoothMover.setPos方法的具體用法?Python SmoothMover.setPos怎麽用?Python SmoothMover.setPos使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pandac.PandaModules.SmoothMover的用法示例。


在下文中一共展示了SmoothMover.setPos方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: ProgressiveLoader

# 需要導入模塊: from pandac.PandaModules import SmoothMover [as 別名]
# 或者: from pandac.PandaModules.SmoothMover import setPos [as 別名]
class ProgressiveLoader(ShowBase.ShowBase):
    
    def __init__(self, scenefile, capturefile=None, showstats=False, screenshot_dir=None):
        
        self.scenefile = scenefile
        self.capturefile = capturefile
        self.scene = scene.Scene.fromfile(scenefile)
        self.unique_models = set(m.slug for m in self.scene)
        self.multiplexer = pool.MultiplexPool()
        self.screenshot_dir = screenshot_dir
        
        print '%d objects in scene, %d unique' % (len(self.scene), len(self.unique_models))
        
        # turns on lazy loading of textures
        p3d.loadPrcFileData('', 'preload-textures 0')
        p3d.loadPrcFileData('', 'preload-simple-textures 1')
        p3d.loadPrcFileData('', 'compressed-textures 1')
        p3d.loadPrcFileData('', 'allow-incomplete-render 0')
        
        
        # window size to 1024x768
        p3d.loadPrcFileData('', 'win-size 1024 768')
        
        ShowBase.ShowBase.__init__(self)
        
        # background color sky blue
        self.win.setClearColorActive(True)
        self.win.setClearColor(p3d.VBase4(0.5294, 0.8078, 0.9215, 0))
        
        # create a nodepath for each unique model
        self.unique_nodepaths = dict((m, p3d.NodePath(m)) for m in self.unique_models)
        
        self.rigid_body_combiners = {}
        self.rigid_body_combiner_np = {}
        for m in self.unique_models:
            #rbc = p3d.RigidBodyCombiner(m)
            rbc = p3d.NodePath(m)
            self.rigid_body_combiners[m] = rbc
            np = p3d.NodePath(rbc)
            np.reparentTo(self.render)
            self.rigid_body_combiner_np[m] = np
        
        # find out how many objects are going to be instanced for each node
        self.instance_count = collections.defaultdict(int)
        for model in self.scene:
            self.instance_count[model.slug] += 1
        
        # then instance each unique model to its instantiation in the actual scene
        self.nodepaths = {}
        self.obj_bounds = {}
        self.nodepaths_byslug = collections.defaultdict(list)
        for model in self.scene:
            unique_np = self.unique_nodepaths[model.slug]
            node_name = model.slug + "_%.7g_%.7g_%.7g" % (model.x, model.y, model.z)
            
            if self.instance_count[model.slug] == 1:
                unique_np.setName(node_name)
                unique_np.reparentTo(self.render)
                np = unique_np
            else:
                np = self.rigid_body_combiner_np[model.slug].attachNewNode(node_name)
            
            self.nodepaths[model] = np
            self.nodepaths_byslug[model.slug].append(np)
            np.setPos(model.x, model.y, model.z)
            np.setScale(model.scale, model.scale, model.scale)
            q = p3d.Quat()
            q.setI(model.orient_x)
            q.setJ(model.orient_y)
            q.setK(model.orient_z)
            q.setR(model.orient_w)
            np.setQuat(q)
            self.obj_bounds[np] = p3d.BoundingSphere(np.getPos(), np.getScale()[0])
        
        #for rbc in self.rigid_body_combiners.itervalues():
        #    rbc.collect()
        
        self.waiting = []
        self.pm_waiting = collections.defaultdict(list)
        self.models_loaded = set()
        self.loading_priority = 2147483647
        
        for m in self.unique_models:
            t = metadata.MetadataDownloadTask(m)
            self.multiplexer.add_task(t)
        
        self.disableMouse()
        pcore.attachLights(self.render)
        self.render.setShaderAuto()
        self.render.setTransparency(p3d.TransparencyAttrib.MNone)
        
        self.camLens.setFar(sys.maxint)
        self.camLens.setNear(8.0)
        self.render.setAntialias(p3d.AntialiasAttrib.MAuto)
        
        self.showstats = showstats
        if showstats:
            self.num_metadata_loaded = 0
            self.num_models_loaded = 0
            self.num_texture_updates = 0
#.........這裏部分代碼省略.........
開發者ID:sirikata,項目名稱:progressive-scheduler,代碼行數:103,代碼來源:loader.py


注:本文中的pandac.PandaModules.SmoothMover.setPos方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。