direct -> base.direct

This commit is contained in:
David Rose 2006-10-16 19:10:13 +00:00
parent fda8e1f335
commit 08c3f5e2d5
19 changed files with 532 additions and 532 deletions

View File

@ -20,10 +20,10 @@ class DirectFastrak(DirectObject):
fastrakCount = 0
notify = DirectNotifyGlobal.directNotify.newCategory('DirectFastrak')
def __init__(self, device = 'Tracker0', nodePath = direct.camera):
def __init__(self, device = 'Tracker0', nodePath = base.direct.camera):
# See if device manager has been initialized
if direct.deviceManager == None:
direct.deviceManager = DirectDeviceManager()
if base.direct.deviceManager == None:
base.direct.deviceManager = DirectDeviceManager()
# Set name
self.name = 'Fastrak-' + `DirectFastrak.fastrakCount`
@ -43,7 +43,7 @@ class DirectFastrak(DirectObject):
# Kill existing task
self.disable()
# Initialize tracker
self.tracker = direct.deviceManager.createTracker(self.device)
self.tracker = base.direct.deviceManager.createTracker(self.device)
# Update task
taskMgr.add(self.updateTask, self.name + '-updateTask')
@ -60,7 +60,7 @@ class DirectFastrak(DirectObject):
def fastrakUpdate(self):
# Get tracker position in feet. Flip x, z axes.
pos = direct.fastrak[self.deviceNo].tracker.getPos()
pos = base.direct.fastrak[self.deviceNo].tracker.getPos()
self.trackerPos = Vec3(3.280839895013123 * pos[2],
3.280839895013123 * pos[1],
3.280839895013123 * pos[0])

View File

@ -36,17 +36,17 @@ class DirectJoybox(DirectObject):
joyboxCount = 0
xyzMultiplier = 1.0
hprMultiplier = 1.0
def __init__(self, device = 'CerealBox', nodePath = direct.camera):
def __init__(self, device = 'CerealBox', nodePath = base.direct.camera):
# See if device manager has been initialized
if direct.deviceManager == None:
direct.deviceManager = DirectDeviceManager()
if base.direct.deviceManager == None:
base.direct.deviceManager = DirectDeviceManager()
# Set name
DirectJoybox.joyboxCount += 1
self.name = 'Joybox-' + `DirectJoybox.joyboxCount`
# Get buttons and analogs
self.device = device
self.analogs = direct.deviceManager.createAnalogs(self.device)
self.buttons = direct.deviceManager.createButtons(self.device)
self.analogs = base.direct.deviceManager.createAnalogs(self.device)
self.buttons = base.direct.deviceManager.createButtons(self.device)
self.aList = [0, 0, 0, 0, 0, 0, 0, 0]
self.bList = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
# For joybox fly mode
@ -59,12 +59,12 @@ class DirectJoybox(DirectObject):
# Record node path
self.nodePath = nodePath
# Ref CS for orbit mode
self.refCS = direct.cameraControl.coaMarker
self.tempCS = direct.group.attachNewNode('JoyboxTempCS')
self.refCS = base.direct.cameraControl.coaMarker
self.tempCS = base.direct.group.attachNewNode('JoyboxTempCS')
# Text object to display current mode
self.readout = OnscreenText.OnscreenText(
pos = (-0.9, 0.95),
font = direct.font,
font = base.direct.font,
mayChange = 1)
# List of functions to cycle through
self.modeList = [self.joeMode, self.driveMode, self.orbitMode]
@ -204,7 +204,7 @@ class DirectJoybox(DirectObject):
def acceptUprightCameraEvent(self, button = L_UPPER):
self.accept(self.getEventName(button),
direct.cameraControl.orbitUprightCam)
base.direct.cameraControl.orbitUprightCam)
def ignoreUprightCameraEvent(self, button = L_UPPER):
self.ignore(self.getEventName(button))

View File

@ -21,16 +21,16 @@ class DirectRadamec(DirectObject):
radamecCount = 0
notify = DirectNotifyGlobal.directNotify.newCategory('DirectRadamec')
def __init__(self, device = 'Analog0', nodePath = direct.camera):
def __init__(self, device = 'Analog0', nodePath = base.direct.camera):
# See if device manager has been initialized
if direct.deviceManager == None:
direct.deviceManager = DirectDeviceManager()
if base.direct.deviceManager == None:
base.direct.deviceManager = DirectDeviceManager()
# Set name
self.name = 'Radamec-' + `DirectRadamec.radamecCount`
DirectRadamec.radamecCount += 1
# Get analogs
self.device = device
self.analogs = direct.deviceManager.createAnalogs(self.device)
self.analogs = base.direct.deviceManager.createAnalogs(self.device)
self.numAnalogs = len(self.analogs)
self.aList = [0, 0, 0, 0, 0, 0, 0, 0]
# Radamec device max/mins

View File

