mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
*** empty log message ***
This commit is contained in:
parent
8c276c3d58
commit
8507ed7137
@ -1,5 +1,11 @@
|
|||||||
""" Class used to create and control vrpn devices """
|
""" Class used to create and control vrpn devices """
|
||||||
from PandaObject import *
|
from PandaObject import *
|
||||||
|
from DirectGeometry import CLAMP
|
||||||
|
|
||||||
|
ANALOG_MIN = -0.95
|
||||||
|
ANALOG_MAX = 0.95
|
||||||
|
ANALOG_RANGE = ANALOG_MAX - ANALOG_MIN
|
||||||
|
ANALOG_DEADBAND = 0.075
|
||||||
|
|
||||||
class DirectDeviceManager(VrpnClient, PandaObject):
|
class DirectDeviceManager(VrpnClient, PandaObject):
|
||||||
def __init__(self, server = None):
|
def __init__(self, server = None):
|
||||||
@ -77,7 +83,7 @@ class DirectAnalogs(AnalogNode, PandaObject):
|
|||||||
self.nodePath = base.dataRoot.attachNewNode(self)
|
self.nodePath = base.dataRoot.attachNewNode(self)
|
||||||
|
|
||||||
def __getitem__(self, index):
|
def __getitem__(self, index):
|
||||||
if (index < 0) | index > self.getNumControls():
|
if (index < 0) | (index > self.getNumControls()):
|
||||||
raise IndexError
|
raise IndexError
|
||||||
return self.getControlState(index)
|
return self.getControlState(index)
|
||||||
|
|
||||||
@ -90,6 +96,22 @@ class DirectAnalogs(AnalogNode, PandaObject):
|
|||||||
def disable(self):
|
def disable(self):
|
||||||
self.nodePath.reparentTo(base.dataUnused)
|
self.nodePath.reparentTo(base.dataUnused)
|
||||||
|
|
||||||
|
def normalize(self, val, min = -1, max = -1):
|
||||||
|
val = CLAMP(val, ANALOG_MIN, ANALOG_MAX)
|
||||||
|
if abs(val) < ANALOG_DEADBAND:
|
||||||
|
val = 0.0
|
||||||
|
return ((max - min) * ((val - ANALOG_MIN) / ANALOG_RANGE)) + min
|
||||||
|
|
||||||
|
def normalizeChannel(self, chan, min = -1, max = 1):
|
||||||
|
try:
|
||||||
|
if (chan == 2) | (chan == 6):
|
||||||
|
# These channels have reduced range
|
||||||
|
return self.normalize(self[chan] * 3.0, min, max)
|
||||||
|
else:
|
||||||
|
return self.normalize(self[chan], min, max)
|
||||||
|
except IndexError:
|
||||||
|
return 0.0
|
||||||
|
|
||||||
def getName(self):
|
def getName(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
""" Class used to create and control joybox device """
|
""" Class used to create and control joybox device """
|
||||||
from PandaObject import *
|
from PandaObject import *
|
||||||
from DirectDeviceManager import *
|
from DirectDeviceManager import *
|
||||||
from DirectGeometry import CLAMP
|
|
||||||
import OnscreenText
|
import OnscreenText
|
||||||
|
|
||||||
JOY_MIN = -0.95
|
"""
|
||||||
JOY_MAX = 0.95
|
TODO:
|
||||||
JOY_RANGE = JOY_MAX - JOY_MIN
|
Handle interaction between widget, followSelectedTask and updateTask
|
||||||
JOY_DEADBAND = 0.05
|
"""
|
||||||
|
|
||||||
# BUTTONS
|
# BUTTONS
|
||||||
L_STICK = 0
|
L_STICK = 0
|
||||||
L_UPPER = 1
|
L_UPPER = 1
|
||||||
@ -16,6 +16,7 @@ R_STICK = 3
|
|||||||
R_UPPER = 4
|
R_UPPER = 4
|
||||||
R_LOWER = 5
|
R_LOWER = 5
|
||||||
# ANALOGS
|
# ANALOGS
|
||||||
|
NULL_AXIS = -1
|
||||||
L_LEFT_RIGHT = 0
|
L_LEFT_RIGHT = 0
|
||||||
L_FWD_BACK = 1
|
L_FWD_BACK = 1
|
||||||
L_TWIST = 2
|
L_TWIST = 2
|
||||||
@ -27,8 +28,8 @@ R_SLIDE = 7
|
|||||||
|
|
||||||
class DirectJoybox(PandaObject):
|
class DirectJoybox(PandaObject):
|
||||||
joyboxCount = 0
|
joyboxCount = 0
|
||||||
xyzScale = 1.0
|
xyzMultiplier = 1.0
|
||||||
hprScale = 1.0
|
hprMultiplier = 1.0
|
||||||
def __init__(self, nodePath = direct.camera):
|
def __init__(self, nodePath = direct.camera):
|
||||||
# See if device manager has been initialized
|
# See if device manager has been initialized
|
||||||
if direct.deviceManager == None:
|
if direct.deviceManager == None:
|
||||||
@ -41,26 +42,57 @@ class DirectJoybox(PandaObject):
|
|||||||
self.buttons = direct.deviceManager.createButtons(self.device)
|
self.buttons = direct.deviceManager.createButtons(self.device)
|
||||||
self.aList = [0,0,0,0,0,0,0,0]
|
self.aList = [0,0,0,0,0,0,0,0]
|
||||||
self.bList = [0,0,0,0,0,0,0,0]
|
self.bList = [0,0,0,0,0,0,0,0]
|
||||||
self.mapping = [0,1,2,4,5,6]
|
# For joybox fly mode
|
||||||
|
self.mapping = [L_LEFT_RIGHT, L_FWD_BACK, L_TWIST,
|
||||||
|
R_TWIST, R_FWD_BACK, R_LEFT_RIGHT]
|
||||||
self.modifier = [1,1,1,1,1,1]
|
self.modifier = [1,1,1,1,1,1]
|
||||||
# Button registry
|
|
||||||
self.addButtonEvents()
|
|
||||||
# Initialize time
|
# Initialize time
|
||||||
self.lastTime = globalClock.getTime()
|
self.lastTime = globalClock.getTime()
|
||||||
# Record node path
|
# Record node path
|
||||||
self.nodePath = nodePath
|
self.nodePath = nodePath
|
||||||
|
# Ref CS for orbit mode
|
||||||
|
self.refCS = direct.cameraControl.coaMarker
|
||||||
|
self.tempCS = direct.group.attachNewNode('JoyboxTempCS')
|
||||||
# Text object to display current mode
|
# Text object to display current mode
|
||||||
self.readout = OnscreenText.OnscreenText( '', -0.9, -0.95 )
|
self.readout = OnscreenText.OnscreenText( '', -0.9, -0.95 )
|
||||||
|
# List of functions to cycle through
|
||||||
|
self.modeList = [self.joeMode, self.driveMode]
|
||||||
# Pick initial mode
|
# Pick initial mode
|
||||||
self.updateFunc = self.joeFly
|
self.updateFunc = self.joeFly
|
||||||
|
self.modeName = 'Joe Mode'
|
||||||
|
# Button registry
|
||||||
|
self.addButtonEvents()
|
||||||
# Spawn update task
|
# Spawn update task
|
||||||
self.enable()
|
self.enable()
|
||||||
|
|
||||||
def enable(self):
|
def enable(self):
|
||||||
|
# Kill existing task
|
||||||
|
self.disable()
|
||||||
|
# Accept button events
|
||||||
|
self.acceptSwitchModeEvent()
|
||||||
|
self.acceptUprightCameraEvent()
|
||||||
|
# If moving widget update wrt info
|
||||||
|
if self.nodePath.id() == direct.widget.id():
|
||||||
|
# Kill follow task
|
||||||
|
taskMgr.removeTasksNamed('followSelectedNodePath')
|
||||||
|
# Record relationship between selected nodes and widget
|
||||||
|
direct.selected.getWrtAll()
|
||||||
|
# Update task
|
||||||
taskMgr.spawnMethodNamed(self.updateTask, self.name + '-updateTask')
|
taskMgr.spawnMethodNamed(self.updateTask, self.name + '-updateTask')
|
||||||
|
|
||||||
def disable(self):
|
def disable(self):
|
||||||
taskMgr.removeTasksNamed(self.name + '-updateTask')
|
taskMgr.removeTasksNamed(self.name + '-updateTask')
|
||||||
|
if self.nodePath.id() == direct.widget.id():
|
||||||
|
# Restart followSelectedNodePath task
|
||||||
|
direct.manipulationControl.spawnFollowSelectedNodePathTask()
|
||||||
|
self.ignoreSwitchModeEvent()
|
||||||
|
self.ignoreUprightCameraEvent()
|
||||||
|
|
||||||
|
def destroy(self):
|
||||||
|
self.disable()
|
||||||
|
self.ignore('selectedNodePath')
|
||||||
|
self.ignore('deselectNodePath')
|
||||||
|
self.tempCS.removeNode()
|
||||||
|
|
||||||
def addButtonEvents(self):
|
def addButtonEvents(self):
|
||||||
self.breg = ButtonRegistry.ptr()
|
self.breg = ButtonRegistry.ptr()
|
||||||
@ -73,14 +105,57 @@ class DirectJoybox(PandaObject):
|
|||||||
|
|
||||||
def setNodePath(self, nodePath):
|
def setNodePath(self, nodePath):
|
||||||
self.nodePath = nodePath
|
self.nodePath = nodePath
|
||||||
|
if self.nodePath.id() == direct.widget.id():
|
||||||
|
# Kill follow task
|
||||||
|
taskMgr.removeTasksNamed('followSelectedNodePath')
|
||||||
|
# Record relationship between selected nodes and widget
|
||||||
|
direct.selected.getWrtAll()
|
||||||
|
# Watch for newly selected objects
|
||||||
|
self.accept('selectedNodePath', self.selectionHook)
|
||||||
|
# Watch for deselections
|
||||||
|
self.accept('deselectNodePath', self.selectionHook)
|
||||||
|
else:
|
||||||
|
self.ignore('selectedNodePath')
|
||||||
|
self.ignore('deselectNodePath')
|
||||||
|
|
||||||
|
def selectionHook(self, dnp):
|
||||||
|
if direct.selected.getSelectedAsList():
|
||||||
|
print 'enable'
|
||||||
|
self.enable()
|
||||||
|
else:
|
||||||
|
print 'disable'
|
||||||
|
self.disable()
|
||||||
|
|
||||||
def getNodePath(self):
|
def getNodePath(self):
|
||||||
return self.nodePath
|
return self.nodePath
|
||||||
|
def setRefCS(self, refCS):
|
||||||
|
self.refCS = refCS
|
||||||
|
def getRefCS(self):
|
||||||
|
return self.refCS
|
||||||
def getEventName(self, index):
|
def getEventName(self, index):
|
||||||
return self.name + '-button-' + `index`
|
return self.name + '-button-' + `index`
|
||||||
|
def setXyzMultiplier(self, multiplier):
|
||||||
|
DirectJoybox.xyzMultiplier = multiplier
|
||||||
|
def getXyzMultiplier(self):
|
||||||
|
return DirectJoybox.xyzMultiplier
|
||||||
|
def setHprMultiplier(self, multiplier):
|
||||||
|
DirectJoybox.hprMultiplier = multiplier
|
||||||
|
def getHprMultiplier(self):
|
||||||
|
return DirectJoybox.hprMultiplier
|
||||||
|
|
||||||
def updateTask(self, state):
|
def updateTask(self, state):
|
||||||
self.updateVals()
|
self.updateVals()
|
||||||
self.updateFunc()
|
self.updateFunc()
|
||||||
|
if self.nodePath.id() == direct.widget.id():
|
||||||
|
if direct.manipulationControl.fSetCoa:
|
||||||
|
# Update coa based on current widget position
|
||||||
|
direct.selected.last.mCoa2Dnp.assign(
|
||||||
|
direct.widget.getMat(direct.selected.last))
|
||||||
|
# Update wrt info
|
||||||
|
direct.selected.getWrtAll()
|
||||||
|
else:
|
||||||
|
# Move the objects with the widget
|
||||||
|
direct.selected.moveWrtWidgetAll()
|
||||||
return Task.cont
|
return Task.cont
|
||||||
|
|
||||||
def updateVals(self):
|
def updateVals(self):
|
||||||
@ -90,31 +165,31 @@ class DirectJoybox(PandaObject):
|
|||||||
self.lastTime = cTime
|
self.lastTime = cTime
|
||||||
# Update analogs
|
# Update analogs
|
||||||
for i in range(len(self.analogs)):
|
for i in range(len(self.analogs)):
|
||||||
try:
|
self.aList[i] = self.analogs.normalizeChannel(i)
|
||||||
self.aList[i] = self.normalizeAnalogChannel(i)
|
|
||||||
except IndexError:
|
|
||||||
# That channel may not have been updated yet
|
|
||||||
pass
|
|
||||||
# Update buttons
|
# Update buttons
|
||||||
for i in range(len(self.buttons)):
|
for i in range(len(self.buttons)):
|
||||||
try:
|
try:
|
||||||
self.bList[i] = self.buttons[i]
|
self.bList[i] = self.buttons[i]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
# That channel may not have been updated yet
|
# That channel may not have been updated yet
|
||||||
|
self.bList[i] = 0
|
||||||
|
|
||||||
|
def acceptSwitchModeEvent(self, button = R_UPPER):
|
||||||
|
self.accept(self.getEventName(button), self.switchMode)
|
||||||
|
def ignoreSwitchModeEvent(self, button = R_UPPER):
|
||||||
|
self.ignore(self.getEventName(button))
|
||||||
|
|
||||||
|
def switchMode(self):
|
||||||
|
try:
|
||||||
|
# Get current mode
|
||||||
|
self.modeFunc = self.modeList[0]
|
||||||
|
# Rotate mode list
|
||||||
|
self.modeList = self.modeList[1:] + self.modeList[:1]
|
||||||
|
# Call new mode
|
||||||
|
self.modeFunc()
|
||||||
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def normalizeAnalog(self, val, min = -1, max = -1):
|
|
||||||
val = CLAMP(val, JOY_MIN, JOY_MAX)
|
|
||||||
if abs(val) < JOY_DEADBAND:
|
|
||||||
val = 0.0
|
|
||||||
return ((max - min) * ((val - JOY_MIN) / JOY_RANGE)) + min
|
|
||||||
|
|
||||||
def normalizeAnalogChannel(self, chan, min = -1, max = 1):
|
|
||||||
if (chan == 2) | (chan == 6):
|
|
||||||
return self.normalizeAnalog(self.analogs[chan] * 3.0, min, max)
|
|
||||||
else:
|
|
||||||
return self.normalizeAnalog(self.analogs[chan], min, max)
|
|
||||||
|
|
||||||
def showMode(self, modeText):
|
def showMode(self, modeText):
|
||||||
def hideText(state, s = self):
|
def hideText(state, s = self):
|
||||||
s.readout.setText('')
|
s.readout.setText('')
|
||||||
@ -125,23 +200,30 @@ class DirectJoybox(PandaObject):
|
|||||||
t = taskMgr.doMethodLater(3.0, hideText, self.name + '-showMode')
|
t = taskMgr.doMethodLater(3.0, hideText, self.name + '-showMode')
|
||||||
t.uponDeath = hideText
|
t.uponDeath = hideText
|
||||||
|
|
||||||
|
def acceptUprightCameraEvent(self, button = L_UPPER):
|
||||||
|
self.accept(self.getEventName(button),
|
||||||
|
direct.cameraControl.orbitUprightCam)
|
||||||
|
def ignoreUprightCameraEvent(self, button = L_UPPER):
|
||||||
|
self.ignore(self.getEventName(button))
|
||||||
|
|
||||||
def setMode(self, func, name):
|
def setMode(self, func, name):
|
||||||
self.disable()
|
self.disable()
|
||||||
self.updateFunc = func
|
self.updateFunc = func
|
||||||
self.showMode(name)
|
self.modeName = name
|
||||||
|
self.showMode(self.modeName)
|
||||||
self.enable()
|
self.enable()
|
||||||
|
|
||||||
def joeMode(self):
|
def joeMode(self):
|
||||||
self.setMode(self.joeFly, 'Joe Mode')
|
self.setMode(self.joeFly, 'Joe Mode')
|
||||||
|
|
||||||
def joeFly(self):
|
def joeFly(self):
|
||||||
hprScale = (self.normalizeAnalogChannel(3, 0.1, 200) *
|
hprScale = (self.analogs.normalizeChannel(L_SLIDE, 0.1, 200) *
|
||||||
DirectJoybox.hprScale)
|
DirectJoybox.hprMultiplier)
|
||||||
posScale = (self.normalizeAnalogChannel(7, 0.1, 100) *
|
posScale = (self.analogs.normalizeChannel(R_SLIDE, 0.1, 100) *
|
||||||
DirectJoybox.xyzScale)
|
DirectJoybox.xyzMultiplier)
|
||||||
# XYZ
|
# XYZ
|
||||||
x = self.aList[4]
|
x = self.aList[R_LEFT_RIGHT]
|
||||||
y = self.aList[5]
|
y = self.aList[R_FWD_BACK]
|
||||||
if self.bList[L_STICK]:
|
if self.bList[L_STICK]:
|
||||||
z = 0.0
|
z = 0.0
|
||||||
else:
|
else:
|
||||||
@ -159,51 +241,98 @@ class DirectJoybox(PandaObject):
|
|||||||
self.nodePath.setPosHpr(self.nodePath, pos, hpr)
|
self.nodePath.setPosHpr(self.nodePath, pos, hpr)
|
||||||
|
|
||||||
def joyboxFly(self):
|
def joyboxFly(self):
|
||||||
hprScale = (self.normalizeAnalogChannel(3, 0.1, 200) *
|
hprScale = (self.analogs.normalizeChannel(L_SLIDE, 0.1, 200) *
|
||||||
DirectJoybox.hprScale)
|
DirectJoybox.hprMultiplier)
|
||||||
posScale = (self.normalizeAnalogChannel(7, 0.1, 100) *
|
posScale = (self.analogs.normalizeChannel(R_SLIDE, 0.1, 100) *
|
||||||
DirectJoybox.xyzScale)
|
DirectJoybox.xyzMultiplier)
|
||||||
x = self.analogs[self.mapping[0]] * self.modifier[0]
|
def getAxisVal(index, s = self):
|
||||||
y = self.analogs[self.mapping[1]] * self.modifier[1]
|
try:
|
||||||
z = self.analogs[self.mapping[2]] * self.modifier[2]
|
return s.aList[s.mapping[index]]
|
||||||
|
except IndexError:
|
||||||
|
# If it is a null axis return 0
|
||||||
|
return 0.0
|
||||||
|
x = getAxisVal(0) * self.modifier[0]
|
||||||
|
y = getAxisVal(1) * self.modifier[1]
|
||||||
|
z = getAxisVal(2) * self.modifier[2]
|
||||||
pos = Vec3(x,y,z) * (posScale * self.deltaTime)
|
pos = Vec3(x,y,z) * (posScale * self.deltaTime)
|
||||||
|
|
||||||
h = self.analogs[self.mapping[3]] * self.modifier[3]
|
h = getAxisVal(3) * self.modifier[3]
|
||||||
p = self.analogs[self.mapping[4]] * self.modifier[4]
|
p = getAxisVal(4) * self.modifier[4]
|
||||||
r = self.analogs[self.mapping[5]] * self.modifier[5]
|
r = getAxisVal(5) * self.modifier[5]
|
||||||
hpr = Vec3(h,p,r) * (hprScale * self.deltaTime)
|
hpr = Vec3(h,p,r) * (hprScale * self.deltaTime)
|
||||||
# Move node path
|
# Move node path
|
||||||
self.nodePath.setPosHpr(self.nodePath, pos, hpr)
|
self.nodePath.setPosHpr(self.nodePath, pos, hpr)
|
||||||
|
|
||||||
def demoMode(self):
|
def demoMode(self):
|
||||||
self.mapping = [4,5,1,6,0,0]
|
self.mapping = [R_LEFT_RIGHT, R_FWD_BACK, L_FWD_BACK,
|
||||||
|
R_TWIST, NULL_AXIS, NULL_AXIS]
|
||||||
self.modifier = [1,1,1,-1,0,0]
|
self.modifier = [1,1,1,-1,0,0]
|
||||||
self.setMode(self.joyboxFly, 'Demo Mode')
|
self.setMode(self.joyboxFly, 'Demo Mode')
|
||||||
|
|
||||||
def driveMode(self):
|
def driveMode(self):
|
||||||
self.mapping = [0,5,1,4,1,0]
|
self.mapping = [L_LEFT_RIGHT, R_FWD_BACK, L_FWD_BACK,
|
||||||
|
R_LEFT_RIGHT, NULL_AXIS, NULL_AXIS]
|
||||||
self.modifier = [1,1,1,-1,0,0]
|
self.modifier = [1,1,1,-1,0,0]
|
||||||
self.setMode(self.joyboxFly, 'Drive Mode')
|
self.setMode(self.joyboxFly, 'Drive Mode')
|
||||||
|
|
||||||
def hprXyzMode(self):
|
def hprXyzMode(self):
|
||||||
self.mapping = [4,5,6,2,1,0]
|
self.mapping = [R_LEFT_RIGHT, R_FWD_BACK, R_TWIST,
|
||||||
|
L_TWIST, L_FWD_BACK, L_LEFT_RIGHT]
|
||||||
self.modifier = [1,1,-1,-1,-1,1]
|
self.modifier = [1,1,-1,-1,-1,1]
|
||||||
self.setMode(self.joyboxFly, 'HprXyz Mode')
|
self.setMode(self.joyboxFly, 'HprXyz Mode')
|
||||||
|
|
||||||
def lookaroundMode(self):
|
def lookaroundMode(self):
|
||||||
self.mapping = [0,0,0,4,5,0]
|
self.mapping = [NULL_AXIS, NULL_AXIS, NULL_AXIS,
|
||||||
|
R_LEFT_RIGHT, R_FWD_BACK, NULL_AXIS]
|
||||||
self.modifier = [0,0,0,-1,-1,0]
|
self.modifier = [0,0,0,-1,-1,0]
|
||||||
self.setMode(self.joyboxFly, 'Lookaround Mode')
|
self.setMode(self.joyboxFly, 'Lookaround Mode')
|
||||||
|
|
||||||
def walkthruMode(self):
|
def walkthruMode(self):
|
||||||
self.mapping = [4,5,2,6,1,0]
|
self.mapping = [R_LEFT_RIGHT, R_FWD_BACK, L_TWIST,
|
||||||
|
R_TWIST, L_FWD_BACK, L_LEFT_RIGHT]
|
||||||
self.modifier = [1,1,-1,-1,-1, 1]
|
self.modifier = [1,1,-1,-1,-1, 1]
|
||||||
self.setMode(self.joyboxFly, 'Walkthru Mode')
|
self.setMode(self.joyboxFly, 'Walkthru Mode')
|
||||||
|
|
||||||
def jbTest():
|
def orbitMode(self):
|
||||||
jb = DirectJoybox()
|
self.setMode(self.orbitFly, 'Orbit Mode')
|
||||||
jb.joeMode()
|
|
||||||
jb.accept(jb.getEventName(R_UPPER), jb.joeMode)
|
def orbitFly(self):
|
||||||
direct.cameraControl.accept(jb.getEventName(L_UPPER),
|
hprScale = (self.analogs.normalizeChannel(L_SLIDE, 0.1, 200) *
|
||||||
direct.cameraControl.orbitUprightCam)
|
DirectJoybox.hprMultiplier)
|
||||||
return jb
|
posScale = (self.analogs.normalizeChannel(R_SLIDE, 0.1, 100) *
|
||||||
|
DirectJoybox.xyzMultiplier)
|
||||||
|
rx = hprScale * self.aList[R_LEFT_RIGHT] * self.deltaTime
|
||||||
|
ry = -1 * hprScale * self.aList[R_FWD_BACK] * self.deltaTime
|
||||||
|
h = -1 * hprScale * self.aList[R_TWIST] * self.deltaTime
|
||||||
|
r = -0.01 * posScale * self.aList[R_FWD_BACK] * self.deltaTime
|
||||||
|
x = posScale * self.aList[L_LEFT_RIGHT] * self.deltaTime
|
||||||
|
z = posScale * self.aList[L_FWD_BACK] * self.deltaTime
|
||||||
|
# Move dcs
|
||||||
|
self.nodePath.setX(self.nodePath, x)
|
||||||
|
self.nodePath.setZ(self.nodePath, z)
|
||||||
|
self.nodePath.setH(self.nodePath, h)
|
||||||
|
if self.bList[R_STICK]:
|
||||||
|
self.orbitNode(rx, ry, 0)
|
||||||
|
else:
|
||||||
|
self.orbitNode(rx, 0, 0)
|
||||||
|
pos = self.nodePath.getPos(self.refCS)
|
||||||
|
if Vec3(pos).length() < 0.005:
|
||||||
|
pos.set(0,-0.01, 0)
|
||||||
|
# Now move on out
|
||||||
|
pos.assign(pos * (1 + r))
|
||||||
|
self.nodePath.setPos(self.refCS, pos)
|
||||||
|
|
||||||
|
def orbitNode(self, h, p, r):
|
||||||
|
# Position the temp node path at the ref CS
|
||||||
|
self.tempCS.setPos(self.refCS, 0, 0, 0)
|
||||||
|
# Orient the temp node path to align with the orbiting node path
|
||||||
|
self.tempCS.setHpr(self.nodePath, 0, 0, 0)
|
||||||
|
# Record the position of the orbiter wrt the helper
|
||||||
|
pos = self.nodePath.getPos(self.tempCS)
|
||||||
|
# Turn the temp node path
|
||||||
|
self.tempCS.setHpr(self.tempCS, h, p, r)
|
||||||
|
# Position the orbiter "back" to its position wrt the helper
|
||||||
|
self.nodePath.setPos(self.tempCS, pos)
|
||||||
|
# Restore the original hpr of the orbiter
|
||||||
|
self.nodePath.setHpr(self.tempCS, 0, 0, 0)
|
||||||
|
|
||||||
|
@ -276,8 +276,10 @@ class DirectCameraControl(PandaObject):
|
|||||||
def updateCoaMarkerSize(self, coaDist = None):
|
def updateCoaMarkerSize(self, coaDist = None):
|
||||||
if not coaDist:
|
if not coaDist:
|
||||||
coaDist = Vec3(self.coaMarker.getPos( direct.camera )).length()
|
coaDist = Vec3(self.coaMarker.getPos( direct.camera )).length()
|
||||||
self.coaMarker.setScale(COA_MARKER_SF * coaDist *
|
sf = COA_MARKER_SF * coaDist * math.tan(deg2Rad(direct.dr.fovV))
|
||||||
math.tan(deg2Rad(direct.dr.fovV)))
|
if sf == 0.0:
|
||||||
|
sf = 0.1
|
||||||
|
self.coaMarker.setScale(sf)
|
||||||
|
|
||||||
def homeCam(self):
|
def homeCam(self):
|
||||||
# Record undo point
|
# Record undo point
|
||||||
|
@ -106,6 +106,8 @@ class SelectedNodePaths(PandaObject):
|
|||||||
del(self.selectedDict[id])
|
del(self.selectedDict[id])
|
||||||
# And keep track of it in the deselected dictionary
|
# And keep track of it in the deselected dictionary
|
||||||
self.deselectedDict[id] = dnp
|
self.deselectedDict[id] = dnp
|
||||||
|
# Send a message
|
||||||
|
messenger.send('deselectNodePath', [dnp])
|
||||||
return dnp
|
return dnp
|
||||||
|
|
||||||
def getSelectedAsList(self):
|
def getSelectedAsList(self):
|
||||||
|
@ -126,6 +126,10 @@ class ParticleEffect(NodePath):
|
|||||||
f.write('\n')
|
f.write('\n')
|
||||||
|
|
||||||
# Make sure we start with a clean slate
|
# Make sure we start with a clean slate
|
||||||
|
f.write('for p in self.getParticlesList():\n')
|
||||||
|
f.write('\tself.removeParticles(p)\n')
|
||||||
|
f.write('for fg in self.getForceGroupList():\n')
|
||||||
|
f.write('\tpe.removeForceGroup(fg)\n')
|
||||||
f.write('self.particlesDict = {}\n')
|
f.write('self.particlesDict = {}\n')
|
||||||
f.write('self.forceGroupDict = {}\n')
|
f.write('self.forceGroupDict = {}\n')
|
||||||
|
|
||||||
|
@ -113,6 +113,9 @@ class Messenger:
|
|||||||
"""
|
"""
|
||||||
self.dict.clear()
|
self.dict.clear()
|
||||||
|
|
||||||
|
def toggleVerbose(self):
|
||||||
|
Messenger.notify.setDebug(1 - Messenger.notify.getDebug())
|
||||||
|
|
||||||
def listAllEvents(self):
|
def listAllEvents(self):
|
||||||
str = 'Messenger\n'
|
str = 'Messenger\n'
|
||||||
str = str + '='*50 + '\n'
|
str = str + '='*50 + '\n'
|
||||||
|
@ -980,11 +980,6 @@ class ParticlePanel(AppShell):
|
|||||||
parent = self.parent)
|
parent = self.parent)
|
||||||
if particleFilename:
|
if particleFilename:
|
||||||
# Delete existing particles and forces
|
# Delete existing particles and forces
|
||||||
pe = self.particleEffect
|
|
||||||
for p in pe.getParticlesList():
|
|
||||||
pe.removeParticles(p)
|
|
||||||
for fg in pe.getForceGroupList():
|
|
||||||
pe.removeForceGroup(fg)
|
|
||||||
self.particleEffect.loadConfig(Filename(particleFilename))
|
self.particleEffect.loadConfig(Filename(particleFilename))
|
||||||
self.selectEffectNamed(self.particleEffect.getName())
|
self.selectEffectNamed(self.particleEffect.getName())
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user