Browse Source

prepareBundle

Joe Shochet 23 years ago
parent
commit
2dcdc21a01
1 changed files with 32 additions and 33 deletions
  1. 32 33
      direct/src/actor/Actor.py

+ 32 - 33
direct/src/actor/Actor.py

@@ -1178,46 +1178,45 @@ class Actor(PandaObject, NodePath):
 
         if (model == None):
             print "model = None!!!"
-        return self.prepareModel(model, partName, lodName)
-
-    def prepareModel(self, model, partName="modelRoot", lodName="lodRoot"):
         bundle = model.find("**/+PartBundleNode")
         if (bundle.isEmpty()):
             Actor.notify.warning("%s is not a character!" % (modelPath))
         else:
-            # Rename the node at the top of the hierarchy, if we
-            # haven't already, to make it easier to identify this
-            # actor in the scene graph.
-            if not self.gotName:
-                self.node().setName(bundle.node().getName())
-                self.gotName = 1
-                
-            # we rename this node to make Actor copying easier
-            bundle.node().setName(Actor.partPrefix + partName)
+            self.prepareBundle(bundle, partName, lodName)
+            model.removeNode()        
 
-            if (self.__partBundleDict.has_key(lodName) == 0):
-                # make a dictionary to store these parts in
-                needsDict = 1
-                bundleDict = {}
-            else:
-                needsDict = 0
-                
-            if (lodName!="lodRoot"):
-                # instance to appropriate node under LOD switch
-                #bundle = bundle.instanceTo(
-                #    self.__LODNode.find("**/" + str(lodName)))
-                bundle.reparentTo(self.__LODNode.find("**/" + str(lodName)))
-            else:
-                #bundle = bundle.instanceTo(self.__geomNode)
-                bundle.reparentTo(self.__geomNode)
+    def prepareBundle(self, bundle, partName="modelRoot", lodName="lodRoot"):
+        # Rename the node at the top of the hierarchy, if we
+        # haven't already, to make it easier to identify this
+        # actor in the scene graph.
+        if not self.gotName:
+            self.node().setName(bundle.node().getName())
+            self.gotName = 1
+
+        # we rename this node to make Actor copying easier
+        bundle.node().setName(Actor.partPrefix + partName)
+
+        if (self.__partBundleDict.has_key(lodName) == 0):
+            # make a dictionary to store these parts in
+            needsDict = 1
+            bundleDict = {}
+        else:
+            needsDict = 0
 
-            if (needsDict):
-                bundleDict[partName] = bundle
-                self.__partBundleDict[lodName] = bundleDict
-            else:
-                self.__partBundleDict[lodName][partName] = bundle
+        if (lodName!="lodRoot"):
+            # instance to appropriate node under LOD switch
+            #bundle = bundle.instanceTo(
+            #    self.__LODNode.find("**/" + str(lodName)))
+            bundle.reparentTo(self.__LODNode.find("**/" + str(lodName)))
+        else:
+            #bundle = bundle.instanceTo(self.__geomNode)
+            bundle.reparentTo(self.__geomNode)
 
-            model.removeNode()        
+        if (needsDict):
+            bundleDict[partName] = bundle
+            self.__partBundleDict[lodName] = bundleDict
+        else:
+            self.__partBundleDict[lodName][partName] = bundle
 
     def loadAnims(self, anims, partName="modelRoot", lodName="lodRoot"):
         """loadAnims(self, string:string{}, string='modelRoot',