mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
added SpecUtil funcs for creating and adapting specs to new level models
This commit is contained in:
parent
be086b33d7
commit
e1f49b2569
27
direct/src/level/LevelUtil.py
Executable file
27
direct/src/level/LevelUtil.py
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
"""LevelUtil module: contains Level utility funcs"""
|
||||||
|
|
||||||
|
def getZoneNum2Node(levelModel):
|
||||||
|
""" given model, returns dict of ZoneNumber -> ZoneNode """
|
||||||
|
def findNumberedNodes(baseString, model):
|
||||||
|
# finds nodes whose name follows the pattern 'baseString#'
|
||||||
|
# where there are no characters after #
|
||||||
|
# returns dictionary that maps # to node
|
||||||
|
potentialNodes = model.findAllMatches(
|
||||||
|
'**/%s*' % baseString).asList()
|
||||||
|
num2node = {}
|
||||||
|
for potentialNode in potentialNodes:
|
||||||
|
name = potentialNode.getName()
|
||||||
|
print 'potential match for %s: %s' % (baseString, name)
|
||||||
|
try:
|
||||||
|
num = int(name[len(baseString):])
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
|
||||||
|
num2node[num] = potentialNode
|
||||||
|
|
||||||
|
return num2node
|
||||||
|
|
||||||
|
zoneNum2node = findNumberedNodes('Zone', levelModel)
|
||||||
|
# add the UberZone to the table
|
||||||
|
zoneNum2node[0] = levelModel
|
||||||
|
return zoneNum2node
|
Loading…
x
Reference in New Issue
Block a user