Esempio n. 1
0
 def disconnect(self):
     if (self.__connection != None):
         __tello = None
         __commanding = False
         __connection = None
         notify = DirectNotify().newCategory("")
         notify.warning("Disonnected!")
     else:
         notify = DirectNotify().newCategory("")
         notify.warning("You are not connected to a drone yet")
         exit()
Esempio n. 2
0
 def connect(self):
     if (self.__connection == None):
         notify = DirectNotify().newCategory("")
         notify.warning("(Connection placeholder)")
         self.__connection = "placeholder"
         notify = DirectNotify().newCategory("")
         notify.warning("Connected!")
         #Note: Connecting to the drone will be considered successful for tests
     else:
         notify = DirectNotify().newCategory("")
         notify.warning("Oops, something went wrong connecting the socket")
         exit()
Esempio n. 3
0
    def __init__(self, parent, newGame, device, devices):
        self._parent = parent
        self._notify = DirectNotify().newCategory("Menu")
        self._notify.info("New Menu-Object created: %s" %(self))
        self.device = device #The keybord
        self.devices = devices #For Wii
        
        time.sleep(1)               #Bad Hack to make sure that the Key isn't pressed.
        self.device.boost = False   #Bad Hack to make sure that the Key isn't .setColor(self.colorA)pressed.
        
        self.newGame = newGame
        self.track = []

        #Wiimotes
        self.wiimoteX = []
                
        #Font
        self.font = DynamicTextFont(FONT)
        self.font.setRenderMode(TextFont.RMSolid)
        
        self.CONF_PATH = "user/config.ini"
        self._conf = settings.Settings()
        self._conf.loadSettings(self.CONF_PATH)
        
        taskMgr.add(self.input, 'input')
Esempio n. 4
0
    def __init__(self, *args, **kwds):
        '''
        '''
        self.points = []
        self.name = "street part"
        self.author = "Rage Tracks Team"
        self.mirrored = True

        self.texcoords = []

        for arg in args:
            if type(arg) == Vec2:
                self.points.append(arg)

        if "name" in list(kwds.keys()):
            self.name = str(kwds["name"])

        if "author" in list(kwds.keys()):
            self.author = str(kwds["author"])

        if "mirrored" in list(kwds.keys()):
            self.mirrored = bool(kwds["mirrored"])

        # if the points should be mirrored, we'll do it
        if self.mirrored:
            self.mirrorPoints()
        self._notify = DirectNotify().newCategory("TrackGen3D")
        self._notify.info("New StreetData-Object created: %s" % (self))
    def __init__(self, camera, parent):
        """Arguments:
        camera -- Camera to be used
        parent -- Aeroplane which the camera should follow
        """

        self.notifier = DirectNotify().newCategory("azure-camera")
        self.camera = camera
        self.parent = parent
        # This gets replaced by a NodePath with all available cameras as
        # children and plane node as parent in createCamNodes()
        self.cameras = None

        #if parent.__class__.__name__ is not "Aeroplane":
        if not isinstance(self.parent, Aeroplane):
            raise ParamError, "Parent must be an Aeroplane instance, " + \
                              "but is %s" % type(self.parent)

        FSM.__init__(self, "PlaneCamera: %s" % self.parent.name)
        DirectObject.__init__(self)

        self.cameras = self.parent.node.find("cameras")
        if self.cameras.isEmpty():
            self.createCamNodes()
        self.updateCamArray()

        self.sideview_direction = 0

        # Set up the default camera
        self.setView("ThirdPerson")
