mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
*** empty log message ***
This commit is contained in:
parent
be2b62c779
commit
9b44311ec2
@ -4,9 +4,8 @@ CAM_MOVE_DURATION = 1.0
|
||||
Y_AXIS = Vec3(0,1,0)
|
||||
|
||||
class DirectCameraControl(PandaObject):
|
||||
def __init__(self, direct):
|
||||
def __init__(self):
|
||||
# Create the grid
|
||||
self.direct = direct
|
||||
self.chan = direct.chan
|
||||
self.camera = self.chan.camera
|
||||
self.orthoViewRoll = 0.0
|
||||
@ -31,19 +30,19 @@ class DirectCameraControl(PandaObject):
|
||||
# Hide the marker for this kind of motion
|
||||
self.coaMarker.hide()
|
||||
# See if the shift key is pressed
|
||||
if (self.direct.fShift):
|
||||
if (direct.fShift):
|
||||
# If shift key is pressed, just perform horiz and vert pan:
|
||||
self.spawnHPPan()
|
||||
else:
|
||||
# Otherwise, check for a hit point based on
|
||||
# current mouse position
|
||||
# And then spawn task to determine mouse mode
|
||||
numEntries = self.direct.iRay.pickGeom(
|
||||
numEntries = direct.iRay.pickGeom(
|
||||
render,chan.mouseX,chan.mouseY)
|
||||
# Filter out hidden nodes from entry list
|
||||
indexList = []
|
||||
for i in range(0,numEntries):
|
||||
entry = self.direct.iRay.cq.getEntry(i)
|
||||
entry = direct.iRay.cq.getEntry(i)
|
||||
node = entry.getIntoNode()
|
||||
if node.isHidden():
|
||||
pass
|
||||
@ -55,7 +54,7 @@ class DirectCameraControl(PandaObject):
|
||||
# Start off with first point
|
||||
minPt = indexList[0]
|
||||
# Find hit point in camera's space
|
||||
hitPt = self.direct.iRay.camToHitPt(minPt)
|
||||
hitPt = direct.iRay.camToHitPt(minPt)
|
||||
coa.set(hitPt[0],hitPt[1],hitPt[2])
|
||||
coaDist = Vec3(coa - self.zeroPoint).length()
|
||||
# Check other intersection points, sorting them
|
||||
@ -63,7 +62,7 @@ class DirectCameraControl(PandaObject):
|
||||
if len(indexList) > 1:
|
||||
for i in range(1,len(indexList)):
|
||||
entryNum = indexList[i]
|
||||
hitPt = self.direct.iRay.camToHitPt(entryNum)
|
||||
hitPt = direct.iRay.camToHitPt(entryNum)
|
||||
dist = Vec3(hitPt - self.zeroPoint).length()
|
||||
if (dist < coaDist):
|
||||
coaDist = dist
|
||||
@ -287,7 +286,7 @@ class DirectCameraControl(PandaObject):
|
||||
taskMgr.spawnTaskNamed(t, 'manipulateCamera')
|
||||
|
||||
def XZTranslateOrHPPanTask(self, state):
|
||||
if self.direct.fShift:
|
||||
if direct.fShift:
|
||||
self.camera.setHpr(self.camera,
|
||||
(0.5 * self.chan.mouseDeltaX *
|
||||
self.chan.fovH),
|
||||
@ -368,7 +367,7 @@ class DirectCameraControl(PandaObject):
|
||||
taskMgr.removeTasksNamed('manipulateCamera')
|
||||
|
||||
# How big is the node?
|
||||
nodeScale = self.direct.widget.scalingNode.getScale(render)
|
||||
nodeScale = direct.widget.scalingNode.getScale(render)
|
||||
maxScale = max(nodeScale[0],nodeScale[1],nodeScale[2])
|
||||
maxDim = min(self.chan.nearWidth, self.chan.nearHeight)
|
||||
|
||||
@ -380,7 +379,7 @@ class DirectCameraControl(PandaObject):
|
||||
centerVec = Y_AXIS * camY
|
||||
|
||||
# Where is the node relative to the viewpoint
|
||||
vWidget2Camera = self.direct.widget.getPos(self.camera)
|
||||
vWidget2Camera = direct.widget.getPos(self.camera)
|
||||
|
||||
# How far do you move the camera to be this distance from the node?
|
||||
deltaMove = vWidget2Camera - centerVec
|
||||
|
@ -2,14 +2,11 @@ from PandaObject import *
|
||||
from DirectGeometry import *
|
||||
|
||||
class DirectGrid(NodePath,PandaObject):
|
||||
def __init__(self, direct):
|
||||
def __init__(self):
|
||||
# Initialize superclass
|
||||
NodePath.__init__(self)
|
||||
self.assign(hidden.attachNewNode( NamedNode('DirectGrid')))
|
||||
|
||||
# Record handle to direct session
|
||||
self.direct = direct
|
||||
|
||||
# Load up grid parts to initialize grid object
|
||||
# Polygon used to mark grid plane
|
||||
self.gridBack = loader.loadModel('models/misc/gridBack')
|
||||
@ -60,7 +57,7 @@ class DirectGrid(NodePath,PandaObject):
|
||||
|
||||
def selectGridBackParent(self, nodePath):
|
||||
if nodePath.getName() == 'GridBack':
|
||||
self.direct.select(self)
|
||||
direct.select(self)
|
||||
|
||||
def updateGrid(self):
|
||||
# Update grid lines based upon current grid spacing and grid size
|
||||
|
@ -5,12 +5,11 @@ MANIPULATION_MOVE_DELAY = 0.65
|
||||
VISIBLE_DISCS = ['x-disc-visible', 'y-disc-visible', 'z-disc-visible']
|
||||
|
||||
class DirectManipulationControl(PandaObject):
|
||||
def __init__(self, direct):
|
||||
def __init__(self):
|
||||
# Create the grid
|
||||
self.direct = direct
|
||||
self.chan = direct.chan
|
||||
self.camera = self.chan.camera
|
||||
self.objectHandles = ObjectHandles(direct)
|
||||
self.objectHandles = ObjectHandles()
|
||||
self.hitPt = Point3(0)
|
||||
self.prevHit = Vec3(0)
|
||||
self.rotationCenter = Point3(0)
|
||||
@ -31,7 +30,7 @@ class DirectManipulationControl(PandaObject):
|
||||
# Start out in select mode
|
||||
self.mode = 'select'
|
||||
# Check for a widget hit point
|
||||
numEntries = self.direct.iRay.pickWidget(
|
||||
numEntries = direct.iRay.pickWidget(
|
||||
render,chan.mouseX,chan.mouseY)
|
||||
# Did we hit a widget?
|
||||
if(numEntries):
|
||||
@ -39,10 +38,10 @@ class DirectManipulationControl(PandaObject):
|
||||
# Entry 0 is the closest hit point if multiple hits
|
||||
minPt = 0
|
||||
# Find hit point in camera's space
|
||||
self.hitPt = self.direct.iRay.camToHitPt(minPt)
|
||||
self.hitPt = direct.iRay.camToHitPt(minPt)
|
||||
self.hitPtDist = Vec3(self.hitPt - ZERO_POINT).length()
|
||||
# Get the associated collision queue object
|
||||
entry = self.direct.iRay.cq.getEntry(minPt)
|
||||
entry = direct.iRay.cq.getEntry(minPt)
|
||||
# Extract the node
|
||||
node = entry.getIntoNode()
|
||||
# Constraint determined by nodes name
|
||||
@ -91,12 +90,12 @@ class DirectManipulationControl(PandaObject):
|
||||
# depending on flag.....
|
||||
if self.mode == 'select':
|
||||
# Check for object under mouse
|
||||
numEntries = self.direct.iRay.pickGeom(
|
||||
numEntries = direct.iRay.pickGeom(
|
||||
render,self.chan.mouseX,self.chan.mouseY)
|
||||
# Pick out the closest object that isn't a widget
|
||||
index = -1
|
||||
for i in range(0,numEntries):
|
||||
entry = self.direct.iRay.cq.getEntry(i)
|
||||
entry = direct.iRay.cq.getEntry(i)
|
||||
node = entry.getIntoNode()
|
||||
if node.isHidden():
|
||||
pass
|
||||
@ -115,14 +114,14 @@ class DirectManipulationControl(PandaObject):
|
||||
if(index >= 0):
|
||||
# Yes!
|
||||
# Find hit point in camera's space
|
||||
self.hitPt = self.direct.iRay.camToHitPt(index)
|
||||
self.hitPt = direct.iRay.camToHitPt(index)
|
||||
self.hitPtDist = Vec3(self.hitPt - ZERO_POINT).length()
|
||||
# Find the node path from the node found above
|
||||
nodePath = render.findPathDownTo(node)
|
||||
# Select it
|
||||
self.direct.select(nodePath)
|
||||
direct.select(nodePath)
|
||||
else:
|
||||
self.direct.deselectAll()
|
||||
direct.deselectAll()
|
||||
else:
|
||||
self.manipulateObjectCleanup()
|
||||
|
||||
@ -133,11 +132,11 @@ class DirectManipulationControl(PandaObject):
|
||||
self.fScaling = 0
|
||||
if self.fSetCoa:
|
||||
self.objectHandles.manipModeColor()
|
||||
self.direct.selected.highlightAll()
|
||||
direct.selected.highlightAll()
|
||||
self.objectHandles.showAllHandles()
|
||||
self.objectHandles.hideGuides()
|
||||
# Restart followSelectedNodePath task
|
||||
if self.direct.selected.last:
|
||||
if direct.selected.last:
|
||||
self.spawnFollowSelectedNodePathTask()
|
||||
messenger.send('manipulateObjectCleanup')
|
||||
|
||||
@ -145,19 +144,19 @@ class DirectManipulationControl(PandaObject):
|
||||
# Where are the object handles relative to the selected object
|
||||
pos = VBase3(0)
|
||||
hpr = VBase3(0)
|
||||
decomposeMatrix(self.direct.selected.last.mCoa2Dnp,
|
||||
decomposeMatrix(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 = self.direct.selected.last
|
||||
t.base = direct.selected.last
|
||||
# Spawn the task
|
||||
taskMgr.spawnTaskNamed(t, 'followSelectedNodePath')
|
||||
|
||||
def followSelectedNodePathTask(self, state):
|
||||
self.direct.widget.setPosHpr(state.base, state.pos, state.hpr)
|
||||
direct.widget.setPosHpr(state.base, state.pos, state.hpr)
|
||||
return Task.cont
|
||||
|
||||
def enableManipulation(self):
|
||||
@ -189,7 +188,7 @@ class DirectManipulationControl(PandaObject):
|
||||
|
||||
def manipulateObject(self):
|
||||
# Only do this if something is selected
|
||||
if self.direct.selected:
|
||||
if direct.selected:
|
||||
# Remove the task to keep the widget attached to the object
|
||||
taskMgr.removeTasksNamed('followSelectedNodePath')
|
||||
# and the task to highlight the widget
|
||||
@ -204,15 +203,15 @@ class DirectManipulationControl(PandaObject):
|
||||
self.objectHandles.coaModeColor()
|
||||
|
||||
# Record relationship between selected nodes and widget
|
||||
self.direct.selected.getWrtAll()
|
||||
direct.selected.getWrtAll()
|
||||
|
||||
# hide the bbox of the selected objects during interaction
|
||||
self.direct.selected.dehighlightAll()
|
||||
direct.selected.dehighlightAll()
|
||||
|
||||
"""
|
||||
# Push the undo dcs for the selected objects
|
||||
self.direct.undo.push(
|
||||
(self.direct.selected, 'dcs'))
|
||||
direct.undo.push(
|
||||
(direct.selected, 'dcs'))
|
||||
"""
|
||||
# Manipulate the real object with the constraint
|
||||
# The constraint is passed as the name of the node
|
||||
@ -236,17 +235,17 @@ class DirectManipulationControl(PandaObject):
|
||||
elif type == 'ring':
|
||||
self.rotate1D()
|
||||
elif self.fFreeManip:
|
||||
if self.fScaling & (not self.direct.fAlt):
|
||||
if self.fScaling & (not direct.fAlt):
|
||||
# We had been scaling and changed modes,
|
||||
# reset object handles
|
||||
self.objectHandles.transferObjectHandlesScale()
|
||||
self.fScaling = 0
|
||||
if self.direct.fControl:
|
||||
if direct.fControl:
|
||||
self.rotate2D()
|
||||
elif self.direct.fAlt:
|
||||
elif direct.fAlt:
|
||||
self.fScaling = 1
|
||||
self.scale3D()
|
||||
elif self.direct.fShift:
|
||||
elif direct.fShift:
|
||||
self.xlateCamXY()
|
||||
else:
|
||||
self.xlateCamXZ()
|
||||
@ -256,12 +255,12 @@ class DirectManipulationControl(PandaObject):
|
||||
|
||||
if self.fSetCoa:
|
||||
# Update coa based on current widget position
|
||||
self.direct.selected.last.mCoa2Dnp.assign(
|
||||
self.direct.widget.getMat(self.direct.selected.last)
|
||||
direct.selected.last.mCoa2Dnp.assign(
|
||||
direct.widget.getMat(direct.selected.last)
|
||||
)
|
||||
else:
|
||||
# Move the objects with the widget
|
||||
self.direct.selected.moveWrtWidgetAll()
|
||||
direct.selected.moveWrtWidgetAll()
|
||||
|
||||
# Continue
|
||||
return Task.cont
|
||||
@ -281,7 +280,7 @@ class DirectManipulationControl(PandaObject):
|
||||
else:
|
||||
# Move widget to keep hit point as close to mouse as possible
|
||||
offset = self.hitPt - self.prevHit
|
||||
self.direct.widget.setPos(self.direct.widget, offset)
|
||||
direct.widget.setPos(direct.widget, offset)
|
||||
|
||||
def xlate2D(self):
|
||||
# Constrained 2D (planar) translation
|
||||
@ -289,7 +288,7 @@ class DirectManipulationControl(PandaObject):
|
||||
# to one of the three orthogonal planes on the widget.
|
||||
# This point tracks all subsequent mouse movements
|
||||
self.hitPt.assign(self.objectHandles.getWidgetIntersectPt(
|
||||
self.direct.widget, self.constraint[:1]))
|
||||
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
|
||||
@ -297,7 +296,7 @@ class DirectManipulationControl(PandaObject):
|
||||
self.prevHit.assign(self.hitPt)
|
||||
else:
|
||||
offset = self.hitPt - self.prevHit
|
||||
self.direct.widget.setPos(self.direct.widget, offset)
|
||||
direct.widget.setPos(direct.widget, offset)
|
||||
|
||||
|
||||
def xlateCamXZ(self):
|
||||
@ -307,17 +306,17 @@ class DirectManipulationControl(PandaObject):
|
||||
# (in case we later switch to another manipulation mode)
|
||||
#self.fHitInit = 1
|
||||
# Where is the widget relative to current camera view
|
||||
vWidget2Camera = self.direct.widget.getPos(self.camera)
|
||||
vWidget2Camera = direct.widget.getPos(self.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
|
||||
chan = self.chan
|
||||
self.direct.widget.setX(
|
||||
direct.widget.setX(
|
||||
self.camera,
|
||||
x + 0.5 * chan.mouseDeltaX * chan.nearWidth * (y/chan.near))
|
||||
self.direct.widget.setZ(
|
||||
direct.widget.setZ(
|
||||
self.camera,
|
||||
z + 0.5 * chan.mouseDeltaY * chan.nearHeight * (y/chan.near))
|
||||
|
||||
@ -325,7 +324,7 @@ class DirectManipulationControl(PandaObject):
|
||||
"""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 = self.direct.widget.getPos(self.camera)
|
||||
vWidget2Camera = direct.widget.getPos(self.camera)
|
||||
# If this is first time around, record initial y distance
|
||||
if self.fHitInit:
|
||||
self.fHitInit = 0
|
||||
@ -338,7 +337,7 @@ class DirectManipulationControl(PandaObject):
|
||||
# Move widget (and objects) based upon mouse motion
|
||||
# Scaled up accordingly based upon widget distance
|
||||
chan = self.chan
|
||||
self.direct.widget.setPos(
|
||||
direct.widget.setPos(
|
||||
self.camera,
|
||||
x + 0.5 * chan.mouseDeltaX * chan.nearWidth * (y/chan.near),
|
||||
y + self.initY * chan.mouseDeltaY,
|
||||
@ -359,7 +358,7 @@ class DirectManipulationControl(PandaObject):
|
||||
# widget's origin and one of the three principle axes
|
||||
axis = self.constraint[:1]
|
||||
# First compute vector from eye through widget origin
|
||||
mWidget2Cam = self.direct.widget.getMat(self.camera)
|
||||
mWidget2Cam = direct.widget.getMat(self.camera)
|
||||
# And determine where the viewpoint is relative to widget
|
||||
pos = VBase3(0)
|
||||
decomposeMatrix(mWidget2Cam, VBase3(0), VBase3(0), pos,
|
||||
@ -385,7 +384,7 @@ class DirectManipulationControl(PandaObject):
|
||||
def getWidgetsNearProjectionPoint(self):
|
||||
# Find the position of the projection of the specified node path
|
||||
# on the near plane
|
||||
widgetOrigin = self.direct.widget.getPos(self.camera)
|
||||
widgetOrigin = direct.widget.getPos(self.camera)
|
||||
# project this onto near plane
|
||||
return widgetOrigin * (self.chan.near / widgetOrigin[1])
|
||||
|
||||
@ -424,23 +423,23 @@ class DirectManipulationControl(PandaObject):
|
||||
if self.fWidgetTop:
|
||||
deltaAngle = -1 * deltaAngle
|
||||
if self.rotateAxis == 'x':
|
||||
self.direct.widget.setP(self.direct.widget, deltaAngle)
|
||||
direct.widget.setP(direct.widget, deltaAngle)
|
||||
elif self.rotateAxis == 'y':
|
||||
self.direct.widget.setR(self.direct.widget, -deltaAngle)
|
||||
direct.widget.setR(direct.widget, -deltaAngle)
|
||||
elif self.rotateAxis == 'z':
|
||||
self.direct.widget.setH(self.direct.widget, deltaAngle)
|
||||
direct.widget.setH(direct.widget, deltaAngle)
|
||||
# Record crank angle for next time around
|
||||
self.lastCrankAngle = newAngle
|
||||
|
||||
def relHpr(self, base, h, p, r):
|
||||
# Compute widget2newWidget relative to base coordinate system
|
||||
mWidget2Base = self.direct.widget.getMat(base)
|
||||
mWidget2Base = direct.widget.getMat(base)
|
||||
mBase2NewBase = Mat4()
|
||||
mBase2NewBase.composeMatrix(
|
||||
UNIT_VEC, VBase3(h,p,r), ZERO_VEC,
|
||||
CSDefault)
|
||||
mBase2Widget = base.getMat(self.direct.widget)
|
||||
mWidget2Parent = self.direct.widget.getMat()
|
||||
mBase2Widget = base.getMat(direct.widget)
|
||||
mWidget2Parent = direct.widget.getMat()
|
||||
# Compose the result
|
||||
resultMat = mWidget2Base * mBase2NewBase
|
||||
resultMat = resultMat * mBase2Widget
|
||||
@ -449,7 +448,7 @@ class DirectManipulationControl(PandaObject):
|
||||
hpr = Vec3(0)
|
||||
decomposeMatrix(resultMat, VBase3(), hpr, VBase3(),
|
||||
CSDefault)
|
||||
self.direct.widget.setHpr(hpr)
|
||||
direct.widget.setHpr(hpr)
|
||||
|
||||
def rotate2D(self):
|
||||
# Virtual trackball or arcball rotation of widget
|
||||
@ -469,13 +468,13 @@ class DirectManipulationControl(PandaObject):
|
||||
# From midpoint to edge doubles or halves objects scale
|
||||
if self.fHitInit:
|
||||
self.fHitInit = 0
|
||||
self.refNodePath.setPos(self.direct.widget, 0, 0, 0)
|
||||
self.refNodePath.setPos(direct.widget, 0, 0, 0)
|
||||
self.refNodePath.setHpr(self.camera, 0, 0, 0)
|
||||
self.initScaleMag = Vec3(
|
||||
self.objectHandles.getWidgetIntersectPt(
|
||||
self.refNodePath, 'y')).length()
|
||||
# record initial scale
|
||||
self.initScale = self.direct.widget.getScale()
|
||||
self.initScale = direct.widget.getScale()
|
||||
# Begin
|
||||
# Scale factor is ratio current mag with init mag
|
||||
currScale = (
|
||||
@ -484,7 +483,7 @@ class DirectManipulationControl(PandaObject):
|
||||
self.refNodePath, 'y').length() /
|
||||
self.initScaleMag)
|
||||
)
|
||||
self.direct.widget.setScale(currScale)
|
||||
direct.widget.setScale(currScale)
|
||||
|
||||
def clamp(self, val, min, max):
|
||||
if val < min:
|
||||
@ -496,9 +495,7 @@ class DirectManipulationControl(PandaObject):
|
||||
|
||||
|
||||
class ObjectHandles(NodePath,PandaObject):
|
||||
def __init__(self,direct):
|
||||
# Record pointer to direct object
|
||||
self.direct = direct
|
||||
def __init__(self):
|
||||
# Initialize the superclass
|
||||
NodePath.__init__(self)
|
||||
|
||||
@ -718,9 +715,9 @@ class ObjectHandles(NodePath,PandaObject):
|
||||
def growToFit(self):
|
||||
taskMgr.removeTasksNamed('resizeObjectHandles')
|
||||
# Increase handles scale until they cover 30% of the min dimension
|
||||
pos = self.direct.widget.getPos(self.direct.camera)
|
||||
minDim = min(self.direct.chan.nearWidth, self.direct.chan.nearHeight)
|
||||
sf = 0.15 * minDim * (pos[1]/self.direct.chan.near)
|
||||
pos = direct.widget.getPos(direct.camera)
|
||||
minDim = min(direct.chan.nearWidth, direct.chan.nearHeight)
|
||||
sf = 0.15 * minDim * (pos[1]/direct.chan.near)
|
||||
self.ohScalingFactor = sf
|
||||
self.scalingNode.lerpScale(sf,sf,sf, 0.5,
|
||||
blendType = 'easeInOut',
|
||||
@ -839,8 +836,8 @@ class ObjectHandles(NodePath,PandaObject):
|
||||
|
||||
def getAxisIntersectPt(self, axis):
|
||||
# Calc the xfrom from camera to widget
|
||||
mCam2Widget = self.direct.camera.getMat(self.direct.widget)
|
||||
lineDir = Vec3(mCam2Widget.xformVec(self.direct.chan.nearVec))
|
||||
mCam2Widget = direct.camera.getMat(direct.widget)
|
||||
lineDir = Vec3(mCam2Widget.xformVec(direct.chan.nearVec))
|
||||
lineDir.normalize()
|
||||
# And determine where the viewpoint is relative to widget
|
||||
lineOrigin = VBase3(0)
|
||||
@ -887,7 +884,7 @@ class ObjectHandles(NodePath,PandaObject):
|
||||
# with the plane containing the 2D xlation or 1D rotation widgets
|
||||
|
||||
# Calc the xfrom from camera to the nodePath
|
||||
mCam2NodePath = self.direct.camera.getMat(nodePath)
|
||||
mCam2NodePath = direct.camera.getMat(nodePath)
|
||||
|
||||
# And determine where the viewpoint is relative to widget
|
||||
lineOrigin = VBase3(0)
|
||||
@ -897,7 +894,7 @@ class ObjectHandles(NodePath,PandaObject):
|
||||
# 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(self.direct.chan.nearVec))
|
||||
lineDir = Vec3(mCam2NodePath.xformVec(direct.chan.nearVec))
|
||||
lineDir.normalize()
|
||||
# Find the hit point
|
||||
if plane == 'x':
|
||||
|
@ -46,8 +46,7 @@ class DirectNodePath(NodePath):
|
||||
|
||||
|
||||
class SelectedNodePaths(PandaObject):
|
||||
def __init__(self,direct):
|
||||
self.direct = direct
|
||||
def __init__(self):
|
||||
self.selectedDict = {}
|
||||
self.deselectedDict = {}
|
||||
self.last = None
|
||||
@ -131,13 +130,13 @@ class SelectedNodePaths(PandaObject):
|
||||
self.forEachSelectedNodePathDo(self.getWrt)
|
||||
|
||||
def getWrt(self, nodePath):
|
||||
nodePath.mDnp2Widget.assign(nodePath.getMat(self.direct.widget))
|
||||
nodePath.mDnp2Widget.assign(nodePath.getMat(direct.widget))
|
||||
|
||||
def moveWrtWidgetAll(self):
|
||||
self.forEachSelectedNodePathDo(self.moveWrtWidget)
|
||||
|
||||
def moveWrtWidget(self, nodePath):
|
||||
nodePath.setMat(self.direct.widget, nodePath.mDnp2Widget)
|
||||
nodePath.setMat(direct.widget, nodePath.mDnp2Widget)
|
||||
|
||||
def deselectAll(self):
|
||||
self.forEachSelectedNodePathDo(self.deselect)
|
||||
|
@ -5,10 +5,14 @@ from DirectSelection import *
|
||||
from DirectGrid import *
|
||||
from DirectGeometry import *
|
||||
import OnscreenText
|
||||
import __builtin__
|
||||
|
||||
class DirectSession(PandaObject):
|
||||
|
||||
def __init__(self):
|
||||
# Establish a global pointer to the direct object early on
|
||||
# so dependant classes can access it in their code
|
||||
__builtin__.direct = self
|
||||
self.contextList = []
|
||||
self.iRayList = []
|
||||
for camera in base.cameraList:
|
||||
@ -17,14 +21,14 @@ class DirectSession(PandaObject):
|
||||
self.chan = self.getChanData(0)
|
||||
self.camera = base.cameraList[0]
|
||||
|
||||
self.cameraControl = DirectCameraControl(self)
|
||||
self.manipulationControl = DirectManipulationControl(self)
|
||||
self.cameraControl = DirectCameraControl()
|
||||
self.manipulationControl = DirectManipulationControl()
|
||||
self.useObjectHandles()
|
||||
self.grid = DirectGrid(self)
|
||||
self.grid = DirectGrid()
|
||||
self.grid.disable()
|
||||
|
||||
# Initialize the collection of selected nodePaths
|
||||
self.selected = SelectedNodePaths(self)
|
||||
self.selected = SelectedNodePaths()
|
||||
|
||||
self.readout = OnscreenText.OnscreenText( '', 0.1, -0.95 )
|
||||
# self.readout.textNode.setCardColor(0.5, 0.5, 0.5, 0.5)
|
||||
|
@ -1,10 +1,11 @@
|
||||
from ShowBaseGlobal import *
|
||||
import __builtin__
|
||||
|
||||
# If specified in the user's Configrc, create the direct session
|
||||
if base.wantDIRECT:
|
||||
from DirectSession import *
|
||||
direct = base.direct = DirectSession()
|
||||
__builtin__.direct = base.direct = DirectSession()
|
||||
else:
|
||||
# Otherwise set the values to None
|
||||
direct = base.direct = None
|
||||
__builtin__.direct = base.direct = None
|
||||
|
||||
|
@ -1,15 +1,16 @@
|
||||
"""instantiate global ShowBase object"""
|
||||
|
||||
from ShowBase import *
|
||||
import __builtin__
|
||||
|
||||
base = ShowBase()
|
||||
__builtin__.base = ShowBase()
|
||||
|
||||
# Make some global aliases for convenience
|
||||
render2d = base.render2d
|
||||
render = base.render
|
||||
hidden = base.hidden
|
||||
camera = base.camera
|
||||
loader = base.loader
|
||||
ostream = Notify.out()
|
||||
run = base.run
|
||||
tkroot = base.tkroot
|
||||
__builtin__.render2d = base.render2d
|
||||
__builtin__.render = base.render
|
||||
__builtin__.hidden = base.hidden
|
||||
__builtin__.camera = base.camera
|
||||
__builtin__.loader = base.loader
|
||||
__builtin__.ostream = Notify.out()
|
||||
__builtin__.run = base.run
|
||||
__builtin__.tkroot = base.tkroot
|
||||
|
Loading…
x
Reference in New Issue
Block a user