@ -28,8 +28,8 @@ class DirectCameraControl(DirectObject):
self.fLockCOA = 0
self.nullHitPointCount = 0
self.cqEntries = []
self.coaMarkerRef = direct.group.attachNewNode('coaMarkerRef')
self.camManipRef = direct.group.attachNewNode('camManipRef')
self.coaMarkerRef = base.direct.group.attachNewNode('coaMarkerRef')
self.camManipRef = base.direct.group.attachNewNode('camManipRef')
t = CAM_MOVE_DURATION
self.actionEvents = [
['DIRECT-mouse1', self.mouseRotateStart],
@ -70,14 +70,14 @@ class DirectCameraControl(DirectObject):
self.useMayaCamControls = 0
def toggleMarkerVis(self):
if direct.cameraControl.coaMarker.isHidden():
direct.cameraControl.coaMarker.show()
if base.direct.cameraControl.coaMarker.isHidden():
base.direct.cameraControl.coaMarker.show()
else:
direct.cameraControl.coaMarker.hide()
base.direct.cameraControl.coaMarker.hide()
def mouseRotateStart(self, modifiers):
if self.useMayaCamControls and modifiers == 4: # alt is pressed - use maya controls
direct.pushUndo([direct.camera])
base.direct.pushUndo([base.direct.camera])
self.spawnMouseRotateTask()
def mouseDollyStart(self, modifiers):
@ -92,7 +92,7 @@ class DirectCameraControl(DirectObject):
def mouseFlyStart(self, modifiers):
# Record undo point
direct.pushUndo([direct.camera])
base.direct.pushUndo([base.direct.camera])
if self.useMayaCamControls and modifiers == 4: # alt is down, use maya controls
# Hide the marker for this kind of motion
self.coaMarker.hide()
@ -103,7 +103,7 @@ class DirectCameraControl(DirectObject):
self.spawnXZTranslate()
else:
# Where are we in the display region?
if ((abs(direct.dr.mouseX) < 0.9) and (abs(direct.dr.mouseY) < 0.9)):
if ((abs(base.direct.dr.mouseX) < 0.9) and (abs(base.direct.dr.mouseY) < 0.9)):
# MOUSE IS IN CENTRAL REGION
# Hide the marker for this kind of motion
self.coaMarker.hide()
@ -114,8 +114,8 @@ class DirectCameraControl(DirectObject):
self.spawnXZTranslateOrHPanYZoom()
# END MOUSE IN CENTRAL REGION
else:
if ((abs(direct.dr.mouseX) > 0.9) and
(abs(direct.dr.mouseY) > 0.9)):
if ((abs(base.direct.dr.mouseX) > 0.9) and
(abs(base.direct.dr.mouseY) > 0.9)):
# Mouse is in corners, spawn roll task
self.spawnMouseRollTask()
else:
@ -137,13 +137,13 @@ class DirectCameraControl(DirectObject):
skipFlags = SKIP_HIDDEN | SKIP_BACKFACE
# Skip camera (and its children), unless control key is pressed
skipFlags |= SKIP_CAMERA * (1 - base.getControl())
self.computeCOA(direct.iRay.pickGeom(skipFlags = skipFlags))
self.computeCOA(base.direct.iRay.pickGeom(skipFlags = skipFlags))
# Record reference point
self.coaMarkerRef.iPosHprScale(base.cam)
# Record entries
self.cqEntries = []
for i in range(direct.iRay.getNumEntries()):
self.cqEntries.append(direct.iRay.getEntry(i))
for i in range(base.direct.iRay.getNumEntries()):
self.cqEntries.append(base.direct.iRay.getEntry(i))
# Show the marker
self.coaMarker.show()
# Resize it
@ -164,7 +164,7 @@ class DirectCameraControl(DirectObject):
# Spawn the new task
t = Task.Task(self.XZTranslateOrHPanYZoomTask)
# For HPanYZoom
t.zoomSF = Vec3(self.coaMarker.getPos(direct.camera)).length()
t.zoomSF = Vec3(self.coaMarker.getPos(base.direct.camera)).length()
taskMgr.add(t, 'manipulateCamera')
def spawnXZTranslateOrHPPan(self):
@ -185,7 +185,7 @@ class DirectCameraControl(DirectObject):
taskMgr.remove('manipulateCamera')
# Spawn new task
t = Task.Task(self.HPanYZoomTask)
t.zoomSF = Vec3(self.coaMarker.getPos(direct.camera)).length()
t.zoomSF = Vec3(self.coaMarker.getPos(base.direct.camera)).length()
taskMgr.add(t, 'manipulateCamera')
def spawnHPPan(self):
@ -195,13 +195,13 @@ class DirectCameraControl(DirectObject):
taskMgr.add(self.HPPanTask, 'manipulateCamera')
def XZTranslateOrHPanYZoomTask(self, state):
if direct.fShift:
if base.direct.fShift:
return self.XZTranslateTask(state)
else:
return self.HPanYZoomTask(state)
def XZTranslateOrHPPanTask(self, state):
if direct.fShift:
if base.direct.fShift:
# Panning action
return self.HPPanTask(state)
else:
@ -209,54 +209,54 @@ class DirectCameraControl(DirectObject):
return self.XZTranslateTask(state)
def XZTranslateTask(self, state):
coaDist = Vec3(self.coaMarker.getPos(direct.camera)).length()
xlateSF = (coaDist / direct.dr.near)
direct.camera.setPos(direct.camera,
(-0.5 * direct.dr.mouseDeltaX *
direct.dr.nearWidth *
coaDist = Vec3(self.coaMarker.getPos(base.direct.camera)).length()
xlateSF = (coaDist / base.direct.dr.near)
base.direct.camera.setPos(base.direct.camera,
(-0.5 * base.direct.dr.mouseDeltaX *
base.direct.dr.nearWidth *
xlateSF),
0.0,
(-0.5 * direct.dr.mouseDeltaY *
direct.dr.nearHeight *
(-0.5 * base.direct.dr.mouseDeltaY *
base.direct.dr.nearHeight *
xlateSF))
return Task.cont
def HPanYZoomTask(self, state):
# If the cam is orthogonal, don't rotate or zoom.
if (hasattr(direct.camera.node(), "getLens") and
direct.camera.node().getLens().__class__.__name__ == "OrthographicLens"):
if (hasattr(base.direct.camera.node(), "getLens") and
base.direct.camera.node().getLens().__class__.__name__ == "OrthographicLens"):
return
if direct.fControl:
moveDir = Vec3(self.coaMarker.getPos(direct.camera))
if base.direct.fControl:
moveDir = Vec3(self.coaMarker.getPos(base.direct.camera))
# If marker is behind camera invert vector
if moveDir[1] < 0.0:
moveDir.assign(moveDir * -1)
moveDir.normalize()
else:
moveDir = Vec3(Y_AXIS)
moveDir.assign(moveDir * (-1.0 * direct.dr.mouseDeltaY *
moveDir.assign(moveDir * (-1.0 * base.direct.dr.mouseDeltaY *
state.zoomSF))
if direct.dr.mouseDeltaY > 0.0:
if base.direct.dr.mouseDeltaY > 0.0:
moveDir.setY(moveDir[1] * 1.0)
direct.camera.setPosHpr(direct.camera,
base.direct.camera.setPosHpr(base.direct.camera,
moveDir[0],
moveDir[1],
moveDir[2],
(0.5 * direct.dr.mouseDeltaX *
direct.dr.fovH),
(0.5 * base.direct.dr.mouseDeltaX *
base.direct.dr.fovH),
0.0, 0.0)
if (self.lockRoll == True):
# flatten roll
direct.camera.setR(0)
base.direct.camera.setR(0)
return Task.cont
def HPPanTask(self, state):
direct.camera.setHpr(direct.camera,
(0.5 * direct.dr.mouseDeltaX *
direct.dr.fovH),
(-0.5 * direct.dr.mouseDeltaY *
direct.dr.fovV),
base.direct.camera.setHpr(base.direct.camera,
(0.5 * base.direct.dr.mouseDeltaX *
base.direct.dr.fovH),
(-0.5 * base.direct.dr.mouseDeltaY *
base.direct.dr.fovV),
0.0)
return Task.cont
@ -265,9 +265,9 @@ class DirectCameraControl(DirectObject):
taskMgr.remove('manipulateCamera')
# Set at markers position in render coordinates
self.camManipRef.setPos(self.coaMarkerPos)
self.camManipRef.setHpr(direct.camera, ZERO_POINT)
self.camManipRef.setHpr(base.direct.camera, ZERO_POINT)
t = Task.Task(self.mouseRotateTask)
if abs(direct.dr.mouseX) > 0.9:
if abs(base.direct.dr.mouseX) > 0.9:
t.constrainedDir = 'y'
else:
t.constrainedDir = 'x'
@ -275,31 +275,31 @@ class DirectCameraControl(DirectObject):
def mouseRotateTask(self, state):
# If the cam is orthogonal, don't rotate.
if (hasattr(direct.camera.node(), "getLens") and
direct.camera.node().getLens().__class__.__name__ == "OrthographicLens"):
if (hasattr(base.direct.camera.node(), "getLens") and
base.direct.camera.node().getLens().__class__.__name__ == "OrthographicLens"):
return
# If moving outside of center, ignore motion perpendicular to edge
if ((state.constrainedDir == 'y') and (abs(direct.dr.mouseX) > 0.9)):
if ((state.constrainedDir == 'y') and (abs(base.direct.dr.mouseX) > 0.9)):
deltaX = 0
deltaY = direct.dr.mouseDeltaY
elif ((state.constrainedDir == 'x') and (abs(direct.dr.mouseY) > 0.9)):
deltaX = direct.dr.mouseDeltaX
deltaY = base.direct.dr.mouseDeltaY
elif ((state.constrainedDir == 'x') and (abs(base.direct.dr.mouseY) > 0.9)):
deltaX = base.direct.dr.mouseDeltaX
deltaY = 0
else:
deltaX = direct.dr.mouseDeltaX
deltaY = direct.dr.mouseDeltaY
if direct.fShift:
direct.camera.setHpr(direct.camera,
(deltaX * direct.dr.fovH),
(-deltaY * direct.dr.fovV),
deltaX = base.direct.dr.mouseDeltaX
deltaY = base.direct.dr.mouseDeltaY
if base.direct.fShift:
base.direct.camera.setHpr(base.direct.camera,
(deltaX * base.direct.dr.fovH),
(-deltaY * base.direct.dr.fovV),
0.0)
if (self.lockRoll == True):
# flatten roll
direct.camera.setR(0)
base.direct.camera.setR(0)
self.camManipRef.setPos(self.coaMarkerPos)
self.camManipRef.setHpr(direct.camera, ZERO_POINT)
self.camManipRef.setHpr(base.direct.camera, ZERO_POINT)
else:
wrt = direct.camera.getTransform(self.camManipRef)
wrt = base.direct.camera.getTransform(self.camManipRef)
self.camManipRef.setHpr(self.camManipRef,
(-1 * deltaX * 180.0),
(deltaY * 180.0),
@ -307,7 +307,7 @@ class DirectCameraControl(DirectObject):
if (self.lockRoll == True):
# flatten roll
self.camManipRef.setR(0)
direct.camera.setTransform(self.camManipRef, wrt)
base.direct.camera.setTransform(self.camManipRef, wrt)
return Task.cont
def spawnMouseRollTask(self):
@ -315,12 +315,12 @@ class DirectCameraControl(DirectObject):
taskMgr.remove('manipulateCamera')
# Set at markers position in render coordinates
self.camManipRef.setPos(self.coaMarkerPos)
self.camManipRef.setHpr(direct.camera, ZERO_POINT)
self.camManipRef.setHpr(base.direct.camera, ZERO_POINT)
t = Task.Task(self.mouseRollTask)
t.coaCenter = getScreenXY(self.coaMarker)
t.lastAngle = getCrankAngle(t.coaCenter)
# Store the camera/manipRef offset transform
t.wrt = direct.camera.getTransform(self.camManipRef)
t.wrt = base.direct.camera.getTransform(self.camManipRef)
taskMgr.add(t, 'manipulateCamera')
def mouseRollTask(self, state):
@ -332,23 +332,23 @@ class DirectCameraControl(DirectObject):
if (self.lockRoll == True):
# flatten roll
self.camManipRef.setR(0)
direct.camera.setTransform(self.camManipRef, wrt)
base.direct.camera.setTransform(self.camManipRef, wrt)
return Task.cont
def lockCOA(self):
self.fLockCOA = 1
direct.message('COA Lock On')
base.direct.message('COA Lock On')
def unlockCOA(self):
self.fLockCOA = 0
direct.message('COA Lock Off')
base.direct.message('COA Lock Off')
def toggleCOALock(self):
self.fLockCOA = 1 - self.fLockCOA
if self.fLockCOA:
direct.message('COA Lock On')
base.direct.message('COA Lock On')
else:
direct.message('COA Lock Off')
base.direct.message('COA Lock Off')
def pickNextCOA(self):
""" Cycle through collision handler entries """
@ -358,7 +358,7 @@ class DirectCameraControl(DirectObject):
self.cqEntries = self.cqEntries[1:] + self.cqEntries[:1]
# Filter out object's under camera
nodePath = entry.getIntoNodePath()
if direct.camera not in nodePath.getAncestry():
if base.direct.camera not in nodePath.getAncestry():
# Compute new hit point
hitPt = entry.getSurfacePoint(entry.getFromNodePath())
# Move coa marker to new point
@ -370,11 +370,11 @@ class DirectCameraControl(DirectObject):
def computeCOA(self, entry):
coa = Point3(0)
dr = direct.drList.getCurrentDr()
dr = base.direct.drList.getCurrentDr()
if self.fLockCOA:
# COA is locked, use existing point
# Use existing point
coa.assign(self.coaMarker.getPos(direct.camera))
coa.assign(self.coaMarker.getPos(base.direct.camera))
# Reset hit point count
self.nullHitPointCount = 0
elif entry:
@ -387,7 +387,7 @@ class DirectCameraControl(DirectObject):
if ((hitPtDist < (1.1 * dr.near)) or
(hitPtDist > dr.far)):
# Just use existing point
coa.assign(self.coaMarker.getPos(direct.camera))
coa.assign(self.coaMarker.getPos(base.direct.camera))
# Reset hit point count
self.nullHitPointCount = 0
else:
@ -399,7 +399,7 @@ class DirectCameraControl(DirectObject):
# MRM: Would be nice to be able to control this
# At least display it
dist = pow(10.0, self.nullHitPointCount)
direct.message('COA Distance: ' + `dist`)
base.direct.message('COA Distance: ' + `dist`)
coa.set(0, dist, 0)
# Compute COA Dist
coaDist = Vec3(coa - ZERO_POINT).length()
@ -417,7 +417,7 @@ class DirectCameraControl(DirectObject):
if ref == None:
# KEH: use the current display region
# ref = base.cam
ref = direct.drList.getCurrentDr().cam
ref = base.direct.drList.getCurrentDr().cam
self.coaMarker.setPos(ref, self.coa)
pos = self.coaMarker.getPos()
self.coaMarker.setPosHprScale(pos, Vec3(0), Vec3(1))
@ -432,10 +432,10 @@ class DirectCameraControl(DirectObject):
def updateCoaMarkerSize(self, coaDist = None):
if not coaDist:
coaDist = Vec3(self.coaMarker.getPos(direct.camera)).length()
coaDist = Vec3(self.coaMarker.getPos(base.direct.camera)).length()
# Nominal size based on default 30 degree vertical FOV
# Need to adjust size based on distance and current FOV
sf = COA_MARKER_SF * coaDist * (direct.drList.getCurrentDr().fovV/30.0)
sf = COA_MARKER_SF * coaDist * (base.direct.drList.getCurrentDr().fovV/30.0)
if sf == 0.0:
sf = 0.1
self.coaMarker.setScale(sf)
@ -453,19 +453,19 @@ class DirectCameraControl(DirectObject):
def homeCam(self):
# Record undo point
direct.pushUndo([direct.camera])
direct.camera.reparentTo(render)
direct.camera.clearMat()
base.direct.pushUndo([base.direct.camera])
base.direct.camera.reparentTo(render)
base.direct.camera.clearMat()
# Resize coa marker
self.updateCoaMarkerSize()
def uprightCam(self):
taskMgr.remove('manipulateCamera')
# Record undo point
direct.pushUndo([direct.camera])
base.direct.pushUndo([base.direct.camera])
# Pitch camera till upright
currH = direct.camera.getH()
direct.camera.lerpHpr(currH, 0, 0,
currH = base.direct.camera.getH()
base.direct.camera.lerpHpr(currH, 0, 0,
CAM_MOVE_DURATION,
other = render,
blendType = 'easeInOut',
@ -474,10 +474,10 @@ class DirectCameraControl(DirectObject):
def orbitUprightCam(self):
taskMgr.remove('manipulateCamera')
# Record undo point
direct.pushUndo([direct.camera])
base.direct.pushUndo([base.direct.camera])
# Transform camera z axis to render space
mCam2Render = Mat4()
mCam2Render.assign(direct.camera.getMat(render))
mCam2Render.assign(base.direct.camera.getMat(render))
zAxis = Vec3(mCam2Render.xformVec(Z_AXIS))
zAxis.normalize()
# Compute rotation angle needed to upright cam
@ -498,8 +498,8 @@ class DirectCameraControl(DirectObject):
self.camManipRef.setPos(self.coaMarker, Vec3(0))
self.camManipRef.setHpr(render, rotAngle, 0, 0)
# Reparent Cam to ref Coordinate system
parent = direct.camera.getParent()
direct.camera.wrtReparentTo(self.camManipRef)
parent = base.direct.camera.getParent()
base.direct.camera.wrtReparentTo(self.camManipRef)
# Rotate ref CS to final orientation
t = self.camManipRef.lerpHpr(rotAngle, orbitAngle, 0,
CAM_MOVE_DURATION,
@ -519,14 +519,14 @@ class DirectCameraControl(DirectObject):
def centerCamIn(self, t):
taskMgr.remove('manipulateCamera')
# Record undo point
direct.pushUndo([direct.camera])
base.direct.pushUndo([base.direct.camera])
# Determine marker location
markerToCam = self.coaMarker.getPos(direct.camera)
markerToCam = self.coaMarker.getPos(base.direct.camera)
dist = Vec3(markerToCam - ZERO_POINT).length()
scaledCenterVec = Y_AXIS * dist
delta = markerToCam - scaledCenterVec
self.camManipRef.setPosHpr(direct.camera, Point3(0), Point3(0))
t = direct.camera.lerpPos(Point3(delta),
self.camManipRef.setPosHpr(base.direct.camera, Point3(0), Point3(0))
t = base.direct.camera.lerpPos(Point3(delta),
CAM_MOVE_DURATION,
other = self.camManipRef,
blendType = 'easeInOut',
@ -536,14 +536,14 @@ class DirectCameraControl(DirectObject):
def zoomCam(self, zoomFactor, t):
taskMgr.remove('manipulateCamera')
# Record undo point
direct.pushUndo([direct.camera])
base.direct.pushUndo([base.direct.camera])
# Find a point zoom factor times the current separation
# of the widget and cam
zoomPtToCam = self.coaMarker.getPos(direct.camera) * zoomFactor
zoomPtToCam = self.coaMarker.getPos(base.direct.camera) * zoomFactor
# Put a target nodePath there
self.camManipRef.setPos(direct.camera, zoomPtToCam)
self.camManipRef.setPos(base.direct.camera, zoomPtToCam)
# Move to that point
t = direct.camera.lerpPos(ZERO_POINT,
t = base.direct.camera.lerpPos(ZERO_POINT,
CAM_MOVE_DURATION,
other = self.camManipRef,
blendType = 'easeInOut',
@ -554,7 +554,7 @@ class DirectCameraControl(DirectObject):
# Kill any existing tasks
taskMgr.remove('manipulateCamera')
# Record undo point
direct.pushUndo([direct.camera])
base.direct.pushUndo([base.direct.camera])
# Calc hprOffset
hprOffset = VBase3()
if view == 8:
@ -583,7 +583,7 @@ class DirectCameraControl(DirectObject):
self.camManipRef.setPosHpr(self.coaMarker, ZERO_VEC,
hprOffset)
# Scale center vec by current distance to target
offsetDistance = Vec3(direct.camera.getPos(self.camManipRef) -
offsetDistance = Vec3(base.direct.camera.getPos(self.camManipRef) -
ZERO_POINT).length()
scaledCenterVec = Y_AXIS * (-1.0 * offsetDistance)
# Now put the camManipRef at that point
@ -592,7 +592,7 @@ class DirectCameraControl(DirectObject):
ZERO_VEC)
# Record view for next time around
self.lastView = view
t = direct.camera.lerpPosHpr(ZERO_POINT,
t = base.direct.camera.lerpPosHpr(ZERO_POINT,
VBase3(0, 0, self.orthoViewRoll),
CAM_MOVE_DURATION,
other = self.camManipRef,
@ -606,15 +606,15 @@ class DirectCameraControl(DirectObject):
taskMgr.remove('manipulateCamera')
# Record undo point
direct.pushUndo([direct.camera])
base.direct.pushUndo([base.direct.camera])
# Coincident with widget
self.camManipRef.setPos(self.coaMarker, ZERO_POINT)
# But aligned with render space
self.camManipRef.setHpr(ZERO_POINT)
parent = direct.camera.getParent()
direct.camera.wrtReparentTo(self.camManipRef)
parent = base.direct.camera.getParent()
base.direct.camera.wrtReparentTo(self.camManipRef)
manipTask = self.camManipRef.lerpHpr(VBase3(degrees, 0, 0),
CAM_MOVE_DURATION,
@ -625,7 +625,7 @@ class DirectCameraControl(DirectObject):
manipTask.uponDeath = self.reparentCam
def reparentCam(self, state):
direct.camera.wrtReparentTo(state.parent)
base.direct.camera.wrtReparentTo(state.parent)
self.updateCoaMarkerSize()
def fitOnWidget(self, nodePath = 'None Given'):
@ -633,29 +633,29 @@ class DirectCameraControl(DirectObject):
# stop any ongoing tasks
taskMgr.remove('manipulateCamera')
# How big is the node?
nodeScale = direct.widget.scalingNode.getScale(render)
nodeScale = base.direct.widget.scalingNode.getScale(render)
maxScale = max(nodeScale[0], nodeScale[1], nodeScale[2])
maxDim = min(direct.dr.nearWidth, direct.dr.nearHeight)
maxDim = min(base.direct.dr.nearWidth, base.direct.dr.nearHeight)
# At what distance does the object fill 30% of the screen?
# Assuming radius of 1 on widget
camY = direct.dr.near * (2.0 * maxScale)/(0.3 * maxDim)
camY = base.direct.dr.near * (2.0 * maxScale)/(0.3 * maxDim)
# What is the vector through the center of the screen?
centerVec = Y_AXIS * camY
# Where is the node relative to the viewpoint
vWidget2Camera = direct.widget.getPos(direct.camera)
vWidget2Camera = base.direct.widget.getPos(base.direct.camera)
# How far do you move the camera to be this distance from the node?
deltaMove = vWidget2Camera - centerVec
# Move a target there
self.camManipRef.setPos(direct.camera, deltaMove)
self.camManipRef.setPos(base.direct.camera, deltaMove)
parent = direct.camera.getParent()
direct.camera.wrtReparentTo(self.camManipRef)
fitTask = direct.camera.lerpPos(Point3(0, 0, 0),
parent = base.direct.camera.getParent()
base.direct.camera.wrtReparentTo(self.camManipRef)
fitTask = base.direct.camera.lerpPos(Point3(0, 0, 0),
CAM_MOVE_DURATION,
blendType = 'easeInOut',
task = 'manipulateCamera')
@ -665,34 +665,34 @@ class DirectCameraControl(DirectObject):
def moveToFit(self):
# How bit is the active widget?
widgetScale = direct.widget.scalingNode.getScale(render)
widgetScale = base.direct.widget.scalingNode.getScale(render)
maxScale = max(widgetScale[0], widgetScale[1], widgetScale[2])
# At what distance does the widget fill 50% of the screen?
camY = ((2 * direct.dr.near * (1.5 * maxScale)) /
min(direct.dr.nearWidth, direct.dr.nearHeight))
camY = ((2 * base.direct.dr.near * (1.5 * maxScale)) /
min(base.direct.dr.nearWidth, base.direct.dr.nearHeight))
# Find a point this distance along the Y axis
# MRM: This needs to be generalized to support non uniform frusta
centerVec = Y_AXIS * camY
# Before moving, record the relationship between the selected nodes
# and the widget, so that this can be maintained
direct.selected.getWrtAll()
base.direct.selected.getWrtAll()
# Push state onto undo stack
direct.pushUndo(direct.selected)
base.direct.pushUndo(base.direct.selected)
# Remove the task to keep the widget attached to the object
taskMgr.remove('followSelectedNodePath')
# Spawn a task to keep the selected objects with the widget
taskMgr.add(self.stickToWidgetTask, 'stickToWidget')
# Spawn a task to move the widget
t = direct.widget.lerpPos(Point3(centerVec),
t = base.direct.widget.lerpPos(Point3(centerVec),
CAM_MOVE_DURATION,
other = direct.camera,
other = base.direct.camera,
blendType = 'easeInOut',
task = 'moveToFitTask')
t.uponDeath = lambda state: taskMgr.remove('stickToWidget')
def stickToWidgetTask(self, state):
# Move the objects with the widget
direct.selected.moveWrtWidgetAll()
base.direct.selected.moveWrtWidgetAll()
# Continue
return Task.cont
@ -706,7 +706,7 @@ class DirectCameraControl(DirectObject):
for event in self.keyEvents:
self.accept(event[0], event[1], extraArgs = event[2:])
# Show marker
self.coaMarker.reparentTo(direct.group)
self.coaMarker.reparentTo(base.direct.group)
def disableMouseFly(self):
# Hide the marker

View File

@ -136,23 +136,23 @@ def planeIntersect (lineOrigin, lineDir, planeOrigin, normal):
def getNearProjectionPoint(nodePath):
# Find the position of the projection of the specified node path
# on the near plane
origin = nodePath.getPos(direct.camera)
origin = nodePath.getPos(base.direct.camera)
# project this onto near plane
if origin[1] != 0.0:
return origin * (direct.dr.near / origin[1])
return origin * (base.direct.dr.near / origin[1])
else:
# Object is coplaner with camera, just return something reasonable
return Point3(0, direct.dr.near, 0)
return Point3(0, base.direct.dr.near, 0)
def getScreenXY(nodePath):
# Where does the node path's projection fall on the near plane
nearVec = getNearProjectionPoint(nodePath)
# Clamp these coordinates to visible screen
nearX = CLAMP(nearVec[0], direct.dr.left, direct.dr.right)
nearY = CLAMP(nearVec[2], direct.dr.bottom, direct.dr.top)
nearX = CLAMP(nearVec[0], base.direct.dr.left, base.direct.dr.right)
nearY = CLAMP(nearVec[2], base.direct.dr.bottom, base.direct.dr.top)
# What percentage of the distance across the screen is this?
percentX = (nearX - direct.dr.left)/direct.dr.nearWidth
percentY = (nearY - direct.dr.bottom)/direct.dr.nearHeight
percentX = (nearX - base.direct.dr.left)/base.direct.dr.nearWidth
percentY = (nearY - base.direct.dr.bottom)/base.direct.dr.nearHeight
# Map this percentage to the same -1 to 1 space as the mouse
screenXY = Vec3((2 * percentX) - 1.0, nearVec[1], (2 * percentY) - 1.0)
# Return the resulting value
@ -161,8 +161,8 @@ def getScreenXY(nodePath):
def getCrankAngle(center):
# Used to compute current angle of mouse (relative to the coa's
# origin) in screen space
x = direct.dr.mouseX - center[0]
y = direct.dr.mouseY - center[2]
x = base.direct.dr.mouseX - center[0]
y = base.direct.dr.mouseY - center[2]
return (180 + rad2Deg(math.atan2(y, x)))
def relHpr(nodePath, base, h, p, r):

View File

@ -52,7 +52,7 @@ class DirectGrid(NodePath, DirectObject):
self.enable()
def enable(self):
self.reparentTo(direct.group)
self.reparentTo(base.direct.group)
self.updateGrid()
self.fEnabled = 1

View File

@ -13,7 +13,7 @@ class DirectManipulationControl(DirectObject):
self.prevHit = Vec3(0)
self.rotationCenter = Point3(0)
self.initScaleMag = 1
self.manipRef = direct.group.attachNewNode('manipRef')
self.manipRef = base.direct.group.attachNewNode('manipRef')
self.hitPtDist = 0
self.constraint = None
self.rotateAxis = 'x'
@ -44,7 +44,7 @@ class DirectManipulationControl(DirectObject):
# Start out in select mode
self.mode = 'select'
# Check for a widget hit point
entry = direct.iRay.pickWidget()
entry = base.direct.iRay.pickWidget()
# Did we hit a widget?
if entry:
# Yes!
@ -56,7 +56,7 @@ class DirectManipulationControl(DirectObject):
# Nope, off the widget, no constraint
self.constraint = None
if not direct.gotAlt(modifiers):
if not base.direct.gotAlt(modifiers):
# Check to see if we are moving the object
# We are moving the object if we either wait long enough
taskMgr.doMethodLater(MANIPULATION_MOVE_DELAY,
@ -65,8 +65,8 @@ class DirectManipulationControl(DirectObject):
# Or we move far enough
self.moveDir = None
watchMouseTask = Task.Task(self.watchMouseTask)
watchMouseTask.initX = direct.dr.mouseX
watchMouseTask.initY = direct.dr.mouseY
watchMouseTask.initX = base.direct.dr.mouseX
watchMouseTask.initY = base.direct.dr.mouseY
taskMgr.add(watchMouseTask, 'manip-watch-mouse')
def switchToMoveMode(self, state):
@ -76,8 +76,8 @@ class DirectManipulationControl(DirectObject):
return Task.done
def watchMouseTask(self, state):
if (((abs (state.initX - direct.dr.mouseX)) > 0.01) or
((abs (state.initY - direct.dr.mouseY)) > 0.01)):
if (((abs (state.initX - base.direct.dr.mouseX)) > 0.01) or
((abs (state.initY - base.direct.dr.mouseY)) > 0.01)):
taskMgr.remove('manip-move-wait')
self.mode = 'move'
self.manipulateObject()
@ -97,15 +97,15 @@ class DirectManipulationControl(DirectObject):
skipFlags = self.defaultSkipFlags | self.optionalSkipFlags
# Skip camera (and its children), unless control key is pressed
skipFlags |= SKIP_CAMERA * (1 - base.getControl())
entry = direct.iRay.pickGeom(skipFlags = skipFlags)
entry = base.direct.iRay.pickGeom(skipFlags = skipFlags)
if entry:
# Record hit point information
self.hitPt.assign(entry.getSurfacePoint(entry.getFromNodePath()))
self.hitPtDist = Vec3(self.hitPt).length()
# Select it
direct.select(entry.getIntoNodePath(), direct.fShift)
base.direct.select(entry.getIntoNodePath(), base.direct.fShift)
else:
direct.deselectAll()
base.direct.deselectAll()
elif self.mode == 'move':
self.manipulateObjectCleanup()
self.mode = None
@ -115,39 +115,39 @@ class DirectManipulationControl(DirectObject):
# We had been scaling, need to reset object handles
self.objectHandles.transferObjectHandlesScale()
self.fScaling = 0
direct.selected.highlightAll()
base.direct.selected.highlightAll()
self.objectHandles.showAllHandles()
if direct.clusterMode == 'client':
if base.direct.clusterMode == 'client':
cluster(
'direct.manipulationControl.objectHandles.showAllHandles()')
'base.direct.manipulationControl.objectHandles.showAllHandles()')
self.objectHandles.hideGuides()
# Restart followSelectedNodePath task
self.spawnFollowSelectedNodePathTask()
messenger.send('DIRECT_manipulateObjectCleanup',
[direct.selected.getSelectedAsList()])
[base.direct.selected.getSelectedAsList()])
def spawnFollowSelectedNodePathTask(self):
# If nothing selected, just return
if not direct.selected.last:
if not base.direct.selected.last:
return
# Clear out old task to make sure
taskMgr.remove('followSelectedNodePath')
# Where are the object handles relative to the selected object
pos = VBase3(0)
hpr = VBase3(0)
decomposeMatrix(direct.selected.last.mCoa2Dnp,
decomposeMatrix(base.direct.selected.last.mCoa2Dnp,
VBase3(0), hpr, pos, CSDefault)
# Create the task
t = Task.Task(self.followSelectedNodePathTask)
# Update state variables
t.pos = pos
t.hpr = hpr
t.base = direct.selected.last
t.base = base.direct.selected.last
# Spawn the task
taskMgr.add(t, 'followSelectedNodePath')
def followSelectedNodePathTask(self, state):
direct.widget.setPosHpr(state.base, state.pos, state.hpr)
base.direct.widget.setPosHpr(state.base, state.pos, state.hpr)
return Task.cont
def enableManipulation(self):
@ -198,7 +198,7 @@ class DirectManipulationControl(DirectObject):
def manipulateObject(self):
# Only do this if something is selected
selectedList = direct.selected.getSelectedAsList()
selectedList = base.direct.selected.getSelectedAsList()
# See if any of the selected are completely uneditable
editTypes = self.getEditTypes(selectedList)
if (editTypes & EDIT_TYPE_UNEDITABLE == EDIT_TYPE_UNEDITABLE):
@ -212,20 +212,20 @@ class DirectManipulationControl(DirectObject):
# Set manipulation flag
self.fManip = 1
# Record undo point
direct.pushUndo(direct.selected)
base.direct.pushUndo(base.direct.selected)
# Update object handles visibility
self.objectHandles.showGuides()
self.objectHandles.hideAllHandles()
self.objectHandles.showHandle(self.constraint)
if direct.clusterMode == 'client':
oh = 'direct.manipulationControl.objectHandles'
if base.direct.clusterMode == 'client':
oh = 'base.direct.manipulationControl.objectHandles'
cluster(oh + '.showGuides()', 0)
cluster(oh + '.hideAllHandles()', 0)
cluster(oh + ('.showHandle("%s")'% self.constraint), 0)
# Record relationship between selected nodes and widget
direct.selected.getWrtAll()
base.direct.selected.getWrtAll()
# hide the bbox of the selected objects during interaction
direct.selected.dehighlightAll()
base.direct.selected.dehighlightAll()
# Send event to signal start of manipulation
messenger.send('DIRECT_manipulateObjectStart')
# Manipulate the real object with the constraint
@ -238,14 +238,14 @@ class DirectManipulationControl(DirectObject):
self.fScaleInit = 1
# record initial offset between widget and camera
t = Task.Task(self.manipulateObjectTask)
t.fMouseX = abs(direct.dr.mouseX) > 0.9
t.fMouseY = abs(direct.dr.mouseY) > 0.9
t.fMouseX = abs(base.direct.dr.mouseX) > 0.9
t.fMouseY = abs(base.direct.dr.mouseY) > 0.9
if t.fMouseX:
t.constrainedDir = 'y'
else:
t.constrainedDir = 'x'
# Compute widget's xy coords in screen space
t.coaCenter = getScreenXY(direct.widget)
t.coaCenter = getScreenXY(base.direct.widget)
# These are used to rotate about view vector
if t.fMouseX and t.fMouseY:
t.lastAngle = getCrankAngle(t.coaCenter)
@ -264,11 +264,11 @@ class DirectManipulationControl(DirectObject):
# No widget interaction, determine free manip mode
elif self.fFreeManip:
# If we've been scaling and changed modes, reset object handles
if 0 and self.fScaling and (not direct.fAlt):
if 0 and self.fScaling and (not base.direct.fAlt):
self.objectHandles.transferObjectHandlesScale()
self.fScaling = 0
# Alt key switches to a scaling mode
if direct.fControl and not self.currEditTypes & EDIT_TYPE_UNSCALABLE:
if base.direct.fControl and not self.currEditTypes & EDIT_TYPE_UNSCALABLE:
self.fScaling = 1
self.scale3D(state)
# Otherwise, manip mode depends on where you started
@ -281,17 +281,17 @@ class DirectManipulationControl(DirectObject):
elif not self.currEditTypes & EDIT_TYPE_UNMOVABLE:
# Mouse started in central region, xlate
# Mode depends on shift key
if direct.fShift or direct.fControl:
if base.direct.fShift or base.direct.fControl:
self.xlateCamXY(state)
else:
self.xlateCamXZ(state)
if self.fSetCoa:
# Update coa based on current widget position
direct.selected.last.mCoa2Dnp.assign(
direct.widget.getMat(direct.selected.last))
base.direct.selected.last.mCoa2Dnp.assign(
base.direct.widget.getMat(base.direct.selected.last))
else:
# Move the objects with the widget
direct.selected.moveWrtWidgetAll()
base.direct.selected.moveWrtWidgetAll()
# Continue
return Task.cont
@ -319,7 +319,7 @@ class DirectManipulationControl(DirectObject):
else:
# Move widget to keep hit point as close to mouse as possible
offset = self.hitPt - self.prevHit
direct.widget.setPos(direct.widget, offset)
base.direct.widget.setPos(base.direct.widget, offset)
def xlate2D(self, state):
# Constrained 2D (planar) translation
@ -327,7 +327,7 @@ class DirectManipulationControl(DirectObject):
# to one of the three orthogonal planes on the widget.
# This point tracks all subsequent mouse movements
self.hitPt.assign(self.objectHandles.getWidgetIntersectPt(
direct.widget, self.constraint[:1]))
base.direct.widget, self.constraint[:1]))
# use it to see how far to move the widget
if self.fHitInit:
# First time through just record hit point
@ -335,7 +335,7 @@ class DirectManipulationControl(DirectObject):
self.prevHit.assign(self.hitPt)
else:
offset = self.hitPt - self.prevHit
direct.widget.setPos(direct.widget, offset)
base.direct.widget.setPos(base.direct.widget, offset)
def rotate1D(self, state):
# Constrained 1D rotation about the widget's main axis (X, Y, or Z)
@ -349,7 +349,7 @@ class DirectManipulationControl(DirectObject):
self.fHitInit = 0
self.rotateAxis = self.constraint[:1]
self.fWidgetTop = self.widgetCheck('top?')
self.rotationCenter = getScreenXY(direct.widget)
self.rotationCenter = getScreenXY(base.direct.widget)
self.lastCrankAngle = getCrankAngle(self.rotationCenter)
# Rotate widget based on how far cursor has swung around origin
@ -358,11 +358,11 @@ class DirectManipulationControl(DirectObject):
if self.fWidgetTop:
deltaAngle = -1 * deltaAngle
if self.rotateAxis == 'x':
direct.widget.setP(direct.widget, deltaAngle)
base.direct.widget.setP(base.direct.widget, deltaAngle)
elif self.rotateAxis == 'y':
direct.widget.setR(direct.widget, deltaAngle)
base.direct.widget.setR(base.direct.widget, deltaAngle)
elif self.rotateAxis == 'z':
direct.widget.setH(direct.widget, deltaAngle)
base.direct.widget.setH(base.direct.widget, deltaAngle)
# Record crank angle for next time around
self.lastCrankAngle = newAngle
@ -374,7 +374,7 @@ class DirectManipulationControl(DirectObject):
# widget's origin and one of the three principle axes
axis = self.constraint[:1]
# First compute vector from eye through widget origin
mWidget2Cam = direct.widget.getMat(direct.camera)
mWidget2Cam = base.direct.widget.getMat(base.direct.camera)
# And determine where the viewpoint is relative to widget
pos = VBase3(0)
decomposeMatrix(mWidget2Cam, VBase3(0), VBase3(0), pos,
@ -406,18 +406,18 @@ class DirectManipulationControl(DirectObject):
# Reset scaling init flag
self.fScaleInit = 1
# Where is the widget relative to current camera view
vWidget2Camera = direct.widget.getPos(direct.camera)
vWidget2Camera = base.direct.widget.getPos(base.direct.camera)
x = vWidget2Camera[0]
y = vWidget2Camera[1]
z = vWidget2Camera[2]
# Move widget (and objects) based upon mouse motion
# Scaled up accordingly based upon widget distance
dr = direct.dr
direct.widget.setX(
direct.camera,
dr = base.direct.dr
base.direct.widget.setX(
base.direct.camera,
x + 0.5 * dr.mouseDeltaX * dr.nearWidth * (y/dr.near))
direct.widget.setZ(
direct.camera,
base.direct.widget.setZ(
base.direct.camera,
z + 0.5 * dr.mouseDeltaY * dr.nearHeight * (y/dr.near))
def xlateCamXY(self, state):
@ -428,17 +428,17 @@ class DirectManipulationControl(DirectObject):
# Reset scaling init flag
self.fScaleInit = 1
# Now, where is the widget relative to current camera view
vWidget2Camera = direct.widget.getPos(direct.camera)
vWidget2Camera = base.direct.widget.getPos(base.direct.camera)
# If this is first time around, record initial y distance
if self.fHitInit:
self.fHitInit = 0
# Use distance to widget to scale motion along Y
self.xlateSF = Vec3(vWidget2Camera).length()
# Get widget's current xy coords in screen space
coaCenter = getNearProjectionPoint(direct.widget)
self.deltaNearX = coaCenter[0] - direct.dr.nearVec[0]
coaCenter = getNearProjectionPoint(base.direct.widget)
self.deltaNearX = coaCenter[0] - base.direct.dr.nearVec[0]
# Which way do we move the object?
if direct.fControl:
if base.direct.fControl:
moveDir = Vec3(vWidget2Camera)
# If widget is behind camera invert vector
if moveDir[1] < 0.0:
@ -447,7 +447,7 @@ class DirectManipulationControl(DirectObject):
else:
moveDir = Vec3(Y_AXIS)
# Move selected objects
dr = direct.dr
dr = base.direct.dr
# Scale move dir
moveDir.assign(moveDir * (2.0 * dr.mouseDeltaY * self.xlateSF))
# Add it to current widget offset
@ -456,7 +456,7 @@ class DirectManipulationControl(DirectObject):
vWidget2Camera.setX((dr.nearVec[0] + self.deltaNearX) *
(vWidget2Camera[1]/dr.near))
# Move widget
direct.widget.setPos(direct.camera, vWidget2Camera)
base.direct.widget.setPos(base.direct.camera, vWidget2Camera)
def rotate2D(self, state):
""" Virtual trackball rotation of widget """
@ -466,17 +466,17 @@ class DirectManipulationControl(DirectObject):
self.fScaleInit = 1
tumbleRate = 360
# If moving outside of center, ignore motion perpendicular to edge
if ((state.constrainedDir == 'y') and (abs(direct.dr.mouseX) > 0.9)):
if ((state.constrainedDir == 'y') and (abs(base.direct.dr.mouseX) > 0.9)):
deltaX = 0
deltaY = direct.dr.mouseDeltaY
elif ((state.constrainedDir == 'x') and (abs(direct.dr.mouseY) > 0.9)):
deltaX = direct.dr.mouseDeltaX
deltaY = base.direct.dr.mouseDeltaY
elif ((state.constrainedDir == 'x') and (abs(base.direct.dr.mouseY) > 0.9)):
deltaX = base.direct.dr.mouseDeltaX
deltaY = 0
else:
deltaX = direct.dr.mouseDeltaX
deltaY = direct.dr.mouseDeltaY
deltaX = base.direct.dr.mouseDeltaX
deltaY = base.direct.dr.mouseDeltaY
# Mouse motion edge to edge of display region results in one full turn
relHpr(direct.widget, direct.camera, deltaX * tumbleRate,
relHpr(base.direct.widget, base.direct.camera, deltaX * tumbleRate,
-deltaY * tumbleRate, 0)
def rotateAboutViewVector(self, state):
@ -489,7 +489,7 @@ class DirectManipulationControl(DirectObject):
deltaAngle = angle - state.lastAngle
state.lastAngle = angle
# Mouse motion edge to edge of display region results in one full turn
relHpr(direct.widget, direct.camera, 0, 0, -deltaAngle)
relHpr(base.direct.widget, base.direct.camera, 0, 0, -deltaAngle)
def scale3D(self, state):
# Scale the selected node based upon up down mouse motion
@ -497,13 +497,13 @@ class DirectManipulationControl(DirectObject):
# From midpoint to edge doubles or halves objects scale
if self.fScaleInit:
self.fScaleInit = 0
self.manipRef.setPos(direct.widget, 0, 0, 0)
self.manipRef.setHpr(direct.camera, 0, 0, 0)
self.manipRef.setPos(base.direct.widget, 0, 0, 0)
self.manipRef.setHpr(base.direct.camera, 0, 0, 0)
self.initScaleMag = Vec3(
self.objectHandles.getWidgetIntersectPt(
self.manipRef, 'y')).length()
# record initial scale
self.initScale = direct.widget.getScale()
self.initScale = base.direct.widget.getScale()
# Reset fHitInitFlag
self.fHitInit = 1
# Begin
@ -514,29 +514,29 @@ class DirectManipulationControl(DirectObject):
self.manipRef, 'y').length() /
self.initScaleMag)
)
direct.widget.setScale(currScale)
base.direct.widget.setScale(currScale)
## Utility functions ##
def plantSelectedNodePath(self):
""" Move selected object to intersection point of cursor on scene """
# Check for intersection
entry = direct.iRay.pickGeom(
entry = base.direct.iRay.pickGeom(
skipFlags = SKIP_HIDDEN | SKIP_BACKFACE | SKIP_CAMERA)
# MRM: Need to handle moving COA
if (entry != None) and (direct.selected.last != None):
if (entry != None) and (base.direct.selected.last != None):
# Record undo point
direct.pushUndo(direct.selected)
base.direct.pushUndo(base.direct.selected)
# Record wrt matrix
direct.selected.getWrtAll()
base.direct.selected.getWrtAll()
# Move selected
direct.widget.setPos(
direct.camera, entry.getSurfacePoint(entry.getFromNodePath()))
base.direct.widget.setPos(
base.direct.camera, entry.getSurfacePoint(entry.getFromNodePath()))
# Move all the selected objects with widget
# Move the objects with the widget
direct.selected.moveWrtWidgetAll()
base.direct.selected.moveWrtWidgetAll()
# Let everyone know that something was moved
messenger.send('DIRECT_manipulateObjectCleanup',
[direct.selected.getSelectedAsList()])
[base.direct.selected.getSelectedAsList()])
class ObjectHandles(NodePath, DirectObject):
def __init__(self):
@ -624,10 +624,10 @@ class ObjectHandles(NodePath, DirectObject):
def showWidgetIfActive(self):
if self.fActive:
self.reparentTo(direct.group)
self.reparentTo(base.direct.group)
def showWidget(self):
self.reparentTo(direct.group)
self.reparentTo(base.direct.group)
def hideWidget(self):
self.reparentTo(hidden)
@ -790,9 +790,9 @@ class ObjectHandles(NodePath, DirectObject):
def growToFit(self):
taskMgr.remove('resizeObjectHandles')
# Increase handles scale until they cover 30% of the min dimension
pos = direct.widget.getPos(direct.camera)
minDim = min(direct.dr.nearWidth, direct.dr.nearHeight)
sf = 0.15 * minDim * (pos[1]/direct.dr.near)
pos = base.direct.widget.getPos(base.direct.camera)
minDim = min(base.direct.dr.nearWidth, base.direct.dr.nearHeight)
sf = 0.15 * minDim * (pos[1]/base.direct.dr.near)
self.ohScalingFactor = sf
self.scalingNode.lerpScale(sf, sf, sf, 0.5,
blendType = 'easeInOut',
@ -911,8 +911,8 @@ class ObjectHandles(NodePath, DirectObject):
def getAxisIntersectPt(self, axis):
# Calc the xfrom from camera to widget
mCam2Widget = direct.camera.getMat(direct.widget)
lineDir = Vec3(mCam2Widget.xformVec(direct.dr.nearVec))
mCam2Widget = base.direct.camera.getMat(base.direct.widget)
lineDir = Vec3(mCam2Widget.xformVec(base.direct.dr.nearVec))
lineDir.normalize()
# And determine where the viewpoint is relative to widget
lineOrigin = VBase3(0)
@ -959,7 +959,7 @@ class ObjectHandles(NodePath, DirectObject):
# with the plane containing the 2D xlation or 1D rotation widgets
# Calc the xfrom from camera to the nodePath
mCam2NodePath = direct.camera.getMat(nodePath)
mCam2NodePath = base.direct.camera.getMat(nodePath)
# And determine where the viewpoint is relative to widget
lineOrigin = VBase3(0)
@ -969,7 +969,7 @@ class ObjectHandles(NodePath, DirectObject):
# Next we find the vector from viewpoint to the widget through
# the mouse's position on near plane.
# This defines the intersection ray
lineDir = Vec3(mCam2NodePath.xformVec(direct.dr.nearVec))
lineDir = Vec3(mCam2NodePath.xformVec(base.direct.dr.nearVec))
lineDir.normalize()
# Find the hit point
if plane == 'x':

View File

@ -19,7 +19,7 @@ class DirectNodePath(NodePath):
# Create matrix to hold the offset between the nodepath
# and its center of action (COA)
self.mCoa2Dnp = Mat4(Mat4.identMat())
if direct.coaMode == COA_CENTER:
if base.direct.coaMode == COA_CENTER:
self.mCoa2Dnp.setRow(3, Vec4(center[0], center[1], center[2], 1))
# Transform from nodePath to widget
@ -104,7 +104,7 @@ class SelectedNodePaths(DirectObject):
# And update last
__builtins__["last"] = self.last = dnp
# Update cluster servers if this is a cluster client
if direct.clusterMode == 'client':
if base.direct.clusterMode == 'client':
cluster.selectNodePath(dnp)
return dnp
@ -125,7 +125,7 @@ class SelectedNodePaths(DirectObject):
# Send a message
messenger.send('DIRECT_deselectedNodePath', [dnp])
# Update cluster servers if this is a cluster client
if direct.clusterMode == 'client':
if base.direct.clusterMode == 'client':
cluster.deselectNodePath(dnp)
return dnp
@ -187,13 +187,13 @@ class SelectedNodePaths(DirectObject):
self.forEachSelectedNodePathDo(self.getWrt)
def getWrt(self, nodePath):
nodePath.tDnp2Widget = nodePath.getTransform(direct.widget)
nodePath.tDnp2Widget = nodePath.getTransform(base.direct.widget)
def moveWrtWidgetAll(self):
self.forEachSelectedNodePathDo(self.moveWrtWidget)
def moveWrtWidget(self, nodePath):
nodePath.setTransform(direct.widget, nodePath.tDnp2Widget)
nodePath.setTransform(base.direct.widget, nodePath.tDnp2Widget)
def deselectAll(self):
self.forEachSelectedNodePathDo(self.deselect)
@ -564,8 +564,8 @@ class SelectionRay(SelectionQueue):
mx = xy[0]
my = xy[1]
elif direct:
mx = direct.dr.mouseX
my = direct.dr.mouseY
mx = base.direct.dr.mouseX
my = base.direct.dr.mouseY
else:
if not base.mouseWatcherNode.hasMouse():
# No mouse in window.

View File

@ -51,7 +51,7 @@ class DirectSession(DirectObject):
self.useObjectHandles()
self.grid = DirectGrid()
self.grid.disable()
self.lights = DirectLights(direct.group)
self.lights = DirectLights(base.direct.group)
# Create some default lights
self.lights.createDefaultLights()
# But turn them off
@ -281,10 +281,10 @@ class DirectSession(DirectObject):
if self.oobeMode:
# Position a target point to lerp the oobe camera to
direct.cameraControl.camManipRef.iPosHpr(self.trueCamera)
base.direct.cameraControl.camManipRef.iPosHpr(self.trueCamera)
t = self.oobeCamera.lerpPosHpr(
Point3(0), Vec3(0), 2.0,
other = direct.cameraControl.camManipRef,
other = base.direct.cameraControl.camManipRef,
task = 'manipulateCamera',
blendType = 'easeInOut')
# When move is done, switch to oobe mode
@ -302,12 +302,12 @@ class DirectSession(DirectObject):
# Put camera under new oobe camera
base.cam.reparentTo(self.oobeCamera)
# Position a target point to lerp the oobe camera to
direct.cameraControl.camManipRef.setPos(
base.direct.cameraControl.camManipRef.setPos(
self.trueCamera, Vec3(-2, -20, 5))
direct.cameraControl.camManipRef.lookAt(self.trueCamera)
base.direct.cameraControl.camManipRef.lookAt(self.trueCamera)
t = self.oobeCamera.lerpPosHpr(
Point3(0), Vec3(0), 2.0,
other = direct.cameraControl.camManipRef,
other = base.direct.cameraControl.camManipRef,
task = 'manipulateCamera',
blendType = 'easeInOut')
# When move is done, switch to oobe mode
@ -315,8 +315,8 @@ class DirectSession(DirectObject):
def beginOOBE(self, state):
# Make sure we've reached our final destination
self.oobeCamera.iPosHpr(direct.cameraControl.camManipRef)
direct.camera = self.oobeCamera
self.oobeCamera.iPosHpr(base.direct.cameraControl.camManipRef)
base.direct.camera = self.oobeCamera
self.oobeMode = 1
def endOOBE(self, state):
@ -324,7 +324,7 @@ class DirectSession(DirectObject):
self.oobeCamera.iPosHpr(self.trueCamera)
# Disable OOBE mode.
base.cam.reparentTo(self.trueCamera)
direct.camera = self.trueCamera
base.direct.camera = self.trueCamera
# Get rid of ancillary node paths
self.oobeVis.reparentTo(hidden)
self.oobeCamera.reparentTo(hidden)
@ -608,7 +608,7 @@ class DirectSession(DirectObject):
if nodePath == 'None Given':
# If nothing specified, try selected node path
nodePath = self.selected.last
direct.select(nodePath)
base.direct.select(nodePath)
def fitTask(state, self = self):
self.cameraControl.fitOnWidget()
return Task.done
@ -783,7 +783,7 @@ class DirectSession(DirectObject):
def useObjectHandles(self):
self.widget = self.manipulationControl.objectHandles
self.widget.reparentTo(direct.group)
self.widget.reparentTo(base.direct.group)
def hideSelectedNPReadout(self):
self.selectedNPReadout.reparentTo(hidden)
@ -1004,7 +1004,7 @@ class DisplayRegionList(DirectObject):
def mouseUpdate(self, modifiers = DIRECT_NO_MOD):
for dr in self.displayRegionList:
dr.mouseUpdate()
direct.dr = self.getCurrentDr()
base.direct.dr = self.getCurrentDr()
def getCurrentDr(self):
for dr in self.displayRegionList:

View File

@ -949,11 +949,11 @@
def select(self):
base.startDirect(fWantTk = 0)
direct.select(self)
base.direct.select(self)
def deselect(self):
base.startDirect(fWantTk = 0)
direct.deselect(self)
base.direct.deselect(self)
def showCS(self, mask = None):
"""

View File

@ -1129,14 +1129,14 @@ del rgbPanel
#####################################################################
def select(self):
base.startDirect(fWantTk = 0)
direct.select(self)
base.direct.select(self)
Dtool_funcToMethod(select, NodePath)
del select
#####################################################################
def deselect(self):
base.startDirect(fWantTk = 0)
direct.deselect(self)
base.direct.deselect(self)
Dtool_funcToMethod(deselect, NodePath)
del deselect

View File

@ -555,15 +555,15 @@ class LevelEditor(NodePath, DirectObject):
# Initialize state
# Make sure direct is running
direct.enable()
base.direct.enable()
# And only the appropriate handles are showing
direct.widget.disableHandles(['x-ring', 'x-disc',
base.direct.widget.disableHandles(['x-ring', 'x-disc',
'y-ring', 'y-disc',
'z-post'])
# Initialize camera
base.camLens.setNear(1.0)
base.camLens.setFar(3000)
direct.camera.setPos(0, -10, 10)
base.direct.camera.setPos(0, -10, 10)
# Initialize drive mode
self.configureDriveModeCollisionData()
# Init visibility variables
@ -620,7 +620,7 @@ class LevelEditor(NodePath, DirectObject):
def enable(self):
""" Enable level editing and show level """
# Make sure level is visible
self.reparentTo(direct.group)
self.reparentTo(base.direct.group)
self.show()
# Add all the action events
for event in self.actionEvents:
@ -636,7 +636,7 @@ class LevelEditor(NodePath, DirectObject):
def disable(self):
""" Disable level editing and hide level """
# Deselect everything as a precaution
direct.deselectAll()
base.direct.deselectAll()
# Hide the level
self.reparentTo(hidden)
# Ignore the hooks
@ -681,7 +681,7 @@ class LevelEditor(NodePath, DirectObject):
# Initialize variables
# Reset grid
direct.grid.setPosHprScale(0, 0, 0, 0, 0, 0, 1, 1, 1)
base.direct.grid.setPosHprScale(0, 0, 0, 0, 0, 0, 1, 1, 1)
# The selected DNA Object/NodePath
self.selectedDNARoot = None
self.selectedNPRoot = None
@ -760,23 +760,23 @@ class LevelEditor(NodePath, DirectObject):
base.cam.iPosHpr()
# Renable mouse
self.enableMouse()
direct.enable()
base.direct.enable()
def useDriveMode(self):
""" Lerp down to eye level then switch to Drive mode """
pos = direct.camera.getPos()
pos = base.direct.camera.getPos()
pos.setZ(4.0)
hpr = direct.camera.getHpr()
hpr = base.direct.camera.getHpr()
hpr.set(hpr[0], 0.0, 0.0)
t = direct.camera.lerpPosHpr(pos, hpr, 1.0, blendType = 'easeInOut',
t = base.direct.camera.lerpPosHpr(pos, hpr, 1.0, blendType = 'easeInOut',
task = 'manipulateCamera')
# Note, if this dies an unatural death, this could screw things up
# t.uponDeath = self.switchToDriveMode
def switchToDriveMode(self, state):
""" Disable direct camera manipulation and enable player drive mode """
direct.minimumConfiguration()
direct.manipulationControl.disableManipulation()
base.direct.minimumConfiguration()
base.direct.manipulationControl.disableManipulation()
# Update vis data
self.initVisibilityData()
# Switch to drive mode
@ -786,9 +786,9 @@ class LevelEditor(NodePath, DirectObject):
# And move down and forward to compensate
base.camera.setPos(base.camera, 0, 5, -4)
# Make sure we're where we want to be
pos = direct.camera.getPos()
pos = base.direct.camera.getPos()
pos.setZ(0.0)
hpr = direct.camera.getHpr()
hpr = base.direct.camera.getHpr()
hpr.set(hpr[0], 0.0, 0.0)
# Fine tune the drive mode
base.mouseInterface.node().setPos(pos)
@ -1048,7 +1048,7 @@ class LevelEditor(NodePath, DirectObject):
# Update visible geometry using new DNA
newRoot = self.replace(self.selectedNPRoot, self.selectedDNARoot)
# Reselect node path and respawn followSelectedNodePathTask
direct.select(newRoot)
base.direct.select(newRoot)
def replace(self, nodePath, dnaNode):
""" Replace a node path with the results of a DNANode traversal """
@ -1083,7 +1083,7 @@ class LevelEditor(NodePath, DirectObject):
DNASTORE.removeDNAGroup(dnaNode)
if nodePath:
# Next deselect nodePath to avoid having bad node paths in the dict
direct.deselect(nodePath)
base.direct.deselect(nodePath)
# Now you can get rid of the node path
nodePath.removeNode()
@ -1224,19 +1224,19 @@ class LevelEditor(NodePath, DirectObject):
# It is, is it a DNA_NODE (i.e. does it have pos/hpr/scale)?
if DNAIsDerivedFrom(dnaObject, DNA_NODE):
# First snap selected node path to grid
pos = selectedNode.getPos(direct.grid)
snapPos = direct.grid.computeSnapPoint(pos)
pos = selectedNode.getPos(base.direct.grid)
snapPos = base.direct.grid.computeSnapPoint(pos)
if self.panel.fPlaneSnap.get():
zheight = 0
else:
zheight = snapPos[2]
selectedNode.setPos(direct.grid,
selectedNode.setPos(base.direct.grid,
snapPos[0], snapPos[1], zheight)
# Angle snap
h = direct.grid.computeSnapAngle(selectedNode.getH())
if direct.grid.getHprSnap():
h = base.direct.grid.computeSnapAngle(selectedNode.getH())
if base.direct.grid.getHprSnap():
selectedNode.setH(h)
if selectedNode == direct.selected.last:
if selectedNode == base.direct.selected.last:
self.setLastAngle(h)
# Update DNA
self.updatePose(dnaObject, selectedNode)
@ -1244,14 +1244,14 @@ class LevelEditor(NodePath, DirectObject):
pointOrCell, type = self.findPointOrCell(selectedNode)
if pointOrCell and type:
# First snap selected node path to grid
pos = selectedNode.getPos(direct.grid)
snapPos = direct.grid.computeSnapPoint(pos)
pos = selectedNode.getPos(base.direct.grid)
snapPos = base.direct.grid.computeSnapPoint(pos)
if self.panel.fPlaneSnap.get():
zheight = 0
else:
zheight = snapPos[2]
selectedNode.setPos(
direct.grid,
base.direct.grid,
snapPos[0], snapPos[1], zheight)
newPos = selectedNode.getPos(self.NPToplevel)
# Update DNA
@ -1457,14 +1457,14 @@ class LevelEditor(NodePath, DirectObject):
# Attach a node, so we can set pos with respect to:
tempNode = hidden.attachNewNode('tempNode')
# Place it:
tempNode.setPos(direct.grid, hitPt)
tempNode.setPos(base.direct.grid, hitPt)
# Copy the pos to where we really want it:
dnaNode.setPos(tempNode.getPos())
# Clean up:
tempNode.removeNode()
else:
# Place the new node path at the current grid origin
dnaNode.setPos(direct.grid.getPos())
dnaNode.setPos(base.direct.grid.getPos())
# Initialize angle to match last object
dnaNode.setHpr(Vec3(self.getLastAngle(), 0, 0))
@ -1479,7 +1479,7 @@ class LevelEditor(NodePath, DirectObject):
if DNAClassEqual(dnaNode, DNA_STREET):
self.snapList = self.getSnapPoint(dnaNode.getCode())
# Select the instance
direct.select(newNodePath)
base.direct.select(newNodePath)
self.lastNodePath = newNodePath
# Update grid to get ready for the next object
self.autoPositionGrid()
@ -1490,14 +1490,14 @@ class LevelEditor(NodePath, DirectObject):
def addGroup(self, nodePath):
""" Add a new DNA Node Group to the specified Node Path """
# Set the node path as the current parent
direct.setActiveParent(nodePath)
base.direct.setActiveParent(nodePath)
# Add a new group to the selected parent
self.createNewGroup()
def addVisGroup(self, nodePath):
""" Add a new DNA Group to the specified Node Path """
# Set the node path as the current parent
direct.setActiveParent(nodePath)
base.direct.setActiveParent(nodePath)
# Add a new group to the selected parent
self.createNewGroup(type = 'vis')
@ -1715,11 +1715,11 @@ class LevelEditor(NodePath, DirectObject):
elif DNAClassEqual(dnaObject, DNA_PROP):
# PROP OPERATIONS
self.DNATarget = dnaObject
if direct.gotControl(modifiers):
if base.direct.gotControl(modifiers):
menuMode = 'prop_color'
elif direct.gotAlt(modifiers) and self.panel.currentBaselineDNA:
elif base.direct.gotAlt(modifiers) and self.panel.currentBaselineDNA:
menuMode = 'baseline_style'
elif direct.gotShift(modifiers):
elif base.direct.gotShift(modifiers):
menuMode = 'sign_texture'
self.DNATarget = DNAGetChildOfClass(dnaObject, DNA_SIGN)
self.DNATargetParent = dnaObject
@ -1783,19 +1783,19 @@ class LevelEditor(NodePath, DirectObject):
hitPt = self.getWallIntersectionPoint(self.selectedNPRoot)
if hitPt[2] < 10.0:
# Do door operations
if direct.gotControl(modifiers):
if base.direct.gotControl(modifiers):
menuMode = 'door_color'
elif direct.gotAlt(modifiers):
elif base.direct.gotAlt(modifiers):
menuMode = 'door_orientation'
else:
menuMode = 'door_double_texture'
else:
# Do sign operations
if direct.gotControl(modifiers):
if base.direct.gotControl(modifiers):
menuMode = 'sign_color'
elif direct.gotAlt(modifiers) and self.panel.currentBaselineDNA:
elif base.direct.gotAlt(modifiers) and self.panel.currentBaselineDNA:
menuMode = 'baseline_style'
elif direct.gotAlt(modifiers):
elif base.direct.gotAlt(modifiers):
menuMode = 'sign_orientation'
else:
menuMode = 'sign_texture'
@ -1807,7 +1807,7 @@ class LevelEditor(NodePath, DirectObject):
wallNum = self.computeWallNum(dnaObject, hitPt)
if wallNum < 0:
# Do building related operations
if direct.gotAlt(modifiers):
if base.direct.gotAlt(modifiers):
menuMode = 'building_width'
else:
menuMode = 'building_style_all'
@ -1825,37 +1825,37 @@ class LevelEditor(NodePath, DirectObject):
# Determine which zone you are pointing at
if (zPt > 0.8):
# Do cornice operations
if direct.gotControl(modifiers):
if base.direct.gotControl(modifiers):
menuMode = 'cornice_color'
elif direct.gotAlt(modifiers):
elif base.direct.gotAlt(modifiers):
menuMode = 'cornice_orientation'
else:
menuMode = 'cornice_texture'
elif ((xPt < 0.3) or (xPt > 0.7)):
# Do wall operations
if direct.gotControl(modifiers):
if base.direct.gotControl(modifiers):
menuMode = 'wall_color'
elif direct.gotAlt(modifiers):
elif base.direct.gotAlt(modifiers):
menuMode = 'wall_orientation'
elif direct.gotShift(modifiers):
elif base.direct.gotShift(modifiers):
menuMode = 'wall_texture'
else:
menuMode = 'wall_style'
elif (zPt < 0.4):
# Do door operations
if direct.gotControl(modifiers):
if base.direct.gotControl(modifiers):
menuMode = 'door_color'
elif direct.gotAlt(modifiers):
elif base.direct.gotAlt(modifiers):
menuMode = 'door_orientation'
else:
menuMode = 'door_single_texture'
else:
# Do window operations
if direct.gotControl(modifiers):
if base.direct.gotControl(modifiers):
menuMode = 'window_color'
elif direct.gotAlt(modifiers):
elif base.direct.gotAlt(modifiers):
menuMode = 'window_orientation'
elif direct.gotShift(modifiers):
elif base.direct.gotShift(modifiers):
menuMode = 'window_count'
else:
menuMode = 'window_texture'
@ -2005,7 +2005,7 @@ class LevelEditor(NodePath, DirectObject):
# Now process newly selected node path
dnaParent = None
dnaNode = self.findDNANode(nodePath)
if direct.fControl:
if base.direct.fControl:
# Is the current node a DNA Object?
if not dnaNode:
# No it isn't, look for a parent DNA object
@ -2018,9 +2018,9 @@ class LevelEditor(NodePath, DirectObject):
# Do we need to switch selection to a parent object?
if dnaParent:
# Yes, deselect currently selected node path
direct.deselect(nodePath)
base.direct.deselect(nodePath)
# And select parent
direct.select(dnaParent, direct.fShift)
base.direct.select(dnaParent, base.direct.fShift)
elif dnaNode:
# We got a valid node path/DNA object, continue
self.selectedNPRoot = nodePath
@ -2048,9 +2048,9 @@ class LevelEditor(NodePath, DirectObject):
suitEdge = self.findSuitEdge(nodePath.getParent())
if suitEdge:
# Yes, deselect currently selected node path
direct.deselect(nodePath)
base.direct.deselect(nodePath)
# And select parent
direct.select(suitEdge, direct.fShift)
base.direct.select(suitEdge, base.direct.fShift)
# Let others know that something new may be selected:
for i in self.selectedNodePathHookHooks:
@ -2135,10 +2135,10 @@ class LevelEditor(NodePath, DirectObject):
def keyboardRotateSelected(self, arrowDirection):
""" Rotate selected objects using arrow keys """
# Get snap angle
if direct.fShift:
oldSnapAngle = direct.grid.snapAngle
direct.grid.setSnapAngle(1.0)
snapAngle = direct.grid.snapAngle
if base.direct.fShift:
oldSnapAngle = base.direct.grid.snapAngle
base.direct.grid.setSnapAngle(1.0)
snapAngle = base.direct.grid.snapAngle
# Compute new angle
if ((arrowDirection == 'left') or (arrowDirection == 'up')):
self.setLastAngle(self.getLastAngle() + snapAngle)
@ -2150,26 +2150,26 @@ class LevelEditor(NodePath, DirectObject):
elif (self.getLastAngle() > 180.0):
self.setLastAngle(self.getLastAngle() - 360.0)
# Move selected objects
for selectedNode in direct.selected:
for selectedNode in base.direct.selected:
selectedNode.setHpr(self.getLastAngle(), 0, 0)
# Snap objects to grid and update DNA if necessary
self.updateSelectedPose(direct.selected.getSelectedAsList())
if direct.fShift:
direct.grid.setSnapAngle(oldSnapAngle)
self.updateSelectedPose(base.direct.selected.getSelectedAsList())
if base.direct.fShift:
base.direct.grid.setSnapAngle(oldSnapAngle)
def keyboardTranslateSelected(self, arrowDirection):
gridToCamera = direct.grid.getMat(direct.camera)
gridToCamera = base.direct.grid.getMat(base.direct.camera)
camXAxis = gridToCamera.xformVec(X_AXIS)
xxDot = camXAxis.dot(X_AXIS)
xzDot = camXAxis.dot(Z_AXIS)
# what is the current grid spacing?
if direct.fShift:
if base.direct.fShift:
# If shift, divide grid spacing by 10.0
oldGridSpacing = direct.grid.gridSpacing
oldGridSpacing = base.direct.grid.gridSpacing
# Use back door to set grid spacing to avoid grid update
direct.grid.gridSpacing = direct.grid.gridSpacing/10.0
deltaMove = direct.grid.gridSpacing
base.direct.grid.gridSpacing = base.direct.grid.gridSpacing/10.0
deltaMove = base.direct.grid.gridSpacing
# Compute the specified delta
deltaPos = Vec3(0)
@ -2199,16 +2199,16 @@ class LevelEditor(NodePath, DirectObject):
deltaPos.setX(deltaPos[0] - deltaMove)
# Move selected objects
for selectedNode in direct.selected:
for selectedNode in base.direct.selected:
# Move it
selectedNode.setPos(direct.grid,
selectedNode.getPos(direct.grid) + deltaPos)
selectedNode.setPos(base.direct.grid,
selectedNode.getPos(base.direct.grid) + deltaPos)
# Snap objects to grid and update DNA if necessary
self.updateSelectedPose(direct.selected.getSelectedAsList())
self.updateSelectedPose(base.direct.selected.getSelectedAsList())
# Restore grid spacing
if direct.fShift:
if base.direct.fShift:
# Use back door to set grid spacing to avoid grid update
direct.grid.gridSpacing = oldGridSpacing
base.direct.grid.gridSpacing = oldGridSpacing
def keyboardXformSelected(self, arrowDirection, mode):
if mode == 'rotate':
@ -2250,9 +2250,9 @@ class LevelEditor(NodePath, DirectObject):
def showGrid(self, flag):
""" toggle direct grid """
if flag:
direct.grid.enable()
base.direct.grid.enable()
else:
direct.grid.disable()
base.direct.grid.disable()
# LEVEL MAP/MARKER FUNCTIONS
def createLevelMaps(self):
@ -2276,7 +2276,7 @@ class LevelEditor(NodePath, DirectObject):
map.setColor(Vec4(1, 1, 1, .4))
self.mapDictionary[neighborhood] = map
# Make sure this item isn't pickable
direct.addUnpickable(neighborhood + '_layout')
base.direct.addUnpickable(neighborhood + '_layout')
def selectMap(self, neighborhood):
if self.activeMap:
@ -2287,7 +2287,7 @@ class LevelEditor(NodePath, DirectObject):
def toggleMapVis(self, flag):
if flag:
self.levelMap.reparentTo(direct.group)
self.levelMap.reparentTo(base.direct.group)
else:
self.levelMap.reparentTo(hidden)
@ -2309,7 +2309,7 @@ class LevelEditor(NodePath, DirectObject):
taskMgr.add(self.insertionMarkerTask, 'insertionMarkerTask')
def insertionMarkerTask(self, state):
self.insertionMarker.setPosHpr(direct.grid, 0, 0, 0, 0, 0, 0)
self.insertionMarker.setPosHpr(base.direct.grid, 0, 0, 0, 0, 0, 0)
# MRM: Why is this necessary?
self.insertionMarker.setScale(1, 1, 1)
return Task.cont
@ -2344,7 +2344,7 @@ class LevelEditor(NodePath, DirectObject):
def autoPositionGrid(self, fLerp = 1):
taskMgr.remove('autoPositionGrid')
# Move grid to prepare for placement of next object
selectedNode = direct.selected.last
selectedNode = base.direct.selected.last
if selectedNode:
dnaNode = self.findDNANode(selectedNode)
if dnaNode == None:
@ -2371,7 +2371,7 @@ class LevelEditor(NodePath, DirectObject):
if fLerp:
# Position grid for placing next object
# Eventually we need to setHpr too
t = direct.grid.lerpPosHpr(
t = base.direct.grid.lerpPosHpr(
deltaPos, deltaHpr, 0.25,
other = selectedNode,
blendType = 'easeInOut',
@ -2381,24 +2381,24 @@ class LevelEditor(NodePath, DirectObject):
t.selectedNode = selectedNode
t.uponDeath = self.autoPositionCleanup
else:
direct.grid.setPosHpr(selectedNode, deltaPos, deltaHpr)
base.direct.grid.setPosHpr(selectedNode, deltaPos, deltaHpr)
# Also move the camera
taskMgr.remove('autoMoveDelay')
handlesToCam = direct.widget.getPos(direct.camera)
handlesToCam = handlesToCam * (direct.dr.near/handlesToCam[1])
if ((abs(handlesToCam[0]) > (direct.dr.nearWidth * 0.4)) or
(abs(handlesToCam[2]) > (direct.dr.nearHeight * 0.4))):
handlesToCam = base.direct.widget.getPos(base.direct.camera)
handlesToCam = handlesToCam * (base.direct.dr.near/handlesToCam[1])
if ((abs(handlesToCam[0]) > (base.direct.dr.nearWidth * 0.4)) or
(abs(handlesToCam[2]) > (base.direct.dr.nearHeight * 0.4))):
taskMgr.remove('manipulateCamera')
direct.cameraControl.centerCamIn(0.5)
base.direct.cameraControl.centerCamIn(0.5)
def autoPositionCleanup(self, state):
direct.grid.setPosHpr(state.selectedNode, state.deltaPos,
base.direct.grid.setPosHpr(state.selectedNode, state.deltaPos,
state.deltaHpr)
if direct.grid.getHprSnap():
if base.direct.grid.getHprSnap():
# Clean up grid angle
direct.grid.setH(ROUND_TO(direct.grid.getH(),
direct.grid.snapAngle))
base.direct.grid.setH(ROUND_TO(base.direct.grid.getH(),
base.direct.grid.snapAngle))
def getNextSnapPoint(self):
""" Pull next pos hpr deltas off of snap list then rotate list """
@ -2416,18 +2416,18 @@ class LevelEditor(NodePath, DirectObject):
through mouse.
"""
# Find mouse point on near plane
mouseX = direct.dr.mouseX
mouseY = direct.dr.mouseY
nearX = (math.tan(deg2Rad(direct.dr.fovH)/2.0) *
mouseX * direct.dr.near)
nearZ = (math.tan(deg2Rad(direct.dr.fovV)/2.0) *
mouseY * direct.dr.near)
mouseX = base.direct.dr.mouseX
mouseY = base.direct.dr.mouseY
nearX = (math.tan(deg2Rad(base.direct.dr.fovH)/2.0) *
mouseX * base.direct.dr.near)
nearZ = (math.tan(deg2Rad(base.direct.dr.fovV)/2.0) *
mouseY * base.direct.dr.near)
# Initialize points
mCam2Wall = direct.camera.getMat(selectedNode)
mCam2Wall = base.direct.camera.getMat(selectedNode)
mouseOrigin = Point3(0)
mouseOrigin.assign(mCam2Wall.getRow3(3))
mouseDir = Vec3(0)
mouseDir.set(nearX, direct.dr.near, nearZ)
mouseDir.set(nearX, base.direct.dr.near, nearZ)
mouseDir.assign(mCam2Wall.xformVec(mouseDir))
# Calc intersection point
return planeIntersect(mouseOrigin, mouseDir, ZERO_POINT, NEG_Y_AXIS)
@ -2437,7 +2437,7 @@ class LevelEditor(NodePath, DirectObject):
Return point of intersection between ground plane and line from cam
through mouse. Return false, if nothing selected. Snap to grid.
"""
return direct.grid.computeSnapPoint(self.getGridIntersectionPoint())
return base.direct.grid.computeSnapPoint(self.getGridIntersectionPoint())
def getGridIntersectionPoint(self):
"""
@ -2445,31 +2445,31 @@ class LevelEditor(NodePath, DirectObject):
through mouse. Return false, if nothing selected
"""
# Find mouse point on near plane
mouseX = direct.dr.mouseX
mouseY = direct.dr.mouseY
nearX = (math.tan(deg2Rad(direct.dr.fovH)/2.0) *
mouseX * direct.dr.near)
nearZ = (math.tan(deg2Rad(direct.dr.fovV)/2.0) *
mouseY * direct.dr.near)
mouseX = base.direct.dr.mouseX
mouseY = base.direct.dr.mouseY
nearX = (math.tan(deg2Rad(base.direct.dr.fovH)/2.0) *
mouseX * base.direct.dr.near)
nearZ = (math.tan(deg2Rad(base.direct.dr.fovV)/2.0) *
mouseY * base.direct.dr.near)
# Initialize points
mCam2Grid = direct.camera.getMat(direct.grid)
mCam2Grid = base.direct.camera.getMat(base.direct.grid)
mouseOrigin = Point3(0)
mouseOrigin.assign(mCam2Grid.getRow3(3))
mouseDir = Vec3(0)
mouseDir.set(nearX, direct.dr.near, nearZ)
mouseDir.set(nearX, base.direct.dr.near, nearZ)
mouseDir.assign(mCam2Grid.xformVec(mouseDir))
# Calc intersection point
return planeIntersect(mouseOrigin, mouseDir, ZERO_POINT, Z_AXIS)
def jumpToInsertionPoint(self):
""" Move selected object to insertion point """
selectedNode = direct.selected.last
selectedNode = base.direct.selected.last
if selectedNode:
# Check if its a dna node
dnaNode = self.findDNANode(selectedNode)
if dnaNode:
# Place the new node path at the current grid origin
selectedNode.setPos(direct.grid, 0, 0, 0)
selectedNode.setPos(base.direct.grid, 0, 0, 0)
# Initialize angle to match last object
selectedNode.setHpr(self.getLastAngle(), 0, 0)
# Now update DNA pos and hpr to reflect final pose
@ -2900,7 +2900,7 @@ class LevelEditor(NodePath, DirectObject):
v = self.getGridSnapIntersectionPoint()
# get the absolute pos relative to the top level.
# That is what gets stored in the point
mat = direct.grid.getMat(self.NPToplevel)
mat = base.direct.grid.getMat(self.NPToplevel)
absPos = Point3(mat.xformPoint(v))
print 'Suit point: ' + `absPos`
# Store the point in the DNA. If this point is already in there,
@ -2974,7 +2974,7 @@ class LevelEditor(NodePath, DirectObject):
def highlightConnected(self, nodePath = None, fReversePath = 0):
if nodePath == None:
nodePath = direct.selected.last
nodePath = base.direct.selected.last
if nodePath:
suitPoint = self.findPointOrCell(nodePath)[0]
if suitPoint:
@ -3044,7 +3044,7 @@ class LevelEditor(NodePath, DirectObject):
return
v = self.getGridSnapIntersectionPoint()
mat = direct.grid.getMat(self.NPParent)
mat = base.direct.grid.getMat(self.NPParent)
absPos = Point3(mat.xformPoint(v))
if (self.currentBattleCellType == '20w 20l'):
cell = DNABattleCell(20, 20, absPos)
@ -3366,7 +3366,7 @@ class LevelEditor(NodePath, DirectObject):
if dnaNode:
if (DNAClassEqual(dnaNode, DNA_FLAT_BUILDING) or
DNAClassEqual(dnaNode, DNA_LANDMARK_BUILDING)):
direct.reparent(nodePath, fWrt = 1)
base.direct.reparent(nodePath, fWrt = 1)
children = nodePath.getChildrenAsList()
for child in children:
self.reparentStreetBuildings(child)
@ -3379,15 +3379,15 @@ class LevelEditor(NodePath, DirectObject):
atrGroup = self.NPParent
atrGroup.setName('ATR')
self.setName(atrGroup, 'ATR')
direct.setActiveParent(atrGroup)
base.direct.setActiveParent(atrGroup)
for child in originalChildren:
direct.reparent(child)
base.direct.reparent(child)
# Now create a new group with just the buildings
self.addGroup(self.NPToplevel)
newGroup = self.NPParent
newGroup.setName('LongStreet')
self.setName(newGroup, 'LongStreet')
direct.setActiveParent(newGroup)
base.direct.setActiveParent(newGroup)
self.reparentStreetBuildings(self.NPToplevel)
return newGroup
@ -3410,7 +3410,7 @@ class LevelEditor(NodePath, DirectObject):
groupName = 'Buildings_' + side + "-" + str(sequenceNum)
newGroup.setName(groupName)
self.setName(newGroup, groupName)
direct.setActiveParent(newGroup)
base.direct.setActiveParent(newGroup)
if 'barricade_curve' in curveName:
parts = curveName.split('_')
@ -3448,7 +3448,7 @@ class LevelEditor(NodePath, DirectObject):
return streetLength
def addStreetUnits(self, streetLength):
direct.grid.setPosHpr(0, -40, 0, 0, 0, 0)
base.direct.grid.setPosHpr(0, -40, 0, 0, 0, 0)
currLength = 0
while (currLength < streetLength):
self.addStreet('street_80x40')
@ -3460,18 +3460,18 @@ class LevelEditor(NodePath, DirectObject):
numBldgs = len(bldgs)
streetLength = self.calcLongStreetLength(bldgs)/2.0
ref = None
direct.grid.fXyzSnap = 0
base.direct.grid.fXyzSnap = 0
currLength = 0
for i in range(numBldgs):
bldg = bldgs[i]
if ref == None:
direct.grid.iPosHpr(bldgGroup)
base.direct.grid.iPosHpr(bldgGroup)
else:
ref.select()
self.autoPositionGrid(fLerp = 0)
if direct.grid.getX() >= streetLength:
direct.grid.setPosHpr(direct.grid, 0, -40, 0, 180, 0, 0)
bldg.iPosHpr(direct.grid)
if base.direct.grid.getX() >= streetLength:
base.direct.grid.setPosHpr(base.direct.grid, 0, -40, 0, 180, 0, 0)
bldg.iPosHpr(base.direct.grid)
self.updateSelectedPose([bldg])
self.adjustPropChildren(bldg)
ref = bldg
@ -3629,8 +3629,8 @@ class LevelEditor(NodePath, DirectObject):
self.innerBarricadeDict = {}
direct.grid.fXyzSnap = 0
direct.grid.fHprSnap = 0
base.direct.grid.fXyzSnap = 0
base.direct.grid.fHprSnap = 0
self.panel.fPlaneSnap.set(0)
bldgGroup = self.consolidateStreetBuildings()
bldgs = bldgGroup.getChildrenAsList()
@ -3689,7 +3689,7 @@ class LevelEditor(NodePath, DirectObject):
self.updateSelectedPose([bldg])
self.adjustPropChildren(bldg)
direct.reparent(bldg, fWrt = 1)
base.direct.reparent(bldg, fWrt = 1)
print bldgIndex
elif curveType == 'trees':
curve.getPoint(currT, currPoint)
@ -3715,11 +3715,11 @@ class LevelEditor(NodePath, DirectObject):
self.addProp(tree)
for selectedNode in direct.selected:
for selectedNode in base.direct.selected:
# Move it
selectedNode.setPos(currPoint)
# Snap objects to grid and update DNA if necessary
self.updateSelectedPose(direct.selected.getSelectedAsList())
self.updateSelectedPose(base.direct.selected.getSelectedAsList())
elif curveType == 'bridge':
# Don't add any dna for the bridge sections, but add the length
# of the bridge so we can increment our building groups correctly
@ -3766,11 +3766,11 @@ class LevelEditor(NodePath, DirectObject):
"prop_snow_tree_large_ur",
"prop_snow_tree_large_ul"])
self.addProp(tree)
for selectedNode in direct.selected:
for selectedNode in base.direct.selected:
# Move it
selectedNode.setPos(currPoint)
# Snap objects to grid and update DNA if necessary
self.updateSelectedPose(direct.selected.getSelectedAsList())
self.updateSelectedPose(base.direct.selected.getSelectedAsList())
@ -3795,8 +3795,8 @@ class LevelEditor(NodePath, DirectObject):
unstashing code to go off kilter.
"""
direct.grid.fXyzSnap = 0
direct.grid.fHprSnap = 0
base.direct.grid.fXyzSnap = 0
base.direct.grid.fHprSnap = 0
self.panel.fPlaneSnap.set(0)
bldgGroup = self.consolidateStreetBuildings()
bldgs = bldgGroup.getChildrenAsList()
@ -3859,7 +3859,7 @@ class LevelEditor(NodePath, DirectObject):
self.updateSelectedPose([bldg])
self.adjustPropChildren(bldg)
direct.reparent(bldg, fWrt = 1)
base.direct.reparent(bldg, fWrt = 1)
print bldgIndex
elif curveType == 'trees':
curve.getPoint(currT, currPoint)
@ -3884,11 +3884,11 @@ class LevelEditor(NodePath, DirectObject):
self.addProp(tree)
for selectedNode in direct.selected:
for selectedNode in base.direct.selected:
# Move it
selectedNode.setPos(currPoint)
# Snap objects to grid and update DNA if necessary
self.updateSelectedPose(direct.selected.getSelectedAsList())
self.updateSelectedPose(base.direct.selected.getSelectedAsList())
elif curveType == 'bridge':
# Don't add any dna for the bridge sections, but add the length
# of the bridge so we can increment our building groups correctly
@ -3935,11 +3935,11 @@ class LevelEditor(NodePath, DirectObject):
"prop_snow_tree_large_ur",
"prop_snow_tree_large_ul"])
self.addProp(tree)
for selectedNode in direct.selected:
for selectedNode in base.direct.selected:
# Move it
selectedNode.setPos(currPoint)
# Snap objects to grid and update DNA if necessary
self.updateSelectedPose(direct.selected.getSelectedAsList())
self.updateSelectedPose(base.direct.selected.getSelectedAsList())
#done with for loop, increment bldgGroupIndex
bldgGroupIndex += 1
@ -4092,7 +4092,7 @@ class LevelStyleManager:
keys.sort()
styles = map(lambda x, d = dictionary: d[x], keys)
sf = 0.1
aspectRatio = (direct.dr.getWidth()/float(direct.dr.getHeight()))
aspectRatio = (base.direct.dr.getWidth()/float(base.direct.dr.getHeight()))
for i in range(numItems):
# Get the node
node = self.createBaselineStyleSample(styles[i])
@ -4215,7 +4215,7 @@ class LevelStyleManager:
keys.sort()
styles = map(lambda x, d = dictionary: d[x], keys)
sf = 0.03
aspectRatio = (direct.dr.getWidth()/float(direct.dr.getHeight()))
aspectRatio = (base.direct.dr.getWidth()/float(base.direct.dr.getHeight()))
for i in range(numItems):
# Get the node
node = self.createWallStyleSample(styles[i])
@ -4417,7 +4417,7 @@ class LevelStyleManager:
keys.sort()
styles = map(lambda x, d = dictionary: d[x], keys)
sf = 0.02
aspectRatio = (direct.dr.getWidth()/float(direct.dr.getHeight()))
aspectRatio = (base.direct.dr.getWidth()/float(base.direct.dr.getHeight()))
for i in range(numItems):
# Get the node
node = self.createBuildingStyleSample(styles[i])
@ -4630,7 +4630,7 @@ class LevelStyleManager:
newColorMenu = hidden.attachNewNode(menuName + 'Menu')
# Compute the angle per item
angle = deg2Rad(360.0/float(numItems))
aspectRatio = (direct.dr.getWidth() / float(direct.dr.getHeight()))
aspectRatio = (base.direct.dr.getWidth() / float(base.direct.dr.getHeight()))
# Attach the color chips to the new menu and adjust sizes
for i in range (numItems):
# Create a text node--just a card, really--of the right color.
@ -4717,7 +4717,7 @@ class LevelStyleManager:
newMenu = hidden.attachNewNode(dnaType + 'Menu')
# Compute angle increment per item
angle = deg2Rad(360.0/numItems)
aspectRatio = direct.dr.getWidth() /float(direct.dr.getHeight())
aspectRatio = base.direct.dr.getWidth() /float(base.direct.dr.getHeight())
# Add items
for i in range(0, numItems):
if dnaList[i]:
@ -4755,7 +4755,7 @@ class LevelStyleManager:
angle = 0.0
else:
angle = deg2Rad(360.0/numItems)
aspectRatio = direct.dr.getWidth()/float(direct.dr.getHeight())
aspectRatio = base.direct.dr.getWidth()/float(base.direct.dr.getHeight())
# Add items
for i in range (numItems):
# Create text node for each item
@ -5863,11 +5863,11 @@ class LevelEditorPanel(Pmw.MegaToplevel):
def toggleWidgetHandles(s = self):
if s.fPlaneSnap.get():
direct.widget.disableHandles(['x-ring', 'x-disc',
base.direct.widget.disableHandles(['x-ring', 'x-disc',
'y-ring', 'y-disc',
'z-post'])
else:
direct.widget.enableHandles('all')
base.direct.widget.enableHandles('all')
self.fPlaneSnap = IntVar()
self.fPlaneSnap.set(1)
self.planeSnapButton = Checkbutton(buttonFrame,
@ -5879,12 +5879,12 @@ class LevelEditorPanel(Pmw.MegaToplevel):
self.fGrid = IntVar()
self.fGrid.set(0)
direct.gridButton = Checkbutton(buttonFrame,
base.direct.gridButton = Checkbutton(buttonFrame,
text = 'Show Grid',
width = 6,
variable = self.fGrid,
command = self.toggleGrid)
direct.gridButton.pack(side = LEFT, expand = 1, fill = X)
base.direct.gridButton.pack(side = LEFT, expand = 1, fill = X)
buttonFrame.pack(fill = X)
buttonFrame4 = Frame(hull)
@ -5907,29 +5907,29 @@ class LevelEditorPanel(Pmw.MegaToplevel):
self.fColl = IntVar()
self.fColl.set(1)
direct.collButton = Checkbutton(
base.direct.collButton = Checkbutton(
buttonFrame4,
text = 'Collide',
variable = self.fColl,
command = self.levelEditor.toggleCollisions)
direct.collButton.pack(side = LEFT, expand = 1, fill = X)
base.direct.collButton.pack(side = LEFT, expand = 1, fill = X)
self.fVis = IntVar()
self.fVis.set(1)
direct.visButton = Checkbutton(
base.direct.visButton = Checkbutton(
buttonFrame4,
text = 'Visibility',
variable = self.fVis,
command = self.levelEditor.toggleVisibility)
direct.visButton.pack(side = LEFT, expand = 1, fill = X)
base.direct.visButton.pack(side = LEFT, expand = 1, fill = X)
self.fVisZones = IntVar()
self.fVisZones.set(visualizeZones)
direct.visZonesButton = Checkbutton(
base.direct.visZonesButton = Checkbutton(
buttonFrame4,
text = 'Show Zones',
variable = self.fVisZones)
direct.visZonesButton.pack(side = LEFT, expand = 1, fill = X)
base.direct.visZonesButton.pack(side = LEFT, expand = 1, fill = X)
buttonFrame4.pack(fill = X, padx = 5)
@ -5960,9 +5960,9 @@ class LevelEditorPanel(Pmw.MegaToplevel):
def toggleGrid(self):
if self.fGrid.get():
direct.grid.enable()
base.direct.grid.enable()
else:
direct.grid.disable()
base.direct.grid.disable()
def toggleSuitPaths(self):
if self.fPaths.get():
@ -5983,10 +5983,10 @@ class LevelEditorPanel(Pmw.MegaToplevel):
self.levelEditor.clearZoneLabels()
def toggleXyzSnap(self):
direct.grid.setXyzSnap(self.fXyzSnap.get())
base.direct.grid.setXyzSnap(self.fXyzSnap.get())
def toggleHprSnap(self):
direct.grid.setHprSnap(self.fXyzSnap.get())
base.direct.grid.setHprSnap(self.fXyzSnap.get())
def toggleMapVis(self):
self.levelEditor.toggleMapVis(self.fMapVis.get())

View File

@ -10,7 +10,7 @@ class PieMenu(NodePath, DirectObject):
NodePath.__init__(self)
# Create a toplevel node for aspect ratio scaling
self.assign(hidden.attachNewNode('PieMenu'))
self.dr = direct.dr
self.dr = base.direct.dr
# Attach the menu
self.visibleMenu = visibleMenu
# Try to flatten the visibleMenu (note, flattenStrong is too strong

View File

@ -145,7 +145,7 @@ def replaceTaskMgrFunc(replaceFuncList):
print ('replaced taskMgr function: %s' % funcName)
def replaceStateFunc(replaceFuncList):
if not sys.modules.get('direct.fsm.State'):
if not sys.modules.get('base.direct.fsm.State'):
return
from direct.fsm.State import State
for oldFunc, funcName, newFunc in replaceFuncList:
@ -174,7 +174,7 @@ def replaceAIRFunc(replaceFuncList):
def replaceIvalFunc(replaceFuncList):
# Make sure we have imported IntervalManager and thus created
# a global ivalMgr.
if not sys.modules.get('direct.interval.IntervalManager'):
if not sys.modules.get('base.direct.interval.IntervalManager'):
return
from direct.interval.FunctionInterval import FunctionInterval
for oldFunc, funcName, newFunc in replaceFuncList:

View File

@ -357,7 +357,7 @@ class ShowBase(DirectObject.DirectObject):
del self.sfxManagerList
try:
direct.panel.destroy()
base.direct.panel.destroy()
except StandardError:
pass
@ -2023,7 +2023,7 @@ class ShowBase(DirectObject.DirectObject):
self.wantDirect = fWantDirect
if self.wantDirect:
from direct.directtools import DirectSession
direct.enable()
base.direct.enable()
else:
__builtins__["direct"] = self.direct = None

View File

@ -41,8 +41,8 @@ class DirectSessionPanel(AppShell):
AppShell.__init__(self, parent)
# Active light
if len(direct.lights) > 0:
name = direct.lights.getNameList()[0]
if len(base.direct.lights) > 0:
name = base.direct.lights.getNameList()[0]
self.lightMenu.selectitem(name)
self.selectLightNamed(name)
else:
@ -59,14 +59,14 @@ class DirectSessionPanel(AppShell):
# Initialize state
# Dictionary keeping track of all node paths selected so far
self.nodePathDict = {}
self.nodePathDict['widget'] = direct.widget
self.nodePathDict['widget'] = base.direct.widget
self.nodePathNames = ['widget']
# Dictionary keeping track of all jb node paths selected so far
self.jbNodePathDict = {}
self.jbNodePathDict['none'] = 'No Node Path'
self.jbNodePathDict['widget'] = direct.widget
self.jbNodePathDict['camera'] = direct.camera
self.jbNodePathDict['widget'] = base.direct.widget
self.jbNodePathDict['camera'] = base.direct.camera
self.jbNodePathNames = ['camera', 'selected', 'none']
# Set up event hooks
@ -98,7 +98,7 @@ class DirectSessionPanel(AppShell):
command = self.toggleDirect)
self.directGridEnabled = BooleanVar()
self.directGridEnabled.set(direct.grid.isEnabled())
self.directGridEnabled.set(base.direct.grid.isEnabled())
self.menuBar.addmenuitem('DIRECT', 'checkbutton',
'DIRECT Grid Enabled',
label = 'Enable Grid',
@ -108,13 +108,13 @@ class DirectSessionPanel(AppShell):
self.menuBar.addmenuitem('DIRECT', 'command',
'Toggle Object Handles Visability',
label = 'Toggle Widget Viz',
command = direct.toggleWidgetVis)
command = base.direct.toggleWidgetVis)
self.menuBar.addmenuitem(
'DIRECT', 'command',
'Toggle Widget Move/COA Mode',
label = 'Toggle Widget Mode',
command = direct.manipulationControl.toggleObjectHandlesMode)
command = base.direct.manipulationControl.toggleObjectHandlesMode)
self.directWidgetOnTop = BooleanVar()
self.directWidgetOnTop.set(0)
@ -127,7 +127,7 @@ class DirectSessionPanel(AppShell):
self.menuBar.addmenuitem('DIRECT', 'command',
'Deselect All',
label = 'Deselect All',
command = direct.deselectAll)
command = base.direct.deselectAll)
# Get a handle to the menu frame
menuFrame = self.menuFrame
@ -147,8 +147,8 @@ class DirectSessionPanel(AppShell):
self.bind(self.nodePathMenu, 'Select node path to manipulate')
self.undoButton = Button(menuFrame, text = 'Undo',
command = direct.undo)
if direct.undoList:
command = base.direct.undo)
if base.direct.undoList:
self.undoButton['state'] = 'normal'
else:
self.undoButton['state'] = 'disabled'
@ -156,8 +156,8 @@ class DirectSessionPanel(AppShell):
self.bind(self.undoButton, 'Undo last operation')
self.redoButton = Button(menuFrame, text = 'Redo',
command = direct.redo)
if direct.redoList:
command = base.direct.redo)
if base.direct.redoList:
self.redoButton['state'] = 'normal'
else:
self.redoButton['state'] = 'disabled'
@ -211,7 +211,7 @@ class DirectSessionPanel(AppShell):
font=('MSSansSerif', 14, 'bold')).pack(expand = 0)
nameList = map(lambda x: 'Display Region ' + `x`,
range(len(direct.drList)))
range(len(base.direct.drList)))
self.drMenu = Pmw.ComboBox(
drFrame, labelpos = W, label_text = 'Display Region:',
entry_width = 20,
@ -289,7 +289,7 @@ class DirectSessionPanel(AppShell):
self.toggleLightsButton = Button(
toggleFrame,
text = 'Lights',
command = direct.lights.toggle)
command = base.direct.lights.toggle)
self.toggleLightsButton.pack(side = LEFT, fill = X, expand = 1)
self.toggleTextureButton = Button(
@ -348,7 +348,7 @@ class DirectSessionPanel(AppShell):
mainSwitchFrame.pack(fill = X, expand = 0)
# Widget to select a light to configure
nameList = direct.lights.getNameList()
nameList = base.direct.lights.getNameList()
lightMenuFrame = Frame(lightFrame)
self.lightMenu = Pmw.ComboBox(
@ -504,31 +504,31 @@ class DirectSessionPanel(AppShell):
gridPage,
text = 'Grid Spacing',
min = 0.1,
value = direct.grid.getGridSpacing())
self.gridSpacing['command'] = direct.grid.setGridSpacing
value = base.direct.grid.getGridSpacing())
self.gridSpacing['command'] = base.direct.grid.setGridSpacing
self.gridSpacing.pack(fill = X, expand = 0)
self.gridSize = Floater.Floater(
gridPage,
text = 'Grid Size',
min = 1.0,
value = direct.grid.getGridSize())
self.gridSize['command'] = direct.grid.setGridSize
value = base.direct.grid.getGridSize())
self.gridSize['command'] = base.direct.grid.setGridSize
self.gridSize.pack(fill = X, expand = 0)
self.gridSnapAngle = Dial.AngleDial(
gridPage,
text = 'Snap Angle',
style = 'mini',
value = direct.grid.getSnapAngle())
self.gridSnapAngle['command'] = direct.grid.setSnapAngle
value = base.direct.grid.getSnapAngle())
self.gridSnapAngle['command'] = base.direct.grid.setSnapAngle
self.gridSnapAngle.pack(fill = X, expand = 0)
## DEVICE PAGE ##
Label(devicePage, text = 'DEVICES',
font=('MSSansSerif', 14, 'bold')).pack(expand = 0)
if direct.joybox != None:
if base.direct.joybox != None:
joyboxFrame = Frame(devicePage, borderwidth = 2, relief = 'sunken')
Label(joyboxFrame, text = 'Joybox',
font=('MSSansSerif', 14, 'bold')).pack(expand = 0)
@ -575,7 +575,7 @@ class DirectSessionPanel(AppShell):
hull_relief = RIDGE, hull_borderwidth = 2,
min = 1.0, max = 100.0)
self.jbXyzSF['command'] = (
lambda v: direct.joybox.setXyzMultiplier(v))
lambda v: base.direct.joybox.setXyzMultiplier(v))
self.jbXyzSF.pack(fill = X, expand = 0)
self.bind(self.jbXyzSF, 'Set joybox XYZ speed multiplier')
@ -586,7 +586,7 @@ class DirectSessionPanel(AppShell):
hull_relief = RIDGE, hull_borderwidth = 2,
min = 1.0, max = 100.0)
self.jbHprSF['command'] = (
lambda v: direct.joybox.setHprMultiplier(v))
lambda v: base.direct.joybox.setHprMultiplier(v))
self.jbHprSF.pack(fill = X, expand = 0)
self.bind(self.jbHprSF, 'Set joybox HPR speed multiplier')
@ -603,23 +603,23 @@ class DirectSessionPanel(AppShell):
def toggleDirect(self):
if self.directEnabled.get():
direct.enable()
base.direct.enable()
else:
direct.disable()
base.direct.disable()
def toggleDirectGrid(self):
if self.directGridEnabled.get():
direct.grid.enable()
base.direct.grid.enable()
else:
direct.grid.disable()
base.direct.grid.disable()
def toggleWidgetOnTop(self):
if self.directWidgetOnTop.get():
direct.widget.setBin('gui-popup', 0)
direct.widget.setDepthTest(0)
base.direct.widget.setBin('gui-popup', 0)
base.direct.widget.setDepthTest(0)
else:
direct.widget.clearBin()
direct.widget.setDepthTest(1)
base.direct.widget.clearBin()
base.direct.widget.setDepthTest(1)
def selectedNodePathHook(self, nodePath):
# Make sure node path is in nodePathDict
@ -649,7 +649,7 @@ class DirectSessionPanel(AppShell):
# Did we finally get something?
if (nodePath != None):
# Yes, select it!
direct.select(nodePath)
base.direct.select(nodePath)
def addNodePath(self, nodePath):
self.addNodePathToDict(nodePath, self.nodePathNames,
@ -657,25 +657,25 @@ class DirectSessionPanel(AppShell):
def selectJBModeNamed(self, name):
if name == 'Joe Mode':
direct.joybox.joeMode()
base.direct.joybox.joeMode()
elif name == 'Drive Mode':
direct.joybox.driveMode()
base.direct.joybox.driveMode()
elif name == 'Orbit Mode':
direct.joybox.orbitMode()
base.direct.joybox.orbitMode()
elif name == 'Look At Mode':
direct.joybox.lookAtMode()
base.direct.joybox.lookAtMode()
elif name == 'Look Around Mode':
direct.joybox.lookAroundMode()
base.direct.joybox.lookAroundMode()
elif name == 'Walkthru Mode':
direct.joybox.walkthruMode()
base.direct.joybox.walkthruMode()
elif name == 'Demo Mode':
direct.joybox.demoMode()
base.direct.joybox.demoMode()
elif name == 'HPRXYZ Mode':
direct.joybox.hprXyzMode()
base.direct.joybox.hprXyzMode()
def selectJBNodePathNamed(self, name):
if name == 'selected':
nodePath = direct.selected.last
nodePath = base.direct.selected.last
# Add Combo box entry for this selected object
self.addJBNodePath(nodePath)
else:
@ -700,9 +700,9 @@ class DirectSessionPanel(AppShell):
if (nodePath != None):
# Yes, select it!
if (nodePath == 'No Node Path'):
direct.joybox.setNodePath(None)
base.direct.joybox.setNodePath(None)
else:
direct.joybox.setNodePath(nodePath)
base.direct.joybox.setNodePath(nodePath)
def addJBNodePath(self, nodePath):
self.addNodePathToDict(nodePath, self.jbNodePathNames,
@ -739,7 +739,7 @@ class DirectSessionPanel(AppShell):
def selectDisplayRegionNamed(self, name):
if (string.find(name, 'Display Region ') >= 0):
drIndex = string.atoi(name[-1:])
self.activeDisplayRegion = direct.drList[drIndex]
self.activeDisplayRegion = base.direct.drList[drIndex]
else:
self.activeDisplayRegion = None
# Make sure info is current
@ -793,10 +793,10 @@ class DirectSessionPanel(AppShell):
# Lights #
def selectLightNamed(self, name):
# See if light exists
self.activeLight = direct.lights[name]
self.activeLight = base.direct.lights[name]
# If not...create new one
if self.activeLight == None:
self.activeLight = direct.lights.create(name)
self.activeLight = base.direct.lights.create(name)
# Do we have a valid light at this point?
if self.activeLight:
light = self.activeLight.getLight()
@ -811,28 +811,28 @@ class DirectSessionPanel(AppShell):
else:
# Restore valid data
listbox = self.lightMenu.component('scrolledlist')
listbox.setlist(direct.lights.getNameList())
if len(direct.lights) > 0:
self.lightMenu.selectitem(direct.lights.getNameList()[0])
listbox.setlist(base.direct.lights.getNameList())
if len(base.direct.lights) > 0:
self.lightMenu.selectitem(base.direct.lights.getNameList()[0])
# Make sure info is current
self.updateLightInfo()
def addAmbient(self):
return direct.lights.create('ambient')
return base.direct.lights.create('ambient')
def addDirectional(self):
return direct.lights.create('directional')
return base.direct.lights.create('directional')
def addPoint(self):
return direct.lights.create('point')
return base.direct.lights.create('point')
def addSpot(self):
return direct.lights.create('spot')
return base.direct.lights.create('spot')
def addLight(self, light):
# Make list reflect current list of lights
listbox = self.lightMenu.component('scrolledlist')
listbox.setlist(direct.lights.getNameList())
listbox.setlist(base.direct.lights.getNameList())
# Select the newly added light
self.lightMenu.selectitem(light.getName())
# And show corresponding page
@ -840,16 +840,16 @@ class DirectSessionPanel(AppShell):
def toggleLights(self):
if self.enableLights.get():
direct.lights.allOn()
base.direct.lights.allOn()
else:
direct.lights.allOff()
base.direct.lights.allOff()
def toggleActiveLight(self):
if self.activeLight:
if self.lightActive.get():
direct.lights.setOn(self.activeLight)
base.direct.lights.setOn(self.activeLight)
else:
direct.lights.setOff(self.activeLight)
base.direct.lights.setOff(self.activeLight)
def setLightColor(self, color):
if self.activeLight:
@ -884,22 +884,22 @@ class DirectSessionPanel(AppShell):
## GRID CONTROLS ##
def toggleGrid(self):
if self.enableGrid.get():
direct.grid.enable()
base.direct.grid.enable()
else:
direct.grid.disable()
base.direct.grid.disable()
def toggleXyzSnap(self):
direct.grid.setXyzSnap(self.xyzSnap.get())
base.direct.grid.setXyzSnap(self.xyzSnap.get())
def toggleHprSnap(self):
direct.grid.setHprSnap(self.hprSnap.get())
base.direct.grid.setHprSnap(self.hprSnap.get())
## DEVICE CONTROLS
def toggleJoybox(self):
if self.enableJoybox.get():
direct.joybox.enable()
base.direct.joybox.enable()
else:
direct.joybox.disable()
base.direct.joybox.disable()
## UPDATE INFO ##
def updateInfo(self, page = 'Environment'):
@ -965,16 +965,16 @@ class DirectSessionPanel(AppShell):
self.pQuadraticAttenuation.set(att[2], 0)
def updateGridInfo(self):
self.enableGrid.set(direct.grid.isEnabled())
self.xyzSnap.set(direct.grid.getXyzSnap())
self.hprSnap.set(direct.grid.getHprSnap())
self.gridSpacing.set(direct.grid.getGridSpacing(), 0)
self.gridSize.set(direct.grid.getGridSize(), 0)
self.gridSnapAngle.set(direct.grid.getSnapAngle(), 0)
self.enableGrid.set(base.direct.grid.isEnabled())
self.xyzSnap.set(base.direct.grid.getXyzSnap())
self.hprSnap.set(base.direct.grid.getHprSnap())
self.gridSpacing.set(base.direct.grid.getGridSpacing(), 0)
self.gridSize.set(base.direct.grid.getGridSize(), 0)
self.gridSnapAngle.set(base.direct.grid.getSnapAngle(), 0)
# UNDO/REDO
def pushUndo(self, fResetRedo = 1):
direct.pushUndo([self['nodePath']])
base.direct.pushUndo([self['nodePath']])
def undoHook(self, nodePathList = []):
pass
@ -988,7 +988,7 @@ class DirectSessionPanel(AppShell):
self.undoButton.configure(state = 'disabled')
def pushRedo(self):
direct.pushRedo([self['nodePath']])
base.direct.pushRedo([self['nodePath']])
def redoHook(self, nodePathList = []):
pass

View File

@ -22,8 +22,8 @@ from direct.tkwidgets import VectorWidgets
import __builtin__
PRF_UTILITIES = [
'lambda: direct.camera.lookAt(render)',
'lambda: direct.camera.setZ(render, 0.0)',
'lambda: base.direct.camera.lookAt(render)',
'lambda: base.direct.camera.setZ(render, 0.0)',
'lambda s = self: s.playbackMarker.lookAt(render)',
'lambda s = self: s.playbackMarker.setZ(render, 0.0)',
'lambda s = self: s.followTerrain(10.0)']
@ -67,7 +67,7 @@ class MopathRecorder(AppShell, DirectObject):
# The active node path's parent
self.nodePathParent = render
# Top level node path
self.recorderNodePath = direct.group.attachNewNode(self.name)
self.recorderNodePath = base.direct.group.attachNewNode(self.name)
# Temp CS for use in refinement/path extension
self.tempCS = self.recorderNodePath.attachNewNode(
'mopathRecorderTempCS')
@ -97,8 +97,8 @@ class MopathRecorder(AppShell, DirectObject):
# Active node path dictionary
self.nodePathDict = {}
self.nodePathDict['marker'] = self.playbackMarker
self.nodePathDict['camera'] = direct.camera
self.nodePathDict['widget'] = direct.widget
self.nodePathDict['camera'] = base.direct.camera
self.nodePathDict['widget'] = base.direct.widget
self.nodePathDict['mopathRecorderTempCS'] = self.tempCS
self.nodePathNames = ['marker', 'camera', 'selected']
# ID of selected object
@ -203,20 +203,20 @@ class MopathRecorder(AppShell, DirectObject):
'Recorder', 'command',
'Toggle widget visability',
label = 'Toggle Widget Vis',
command = direct.toggleWidgetVis)
command = base.direct.toggleWidgetVis)
self.menuBar.addmenuitem(
'Recorder', 'command',
'Toggle widget manipulation mode',
label = 'Toggle Widget Mode',
command = direct.manipulationControl.toggleObjectHandlesMode)
command = base.direct.manipulationControl.toggleObjectHandlesMode)
self.createComboBox(self.menuFrame, 'Mopath', 'History',
'Select input points to fit curve to', '',
self.selectPointSetNamed, expand = 1)
self.undoButton = Button(self.menuFrame, text = 'Undo',
command = direct.undo)
if direct.undoList:
command = base.direct.undo)
if base.direct.undoList:
self.undoButton['state'] = 'normal'
else:
self.undoButton['state'] = 'disabled'
@ -224,8 +224,8 @@ class MopathRecorder(AppShell, DirectObject):
self.bind(self.undoButton, 'Undo last operation')
self.redoButton = Button(self.menuFrame, text = 'Redo',
command = direct.redo)
if direct.redoList:
command = base.direct.redo)
if base.direct.redoList:
self.redoButton['state'] = 'normal'
else:
self.redoButton['state'] = 'disabled'
@ -239,7 +239,7 @@ class MopathRecorder(AppShell, DirectObject):
# Button to select active node path
widget = self.createButton(frame, 'Recording', 'Node Path:',
'Select Active Mopath Node Path',
lambda s = self: direct.select(s.nodePath),
lambda s = self: base.direct.select(s.nodePath),
side = LEFT, expand = 0)
widget['relief'] = FLAT
self.nodePathMenu = Pmw.ComboBox(
@ -627,7 +627,7 @@ class MopathRecorder(AppShell, DirectObject):
self.mainNotebook.setnaturalsize()
def pushUndo(self, fResetRedo = 1):
direct.pushUndo([self.nodePath])
base.direct.pushUndo([self.nodePath])
def undoHook(self, nodePathList = []):
# Reflect new changes
@ -642,7 +642,7 @@ class MopathRecorder(AppShell, DirectObject):
self.undoButton.configure(state = 'disabled')
def pushRedo(self):
direct.pushRedo([self.nodePath])
base.direct.pushRedo([self.nodePath])
def redoHook(self, nodePathList = []):
# Reflect new changes
@ -664,9 +664,9 @@ class MopathRecorder(AppShell, DirectObject):
taskMgr.remove(self.name + '-curveEditTask')
print nodePath.id()
if nodePath.id() in self.playbackMarkerIds:
direct.select(self.playbackMarker)
base.direct.select(self.playbackMarker)
elif nodePath.id() in self.tangentMarkerIds:
direct.select(self.tangentMarker)
base.direct.select(self.tangentMarker)
elif nodePath.id() == self.playbackMarker.id():
self.tangentGroup.show()
taskMgr.add(self.curveEditTask,
@ -745,10 +745,10 @@ class MopathRecorder(AppShell, DirectObject):
def manipulateObjectStartHook(self):
self.manipulandumId = None
if direct.selected.last:
if direct.selected.last.id() == self.playbackMarker.id():
if base.direct.selected.last:
if base.direct.selected.last.id() == self.playbackMarker.id():
self.manipulandumId = self.playbackMarker.id()
elif direct.selected.last.id() == self.tangentMarker.id():
elif base.direct.selected.last.id() == self.tangentMarker.id():
self.manipulandumId = self.tangentMarker.id()
def manipulateObjectCleanupHook(self, nodePathList = []):
@ -766,8 +766,8 @@ class MopathRecorder(AppShell, DirectObject):
self.trace.reparentTo(self.recorderNodePath)
self.recorderNodePath.removeNode()
# Make sure markers are deselected
direct.deselect(self.playbackMarker)
direct.deselect(self.tangentMarker)
base.direct.deselect(self.playbackMarker)
base.direct.deselect(self.tangentMarker)
# Remove tasks
taskMgr.remove(self.name + '-recordTask')
taskMgr.remove(self.name + '-playbackTask')
@ -1180,7 +1180,7 @@ class MopathRecorder(AppShell, DirectObject):
# Add Combo box entry for the initial node path
self.addNodePath(nodePath)
elif name == 'selected':
nodePath = direct.selected.last
nodePath = base.direct.selected.last
# Add Combo box entry for this selected object
self.addNodePath(nodePath)
else:
@ -1203,7 +1203,7 @@ class MopathRecorder(AppShell, DirectObject):
else:
if name == 'widget':
# Record relationship between selected nodes and widget
direct.selected.getWrtAll()
base.direct.selected.getWrtAll()
if name == 'marker':
self.playbackMarker.show()
# Initialize tangent marker position

View File

@ -132,7 +132,7 @@ class ParticlePanel(AppShell):
command = self.createNewEffect)
self.effectsLabelMenu.add_command(
label = 'Select Particle Effect',
command = lambda s = self: direct.select(s.particleEffect))
command = lambda s = self: base.direct.select(s.particleEffect))
self.effectsLabelMenu.add_command(
label = 'Place Particle Effect',
command = lambda s = self: Placer.place(s.particleEffect))

View File

@ -29,7 +29,7 @@ class Placer(AppShell):
INITOPT = Pmw.INITOPT
optiondefs = (
('title', self.appname, None),
('nodePath', direct.camera, None),
('nodePath', base.direct.camera, None),
)
self.defineoptions(kw, optiondefs)
@ -40,23 +40,23 @@ class Placer(AppShell):
def appInit(self):
# Initialize state
self.tempCS = direct.group.attachNewNode('placerTempCS')
self.orbitFromCS = direct.group.attachNewNode(
self.tempCS = base.direct.group.attachNewNode('placerTempCS')
self.orbitFromCS = base.direct.group.attachNewNode(
'placerOrbitFromCS')
self.orbitToCS = direct.group.attachNewNode('placerOrbitToCS')
self.orbitToCS = base.direct.group.attachNewNode('placerOrbitToCS')
self.refCS = self.tempCS
# Dictionary keeping track of all node paths manipulated so far
self.nodePathDict = {}
self.nodePathDict['camera'] = direct.camera
self.nodePathDict['widget'] = direct.widget
self.nodePathDict['camera'] = base.direct.camera
self.nodePathDict['widget'] = base.direct.widget
self.nodePathNames = ['camera', 'widget', 'selected']
self.refNodePathDict = {}
self.refNodePathDict['parent'] = self['nodePath'].getParent()
self.refNodePathDict['render'] = render
self.refNodePathDict['camera'] = direct.camera
self.refNodePathDict['widget'] = direct.widget
self.refNodePathDict['camera'] = base.direct.camera
self.refNodePathDict['widget'] = base.direct.widget
self.refNodePathNames = ['parent', 'self', 'render',
'camera', 'widget', 'selected']
@ -104,12 +104,12 @@ class Placer(AppShell):
'Placer', 'command',
'Toggle widget visability',
label = 'Toggle Widget Vis',
command = direct.toggleWidgetVis)
command = base.direct.toggleWidgetVis)
self.menuBar.addmenuitem(
'Placer', 'command',
'Toggle widget manipulation mode',
label = 'Toggle Widget Mode',
command = direct.manipulationControl.toggleObjectHandlesMode)
command = base.direct.manipulationControl.toggleObjectHandlesMode)
# Get a handle to the menu frame
menuFrame = self.menuFrame
@ -146,8 +146,8 @@ class Placer(AppShell):
self.bind(self.refNodePathMenu, 'Select relative node path')
self.undoButton = Button(menuFrame, text = 'Undo',
command = direct.undo)
if direct.undoList:
command = base.direct.undo)
if base.direct.undoList:
self.undoButton['state'] = 'normal'
else:
self.undoButton['state'] = 'disabled'
@ -155,8 +155,8 @@ class Placer(AppShell):
self.bind(self.undoButton, 'Undo last operation')
self.redoButton = Button(menuFrame, text = 'Redo',
command = direct.redo)
if direct.redoList:
command = base.direct.redo)
if base.direct.redoList:
self.redoButton['state'] = 'normal'
else:
self.redoButton['state'] = 'disabled'
@ -395,7 +395,7 @@ class Placer(AppShell):
# Add Combo box entry for the initial node path
self.addNodePath(nodePath)
elif name == 'selected':
nodePath = direct.selected.last
nodePath = base.direct.selected.last
# Add Combo box entry for this selected object
self.addNodePath(nodePath)
else:
@ -418,7 +418,7 @@ class Placer(AppShell):
else:
if name == 'widget':
# Record relationship between selected nodes and widget
direct.selected.getWrtAll()
base.direct.selected.getWrtAll()
# Update active node path
self.setActiveNodePath(nodePath)
@ -451,7 +451,7 @@ class Placer(AppShell):
if name == 'self':
nodePath = self.tempCS
elif name == 'selected':
nodePath = direct.selected.last
nodePath = base.direct.selected.last
# Add Combo box entry for this selected object
self.addRefNodePath(nodePath)
elif name == 'parent':
@ -562,13 +562,13 @@ class Placer(AppShell):
elif self.movementMode == 'Orbit:':
self.xformOrbit(value, axis)
if self.nodePathMenu.get() == 'widget':
if direct.manipulationControl.fSetCoa:
if base.direct.manipulationControl.fSetCoa:
# Update coa based on current widget position
direct.selected.last.mCoa2Dnp.assign(
direct.widget.getMat(direct.selected.last))
base.direct.selected.last.mCoa2Dnp.assign(
base.direct.widget.getMat(base.direct.selected.last))
else:
# Move the objects with the widget
direct.selected.moveWrtWidgetAll()
base.direct.selected.moveWrtWidgetAll()
def xformStart(self, data):
# Record undo point
@ -577,7 +577,7 @@ class Placer(AppShell):
if self.nodePathMenu.get() == 'widget':
taskMgr.remove('followSelectedNodePath')
# Record relationship between selected nodes and widget
direct.selected.getWrtAll()
base.direct.selected.getWrtAll()
# Record initial state
self.deltaHpr = self['nodePath'].getHpr(self.refCS)
# Update placer to reflect new state
@ -592,7 +592,7 @@ class Placer(AppShell):
# If moving widget restart follow task
if self.nodePathMenu.get() == 'widget':
# Restart followSelectedNodePath task
direct.manipulationControl.spawnFollowSelectedNodePathTask()
base.direct.manipulationControl.spawnFollowSelectedNodePathTask()
def xformRelative(self, value, axis):
nodePath = self['nodePath']
@ -731,7 +731,7 @@ class Placer(AppShell):
self.xformStop(None)
def pushUndo(self, fResetRedo = 1):
direct.pushUndo([self['nodePath']])
base.direct.pushUndo([self['nodePath']])
def undoHook(self, nodePathList = []):
# Reflect new changes
@ -746,7 +746,7 @@ class Placer(AppShell):
self.undoButton.configure(state = 'disabled')
def pushRedo(self):
direct.pushRedo([self['nodePath']])
base.direct.pushRedo([self['nodePath']])
def redoHook(self, nodePathList = []):
# Reflect new changes