mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
*** empty log message ***
This commit is contained in:
parent
d05416a7cd
commit
ddc3b433d4
@ -1,21 +1,28 @@
|
|||||||
""" Class used to create and control vrpn devices """
|
""" Class used to create and control vrpn devices """
|
||||||
from PandaObject import *
|
|
||||||
from DirectGeometry import CLAMP
|
from DirectObject import *
|
||||||
|
from PandaModules import *
|
||||||
|
|
||||||
ANALOG_MIN = -0.95
|
ANALOG_MIN = -0.95
|
||||||
ANALOG_MAX = 0.95
|
ANALOG_MAX = 0.95
|
||||||
ANALOG_RANGE = ANALOG_MAX - ANALOG_MIN
|
ANALOG_RANGE = ANALOG_MAX - ANALOG_MIN
|
||||||
ANALOG_DEADBAND = 0.075
|
ANALOG_DEADBAND = 0.075
|
||||||
|
|
||||||
class DirectDeviceManager(VrpnClient, PandaObject):
|
try:
|
||||||
|
myBase = base
|
||||||
|
except:
|
||||||
|
myBase = simbase
|
||||||
|
|
||||||
|
class DirectDeviceManager(VrpnClient, DirectObject):
|
||||||
def __init__(self, server = None):
|
def __init__(self, server = None):
|
||||||
|
|
||||||
# Determine which server to use
|
# Determine which server to use
|
||||||
if server != None:
|
if server != None:
|
||||||
# One give as constructor argument
|
# One give as constructor argument
|
||||||
self.server = server
|
self.server = server
|
||||||
else:
|
else:
|
||||||
# Check config file, if that fails, use default
|
# Check config file, if that fails, use default
|
||||||
self.server = base.config.GetString('vrpn-server', 'spacedyne')
|
self.server = myBase.config.GetString('vrpn-server', 'spacedyne')
|
||||||
|
|
||||||
# Create a vrpn client
|
# Create a vrpn client
|
||||||
VrpnClient.__init__(self, self.server)
|
VrpnClient.__init__(self, self.server)
|
||||||
@ -35,7 +42,7 @@ class DirectDeviceManager(VrpnClient, PandaObject):
|
|||||||
def createTimecodeReader(self, device):
|
def createTimecodeReader(self, device):
|
||||||
return DirectTimecodeReader(self, device)
|
return DirectTimecodeReader(self, device)
|
||||||
|
|
||||||
class DirectButtons(ButtonNode, PandaObject):
|
class DirectButtons(ButtonNode, DirectObject):
|
||||||
buttonCount = 0
|
buttonCount = 0
|
||||||
def __init__(self, vrpnClient, device):
|
def __init__(self, vrpnClient, device):
|
||||||
# Keep track of number of buttons created
|
# Keep track of number of buttons created
|
||||||
@ -45,7 +52,7 @@ class DirectButtons(ButtonNode, PandaObject):
|
|||||||
# Create a new button node for the given device
|
# Create a new button node for the given device
|
||||||
ButtonNode.__init__(self, vrpnClient, device)
|
ButtonNode.__init__(self, vrpnClient, device)
|
||||||
# Attach node to data graph
|
# Attach node to data graph
|
||||||
self.nodePath = base.dataRoot.attachNewNode(self)
|
self.nodePath = myBase.dataRoot.attachNewNode(self)
|
||||||
|
|
||||||
def __getitem__(self, index):
|
def __getitem__(self, index):
|
||||||
if (index < 0) or (index > self.getNumButtons()):
|
if (index < 0) or (index > self.getNumButtons()):
|
||||||
@ -56,10 +63,10 @@ class DirectButtons(ButtonNode, PandaObject):
|
|||||||
return self.getNumButtons()
|
return self.getNumButtons()
|
||||||
|
|
||||||
def enable(self):
|
def enable(self):
|
||||||
self.nodePath.reparentTo(base.dataRoot)
|
self.nodePath.reparentTo(myBase.dataRoot)
|
||||||
|
|
||||||
def disable(self):
|
def disable(self):
|
||||||
self.nodePath.reparentTo(base.dataUnused)
|
self.nodePath.reparentTo(myBase.dataUnused)
|
||||||
|
|
||||||
def getName(self):
|
def getName(self):
|
||||||
return self.name
|
return self.name
|
||||||
@ -73,7 +80,7 @@ class DirectButtons(ButtonNode, PandaObject):
|
|||||||
str = str + '%d' % val + ' '
|
str = str + '%d' % val + ' '
|
||||||
return str
|
return str
|
||||||
|
|
||||||
class DirectAnalogs(AnalogNode, PandaObject):
|
class DirectAnalogs(AnalogNode, DirectObject):
|
||||||
analogCount = 0
|
analogCount = 0
|
||||||
def __init__(self, vrpnClient, device):
|
def __init__(self, vrpnClient, device):
|
||||||
# Keep track of number of analogs created
|
# Keep track of number of analogs created
|
||||||
@ -83,7 +90,7 @@ class DirectAnalogs(AnalogNode, PandaObject):
|
|||||||
# Create a new analog node for the given device
|
# Create a new analog node for the given device
|
||||||
AnalogNode.__init__(self, vrpnClient, device)
|
AnalogNode.__init__(self, vrpnClient, device)
|
||||||
# Attach node to data graph
|
# Attach node to data graph
|
||||||
self.nodePath = base.dataRoot.attachNewNode(self)
|
self.nodePath = myBase.dataRoot.attachNewNode(self)
|
||||||
|
|
||||||
def __getitem__(self, index):
|
def __getitem__(self, index):
|
||||||
if (index < 0) or (index > self.getNumControls()):
|
if (index < 0) or (index > self.getNumControls()):
|
||||||
@ -94,10 +101,10 @@ class DirectAnalogs(AnalogNode, PandaObject):
|
|||||||
return self.getNumControls()
|
return self.getNumControls()
|
||||||
|
|
||||||
def enable(self):
|
def enable(self):
|
||||||
self.nodePath.reparentTo(base.dataRoot)
|
self.nodePath.reparentTo(myBase.dataRoot)
|
||||||
|
|
||||||
def disable(self):
|
def disable(self):
|
||||||
self.nodePath.reparentTo(base.dataUnused)
|
self.nodePath.reparentTo(myBase.dataUnused)
|
||||||
|
|
||||||
def normalize(self, val, minVal = -1, maxVal = 1):
|
def normalize(self, val, minVal = -1, maxVal = 1):
|
||||||
# First record sign
|
# First record sign
|
||||||
@ -108,7 +115,8 @@ class DirectAnalogs(AnalogNode, PandaObject):
|
|||||||
# Zero out values in deadband
|
# Zero out values in deadband
|
||||||
val = sign * max(abs(val) - ANALOG_DEADBAND, 0.0)
|
val = sign * max(abs(val) - ANALOG_DEADBAND, 0.0)
|
||||||
# Now clamp value between minVal and maxVal
|
# Now clamp value between minVal and maxVal
|
||||||
val = CLAMP(val, ANALOG_MIN, ANALOG_MAX)
|
val = min( max( val, ANALOG_MIN ), ANALOG_MAX )
|
||||||
|
# val = CLAMP(val, ANALOG_MIN, ANALOG_MAX)
|
||||||
return (((maxVal - minVal) * ((val - ANALOG_MIN) / ANALOG_RANGE))
|
return (((maxVal - minVal) * ((val - ANALOG_MIN) / ANALOG_RANGE))
|
||||||
+ minVal)
|
+ minVal)
|
||||||
|
|
||||||
@ -134,7 +142,7 @@ class DirectAnalogs(AnalogNode, PandaObject):
|
|||||||
str = str + '%.3f' % val + ' '
|
str = str + '%.3f' % val + ' '
|
||||||
return str
|
return str
|
||||||
|
|
||||||
class DirectTracker(TrackerNode, PandaObject):
|
class DirectTracker(TrackerNode, DirectObject):
|
||||||
trackerCount = 0
|
trackerCount = 0
|
||||||
def __init__(self, vrpnClient, device):
|
def __init__(self, vrpnClient, device):
|
||||||
# Keep track of number of trackers created
|
# Keep track of number of trackers created
|
||||||
@ -144,13 +152,13 @@ class DirectTracker(TrackerNode, PandaObject):
|
|||||||
# Create a new tracker node for the given device
|
# Create a new tracker node for the given device
|
||||||
TrackerNode.__init__(self, vrpnClient, device)
|
TrackerNode.__init__(self, vrpnClient, device)
|
||||||
# Attach node to data graph
|
# Attach node to data graph
|
||||||
self.nodePath = base.dataRoot.attachNewNode(self)
|
self.nodePath = myBase.dataRoot.attachNewNode(self)
|
||||||
|
|
||||||
def enable(self):
|
def enable(self):
|
||||||
self.nodePath.reparentTo(base.dataRoot)
|
self.nodePath.reparentTo(myBase.dataRoot)
|
||||||
|
|
||||||
def disable(self):
|
def disable(self):
|
||||||
self.nodePath.reparentTo(base.dataUnused)
|
self.nodePath.reparentTo(myBase.dataUnused)
|
||||||
|
|
||||||
def getName(self):
|
def getName(self):
|
||||||
return self.name
|
return self.name
|
||||||
@ -164,7 +172,7 @@ class DirectTracker(TrackerNode, PandaObject):
|
|||||||
str = str + '%.3f' % val + ' '
|
str = str + '%.3f' % val + ' '
|
||||||
return str
|
return str
|
||||||
|
|
||||||
class DirectDials(DialNode, PandaObject):
|
class DirectDials(DialNode, DirectObject):
|
||||||
dialCount = 0
|
dialCount = 0
|
||||||
def __init__(self, vrpnClient, device):
|
def __init__(self, vrpnClient, device):
|
||||||
# Keep track of number of dials created
|
# Keep track of number of dials created
|
||||||
@ -174,7 +182,7 @@ class DirectDials(DialNode, PandaObject):
|
|||||||
# Create a new dial node for the given device
|
# Create a new dial node for the given device
|
||||||
DialNode.__init__(self, vrpnClient, device)
|
DialNode.__init__(self, vrpnClient, device)
|
||||||
# Attach node to data graph
|
# Attach node to data graph
|
||||||
self.nodePath = base.dataRoot.attachNewNode(self)
|
self.nodePath = myBase.dataRoot.attachNewNode(self)
|
||||||
|
|
||||||
def __getitem__(self, index):
|
def __getitem__(self, index):
|
||||||
if (index < 0) or (index > self.getNumDials()):
|
if (index < 0) or (index > self.getNumDials()):
|
||||||
@ -185,10 +193,10 @@ class DirectDials(DialNode, PandaObject):
|
|||||||
return self.getNumDials()
|
return self.getNumDials()
|
||||||
|
|
||||||
def enable(self):
|
def enable(self):
|
||||||
self.nodePath.reparentTo(base.dataRoot)
|
self.nodePath.reparentTo(myBase.dataRoot)
|
||||||
|
|
||||||
def disable(self):
|
def disable(self):
|
||||||
self.nodePath.reparentTo(base.dataUnused)
|
self.nodePath.reparentTo(myBase.dataUnused)
|
||||||
|
|
||||||
def getName(self):
|
def getName(self):
|
||||||
return self.name
|
return self.name
|
||||||
@ -202,7 +210,7 @@ class DirectDials(DialNode, PandaObject):
|
|||||||
str = str + '%.3f' % val + ' '
|
str = str + '%.3f' % val + ' '
|
||||||
return str
|
return str
|
||||||
|
|
||||||
class DirectTimecodeReader(AnalogNode, PandaObject):
|
class DirectTimecodeReader(AnalogNode, DirectObject):
|
||||||
timecodeReaderCount = 0
|
timecodeReaderCount = 0
|
||||||
def __init__(self, vrpnClient, device):
|
def __init__(self, vrpnClient, device):
|
||||||
# Keep track of number of timecodeReader created
|
# Keep track of number of timecodeReader created
|
||||||
@ -218,13 +226,13 @@ class DirectTimecodeReader(AnalogNode, PandaObject):
|
|||||||
# Create a new dial node for the given device
|
# Create a new dial node for the given device
|
||||||
AnalogNode.__init__(self, vrpnClient, device)
|
AnalogNode.__init__(self, vrpnClient, device)
|
||||||
# Attach node to data graph
|
# Attach node to data graph
|
||||||
self.nodePath = base.dataRoot.attachNewNode(self)
|
self.nodePath = myBase.dataRoot.attachNewNode(self)
|
||||||
|
|
||||||
def enable(self):
|
def enable(self):
|
||||||
self.nodePath.reparentTo(base.dataRoot)
|
self.nodePath.reparentTo(myBase.dataRoot)
|
||||||
|
|
||||||
def disable(self):
|
def disable(self):
|
||||||
self.nodePath.reparentTo(base.dataUnused)
|
self.nodePath.reparentTo(myBase.dataUnused)
|
||||||
|
|
||||||
def getName(self):
|
def getName(self):
|
||||||
return self.name
|
return self.name
|
||||||
@ -253,3 +261,18 @@ class DirectTimecodeReader(AnalogNode, PandaObject):
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
str = ('%s: %d:%d:%d:%d' % ((self.name,) + self.getTime()[:-1]))
|
str = ('%s: %d:%d:%d:%d' % ((self.name,) + self.getTime()[:-1]))
|
||||||
return str
|
return str
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class DirectJoybox(PandaObject):
|
|||||||
self.analogs = direct.deviceManager.createAnalogs(self.device)
|
self.analogs = direct.deviceManager.createAnalogs(self.device)
|
||||||
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,0,0,0,0]
|
||||||
# For joybox fly mode
|
# For joybox fly mode
|
||||||
# Default is joe mode
|
# Default is joe mode
|
||||||
self.mapping = [R_LEFT_RIGHT, R_FWD_BACK, L_FWD_BACK,
|
self.mapping = [R_LEFT_RIGHT, R_FWD_BACK, L_FWD_BACK,
|
||||||
|
@ -960,3 +960,9 @@ __builtin__.direct = base.direct = DirectSession()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +13,12 @@ shift
|
|||||||
firstarg="$1"
|
firstarg="$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$firstarg" = "-v" ]; then
|
||||||
|
extra_genPyCode_libs="libvrpn"
|
||||||
|
shift
|
||||||
|
firstarg="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
shift
|
shift
|
||||||
extra_genPyCode_libs="$extra_genPyCode_libs $*"
|
extra_genPyCode_libs="$extra_genPyCode_libs $*"
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@ class DirectFrame(DirectGuiWidget):
|
|||||||
if text == None:
|
if text == None:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
from OnscreenText import OnscreenText
|
||||||
self.createcomponent(
|
self.createcomponent(
|
||||||
component, (), 'text',
|
component, (), 'text',
|
||||||
OnscreenText,
|
OnscreenText,
|
||||||
|
@ -39,7 +39,7 @@ class SoundInterval(Interval):
|
|||||||
#duration += 1.5
|
#duration += 1.5
|
||||||
# DCR - hack for Miles bug - adding 1.5 seconds caused
|
# DCR - hack for Miles bug - adding 1.5 seconds caused
|
||||||
# problems for MG_neg_buzzer.wav
|
# problems for MG_neg_buzzer.wav
|
||||||
duration += min(duration * 0.4, 1.5)
|
duration += min(duration * 2.4, 1.5)
|
||||||
else:
|
else:
|
||||||
# This will screw up any intervals that base their
|
# This will screw up any intervals that base their
|
||||||
# time on the duration of this sound interval
|
# time on the duration of this sound interval
|
||||||
@ -86,3 +86,4 @@ class SoundInterval(Interval):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user