コード例 #1
0
    def Create(cls, *args, **kwargs):
        modelPath = kwargs.pop('modelPath', '')
        if not modelPath:
            np = pm.NodePath(pm.ModelRoot(''))
        else:
            filePath = pm.Filename.fromOsSpecific(modelPath)
            try:
                np = loader.loadModel(filePath)
            except:
                try:
                    np = loader.loadModel(filePath + '.bam')
                except IOError:
                    print 'Failed to load: ', filePath
                    np = pm.NodePath(pm.ModelRoot(''))
            np.setName(filePath.getBasenameWoExtension())

        wrpr = cls(np)
        wrpr.SetupNodePath()

        # Iterate over child nodes
        wrpr.extraNps = []

        def Recurse(node):
            nTypeStr = node.getTag(TAG_NODE_TYPE)
            cWrprCls = base.game.nodeMgr.GetWrapperByName(nTypeStr)
            if cWrprCls is not None:
                cWrpr = cWrprCls.Create(inputNp=node)
                wrpr.extraNps.append(cWrpr.data)

            # Recurse
            for child in node.getChildren():
                Recurse(child)

        Recurse(np)

        return wrpr