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


Python GeomNode.getNumGeoms方法代码示例

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


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

示例1: Environment

# 需要导入模块: from pandac.PandaModules import GeomNode [as 别名]
# 或者: from pandac.PandaModules.GeomNode import getNumGeoms [as 别名]
class Environment(DirectObject):
        
    def __init__(self, blocks, mapInfo):        
        self.destroyedBlocks = []
        self.addedBlocks = []
        self.hasChanged = 0
        self.node = GeomNode('gnode') 
        self.chunks = [] 
        self.collisionGeom = 0
        self.blocks = blocks
        self.mapInfo = mapInfo   
        
        self.xmax = self.mapInfo.GetSize()[0]
        self.ymax = self.mapInfo.GetSize()[1]
        self.zmax = self.mapInfo.GetSize()[2]
        
        self.InitializeChunks()
                    
        terrain = render.attachNewNode(self.node) 
        #terrain.flattenStrong()
        #terrain.setRenderModeWireframe() 
        terrain.analyze()
        
        if(not Settings.IS_SERVER):
            self.SetupLights()
            
    def InitializeChunks(self):
        """ Builds the chunks for the first time."""
        numXChunks = self.xmax / ChunkOfBlocks.CHUNK_SIZE
        numYChunks = self.ymax / ChunkOfBlocks.CHUNK_SIZE
        numZChunks = self.zmax / ChunkOfBlocks.CHUNK_SIZE
        
        # Creating all of the chunks for the environment
        for x in xrange(numXChunks):
            rowOfGeoms = []
            for y in xrange(numYChunks): 
                colOfGeoms = []
                for z in xrange(numZChunks):
                    myChunk = ChunkOfBlocks(x, y, z, self, self.blocks, self.node, x * numYChunks * numZChunks + y * numZChunks + z)
                    colOfGeoms.append(myChunk)
                rowOfGeoms.append(colOfGeoms)
                LoadProgressEvent('Construct ALL the Geometry!', (1.0 * (x+1) / numXChunks)).Fire()
            self.chunks.append(rowOfGeoms)
            
        print self.xmax, ' x ', self.ymax, ' x ', self.zmax
        print self.node.getNumGeoms()
            
    def ClearBlockNotifications(self):
        """ Clears the list of recently added and removed blocks."""
        self.destroyedBlocks = []
        self.addedBlocks = []
        
    def HasChanged(self):
        """ Returns whether the environment has been changed by players since last checked."""
        if self.hasChanged:
            self.hasChanged = 0
            return True
        return False
         
    def Update(self):
        for row in self.chunks:
            for col in row:
                for chunk in col:
                    if(chunk.IsDirty()):
                        chunk.Update()
            
    def AreValidIndices(self, x, y, z):
        return not (x >= self.GetNumBlocksX() or y >= self.GetNumBlocksY() or z >= self.GetNumBlocksZ() or x < 0 or y < 0 or z < 0)      
    
    # Removes a block to the specified location. If we are connected
    # to a server and this is a prediction, we need to make
    # sure it gets verified by the server
    def DestroyBlock(self, x, y, z, firstTime = True):
        if(z == 0):
            return
        
        if(self.AreValidIndices(x, y, z)):
            oldId = copy.deepcopy(self.blocks[x][y][z].GetId())
            self.blocks[x][y][z].SetId(0)
            self.GetChunkFromBlockCoords(x, y, z).SetDirty(True)
            self.NotifyNeighborsToUpdate(x, y, z)
            self.hasChanged = True
            
            if(not Globals.OFFLINE and firstTime):
                if (x, y, z, oldId) not in self.destroyedBlocks:
                    self.destroyedBlocks.append((x, y, z, oldId))
                if(not Settings.IS_SERVER):
                    taskMgr.doMethodLater(1, self.CheckDestroyed, 'CheckDestroyed', extraArgs = [(x, y, z, oldId)])
        
    # Adds a block to the specified location. If we are connected
    # to a server and this is a prediction, we need to make
    # sure it gets verified by the server
    def AddBlock(self, x, y, z, bid, firstTime = True):
        if(self.AreValidIndices(x, y, z)):
            self.blocks[x][y][z].SetId(bid)
            self.GetChunkFromBlockCoords(x, y, z).SetDirty(True)
            self.NotifyNeighborsToUpdate(x, y, z)
            self.hasChanged = True
            
            if(not Globals.OFFLINE and firstTime):
#.........这里部分代码省略.........
开发者ID:czorn,项目名称:Modifire,代码行数:103,代码来源:Environment.py


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