class DistributedMinigameStation(DistributedGroupStation,
                                 MinigameStation.MinigameStation,
                                 DistributedObject):
    notify = DirectNotify().newCategory("DistributedMinigameStation")

    def __init__(self, cr):
        try:
            self.DistributedMinigameStation_initialized
            return
        except:
            self.DistributedMinigameStation_initialized = 1
        MinigameStation.MinigameStation.__init__(self)
        DistributedObject.__init__(self, cr)
        return

    def setStation(self, game):
        self.generateStation(game)

    def headOff(self, zone, laffMeter):
        if self.camIval:
            self.camIval.finish()
            self.camIval = None
        self.deleteStationAbortGui()
        requestStatus = {
            'zoneId': zone,
            'hoodId': self.cr.playGame.hood.hoodId,
            'where': 'minigame',
            'avId': base.localAvatar.doId,
            'loader': 'minigame',
            'shardId': None,
            'wantLaffMeter': laffMeter
        }
        self.cr.playGame.getPlace().fsm.request('teleportOut', [requestStatus])
        Sequence(Wait(3.0), Func(self.d_leaving)).start()
Esempio n. 7
0
 def __init__(self):
     #create a new notify category
     self._notify = DirectNotify().newCategory("CamMovement")
     self._notify.info("Put some informational text here.")
     self._notify.debug("Put some informational text here.")
     self._notify.warning("Put some informational text here.")
     self._notify.error(
         "Put some informational text here.")  #raise an exeption
Esempio n. 8
0
def setup(name='Server Name'):
    log = DirectNotify().newCategory("Allegiance-Server-" + name)
    log.debug("Loading space drive")
    spacedrive.init(run_server=True,
                    run_client=False,
                    log_level='debug',
                    window_title='Allegiance 2')
    log.info("Setting up server network")
    spacedrive.init_server_net(NetworkSystem, port=47624)
Esempio n. 9
0
 def down(self, distance):
     self.__commandCheck()
     if (distance > 500 or distance < 20):
         #print("Error Line ",self.__get_linenumber,": Please enter amount between 1 and 3600 ")
         notify = DirectNotify().newCategory("")
         notify.warning(
             "Error: For 'down' please enter amount between 20 and 500 ")
         exit()
     distance = distance / 10
     newz = self.__z - distance
     if (newz < 10):
         notify = DirectNotify().newCategory("")
         notify.warning("Error: You cannot go lower than takeoff distance ")
         exit()
     seq = self.droneActor.posInterval(distance / 5,
                                       Point3(self.__x, self.__y, newz))
     self.__z = newz
     self.__overallSequence.append(seq)
Esempio n. 10
0
 def land(self):
     if (self.__z == 0):
         notify = DirectNotify().newCategory("")
         notify.warning("The drone has already landed")
         exit()
     self.__commandCheck()
     seq = self.droneActor.posInterval(self.__z / 5,
                                       Point3(self.__x, self.__y, 0))
     self.__z = 0
     self.__overallSequence.append(seq)
Esempio n. 11
0
 def takeoff(self):
     if (self.__z != 0):
         notify = DirectNotify().newCategory("")
         notify.warning("The drone has already taken off")
         exit()
     self.__commandCheck()
     seq = self.droneActor.posInterval(
         2, Point3(self.__x, self.__y, self.__z + 10))
     self.__z = self.__z + 10
     self.__overallSequence.append(seq)
Esempio n. 12
0
    def __init__(self):
        '''
        '''
        self._notify = DirectNotify().newCategory("Input")
        self._notify.info("New Keyboard-Object created: %s" % (self))
        base.buttonThrowers[0].node().setButtonUpEvent("button-up")
        base.buttonThrowers[0].node().setButtonDownEvent("button")
        base.accept("button-up", self.setKey, [False])
        base.accept("button", self.setKey, [True])

        self.keys = {}
Esempio n. 13
0
    def __init__(self, gui=None, out_file=None):
        self.notify = DirectNotify().newCategory('a4p')
        self.gui = gui
        self.out_file = None
        if out_file:
            self.out_file = open(path + out_file, 'a')
            self.out_file.write('---<Opening file on: ' + str(datetime.now()) +
                                ' >---\n')

        self.debug('Logger is now logging')
        self.debug('Logger gui is ' + str(gui))
        self.debug('Logger out_file is ' + str(out_file))
