mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
*** empty log message ***
This commit is contained in:
parent
5820b4f320
commit
3a907839c4
@ -1,6 +1,8 @@
|
|||||||
from PandaObject import *
|
from PandaObject import *
|
||||||
|
from DirectGeometry import useDirectRenderStyle
|
||||||
|
|
||||||
CAM_MOVE_DURATION = 1.0
|
CAM_MOVE_DURATION = 1.0
|
||||||
|
COA_MARKER_SF = 0.0075
|
||||||
Y_AXIS = Vec3(0,1,0)
|
Y_AXIS = Vec3(0,1,0)
|
||||||
|
|
||||||
class DirectCameraControl(PandaObject):
|
class DirectCameraControl(PandaObject):
|
||||||
@ -10,9 +12,11 @@ class DirectCameraControl(PandaObject):
|
|||||||
self.camera = self.chan.camera
|
self.camera = self.chan.camera
|
||||||
self.orthoViewRoll = 0.0
|
self.orthoViewRoll = 0.0
|
||||||
self.lastView = 0
|
self.lastView = 0
|
||||||
self.coa = Point3(0)
|
self.coa = Point3(0,100,0)
|
||||||
|
self.coaDist = 100
|
||||||
self.coaMarker = loader.loadModel('models/misc/sphere')
|
self.coaMarker = loader.loadModel('models/misc/sphere')
|
||||||
self.coaMarker.setColor(1,0,0)
|
self.coaMarker.setColor(1,0,0)
|
||||||
|
useDirectRenderStyle(self.coaMarker)
|
||||||
self.coaMarkerPos = Point3(0)
|
self.coaMarkerPos = Point3(0)
|
||||||
self.relNodePath = render.attachNewNode(NamedNode('targetNode'))
|
self.relNodePath = render.attachNewNode(NamedNode('targetNode'))
|
||||||
self.zeroBaseVec = VBase3(0)
|
self.zeroBaseVec = VBase3(0)
|
||||||
@ -68,19 +72,17 @@ class DirectCameraControl(PandaObject):
|
|||||||
coaDist = dist
|
coaDist = dist
|
||||||
coa.set(hitPt[0],hitPt[1],hitPt[2])
|
coa.set(hitPt[0],hitPt[1],hitPt[2])
|
||||||
minPt = i
|
minPt = i
|
||||||
|
|
||||||
# Handle case of bad coa point (too close or too far)
|
# Handle case of bad coa point (too close or too far)
|
||||||
if ((coaDist < (1.1 * self.chan.near)) |
|
if ((coaDist < (1.1 * self.chan.near)) |
|
||||||
(coaDist > self.chan.far)):
|
(coaDist > self.chan.far)):
|
||||||
# Put it out in front of the camera
|
# Just use existing point
|
||||||
coa.set(0,100,0)
|
coa.assign(self.coaMarker.getPos(camera))
|
||||||
coaDist = 100
|
coaDist = Vec3(coa - self.zeroPoint).length()
|
||||||
else:
|
else:
|
||||||
# If no intersection point:
|
# If no intersection point:
|
||||||
# Put coa out in front of the camera
|
# Use existing point
|
||||||
coa.set(0,100,0)
|
coa.assign(self.coaMarker.getPos(camera))
|
||||||
coaDist = 100
|
coaDist = Vec3(coa - self.zeroPoint).length()
|
||||||
|
|
||||||
# Update coa and marker
|
# Update coa and marker
|
||||||
self.updateCoa(coa, coaDist)
|
self.updateCoa(coa, coaDist)
|
||||||
# Now spawn task to determine mouse fly mode
|
# Now spawn task to determine mouse fly mode
|
||||||
@ -131,7 +133,7 @@ class DirectCameraControl(PandaObject):
|
|||||||
def updateCoaMarkerSize(self, coaDist = None):
|
def updateCoaMarkerSize(self, coaDist = None):
|
||||||
if not coaDist:
|
if not coaDist:
|
||||||
coaDist = Vec3(self.coaMarker.getPos( self.chan.camera )).length()
|
coaDist = Vec3(self.coaMarker.getPos( self.chan.camera )).length()
|
||||||
self.coaMarker.setScale(0.01 * coaDist *
|
self.coaMarker.setScale(COA_MARKER_SF * coaDist *
|
||||||
math.tan(deg2Rad(self.chan.fovV)))
|
math.tan(deg2Rad(self.chan.fovV)))
|
||||||
|
|
||||||
def homeCam(self, chan):
|
def homeCam(self, chan):
|
||||||
@ -265,7 +267,8 @@ class DirectCameraControl(PandaObject):
|
|||||||
|
|
||||||
def HPanYZoomTask(self,state):
|
def HPanYZoomTask(self,state):
|
||||||
targetVector = state.targetVector
|
targetVector = state.targetVector
|
||||||
distToMove = targetVector * self.chan.mouseDeltaY
|
# Can bring object to you by dragging across half the screen
|
||||||
|
distToMove = targetVector * (2.0 * self.chan.mouseDeltaY)
|
||||||
self.camera.setPosHpr(self.camera,
|
self.camera.setPosHpr(self.camera,
|
||||||
distToMove[0],
|
distToMove[0],
|
||||||
distToMove[1],
|
distToMove[1],
|
||||||
|
@ -86,3 +86,9 @@ def ROUND_TO(value, divisor):
|
|||||||
return round(value/float(divisor)) * divisor
|
return round(value/float(divisor)) * divisor
|
||||||
def ROUND_INT(val):
|
def ROUND_INT(val):
|
||||||
return int(round(val))
|
return int(round(val))
|
||||||
|
|
||||||
|
# Set direct drawing style for an object
|
||||||
|
# Never light object or draw in wireframe
|
||||||
|
def useDirectRenderStyle(nodePath):
|
||||||
|
nodePath.getBottomArc().setTransition(LightTransition.allOff())
|
||||||
|
nodePath.setRenderModeFilled()
|
||||||
|
@ -6,6 +6,8 @@ class DirectGrid(NodePath,PandaObject):
|
|||||||
# Initialize superclass
|
# Initialize superclass
|
||||||
NodePath.__init__(self)
|
NodePath.__init__(self)
|
||||||
self.assign(hidden.attachNewNode( NamedNode('DirectGrid')))
|
self.assign(hidden.attachNewNode( NamedNode('DirectGrid')))
|
||||||
|
# Don't wireframe or light
|
||||||
|
useDirectRenderStyle(self)
|
||||||
|
|
||||||
# Load up grid parts to initialize grid object
|
# Load up grid parts to initialize grid object
|
||||||
# Polygon used to mark grid plane
|
# Polygon used to mark grid plane
|
||||||
|
@ -564,6 +564,9 @@ class ObjectHandles(NodePath,PandaObject):
|
|||||||
self.createGuideLines()
|
self.createGuideLines()
|
||||||
self.hideGuides()
|
self.hideGuides()
|
||||||
|
|
||||||
|
# Make sure object handles are never lit or drawn in wireframe
|
||||||
|
useDirectRenderStyle(self)
|
||||||
|
|
||||||
def coaModeColor(self):
|
def coaModeColor(self):
|
||||||
self.setColor(.5,.5,.5,1)
|
self.setColor(.5,.5,.5,1)
|
||||||
|
|
||||||
|
@ -297,6 +297,10 @@ class DirectBoundingBox:
|
|||||||
|
|
||||||
# Create and return bbox lines
|
# Create and return bbox lines
|
||||||
lines.create()
|
lines.create()
|
||||||
|
|
||||||
|
# Make sure bbox is never lit or drawn in wireframe
|
||||||
|
useDirectRenderStyle(lines)
|
||||||
|
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
def updateBBoxLines(self):
|
def updateBBoxLines(self):
|
||||||
|
@ -31,6 +31,8 @@ class DirectSession(PandaObject):
|
|||||||
self.selected = SelectedNodePaths()
|
self.selected = SelectedNodePaths()
|
||||||
|
|
||||||
self.readout = OnscreenText.OnscreenText( '', 0.1, -0.95 )
|
self.readout = OnscreenText.OnscreenText( '', 0.1, -0.95 )
|
||||||
|
# Make sure readout is never lit or drawn in wireframe
|
||||||
|
useDirectRenderStyle(self.readout)
|
||||||
# self.readout.textNode.setCardColor(0.5, 0.5, 0.5, 0.5)
|
# self.readout.textNode.setCardColor(0.5, 0.5, 0.5, 0.5)
|
||||||
self.readout.reparentTo( hidden )
|
self.readout.reparentTo( hidden )
|
||||||
|
|
||||||
|
@ -74,6 +74,10 @@ class Placer(Pmw.MegaToplevel):
|
|||||||
menuBar = Pmw.MenuBar(menuFrame, hotkeys = 1, balloon = balloon)
|
menuBar = Pmw.MenuBar(menuFrame, hotkeys = 1, balloon = balloon)
|
||||||
menuBar.pack(side = LEFT, expand = 1, fill = X)
|
menuBar.pack(side = LEFT, expand = 1, fill = X)
|
||||||
menuBar.addmenu('Placer', 'Placer Panel Operations')
|
menuBar.addmenu('Placer', 'Placer Panel Operations')
|
||||||
|
menuBar.addmenuitem('Placer', 'command',
|
||||||
|
'Zero Node Path',
|
||||||
|
label = 'Zero All',
|
||||||
|
command = self.zeroAll)
|
||||||
menuBar.addmenuitem('Placer', 'command',
|
menuBar.addmenuitem('Placer', 'command',
|
||||||
'Reset Node Path',
|
'Reset Node Path',
|
||||||
label = 'Reset All',
|
label = 'Reset All',
|
||||||
@ -417,6 +421,8 @@ class Placer(Pmw.MegaToplevel):
|
|||||||
nodePath = self.tempCS
|
nodePath = self.tempCS
|
||||||
else:
|
else:
|
||||||
nodePath = None
|
nodePath = None
|
||||||
|
elif name == 'parent':
|
||||||
|
nodePath = self['nodePath'].getParent()
|
||||||
else:
|
else:
|
||||||
nodePath = self.refNodePathDict.get(name, None)
|
nodePath = self.refNodePathDict.get(name, None)
|
||||||
if (nodePath == None):
|
if (nodePath == None):
|
||||||
@ -610,6 +616,11 @@ class Placer(Pmw.MegaToplevel):
|
|||||||
self.scaleY.set(scale[1])
|
self.scaleY.set(scale[1])
|
||||||
self.scaleZ.set(scale[2])
|
self.scaleZ.set(scale[2])
|
||||||
|
|
||||||
|
def zeroAll(self):
|
||||||
|
self.zeroPos()
|
||||||
|
self.zeroHpr()
|
||||||
|
self.unitScale()
|
||||||
|
|
||||||
def zeroPos(self):
|
def zeroPos(self):
|
||||||
self.updatePosWidgets(ZERO_VEC)
|
self.updatePosWidgets(ZERO_VEC)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user