Example #1
0
 def __init__(self,
              device='CerealBox',
              nodePath=base.direct.camera,
              headingNP=base.direct.camera):
     # See if device manager has been initialized
     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 = 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
     # Default is joe mode
     self.mapping = [
         R_LEFT_RIGHT, R_FWD_BACK, L_FWD_BACK, R_TWIST, L_TWIST, NULL_AXIS
     ]
     self.modifier = [1, 1, 1, -1, -1, 0]
     # Initialize time
     self.lastTime = globalClock.getFrameTime()
     # Record node path
     self.nodePath = nodePath
     self.headingNP = headingNP
     self.useHeadingNP = False
     self.rotateInPlace = False
     self.floatingNP = NodePath("floating")
     # Ref CS for orbit mode
     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=base.direct.font,
                                              mayChange=1)
     # List of functions to cycle through
     self.modeList = [self.joeMode, self.driveMode, self.orbitMode]
     # Pick initial mode
     self.updateFunc = self.joyboxFly
     self.modeName = 'Joe Mode'
     # Auxiliary data
     self.auxData = []
     # Button registry
     self.addButtonEvents()
     # Spawn update task
     self.enable()
    def __init__(self, device='Tracker0', nodePath=base.direct.camera):
        # See if device manager has been initialized
        if base.direct.deviceManager == None:
            base.direct.deviceManager = DirectDeviceManager()

        # Set name
        self.name = 'Fastrak-' + ` DirectFastrak.fastrakCount `
        self.deviceNo = DirectFastrak.fastrakCount
        DirectFastrak.fastrakCount += 1

        # Get analogs
        self.device = device
        self.tracker = None
        self.trackerPos = None

        # Spawn update task
        self.updateFunc = self.fastrakUpdate
        self.enable()
 def __init__(self, device='Analog0', nodePath=base.direct.camera):
     # See if device manager has been initialized
     if base.direct.deviceManager == None:
         base.direct.deviceManager = DirectDeviceManager()
     # Set name
     self.name = 'Radamec-' + repr(DirectRadamec.radamecCount)
     DirectRadamec.radamecCount += 1
     # Get analogs
     self.device = 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
     # Note:  These values change quite often, i.e. everytime
     #        you unplug the radamec cords, or jostle them too
     #        much.  For best results, re-record these values often.
     self.minRange = [-180.0, -90, 522517.0, 494762.0]
     self.maxRange = [180.0, 90, 547074.0, 533984.0]
     # Spawn update task
     self.enable()