Esempio n. 14
0
    def __init__(self):
        '''
        this class is able to load and save the application's settings
        '''
        self._notify = DirectNotify().newCategory("Settings")
        self._notify.info("New Settings-Object created: %s" % (self))
        self.width = 800
        self.height = 600
        self.antialias = False

        self.fullscreen = False
        self._input_settings = {"keyboard": {}, "joysticks": {}}
Esempio n. 15
0
 def cw(self, amount):
     self.__commandCheck()
     if (amount > 3600 or amount < 1):
         #print("Error Line ",self.__get_linenumber,": Please enter amount between 1 and 3600 ")
         notify = DirectNotify().newCategory("MyCategory")
         notify.warning(
             "Error: For 'cw' please enter amount between 1 and 3600 ")
         exit()
     seq = self.droneActor.hprInterval(amount / 45, Vec3(amount, 0, 0))
     self.__heading = self.__heading + amount
     while (self.__heading > 360):
         self.__heading = self.__heading - 360
     self.__overallSequence.append(seq)
Esempio n. 16
0
 def __init__(self, camera):
     '''
     '''
     self._notify = DirectNotify().newCategory("PlayerCam")
     self._notify.info("New PlayerCam-Object created: %s" % (self))
     self._position = Vec3(0, -20, 5)
     self._camera = camera
     self._vehicle_direction = Vec3(0, 0,
                                    0)  # the direction the object is moving
     self._nodepath = None
     self._distance = 0.7
     self._cam_node = NodePath()
     self._vehicle = None
Esempio n. 17
0
    def __init__(self):
        ShowBase.__init__(self)

        # Load the environment model.
        self.scene = self.loader.loadModel("models/environment")
        # Reparent the model to render.
        self.scene.reparentTo(self.render)
        # Apply scale and position transforms on the model.
        self.scene.setScale(0.25, 0.25, 0.25)
        self.scene.setPos(-8, 42, 0)

        self.accept('a', self.printRepeat)

        self.py3notify = DirectNotify().newCategory("Python3_main")
Esempio n. 18
0
    def __init__(self, res, x, y, z=200, player_count=1, street_data=""):
        '''
        '''
        self._notify = DirectNotify().newCategory("TrackGen3D")
        self._notify.info("New Track3D-Object created: %s" % (self))
        # street_data = (Vec2(4.0,4.0), Vec2(10.0,10.0), Vec2(10.0,0.0), Vec2(4.0,0.0), Vec2(0.0,-1.0))
        # street_data = StreetData(Vec2(15.0,1.0), Vec2(15.0,-5.0), Vec2(0.0,-5.0), mirrored=True) #, Vec2(15.0,0.0)
        self.street_data = StreetData()

        # self.street_data.readFile("data/road/road01.xml")
        # self.street_data.readFile("data/road/tube.xml")
        if street_data == "":
            datas = ["road01", "tube"]
            street_data = datas[random.randint(0, len(datas) - 1)]
        self.street_data.readFile("data/road/" + street_data + ".xml")

        self.streetTextrange = 0.0
        self.track = Track(x, y, z)
        self.track.generateTestTrack(player_count)
        # self.track.generateTrack(player_count)

        self.track_points = self.track.getInterpolatedPoints(res)
        self.varthickness = []  # Generate the Vector for thickness of the road

        self.generateNormals()
        # for i in range(len(self.track_points)-1):
        # if i == 0:
        # self.varthickness.append(self.calcTheVector(self.track_points[i],self.track_points[i],self.track_points[i+1])) #First
        # continue
        # self.varthickness.append(self.calcTheVector(self.track_points[i-1],self.track_points[i],self.track_points[i+1]))
        # self.varthickness.append(self.calcTheVector(self.track_points[len(self.track_points)-2],self.track_points[len(self.track_points)-1],self.track_points[len(self.track_points)-1])) #Last
        ##
        # Normalizing the Vector
        # for i in self.varthickness:
        # i.normalize()
        ##
        # print self.varthickness[-1]
        # print self.varthickness[0]
        # print self.varthickness[1]
        # print self.varthickness[2]

        # Spin the last 100 Points a litte bit to Vec3(-1,0,0)
        for i in range(-100, 1):
            # print self.varthickness[i] * (-i / 100), self.varthickness[i] , ((i* -1) / 100.0), i
            # print ((i* -1) / 100.0), self.varthickness[i], self.varthickness[i] * ((i* -1) / 100.0)
            self.varthickness[i] = self.varthickness[i] * (((i + 1) * -1) / 100.0) + Vec3(-1, 0, 0)
            self.normals[i] = self.normals[i] * (((i + 1) * -1) / 100.0) + Vec3(0, 0, 1)

            self.varthickness[i].normalize()
            self.normals[i].normalize()
