mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
*** empty log message ***
This commit is contained in:
parent
8ecb2f612c
commit
79ab675f32
@ -47,13 +47,10 @@ class DirectCameraControl(PandaObject):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def mouseFlyStart(self):
|
def mouseFlyStart(self):
|
||||||
# Record starting mouse positions
|
|
||||||
self.initMouseX = direct.dr.mouseX
|
|
||||||
self.initMouseY = direct.dr.mouseY
|
|
||||||
# Record undo point
|
# Record undo point
|
||||||
direct.pushUndo([direct.camera])
|
direct.pushUndo([direct.camera])
|
||||||
# Where are we in the display region?
|
# Where are we in the display region?
|
||||||
if ((abs(self.initMouseX) < 0.9) & (abs(self.initMouseY) < 0.9)):
|
if ((abs(direct.dr.mouseX) < 0.9) & (abs(direct.dr.mouseY) < 0.9)):
|
||||||
# MOUSE IS IN CENTRAL REGION
|
# MOUSE IS IN CENTRAL REGION
|
||||||
# Hide the marker for this kind of motion
|
# Hide the marker for this kind of motion
|
||||||
self.coaMarker.hide()
|
self.coaMarker.hide()
|
||||||
@ -119,7 +116,7 @@ class DirectCameraControl(PandaObject):
|
|||||||
self.spawnXZTranslateOrHPanYZoom()
|
self.spawnXZTranslateOrHPanYZoom()
|
||||||
# END MOUSE IN CENTRAL REGION
|
# END MOUSE IN CENTRAL REGION
|
||||||
else:
|
else:
|
||||||
if ((abs(self.initMouseX) > 0.9) & (abs(self.initMouseY) > 0.9)):
|
if ((abs(direct.dr.mouseX) > 0.9) & (abs(direct.dr.mouseY) > 0.9)):
|
||||||
# Mouse is in corners, spawn roll task
|
# Mouse is in corners, spawn roll task
|
||||||
self.spawnMouseRollTask()
|
self.spawnMouseRollTask()
|
||||||
else:
|
else:
|
||||||
@ -239,7 +236,7 @@ class DirectCameraControl(PandaObject):
|
|||||||
taskMgr.spawnTaskNamed(t, 'manipulateCamera')
|
taskMgr.spawnTaskNamed(t, 'manipulateCamera')
|
||||||
|
|
||||||
def mouseRotateTask(self, state):
|
def mouseRotateTask(self, state):
|
||||||
# If moving within frame, ignore motion perpendicular to edge
|
# If moving outside of center, ignore motion perpendicular to edge
|
||||||
if ((state.constrainedDir == 'y') & (abs(direct.dr.mouseX) > 0.9)):
|
if ((state.constrainedDir == 'y') & (abs(direct.dr.mouseX) > 0.9)):
|
||||||
deltaX = 0
|
deltaX = 0
|
||||||
deltaY = direct.dr.mouseDeltaY
|
deltaY = direct.dr.mouseDeltaY
|
||||||
|
@ -20,9 +20,10 @@ class DirectManipulationControl(PandaObject):
|
|||||||
self.lastCrankAngle = 0
|
self.lastCrankAngle = 0
|
||||||
self.fSetCoa = 0
|
self.fSetCoa = 0
|
||||||
self.fHitInit = 1
|
self.fHitInit = 1
|
||||||
|
self.fScaleInit = 1
|
||||||
self.fWidgetTop = 0
|
self.fWidgetTop = 0
|
||||||
self.fFreeManip = 1
|
self.fFreeManip = 1
|
||||||
self.fScaling = 1
|
self.fScaling = 0
|
||||||
self.unpickable = UNPICKABLE
|
self.unpickable = UNPICKABLE
|
||||||
self.mode = None
|
self.mode = None
|
||||||
self.actionEvents = [
|
self.actionEvents = [
|
||||||
@ -61,14 +62,12 @@ class DirectManipulationControl(PandaObject):
|
|||||||
self.constraint = None
|
self.constraint = None
|
||||||
# Check to see if we are moving the object
|
# Check to see if we are moving the object
|
||||||
# We are moving the object if we either wait long enough
|
# We are moving the object if we either wait long enough
|
||||||
"""
|
|
||||||
taskMgr.spawnTaskNamed(
|
taskMgr.spawnTaskNamed(
|
||||||
Task.doLater(MANIPULATION_MOVE_DELAY,
|
Task.doLater(MANIPULATION_MOVE_DELAY,
|
||||||
Task.Task(self.switchToMoveMode),
|
Task.Task(self.switchToMoveMode),
|
||||||
'manip-move-wait'),
|
'manip-move-wait'),
|
||||||
'manip-move-wait')
|
'manip-move-wait')
|
||||||
"""
|
# Or we move far enough
|
||||||
# Begin manipulating once we move far enough
|
|
||||||
self.moveDir = None
|
self.moveDir = None
|
||||||
watchMouseTask = Task.Task(self.watchMouseTask)
|
watchMouseTask = Task.Task(self.watchMouseTask)
|
||||||
watchMouseTask.initX = direct.dr.mouseX
|
watchMouseTask.initX = direct.dr.mouseX
|
||||||
@ -223,52 +222,68 @@ class DirectManipulationControl(PandaObject):
|
|||||||
def spawnManipulateObjectTask(self):
|
def spawnManipulateObjectTask(self):
|
||||||
# reset hit-pt flag
|
# reset hit-pt flag
|
||||||
self.fHitInit = 1
|
self.fHitInit = 1
|
||||||
|
self.fScaleInit = 1
|
||||||
# record initial offset between widget and camera
|
# record initial offset between widget and camera
|
||||||
t = Task.Task(self.manipulateObjectTask)
|
t = Task.Task(self.manipulateObjectTask)
|
||||||
|
t.fMouseX = abs(direct.dr.mouseX) > 0.9
|
||||||
|
t.fMouseY = abs(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)
|
||||||
|
# These are used to rotate about view vector
|
||||||
|
if t.fMouseX & t.fMouseY:
|
||||||
|
t.lastAngle = getCrankAngle(t.coaCenter)
|
||||||
taskMgr.spawnTaskNamed(t, 'manipulateObject')
|
taskMgr.spawnTaskNamed(t, 'manipulateObject')
|
||||||
|
|
||||||
def manipulateObjectTask(self, state):
|
def manipulateObjectTask(self, state):
|
||||||
|
# Widget takes precedence
|
||||||
if self.constraint:
|
if self.constraint:
|
||||||
type = self.constraint[2:]
|
type = self.constraint[2:]
|
||||||
if type == 'post':
|
if type == 'post':
|
||||||
self.xlate1D()
|
self.xlate1D(state)
|
||||||
elif type == 'disc':
|
elif type == 'disc':
|
||||||
self.xlate2D()
|
self.xlate2D(state)
|
||||||
elif type == 'ring':
|
elif type == 'ring':
|
||||||
self.rotate1D()
|
self.rotate1D(state)
|
||||||
|
# No widget interaction, determine free manip mode
|
||||||
elif self.fFreeManip:
|
elif self.fFreeManip:
|
||||||
if self.fScaling & (not direct.fAlt):
|
# If we've been scaling and changed modes, reset object handles
|
||||||
# We had been scaling and changed modes,
|
if 0 & self.fScaling & (not direct.fAlt):
|
||||||
# reset object handles
|
|
||||||
self.objectHandles.transferObjectHandlesScale()
|
self.objectHandles.transferObjectHandlesScale()
|
||||||
self.fScaling = 0
|
self.fScaling = 0
|
||||||
if direct.fControl:
|
# Alt key switches to a scaling mode
|
||||||
self.rotate2D()
|
if direct.fAlt:
|
||||||
elif direct.fAlt:
|
|
||||||
self.fScaling = 1
|
self.fScaling = 1
|
||||||
self.scale3D()
|
self.scale3D(state)
|
||||||
elif direct.fShift:
|
# Otherwise, manip mode depends on where you started
|
||||||
self.xlateCamXY()
|
elif state.fMouseX & state.fMouseY:
|
||||||
|
# In the corner, spin around camera's axis
|
||||||
|
self.rotateAboutViewVector(state)
|
||||||
|
elif state.fMouseX | state.fMouseY:
|
||||||
|
# Mouse started elsewhere in the outer frame, rotate
|
||||||
|
self.rotate2D(state)
|
||||||
else:
|
else:
|
||||||
self.xlateCamXZ()
|
# Mouse starte in central region, xlate
|
||||||
|
# Mode depends on shift key
|
||||||
|
if direct.fShift:
|
||||||
|
self.xlateCamXZ(state)
|
||||||
else:
|
else:
|
||||||
# MRM: Needed, more elegant fallback
|
self.xlateCamXY(state)
|
||||||
return Task.cont
|
|
||||||
|
|
||||||
if self.fSetCoa:
|
if self.fSetCoa:
|
||||||
# Update coa based on current widget position
|
# Update coa based on current widget position
|
||||||
direct.selected.last.mCoa2Dnp.assign(
|
direct.selected.last.mCoa2Dnp.assign(
|
||||||
direct.widget.getMat(direct.selected.last)
|
direct.widget.getMat(direct.selected.last))
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
# Move the objects with the widget
|
# Move the objects with the widget
|
||||||
direct.selected.moveWrtWidgetAll()
|
direct.selected.moveWrtWidgetAll()
|
||||||
|
|
||||||
# Continue
|
# Continue
|
||||||
return Task.cont
|
return Task.cont
|
||||||
|
|
||||||
def xlate1D(self):
|
### WIDGET MANIPULATION METHODS ###
|
||||||
|
def xlate1D(self, state):
|
||||||
# Constrained 1D Translation along widget axis
|
# Constrained 1D Translation along widget axis
|
||||||
# Compute nearest hit point along axis and try to keep
|
# Compute nearest hit point along axis and try to keep
|
||||||
# that point as close to the current mouse position as possible
|
# that point as close to the current mouse position as possible
|
||||||
@ -285,7 +300,7 @@ class DirectManipulationControl(PandaObject):
|
|||||||
offset = self.hitPt - self.prevHit
|
offset = self.hitPt - self.prevHit
|
||||||
direct.widget.setPos(direct.widget, offset)
|
direct.widget.setPos(direct.widget, offset)
|
||||||
|
|
||||||
def xlate2D(self):
|
def xlate2D(self, state):
|
||||||
# Constrained 2D (planar) translation
|
# Constrained 2D (planar) translation
|
||||||
# Compute point of intersection of ray from eyepoint through cursor
|
# Compute point of intersection of ray from eyepoint through cursor
|
||||||
# to one of the three orthogonal planes on the widget.
|
# to one of the three orthogonal planes on the widget.
|
||||||
@ -301,50 +316,34 @@ class DirectManipulationControl(PandaObject):
|
|||||||
offset = self.hitPt - self.prevHit
|
offset = self.hitPt - self.prevHit
|
||||||
direct.widget.setPos(direct.widget, offset)
|
direct.widget.setPos(direct.widget, offset)
|
||||||
|
|
||||||
|
def rotate1D(self, state):
|
||||||
|
# Constrained 1D rotation about the widget's main axis (X,Y, or Z)
|
||||||
|
# Rotation depends upon circular motion of the mouse about the
|
||||||
|
# projection of the widget's origin on the image plane
|
||||||
|
# A complete circle about the widget results in a change in
|
||||||
|
# orientation of 360 degrees.
|
||||||
|
|
||||||
def xlateCamXZ(self):
|
# First initialize hit point/rotation angle
|
||||||
"""Constrained 2D motion parallel to the camera's image plane
|
|
||||||
This moves the object in the camera's XZ plane"""
|
|
||||||
# reset fHitInit
|
|
||||||
# (in case we later switch to another manipulation mode)
|
|
||||||
#self.fHitInit = 1
|
|
||||||
# Where is the widget relative to current camera view
|
|
||||||
vWidget2Camera = direct.widget.getPos(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,
|
|
||||||
x + 0.5 * dr.mouseDeltaX * dr.nearWidth * (y/dr.near))
|
|
||||||
direct.widget.setZ(
|
|
||||||
direct.camera,
|
|
||||||
z + 0.5 * dr.mouseDeltaY * dr.nearHeight * (y/dr.near))
|
|
||||||
|
|
||||||
def xlateCamXY(self):
|
|
||||||
"""Constrained 2D motion perpendicular to camera's image plane
|
|
||||||
This moves the object in the camera's XY plane"""
|
|
||||||
# Now, where is the widget relative to current camera view
|
|
||||||
vWidget2Camera = direct.widget.getPos(direct.camera)
|
|
||||||
# If this is first time around, record initial y distance
|
|
||||||
if self.fHitInit:
|
if self.fHitInit:
|
||||||
self.fHitInit = 0
|
self.fHitInit = 0
|
||||||
# Record widget offset along y
|
self.rotateAxis = self.constraint[:1]
|
||||||
self.initY = vWidget2Camera[1]
|
self.fWidgetTop = self.widgetCheck('top?')
|
||||||
# Extract current values
|
self.rotationCenter = getScreenXY(direct.widget)
|
||||||
x = vWidget2Camera[0]
|
self.lastCrankAngle = getCrankAngle(self.rotationCenter)
|
||||||
y = vWidget2Camera[1]
|
|
||||||
z = vWidget2Camera[2]
|
# Rotate widget based on how far cursor has swung around origin
|
||||||
# Move widget (and objects) based upon mouse motion
|
newAngle = getCrankAngle(self.rotationCenter)
|
||||||
# Scaled up accordingly based upon widget distance
|
deltaAngle = self.lastCrankAngle - newAngle
|
||||||
dr = direct.dr
|
if self.fWidgetTop:
|
||||||
direct.widget.setPos(
|
deltaAngle = -1 * deltaAngle
|
||||||
direct.camera,
|
if self.rotateAxis == 'x':
|
||||||
x + 0.5 * dr.mouseDeltaX * dr.nearWidth * (y/dr.near),
|
direct.widget.setP(direct.widget, deltaAngle)
|
||||||
y + self.initY * dr.mouseDeltaY,
|
elif self.rotateAxis == 'y':
|
||||||
z)
|
direct.widget.setR(direct.widget, -deltaAngle)
|
||||||
|
elif self.rotateAxis == 'z':
|
||||||
|
direct.widget.setH(direct.widget, deltaAngle)
|
||||||
|
# Record crank angle for next time around
|
||||||
|
self.lastCrankAngle = newAngle
|
||||||
|
|
||||||
def widgetCheck(self,type):
|
def widgetCheck(self,type):
|
||||||
# Utility to see if we are looking at the top or bottom of
|
# Utility to see if we are looking at the top or bottom of
|
||||||
@ -377,34 +376,84 @@ class DirectManipulationControl(PandaObject):
|
|||||||
# Check angle between two vectors
|
# Check angle between two vectors
|
||||||
return(abs(widgetDir.dot(widgetAxis)) < .2)
|
return(abs(widgetDir.dot(widgetAxis)) < .2)
|
||||||
|
|
||||||
def rotate1D(self):
|
### FREE MANIPULATION METHODS ###
|
||||||
# Constrained 1D rotation about the widget's main axis (X,Y, or Z)
|
def xlateCamXZ(self, state):
|
||||||
# Rotation depends upon circular motion of the mouse about the
|
"""Constrained 2D motion parallel to the camera's image plane
|
||||||
# projection of the widget's origin on the image plane
|
This moves the object in the camera's XZ plane"""
|
||||||
# A complete circle about the widget results in a change in
|
# reset fHitInit in case we later switch to manip mode
|
||||||
# orientation of 360 degrees.
|
self.fHitInit = 1
|
||||||
|
# Reset scaling init flag
|
||||||
|
self.fScaleInit = 1
|
||||||
|
# Where is the widget relative to current camera view
|
||||||
|
vWidget2Camera = direct.widget.getPos(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,
|
||||||
|
x + 0.5 * dr.mouseDeltaX * dr.nearWidth * (y/dr.near))
|
||||||
|
direct.widget.setZ(
|
||||||
|
direct.camera,
|
||||||
|
z + 0.5 * dr.mouseDeltaY * dr.nearHeight * (y/dr.near))
|
||||||
|
|
||||||
# First initialize hit point/rotation angle
|
def xlateCamXY(self, state):
|
||||||
|
"""Constrained 2D motion perpendicular to camera's image plane
|
||||||
|
This moves the object in the camera's XY plane"""
|
||||||
|
# Now, where is the widget relative to current camera view
|
||||||
|
vWidget2Camera = direct.widget.getPos(direct.camera)
|
||||||
|
# If this is first time around, record initial y distance
|
||||||
if self.fHitInit:
|
if self.fHitInit:
|
||||||
self.fHitInit = 0
|
self.fHitInit = 0
|
||||||
self.rotateAxis = self.constraint[:1]
|
# Use distance to widget to scale motion along Y
|
||||||
self.fWidgetTop = self.widgetCheck('top?')
|
self.xlateSF = Vec3(vWidget2Camera).length()
|
||||||
self.rotationCenter = getScreenXY(direct.widget)
|
# Get widget's current xy coords in screen space
|
||||||
self.lastCrankAngle = getCrankAngle(self.rotationCenter)
|
coaCenter = getNearProjectionPoint(direct.widget)
|
||||||
|
self.deltaNearX = coaCenter[0] - direct.dr.nearVec[0]
|
||||||
|
# Reset scaling init flag
|
||||||
|
self.fScaleInit = 1
|
||||||
|
# Move selected objects
|
||||||
|
dr = direct.dr
|
||||||
|
# Move object in y axis based on mouse motion
|
||||||
|
newY = vWidget2Camera[1] + self.xlateSF * dr.mouseDeltaY
|
||||||
|
# Put object at same relative point to mouse in X
|
||||||
|
newX = (direct.dr.nearVec[0] + self.deltaNearX) * (newY/dr.near)
|
||||||
|
direct.widget.setPos(direct.camera, newX, newY, vWidget2Camera[2])
|
||||||
|
|
||||||
# Rotate widget based on how far cursor has swung around origin
|
def rotate2D(self, state):
|
||||||
newAngle = getCrankAngle(self.rotationCenter)
|
""" Virtual trackball rotation of widget """
|
||||||
deltaAngle = self.lastCrankAngle - newAngle
|
# Reset init flag in case we switch to another mode
|
||||||
if self.fWidgetTop:
|
self.fHitInit = 1
|
||||||
deltaAngle = -1 * deltaAngle
|
# Reset scaling init flag
|
||||||
if self.rotateAxis == 'x':
|
self.fScaleInit = 1
|
||||||
direct.widget.setP(direct.widget, deltaAngle)
|
tumbleRate = 360
|
||||||
elif self.rotateAxis == 'y':
|
# If moving outside of center, ignore motion perpendicular to edge
|
||||||
direct.widget.setR(direct.widget, -deltaAngle)
|
if ((state.constrainedDir == 'y') & (abs(direct.dr.mouseX) > 0.9)):
|
||||||
elif self.rotateAxis == 'z':
|
deltaX = 0
|
||||||
direct.widget.setH(direct.widget, deltaAngle)
|
deltaY = direct.dr.mouseDeltaY
|
||||||
# Record crank angle for next time around
|
elif ((state.constrainedDir == 'x') & (abs(direct.dr.mouseY) > 0.9)):
|
||||||
self.lastCrankAngle = newAngle
|
deltaX = direct.dr.mouseDeltaX
|
||||||
|
deltaY = 0
|
||||||
|
else:
|
||||||
|
deltaX = direct.dr.mouseDeltaX
|
||||||
|
deltaY = direct.dr.mouseDeltaY
|
||||||
|
# Mouse motion edge to edge of display region results in one full turn
|
||||||
|
self.relHpr(direct.camera, deltaX * tumbleRate,
|
||||||
|
-deltaY * tumbleRate, 0)
|
||||||
|
|
||||||
|
def rotateAboutViewVector(self, state):
|
||||||
|
# Reset init flag in case we switch to another mode
|
||||||
|
self.fHitInit = 1
|
||||||
|
# Reset scaling init flag
|
||||||
|
self.fScaleInit = 1
|
||||||
|
# Compute current angle
|
||||||
|
angle = getCrankAngle(state.coaCenter)
|
||||||
|
deltaAngle = angle - state.lastAngle
|
||||||
|
state.lastAngle = angle
|
||||||
|
# Mouse motion edge to edge of display region results in one full turn
|
||||||
|
self.relHpr(direct.camera, 0, 0, deltaAngle)
|
||||||
|
|
||||||
def relHpr(self, base, h, p, r):
|
def relHpr(self, base, h, p, r):
|
||||||
# Compute widget2newWidget relative to base coordinate system
|
# Compute widget2newWidget relative to base coordinate system
|
||||||
@ -424,24 +473,12 @@ class DirectManipulationControl(PandaObject):
|
|||||||
CSDefault)
|
CSDefault)
|
||||||
direct.widget.setHpr(hpr)
|
direct.widget.setHpr(hpr)
|
||||||
|
|
||||||
def rotate2D(self):
|
def scale3D(self, state):
|
||||||
# Virtual trackball or arcball rotation of widget
|
|
||||||
# Rotation method depends upon variable dd-want-arcball
|
|
||||||
# Default is virtual trackball (handles 1D rotations better)
|
|
||||||
self.fHitInit = 1
|
|
||||||
tumbleRate = 360
|
|
||||||
# Mouse motion edge to edge of display region results in one full turn
|
|
||||||
self.relHpr(direct.camera,
|
|
||||||
direct.dr.mouseDeltaX * tumbleRate,
|
|
||||||
-direct.dr.mouseDeltaY * tumbleRate,
|
|
||||||
0)
|
|
||||||
|
|
||||||
def scale3D(self):
|
|
||||||
# Scale the selected node based upon up down mouse motion
|
# Scale the selected node based upon up down mouse motion
|
||||||
# Mouse motion from edge to edge results in a factor of 4 scaling
|
# Mouse motion from edge to edge results in a factor of 4 scaling
|
||||||
# From midpoint to edge doubles or halves objects scale
|
# From midpoint to edge doubles or halves objects scale
|
||||||
if self.fHitInit:
|
if self.fScaleInit:
|
||||||
self.fHitInit = 0
|
self.fScaleInit = 0
|
||||||
self.manipRef.setPos(direct.widget, 0, 0, 0)
|
self.manipRef.setPos(direct.widget, 0, 0, 0)
|
||||||
self.manipRef.setHpr(direct.camera, 0, 0, 0)
|
self.manipRef.setHpr(direct.camera, 0, 0, 0)
|
||||||
self.initScaleMag = Vec3(
|
self.initScaleMag = Vec3(
|
||||||
@ -449,6 +486,8 @@ class DirectManipulationControl(PandaObject):
|
|||||||
self.manipRef, 'y')).length()
|
self.manipRef, 'y')).length()
|
||||||
# record initial scale
|
# record initial scale
|
||||||
self.initScale = direct.widget.getScale()
|
self.initScale = direct.widget.getScale()
|
||||||
|
# Reset fHitInitFlag
|
||||||
|
self.fHitInit = 1
|
||||||
# Begin
|
# Begin
|
||||||
# Scale factor is ratio current mag with init mag
|
# Scale factor is ratio current mag with init mag
|
||||||
currScale = (
|
currScale = (
|
||||||
@ -465,6 +504,8 @@ class ObjectHandles(NodePath,PandaObject):
|
|||||||
# Initialize the superclass
|
# Initialize the superclass
|
||||||
NodePath.__init__(self)
|
NodePath.__init__(self)
|
||||||
|
|
||||||
|
# Starts off deactivated
|
||||||
|
self.fActive = 0
|
||||||
# Load up object handles model and assign it to self
|
# Load up object handles model and assign it to self
|
||||||
self.assign(loader.loadModel('models/misc/objectHandles'))
|
self.assign(loader.loadModel('models/misc/objectHandles'))
|
||||||
self.node().setName('objectHandles')
|
self.node().setName('objectHandles')
|
||||||
@ -526,6 +567,21 @@ class ObjectHandles(NodePath,PandaObject):
|
|||||||
def manipModeColor(self):
|
def manipModeColor(self):
|
||||||
self.clearColor()
|
self.clearColor()
|
||||||
|
|
||||||
|
def toggleWidget(self):
|
||||||
|
if self.fActive:
|
||||||
|
self.reparentTo(hidden)
|
||||||
|
self.fActive = 0
|
||||||
|
else:
|
||||||
|
self.reparentTo(direct.group)
|
||||||
|
self.fActive = 1
|
||||||
|
|
||||||
|
def showWidgetIfActive(self):
|
||||||
|
if self.fActive:
|
||||||
|
self.reparentTo(direct.group)
|
||||||
|
|
||||||
|
def hideWidget(self):
|
||||||
|
self.reparentTo(hidden)
|
||||||
|
|
||||||
def enableHandles(self, handles):
|
def enableHandles(self, handles):
|
||||||
if type(handles) == types.ListType:
|
if type(handles) == types.ListType:
|
||||||
for handle in handles:
|
for handle in handles:
|
||||||
|
@ -226,7 +226,7 @@ class DirectSession(PandaObject):
|
|||||||
self.readout.reparentTo(render2d)
|
self.readout.reparentTo(render2d)
|
||||||
self.readout.setText(dnp.name)
|
self.readout.setText(dnp.name)
|
||||||
# Show the manipulation widget
|
# Show the manipulation widget
|
||||||
self.reparentWidgetTo('direct')
|
self.widget.showWidgetIfActive()
|
||||||
# Update camera controls coa to this point
|
# Update camera controls coa to this point
|
||||||
# Coa2Camera = Coa2Dnp * Dnp2Camera
|
# Coa2Camera = Coa2Dnp * Dnp2Camera
|
||||||
mCoa2Camera = dnp.mCoa2Dnp * dnp.getMat(self.camera)
|
mCoa2Camera = dnp.mCoa2Dnp * dnp.getMat(self.camera)
|
||||||
@ -257,7 +257,7 @@ class DirectSession(PandaObject):
|
|||||||
dnp = self.selected.deselect(nodePath)
|
dnp = self.selected.deselect(nodePath)
|
||||||
if dnp:
|
if dnp:
|
||||||
# Hide the manipulation widget
|
# Hide the manipulation widget
|
||||||
self.reparentWidgetTo('hidden')
|
self.widget.hideWidget()
|
||||||
self.readout.reparentTo(hidden)
|
self.readout.reparentTo(hidden)
|
||||||
self.readout.setText(' ')
|
self.readout.setText(' ')
|
||||||
taskMgr.removeTasksNamed('followSelectedNodePath')
|
taskMgr.removeTasksNamed('followSelectedNodePath')
|
||||||
@ -268,7 +268,7 @@ class DirectSession(PandaObject):
|
|||||||
def deselectAll(self):
|
def deselectAll(self):
|
||||||
self.selected.deselectAll()
|
self.selected.deselectAll()
|
||||||
# Hide the manipulation widget
|
# Hide the manipulation widget
|
||||||
self.reparentWidgetTo('hidden')
|
self.widget.hideWidget()
|
||||||
self.readout.reparentTo(hidden)
|
self.readout.reparentTo(hidden)
|
||||||
self.readout.setText(' ')
|
self.readout.setText(' ')
|
||||||
taskMgr.removeTasksNamed('followSelectedNodePath')
|
taskMgr.removeTasksNamed('followSelectedNodePath')
|
||||||
@ -469,19 +469,8 @@ class DirectSession(PandaObject):
|
|||||||
def hideReadout(self):
|
def hideReadout(self):
|
||||||
self.readout.reparentTo(hidden)
|
self.readout.reparentTo(hidden)
|
||||||
|
|
||||||
def reparentWidgetTo(self, parent):
|
|
||||||
if parent == 'direct':
|
|
||||||
self.widget.reparentTo(direct.group)
|
|
||||||
self.widgetParent = 'direct'
|
|
||||||
else:
|
|
||||||
self.widget.reparentTo(hidden)
|
|
||||||
self.widgetParent = 'hidden'
|
|
||||||
|
|
||||||
def toggleWidgetVis(self):
|
def toggleWidgetVis(self):
|
||||||
if self.widgetParent == 'direct':
|
self.widget.toggleWidget()
|
||||||
self.reparentWidgetTo('hidden')
|
|
||||||
else:
|
|
||||||
self.reparentWidgetTo('direct')
|
|
||||||
|
|
||||||
class DisplayRegionList:
|
class DisplayRegionList:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user