Browse Source

Made camera rotate around center of persp view in new LE

Gyedo Jeon 16 years ago
parent
commit
a20bd77706

+ 16 - 0
direct/src/directtools/DirectCameraControl.py

@@ -100,6 +100,7 @@ class DirectCameraControl(DirectObject):
         # NIK - flag to determine whether to use maya camera controls
         self.useMayaCamControls = 0
         self.altDown = 0
+        self.perspCollPlane = None # [gjeon] used for new LE
 
     def toggleMarkerVis(self):
 ##        if base.direct.cameraControl.coaMarker.isHidden():
@@ -368,6 +369,21 @@ class DirectCameraControl(DirectObject):
     def spawnMouseRotateTask(self):
         # Kill any existing tasks
         taskMgr.remove('manipulateCamera')
+        if self.perspCollPlane:
+            iRay = SelectionRay(base.direct.camera)
+            iRay.collider.setFromLens(base.direct.camNode, 0.0, 0.0)
+            iRay.collideWithBitMask(1)
+            iRay.ct.traverse(self.perspCollPlane)
+            if iRay.getNumEntries() > 0:
+                entry = iRay.getEntry(0)
+                hitPt = entry.getSurfacePoint(entry.getFromNodePath())
+                # create a temp nodePath to get the position
+                np = NodePath('temp')
+                np.setPos(base.direct.camera, hitPt)
+                self.coaMarkerPos = np.getPos()
+                np.remove()
+                self.coaMarker.setPos(self.coaMarkerPos)
+
         # Set at markers position in render coordinates
         self.camManipRef.setPos(self.coaMarkerPos)
         self.camManipRef.setHpr(base.direct.camera, ZERO_POINT)

+ 1 - 1
direct/src/leveleditor/LevelEditorBase.py

@@ -94,7 +94,7 @@ class LevelEditorBase(DirectObject):
         base.direct.manipulationControl.fAllowMarquee = 1
         base.direct.manipulationControl.supportMultiView()
         base.direct.cameraControl.useMayaCamControls = 1
-
+        base.direct.cameraControl.perspCollPlane = self.ui.perspView.collPlane
         for widget in base.direct.manipulationControl.widgetList:
             widget.setBin('gui-popup', 0)
             widget.setDepthTest(0)