Esempio n. 19
0
    def __init__(self, cam_count=0):
        '''
        @param cam_count: (int) number of cameras which should be added
        '''
        self._notify = DirectNotify().newCategory("SplitScreen")
        self._notify.info("New SplitScreen-Object created: %s" % (self))
        self.regions = []  # the regions the screen is separated into
        self.cameras = []  # the cameras (empty ones are None)
        self.filters = []  # the shader filters applied to each camera
        self.cameraPosPre = []  # the position of the cameras before change
        self.steps = 1
        self.shaders_on = False

        if cam_count > 0:  # add cameras, if needed
            self.addCameras(cam_count)
Esempio n. 20
0
    def __init__(self, *args, **kwds):
        '''
        '''
        self.points = []
        self.name = "special street part"
        self._notify = DirectNotify().newCategory("TrackGen")

        for arg in args:
            if type(arg) == Vec2:
                self.points.append(arg)

        if "filename" in list(kwds.keys()):
            self.readFile(str(kwds["filename"]))

        if "name" in list(kwds.keys()):
            self.name = str(kwds["name"])
Esempio n. 21
0
def setup():
    log = DirectNotify().newCategory("Allegiance-Client")
    log.debug("Loading space drive")
    spacedrive.init(run_server=False,
                    run_client=True,
                    log_level='debug',
                    window_title='Allegiance 2')
    log.info('Setting up graphics')
    #spacedrive.init_graphics(debug_mouse=False)
    log.info("Setting up client gui")
    spacedrive.init_gui()
    spacedrive.base.wireframe = False
    spacedrive.base.accept("f3", toggleSceneWireframe)
    spacedrive.gui_system.setup_screen(MainMenu())
    log.info("Setting up client network")
    spacedrive.init_server_net(NetworkSystem)
Esempio n. 22
0
    def __init__(self, size_x, size_y, max_height=2300):
        '''
        the constructor creates an empty track
        @param size_x: (int) maximum x-coordinates
        @param size_y: (int) maximum y-coordinates
        @param max_height: (int) maximum z-coordinates
        '''
        # self.setSize(size_x, size_y, max_height)
        # self.setSize(8000, 8000, 1000)
        self.setSize(1600, 1600, 800)
        self.points = []
        self.curve = None
        self._notify = DirectNotify().newCategory("TrackGen")
        self._notify.info("New Track-Object created: %s" % (self))

        self.prefabs = glob.glob("data/road/parts/*.xml")
Esempio n. 23
0
 def __init__(self, number, ode_world, ode_space, device=None, camera=None):
     '''
     '''
     self._notify = DirectNotify().newCategory("Player")
     self._notify.info("New Player-Object created: %s" % (self))
     self._ode_world = ode_world
     self._ode_space = ode_space
     self._number = number
     self._camera = camera
     self._vehicle = vehicle.Vehicle(self._ode_world, self._ode_space)  # the properties of the vehicle
     self._device = device  # The input device
     # self._osd_health = OnscreenText(text = "100", pos = ((self._number*0.2)-1,0.9))
     self._position = 0
     self._pre_position = 0
     self._rank = 0
     self._lap = 1
     self._time = 0
