mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
support for Directtools
This commit is contained in:
parent
4c5a5d591c
commit
ad981aaee2
@ -24,7 +24,7 @@ class LineNodePath(NodePath):
|
|||||||
|
|
||||||
# Attach a geomNode to the parent and set self to be
|
# Attach a geomNode to the parent and set self to be
|
||||||
# the resulting node path
|
# the resulting node path
|
||||||
self.lineNode = GeomNode()
|
self.lineNode = GeomNode("lineNode")
|
||||||
self.assign(parent.attachNewNode( self.lineNode ))
|
self.assign(parent.attachNewNode( self.lineNode ))
|
||||||
if name:
|
if name:
|
||||||
self.setName(name)
|
self.setName(name)
|
||||||
@ -46,7 +46,12 @@ class LineNodePath(NodePath):
|
|||||||
|
|
||||||
def reset( self ):
|
def reset( self ):
|
||||||
self.lineSegs.reset()
|
self.lineSegs.reset()
|
||||||
self.lineNode.clear()
|
try:
|
||||||
|
# Old-style graph
|
||||||
|
self.lineNode.clear()
|
||||||
|
except:
|
||||||
|
# New-style graph
|
||||||
|
self.lineNode.removeAllGeoms()
|
||||||
|
|
||||||
def isEmpty( self ):
|
def isEmpty( self ):
|
||||||
return self.lineSegs.isEmpty()
|
return self.lineSegs.isEmpty()
|
||||||
@ -210,5 +215,10 @@ def relHpr(nodePath, base, h, p, r):
|
|||||||
# Set direct drawing style for an object
|
# Set direct drawing style for an object
|
||||||
# Never light object or draw in wireframe
|
# Never light object or draw in wireframe
|
||||||
def useDirectRenderStyle(nodePath):
|
def useDirectRenderStyle(nodePath):
|
||||||
nodePath.arc().setTransition(LightTransition.allOff())
|
try:
|
||||||
|
# Old-style scene graph
|
||||||
|
nodePath.arc().setTransition(LightTransition.allOff())
|
||||||
|
except:
|
||||||
|
# No new-style equivalent yet.
|
||||||
|
pass
|
||||||
nodePath.setRenderModeFilled()
|
nodePath.setRenderModeFilled()
|
||||||
|
@ -9,11 +9,20 @@ class DirectLight(NodePath):
|
|||||||
# Record light and name
|
# Record light and name
|
||||||
self.light = light
|
self.light = light
|
||||||
self.name = light.getName()
|
self.name = light.getName()
|
||||||
# Attach node to self
|
|
||||||
|
# Upcast the light object to its node base pointer
|
||||||
if isinstance(light, Spotlight):
|
if isinstance(light, Spotlight):
|
||||||
self.assign(parent.attachNewNode(light.upcastToProjectionNode()))
|
node = light.upcastToProjectionNode()
|
||||||
else:
|
else:
|
||||||
self.assign(parent.attachNewNode(light.upcastToNamedNode()))
|
node = light.upcastToNamedNode()
|
||||||
|
|
||||||
|
# Attach node to self
|
||||||
|
try:
|
||||||
|
self.assign(parent.attachNewNode(none))
|
||||||
|
except:
|
||||||
|
# New scene graph doesn't have lights yet.
|
||||||
|
pass
|
||||||
|
|
||||||
def getName(self):
|
def getName(self):
|
||||||
return self.name
|
return self.name
|
||||||
def getLight(self):
|
def getLight(self):
|
||||||
@ -99,13 +108,23 @@ class DirectLights(NodePath):
|
|||||||
|
|
||||||
def allOn(self):
|
def allOn(self):
|
||||||
""" Turn on all DIRECT lights """
|
""" Turn on all DIRECT lights """
|
||||||
render.arc().setTransition(self.lt)
|
try:
|
||||||
|
# Old-style scene graph
|
||||||
|
render.arc().setTransition(self.lt)
|
||||||
|
except:
|
||||||
|
# No new-style equivalent yet.
|
||||||
|
pass
|
||||||
# Make sure there is a default material
|
# Make sure there is a default material
|
||||||
render.setMaterial(Material())
|
render.setMaterial(Material())
|
||||||
|
|
||||||
def allOff(self):
|
def allOff(self):
|
||||||
""" Turn off all DIRECT lights """
|
""" Turn off all DIRECT lights """
|
||||||
render.arc().clearTransition(LightTransition.getClassType())
|
try:
|
||||||
|
# Old-style scene graph
|
||||||
|
render.arc().clearTransition(LightTransition.getClassType())
|
||||||
|
except:
|
||||||
|
# No new-style equivalent yet.
|
||||||
|
pass
|
||||||
|
|
||||||
def toggle(self):
|
def toggle(self):
|
||||||
""" Toggles light attribute, but doesn't toggle individual lights """
|
""" Toggles light attribute, but doesn't toggle individual lights """
|
||||||
|
@ -383,7 +383,7 @@ class DirectBoundingBox:
|
|||||||
class SelectionRay:
|
class SelectionRay:
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
# Create a collision node path attached to the given parent
|
# Create a collision node path attached to the given parent
|
||||||
self.rayCollisionNodePath = parent.attachNewNode( CollisionNode() )
|
self.rayCollisionNodePath = parent.attachNewNode( CollisionNode("ray") )
|
||||||
# Don't pay the penalty of drawing this collision ray
|
# Don't pay the penalty of drawing this collision ray
|
||||||
self.rayCollisionNodePath.hide()
|
self.rayCollisionNodePath.hide()
|
||||||
self.rayCollisionNode = self.rayCollisionNodePath.node()
|
self.rayCollisionNode = self.rayCollisionNodePath.node()
|
||||||
@ -400,7 +400,7 @@ class SelectionRay:
|
|||||||
# Current entry in collision queue
|
# Current entry in collision queue
|
||||||
self.cqIndex = 0
|
self.cqIndex = 0
|
||||||
# And a traverser to do the actual collision tests
|
# And a traverser to do the actual collision tests
|
||||||
self.ct = CollisionTraverser( RenderRelation.getClassType() )
|
self.ct = CollisionTraverser()
|
||||||
# Let the traverser know about the queue and the collision node
|
# Let the traverser know about the queue and the collision node
|
||||||
self.ct.addCollider(self.rayCollisionNode, self.cq )
|
self.ct.addCollider(self.rayCollisionNode, self.cq )
|
||||||
# Reference node path (for picking next)
|
# Reference node path (for picking next)
|
||||||
|
@ -865,8 +865,10 @@ class DisplayRegionContext:
|
|||||||
# one display region per camera, since we are defining a
|
# one display region per camera, since we are defining a
|
||||||
# display region on a per-camera basis. See note in
|
# display region on a per-camera basis. See note in
|
||||||
# DisplayRegionList.__init__()
|
# DisplayRegionList.__init__()
|
||||||
numDrs = self.camNode.getNumDrs()
|
try:
|
||||||
self.dr = self.camNode.getDr(0)
|
self.dr = self.camNode.getDr(0)
|
||||||
|
except:
|
||||||
|
self.dr = self.camNode.getDisplayRegion(0)
|
||||||
left = self.dr.getLeft()
|
left = self.dr.getLeft()
|
||||||
right = self.dr.getRight()
|
right = self.dr.getRight()
|
||||||
bottom = self.dr.getBottom()
|
bottom = self.dr.getBottom()
|
||||||
|
@ -5,8 +5,11 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def id(self):
|
def id(self):
|
||||||
"""Returns the bottom node's this pointer as a unique id"""
|
"""Returns a unique id identifying the NodePath instance"""
|
||||||
return self.arc()
|
# Nowadays, the NodePath itself serves as that unique id.
|
||||||
|
# This function is therefore deprecated and should be removed
|
||||||
|
# soon.
|
||||||
|
return self
|
||||||
|
|
||||||
def getName(self):
|
def getName(self):
|
||||||
"""Returns the name of the bottom node if it exists, or <noname>"""
|
"""Returns the name of the bottom node if it exists, or <noname>"""
|
||||||
|
@ -98,15 +98,21 @@ pgraphClassRenameDictionary = {
|
|||||||
'ButtonNode' : 'SpButtonNode',
|
'ButtonNode' : 'SpButtonNode',
|
||||||
'ButtonThrower' : 'SpButtonThrower',
|
'ButtonThrower' : 'SpButtonThrower',
|
||||||
'Camera' : 'SpCamera',
|
'Camera' : 'SpCamera',
|
||||||
|
'CardMaker' : 'SpCardMaker',
|
||||||
'ChanConfig' : 'SpChanConfig',
|
'ChanConfig' : 'SpChanConfig',
|
||||||
'Character' : 'SpCharacter',
|
'Character' : 'SpCharacter',
|
||||||
|
'CollisionNode' : 'SpCollisionNode',
|
||||||
|
'CollisionTraverser' : 'SpCollisionTraverser',
|
||||||
'DataGraphTraverser' : 'SpDataGraphTraverser',
|
'DataGraphTraverser' : 'SpDataGraphTraverser',
|
||||||
'DataNode' : 'SpDataNode',
|
'DataNode' : 'SpDataNode',
|
||||||
'DialNode' : 'SpDialNode',
|
'DialNode' : 'SpDialNode',
|
||||||
'DriveInterface' : 'SpDriveInterface',
|
'DriveInterface' : 'SpDriveInterface',
|
||||||
'GeomNode' : 'SpGeomNode',
|
'GeomNode' : 'SpGeomNode',
|
||||||
'LODNode' : 'SpLODNode',
|
'LODNode' : 'SpLODNode',
|
||||||
|
'LineSegs' : 'SpLineSegs',
|
||||||
'LensNode' : 'SpLensNode',
|
'LensNode' : 'SpLensNode',
|
||||||
|
'ModelNode' : 'SpModelNode',
|
||||||
|
'ModelRoot' : 'SpModelRoot',
|
||||||
'ModelPool' : 'SpModelPool',
|
'ModelPool' : 'SpModelPool',
|
||||||
'MouseAndKeyboard' : 'SpMouseAndKeyboard',
|
'MouseAndKeyboard' : 'SpMouseAndKeyboard',
|
||||||
'MouseWatcher' : 'SpMouseWatcher',
|
'MouseWatcher' : 'SpMouseWatcher',
|
||||||
@ -131,15 +137,21 @@ pgraphClassRenameDictionary = {
|
|||||||
'QpButtonNode' : 'ButtonNode',
|
'QpButtonNode' : 'ButtonNode',
|
||||||
'QpButtonThrower' : 'ButtonThrower',
|
'QpButtonThrower' : 'ButtonThrower',
|
||||||
'QpCamera' : 'Camera',
|
'QpCamera' : 'Camera',
|
||||||
|
'QpCardMaker' : 'CardMaker',
|
||||||
'QpChanConfig' : 'ChanConfig',
|
'QpChanConfig' : 'ChanConfig',
|
||||||
'QpCharacter' : 'Character',
|
'QpCharacter' : 'Character',
|
||||||
|
'QpCollisionNode' : 'CollisionNode',
|
||||||
|
'QpCollisionTraverser' : 'CollisionTraverser',
|
||||||
'QpDataGraphTraverser' : 'DataGraphTraverser',
|
'QpDataGraphTraverser' : 'DataGraphTraverser',
|
||||||
'QpDataNode' : 'DataNode',
|
'QpDataNode' : 'DataNode',
|
||||||
'QpDialNode' : 'DialNode',
|
'QpDialNode' : 'DialNode',
|
||||||
'QpDriveInterface' : 'DriveInterface',
|
'QpDriveInterface' : 'DriveInterface',
|
||||||
'QpGeomNode' : 'GeomNode',
|
'QpGeomNode' : 'GeomNode',
|
||||||
'QpLODNode' : 'LODNode',
|
'QpLODNode' : 'LODNode',
|
||||||
|
'QpLineSegs' : 'LineSegs',
|
||||||
'QpLensNode' : 'LensNode',
|
'QpLensNode' : 'LensNode',
|
||||||
|
'QpModelNode' : 'ModelNode',
|
||||||
|
'QpModelRoot' : 'ModelRoot',
|
||||||
'QpModelPool' : 'ModelPool',
|
'QpModelPool' : 'ModelPool',
|
||||||
'QpMouseAndKeyboard' : 'MouseAndKeyboard',
|
'QpMouseAndKeyboard' : 'MouseAndKeyboard',
|
||||||
'QpMouseWatcher' : 'MouseWatcher',
|
'QpMouseWatcher' : 'MouseWatcher',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user