mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
pgraph refinements
This commit is contained in:
parent
5954465fbc
commit
3f3ce5a238
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from PandaModules import *
|
from PandaModules import *
|
||||||
from DirectNotifyGlobal import *
|
from DirectNotifyGlobal import *
|
||||||
|
import UsePgraph
|
||||||
|
|
||||||
# You can specify a phaseChecker callback to check
|
# You can specify a phaseChecker callback to check
|
||||||
# a modelPath to see if it is being loaded in the correct
|
# a modelPath to see if it is being loaded in the correct
|
||||||
@ -32,6 +33,9 @@ class Loader:
|
|||||||
phaseChecker(modelPath)
|
phaseChecker(modelPath)
|
||||||
node = self.loader.loadSync(Filename(modelPath))
|
node = self.loader.loadSync(Filename(modelPath))
|
||||||
if (node != None):
|
if (node != None):
|
||||||
|
if UsePgraph.use:
|
||||||
|
nodePath = NodePath(node)
|
||||||
|
else:
|
||||||
nodePath = self.base.hidden.attachNewNode(node)
|
nodePath = self.base.hidden.attachNewNode(node)
|
||||||
else:
|
else:
|
||||||
nodePath = None
|
nodePath = None
|
||||||
@ -47,11 +51,35 @@ class Loader:
|
|||||||
phaseChecker(modelPath)
|
phaseChecker(modelPath)
|
||||||
node = ModelPool.loadModel(modelPath)
|
node = ModelPool.loadModel(modelPath)
|
||||||
if (node != None):
|
if (node != None):
|
||||||
|
if UsePgraph.use:
|
||||||
|
nodePath = NodePath(node)
|
||||||
|
else:
|
||||||
nodePath = self.base.hidden.attachNewNode(node)
|
nodePath = self.base.hidden.attachNewNode(node)
|
||||||
else:
|
else:
|
||||||
nodePath = None
|
nodePath = None
|
||||||
return nodePath
|
return nodePath
|
||||||
|
|
||||||
|
def loadModelOnceUnder(self, modelPath, nodeName):
|
||||||
|
"""loadModelOnceUnder(self, string, string)
|
||||||
|
Behaves like loadModelOnce, but also implicitly creates a new
|
||||||
|
node to attach the model under, which helps to differentiate
|
||||||
|
different instances. This is useful when you want to load a
|
||||||
|
model once several times before parenting each instance
|
||||||
|
somewhere, or when you want to load a model and immediately
|
||||||
|
set a transform on it. But also consider loadModelCopy().
|
||||||
|
"""
|
||||||
|
|
||||||
|
Loader.notify.debug("Loading model once: %s under %s" % (modelPath, nodeName))
|
||||||
|
if phaseChecker:
|
||||||
|
phaseChecker(modelPath)
|
||||||
|
node = ModelPool.loadModel(modelPath)
|
||||||
|
if (node != None):
|
||||||
|
nodePath = NodePath(nodeName)
|
||||||
|
nodePath.attachNewNode(node)
|
||||||
|
else:
|
||||||
|
nodePath = None
|
||||||
|
return nodePath
|
||||||
|
|
||||||
def loadModelCopy(self, modelPath):
|
def loadModelCopy(self, modelPath):
|
||||||
"""loadModelCopy(self, string)
|
"""loadModelCopy(self, string)
|
||||||
Attempt to load a model from modelPool, if not present
|
Attempt to load a model from modelPool, if not present
|
||||||
@ -62,6 +90,9 @@ class Loader:
|
|||||||
phaseChecker(modelPath)
|
phaseChecker(modelPath)
|
||||||
node = ModelPool.loadModel(modelPath)
|
node = ModelPool.loadModel(modelPath)
|
||||||
if (node != None):
|
if (node != None):
|
||||||
|
if UsePgraph.use:
|
||||||
|
return (NodePath(node.copySubgraph()))
|
||||||
|
else:
|
||||||
return (NodePath(node).copyTo(self.base.hidden))
|
return (NodePath(node).copyTo(self.base.hidden))
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user