Esempio n. 24
0
 def __init__(self, parent):
     
     self._notify = DirectNotify().newCategory("Menu")
     self._notify.info("New Menu-Object created: %s" %(self))
     
     #Font
     self.font = DynamicTextFont(FONT)
     self.font.setRenderMode(TextFont.RMSolid)
     
     self.KEY_DELAY = 0.15
     self.player_buttonpressed = []
     
     self._parent = parent
     self._players = parent.players
     self._devices = parent.devices
     
     taskMgr.add(self.fetchAnyKey, "fetchAnyKey")
Esempio n. 25
0
 def forward(self, distance):
     self.__commandCheck()
     if (distance > 500 or distance < 20):
         #print("Error Line ",self.__get_linenumber,": Please enter amount between 1 and 3600 ")
         notify = DirectNotify().newCategory("")
         notify.warning(
             "Error: For 'forwards' please enter amount between 20 and 500 "
         )
         exit()
     distance = distance / 10
     newx = (distance * math.cos(self.__heading)) + self.__x
     newy = (distance * math.sin(self.__heading)) + self.__y
     seq = self.droneActor.posInterval(distance / 5,
                                       Point3(newx, newy, self.__z))
     self.__x = newx
     self.__y = newy
     self.__overallSequence.append(seq)
Esempio n. 26
0
    def __init__(self, ode_world, ode_space, name="standard"):
        '''
        '''
        self._notify = DirectNotify().newCategory("Vehicle")
        self._notify.info("New Vehicle-Object created: %s" % (self))
        self._ode_world = ode_world
        self._ode_space = ode_space
        self._model = None
        self._physics_model = None
        self._physics_mass = None
        self._collision_model = None
        self._speed = 0.0  # the actual speed of the vehicle (forward direction)
        self._direction = Vec3(0, 0, 0)  # the direction the car is heading
        self._boost_direction = Vec3(0, 0, 0)
        self._boost_strength = 10.0  # the boost propertys of the vehicle
        self._control_strength = 1.5  # impact on the steering behaviour
        self._grip_strength = 0.5  # impact on the steering behaviour
        self._track_grip = 0.8  # impact on the steering behaviour
        self._energy = 100.0
        self._armor = 100.0
        self._max_energy = 100.0
        self._max_armor = 100.0
        self._weight = 10.0
        self._description = "The best vehicle ever"
        self._name = "The flying egg"
        self._brake_strength = 10.0
        self._hit_ground = True
        self._model_loading = False
        self._blowout = []
        self._blowout_on = False
        self._streetnormal = Vec3(0, 0, 1)

        # set up the propertys of the vehicle that schould be loaded
        # the methods get called because the data is immutable and
        # wouldnt get updated when calling the objects directly
        # the last entry is the function to convert the string
        self._tags = [["name", self.setName, str],
                      ["description", self.setDescription, str],
                      ["control_strength", self.setControlStrength, float],
                      ["grip_strength", self.setGripStrength, float],
                      ["track_grip", self.setTrackGrip, float],
                      ["max_energy", self.setMaxEnergy, float],
                      ["max_armor", self.setMaxArmor, float],
                      ["weight", self.setWeight, float],
                      ["brake_strength", self.setBrakeStrength, float],
                      ["boost_strength", self.setBoostStrength, float]]
Esempio n. 27
0
class CEFClientHandler(object):
    """
    A custom client handler for CEFPython that processes callbacks from the browser to Panda
    """
    notify = DirectNotify().newCategory('PandaChromiumManager')

    def __init__(self, browser, texture):
        self._browser = browser
        self._texture = texture

    @property
    def browser(self):
        return self._browser

    @property
    def texture(self):
        return self._texture

    def OnPaint(self, browser, element_type, dirty_rects, paint_buffer, width,
                height):
        img = self.texture.modify_ram_image()
        if element_type == cefpython.PET_VIEW:
            img.set_data(
                paint_buffer.GetString(mode="rgba", origin="bottom-left"))
        else:
            raise CEFClientException("Unknown elemenet_type: %s" %
                                     element_type)

    def GetViewRect(self, browser, rect_out):
        width = self.texture.getXSize()
        height = self.texture.getYSize()
        rect_out.extend([0, 0, width, height])
        return True

    def GetScreenPoint(self, browser, viewX, viewY, screenCoordinates):
        return False

    def OnLoadEnd(self, browser, frame, http_code):
        return

    def OnLoadError(self, browser, frame, error_code, error_text_out,
                    failed_url):
        raise CEFClientException(
            'Failed to load; %s %s %s %s %s' %
            (browser, frame, error_code, error_text_out, failed_url))
