浏览代码

*** empty log message ***

Mark Mine 25 年之前
父节点
当前提交
3a907839c4

+ 14 - 11
direct/src/directutil/DirectCameraControl.py

@@ -1,6 +1,8 @@
 from PandaObject import *
+from DirectGeometry import useDirectRenderStyle
 
 CAM_MOVE_DURATION = 1.0
+COA_MARKER_SF = 0.0075
 Y_AXIS = Vec3(0,1,0)
 
 class DirectCameraControl(PandaObject):
@@ -10,9 +12,11 @@ class DirectCameraControl(PandaObject):
         self.camera = self.chan.camera
 	self.orthoViewRoll = 0.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.setColor(1,0,0)
+        useDirectRenderStyle(self.coaMarker)
         self.coaMarkerPos = Point3(0)
 	self.relNodePath = render.attachNewNode(NamedNode('targetNode'))
         self.zeroBaseVec = VBase3(0)
@@ -68,19 +72,17 @@ class DirectCameraControl(PandaObject):
                                 coaDist = dist
                                 coa.set(hitPt[0],hitPt[1],hitPt[2])
                                 minPt = i
-
                     # Handle case of bad coa point (too close or too far)
                     if ((coaDist < (1.1 * self.chan.near)) |
                         (coaDist > self.chan.far)):
-                        # Put it out in front of the camera
-                        coa.set(0,100,0)
-                        coaDist = 100
+                        # Just use existing point
+                        coa.assign(self.coaMarker.getPos(camera))
+                        coaDist = Vec3(coa - self.zeroPoint).length()
                 else:
                     # If no intersection point:
-                    # Put coa out in front of the camera
-                    coa.set(0,100,0)
-                    coaDist = 100
-
+                    # Use existing point
+                    coa.assign(self.coaMarker.getPos(camera))
+                    coaDist = Vec3(coa - self.zeroPoint).length()
                 # Update coa and marker
                 self.updateCoa(coa, coaDist)
                 # Now spawn task to determine mouse fly mode
@@ -131,7 +133,7 @@ class DirectCameraControl(PandaObject):
     def updateCoaMarkerSize(self, coaDist = None):
         if not coaDist:
             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)))
 
     def homeCam(self, chan):
@@ -265,7 +267,8 @@ class DirectCameraControl(PandaObject):
 
     def HPanYZoomTask(self,state):
         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,
                               distToMove[0],
                               distToMove[1],

+ 6 - 0
direct/src/directutil/DirectGeometry.py

@@ -86,3 +86,9 @@ def ROUND_TO(value, divisor):
     return round(value/float(divisor)) * divisor
 def ROUND_INT(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()

+ 2 - 0
direct/src/directutil/DirectGrid.py

@@ -6,6 +6,8 @@ class DirectGrid(NodePath,PandaObject):
         # Initialize superclass
         NodePath.__init__(self)
         self.assign(hidden.attachNewNode( NamedNode('DirectGrid')))
+        # Don't wireframe or light
+        useDirectRenderStyle(self)
 
 	# Load up grid parts to initialize grid object
 	# Polygon used to mark grid plane

+ 3 - 0
direct/src/directutil/DirectManipulation.py

@@ -564,6 +564,9 @@ class ObjectHandles(NodePath,PandaObject):
         self.createGuideLines()
         self.hideGuides()
 
+        # Make sure object handles are never lit or drawn in wireframe
+        useDirectRenderStyle(self)
+
     def coaModeColor(self):
         self.setColor(.5,.5,.5,1)
 

+ 4 - 0
direct/src/directutil/DirectSelection.py

@@ -297,6 +297,10 @@ class DirectBoundingBox:
 
         # Create and return bbox lines
 	lines.create()
+        
+        # Make sure bbox is never lit or drawn in wireframe
+        useDirectRenderStyle(lines)
+        
         return lines
 
     def updateBBoxLines(self):

+ 2 - 0
direct/src/directutil/DirectSession.py

@@ -31,6 +31,8 @@ class DirectSession(PandaObject):
         self.selected = SelectedNodePaths()
 
         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.reparentTo( hidden )
 

+ 11 - 0
direct/src/tkpanels/Placer.py

@@ -74,6 +74,10 @@ class Placer(Pmw.MegaToplevel):
         menuBar = Pmw.MenuBar(menuFrame, hotkeys = 1, balloon = balloon)
         menuBar.pack(side = LEFT, expand = 1, fill = X)
         menuBar.addmenu('Placer', 'Placer Panel Operations')
+        menuBar.addmenuitem('Placer', 'command',
+                            'Zero Node Path',
+                            label = 'Zero All',
+                            command = self.zeroAll)
         menuBar.addmenuitem('Placer', 'command',
                             'Reset Node Path',
                             label = 'Reset All',
@@ -417,6 +421,8 @@ class Placer(Pmw.MegaToplevel):
                 nodePath = self.tempCS
             else:
                 nodePath = None
+        elif name == 'parent':
+            nodePath = self['nodePath'].getParent()
         else:
             nodePath = self.refNodePathDict.get(name, None)
             if (nodePath == None):
@@ -610,6 +616,11 @@ class Placer(Pmw.MegaToplevel):
         self.scaleY.set(scale[1])
         self.scaleZ.set(scale[2])
 
+    def zeroAll(self):
+        self.zeroPos()
+        self.zeroHpr()
+        self.unitScale()
+
     def zeroPos(self):
         self.updatePosWidgets(ZERO_VEC)