Esempio n. 28
0
	def __init__(self):
		ShowBase.__init__(self)

		self.useAdvancedVisualEffects =\
			ConfigVariableBool("use-advanced-visual-effects", True) and\
			base.win.getGsg().getSupportsBasicShaders() and\
			base.win.getGsg().getSupportsGlsl() and\
			base.win.getGsg().getSupportsDepthTexture()

		self.debug = DirectNotify().newCategory("Debug")

		self.phoneState = PhoneState(self)
		self.setupFilters()
		self.setupModels()
		self.setupKeyboardControl()
		self.camera.setPos(0, 0, 2)
		self.setupMouseControl()
		self.phoneState.request("Hidden")
Esempio n. 29
0
    def __init__(self, device, settings):
        '''
        '''
        self._notify = DirectNotify().newCategory("Input")
        self._notify.info("New Input-Object created: %s" % (self))
        self.device = device
        self.directions = [0, 0]  # x and y movement
        self.boost = False  # Button for boosting
        self.use_item = False  # Button for using items
        self.escape = False

        # if this is a Joystick, look if there are Settings for Joysticks with this name
        if type(self.device) == joystickdevice.JoystickDevice:
            if self.device.getName() in settings["joysticks"]:
                self.settings = settings["joysticks"][self.device.getName()]
            else:
                self.settings = {}
                self._setStandardSettings()

        # Keyboard settings are always available
        elif type(self.device) == keyboarddevice.KeyboardDevice:
            #self.settings = settings["keyboard"]
            self.settings = {}
            self.settings["boost"] = "space"
            self.settings["use_item"] = "lalt"
            self.settings["up"] = "arrow_up"
            self.settings["down"] = "arrow_down"
            self.settings["left"] = "arrow_left"
            self.settings["right"] = "arrow_right"
            self.settings["escape"] = "escape"

            self.device.keys[self.settings["up"]] = False
            self.device.keys[self.settings["down"]] = False
            self.device.keys[self.settings["left"]] = False
            self.device.keys[self.settings["right"]] = False
            self.device.keys[self.settings["boost"]] = False
            self.device.keys[self.settings["use_item"]] = False
            self.device.keys[self.settings["escape"]] = False

        elif type(self.device) == wiidevice.WiiDevice:
            pass  #Think isn't necessary by Wiimotes
Esempio n. 30
0
class ChromiumNode(NodePath):
    """
    Custom Panda3D Node that contains a card for displaying a browser
    """
    notify = DirectNotify().newCategory('ChromiumNode')

    def __init__(self, name=None, navigation_url=None, browser_settings=None):

        if name is None:
            name = self.__class__.__name__
        NodePath.__init__(self, name)

        self._chrome_texture = ChromiumTexture(
            '%s-ChromiumBrowserTexture' % name,
            navigation_url=navigation_url,
            browser_settings=browser_settings)

        card_maker = CardMaker('chromebrowser2d')
        card_maker.set_frame(-0.75, 0.75, -0.75, 0.75)
        self._card = self.attach_new_node(card_maker.generate())
        self._card.set_texture(self._chrome_texture)

    @property
    def chrome_texture(self):
        return self._chrome_texture

    @property
    def card(self):
        return self._card

    @classmethod
    def load_from_file(cls, path, name=None, browser_settings=None):
        """
        Loads a HTML file into the texture used by the ChromiumNode
        """
        uri = create_uri_from_file(path)
        return cls(name=name,
                   navigation_url=uri,
                   browser_settings=browser_settings)