def readerPollUntilEmpty(self, task):
        while self.readerPollOnce():
            pass

        if not metadata.IS_PRODUCTION:
            if ConfigVariableBool('simulated-latency', False).getValue():
                latency = random.uniform(
                    ConfigVariableDouble('simulated-latency-min',
                                         0.125).getValue(),
                    ConfigVariableDouble('simulated-latency-max',
                                         0.15).getValue())
                task.delayTime = latency
                return task.again

        return task.cont
예제 #2
0
class beastGlobals(DirectObject):
	def __init__(self, base):
		DirectObject.__init__(self)
		self.base = base

        '''
            Setup point2d NodePath
        '''
		self.point2d = NodePath(PGTop('point2d'))
		self.point2d.node().setMouseWatcher(self.base.mouseWatcherNode)
		self.point2d.setDepthTest(False)
		self.point2d.setDepthWrite(False)
		self.point2d.setMaterialOff(True)
		self.point2d.setTwoSided(True)

		self.p2dTopLeft = self.point2d.attachNewNode('p2dTopLeft')
		self.p2dTopRight = self.point2d.attachNewNode('p2dTopRight')
		self.p2dTopCenter = self.point2d.attachNewNode('p2dTopCenter')

		self.p2dCenterLeft = self.point2d.attachNewNode('p2dCenterLeft')
		self.p2dCenterRight = self.point2d.attachNewNode('p2dCenterRight')

		self.p2dBottomLeft = self.point2d.attachNewNode('p2dBottomLeft')
		self.p2dBottomRight = self.point2d.attachNewNode('p2dBottomRight')
		self.p2dBottomCenter = self.point2d.attachNewNode('p2dBottomCenter')

		self.beastPointSize = ConfigVariableDouble('beast-point-size', 1.0).getValue()
		self.beastPointSizeAuto = ConfigVariableBool('beast-point-size-auto', False).getValue()
		self.beastRenderCache = ConfigVariableBool('beast-render-cache', True).getValue()
		self.beastRenderDebug = ConfigVariableBool('beast-render-debug', False).getValue()

		self.setPointSize(self.beastPointSize, update = False)
		self.setPointSizeAuto(self.beastPointSizeAuto, update = False)
		self.accept('window-event', self.windowEvent)
		self.originalResolution = (float(self.base.win.getXSize()), float(self.base.win.getYSize()))
예제 #3
0
    def __init__(self, taskMgr, base):
        DirectObject.__init__(self)
        self.taskMgr = taskMgr
        self.base = base
        self.setupPoint2d()

        self.beastPointSize = ConfigVariableDouble('beast-point-size',
                                                   1.0).getValue()
        self.beastPointSizeAuto = ConfigVariableBool('beast-point-size-auto',
                                                     False).getValue()
        self.beastRenderBruteForce = ConfigVariableBool(
            'beast-render-brute-force', False).getValue()
        self.beastRenderDebug = ConfigVariableBool('beast-render-debug',
                                                   False).getValue()

        self.setPointSize(self.beastPointSize, update=False)
        self.setPointSizeAuto(self.beastPointSizeAuto, update=False)
        self.accept('window-event', self.windowEvent)
        self.originalResolution = (float(self.base.win.getXSize()),
                                   float(self.base.win.getYSize()))

        self.buffer = None
        #- If bruteForce == False then we will setup beast frame rendering system
        if self.beastRenderBruteForce == False:
            self._setupTextureBuffer()
            taskMgr.add(self.renderTask, 'beastRender', sort=-100000000)

        self.windowEvent()
예제 #4
0
    def __init__(self, world):
        self.world = world
        self.root = self.world.root.attach_new_node("player")
        self.root_target = self.world.root.attach_new_node("player_target")
        self.pivot = self.root.attach_new_node("player_pivot")
        base.camera.reparent_to(self.pivot)
        base.camera.set_z(1.7)
        base.cam.node().get_lens().set_fov(90)
        self.traverser = CollisionTraverser()
        self.ray = setup_ray(
            self.pivot,
            self.traverser,
            self.world.mask,
            # ray ends well below feet to register downward slopes
            (0, 0, 1),
            (0, 0, -1))
        self.xyh_inertia = Vec3(0, 0, 0)
        h_acc = ConfigVariableDouble('mouse-accelleration', 0.1).get_value()
        self.xyh_acceleration = Vec3(0.8, 0.8, h_acc)
        self.friction = 0.15
        self.torque = 0.5
        self.last_up = Vec3(0, 0, 1)

        # Collider for portals
        csphere = CollisionSphere(0, 0, 1.25, 1.5)
        cnode = CollisionNode('player')
        cnode.add_solid(csphere)
        cnode.set_from_collide_mask(0x2)
        cnode.set_into_collide_mask(CollideMask.all_off())
        self.collider = self.root.attach_new_node(cnode)
        self.event_handler = CollisionHandlerEvent()
        self.event_handler.add_in_pattern('into-%in')
        self.traverser.add_collider(self.collider, self.event_handler)
        self.collider.show()
        self.teleported = False

        base.input.set_mouse_relativity(True)
예제 #5
0
#from otp.ai.AIBaseGlobal import *
from direct.directnotify import DirectNotifyGlobal
from direct.showbase.DirectObject import DirectObject
from .ConnectionRepository import *
from panda3d.core import ConfigVariableDouble, ConfigVariableInt, ConfigVariableBool

ASYNC_REQUEST_DEFAULT_TIMEOUT_IN_SECONDS = 8.0
ASYNC_REQUEST_INFINITE_RETRIES = -1
ASYNC_REQUEST_DEFAULT_NUM_RETRIES = 0

if __debug__:
    _overrideTimeoutTimeForAllAsyncRequests = ConfigVariableDouble(
        "async-request-timeout", -1.0)
    _overrideNumRetriesForAllAsyncRequests = ConfigVariableInt(
        "async-request-num-retries", -1)
    _breakOnTimeout = ConfigVariableBool("async-request-break-on-timeout",
                                         False)


class AsyncRequest(DirectObject):
    """
    This class is used to make asynchronos reads and creates to a database.

    You can create a list of self.neededObjects and then ask for each to be
    read or created, or if you only have one object that you need you can
    skip the self.neededObjects because calling askForObject or createObject
    will set the self.neededObjects value for you.

    Once all the objects have been read or created, the self.finish() method
    will be called.  You may override this function to run your code in a
    derived class.
예제 #6
0
fgd_files = ConfigVariableList(
    "fgd-file", "List of FGD files that are to be loaded by the level editor")

default_material = ConfigVariableString(
    "default-material",
    #"materials/dev/dev_measuregeneric01.mat",
    "maps/smiley.txo",
    "The default material to use for solids")

default_point_entity = ConfigVariableString("default-point-entity",
                                            "prop_static",
                                            "The default point entity")

default_solid_entity = ConfigVariableString(
    "default-solid-entity", "func_wall",
    "The default solid/brush entity. Brushes that get tied to entities are this "
    "entity by default.")

default_texture_scale = ConfigVariableDouble(
    "default-texture-scale", 1.0, "The default texture scale for solid faces.")

default_lightmap_scale = ConfigVariableInt(
    "default-lightmap-scale", 16,
    "The default lightmap scale for solid faces. Lower value = more detailed")

default_prop_model = ConfigVariableString(
    "default-prop-model", "models/misc/smiley.bam",
    "The default model used when placing a prop_static or prop_dynamic entity."
)
예제 #7
0
from vehicle import TARGET_FLIGHT_HEIGHT
from vehicle import CLIMB_SPEED
from vehicle import HEIGHT_OVER_TARGET
from vehicle import HEIGHT_OVER_TARGET_PROJECTED
from vehicle import REPULSOR_POWER_FRACTION_NEEDED
from vehicle import GYRO_ROTATION
from vehicle import THRUSTER_HEATING
from vehicle import THRUSTER_COOLING

from keybindings import GE_CAMERA_MODE

from controller import DM_STUNT
from controller import DM_CRUISE

COCKPIT_CAMERA = 'fz_cockpit_camera'
first_person_fov = ConfigVariableDouble('first_person_fov', 90).value
third_person_fov = ConfigVariableDouble('third_person_fov', 60).value


class CameraModes(Enum):
    FOLLOW = 1
    FIXED = 2
    COCKPIT = 3
    # FIXME: To be merged with FOLLOW
    # DIRECTION = 4
    # MIXED = 5


def color_gradient(v):
    red = v * 2
    if red > 1.0:
예제 #8
0
from direct.showbase.ShowBase import ShowBase
base = ShowBase()

from panda3d.recastnavigation import RNNavMeshManager

nmMgr = RNNavMeshManager.get_global_ptr()
nmMgr.set_root_node_path(render)
nmMgr.get_reference_node_path().reparentTo(render)
nmMgr.start_default_update()
nmMgr.get_reference_node_path_debug().reparentTo(render)
base.nmMgr = nmMgr

from direct.distributed.ClockDelta import globalClockDelta
builtins.globalClockDelta = globalClockDelta

ConfigVariableDouble('decompressor-step-time').setValue(0.01)
ConfigVariableDouble('extractor-step-time').setValue(0.01)

from src.mod import ModGlobals

from src.mod.distributed.ModServerRepository import ModServerRepository
base.sr = ModServerRepository(7032, dcFileNames = ModGlobals.DCFileNames)

def __handleAIReady():
    print("AI ready")
    base.air.setInterestZones([ModGlobals.UberZoneId, ModGlobals.BattleZoneId])
    from direct.distributed.TimeManagerAI import TimeManagerAI
    tm = TimeManagerAI(base.air)
    tm.generateWithRequiredAndId(ModGlobals.TimeManagerID, 0, ModGlobals.UberZoneId)

    def makeBattle():
예제 #9
0
def GetDouble(sym, default=0.0):
    return ConfigVariableDouble(sym, default, "DConfig", ConfigFlags.F_dconfig).value
예제 #10
0
    from src.coginvasion.settings.Setting import SHOWBASE_PREINIT, SHOWBASE_POSTINIT
    jsonFile = "settings.json"

    sm = SettingsManager()

    from src.coginvasion.globals import CIGlobals
    CIGlobals.SettingsMgr = sm
    sm.loadFile(jsonFile)
    sm.doSunriseFor(sunrise=SHOWBASE_PREINIT)

    from src.mod.ModBase import ModBase
    base = ModBase()

    sm.doSunriseFor(sunrise=SHOWBASE_POSTINIT)

    ConfigVariableDouble('decompressor-step-time').setValue(0.01)
    ConfigVariableDouble('extractor-step-time').setValue(0.01)

    from direct.gui import DirectGuiGlobals
    DirectGuiGlobals.setDefaultFontFunc(CIGlobals.getToonFont)
    DirectGuiGlobals.setDefaultFont(CIGlobals.getToonFont())
    DirectGuiGlobals.setDefaultRolloverSound(
        loader.loadSfx("phase_3/audio/sfx/GUI_rollover.ogg"))
    DirectGuiGlobals.setDefaultClickSound(
        loader.loadSfx("phase_3/audio/sfx/GUI_create_toon_fwd.ogg"))
    DirectGuiGlobals.setDefaultDialogGeom(
        loader.loadModel("phase_3/models/gui/dialog_box_gui.bam"))

    from src.coginvasion.nametag import NametagGlobals
    NametagGlobals.setMe(base.cam)
    NametagGlobals.setCardModel('phase_3/models/props/panel.bam')
예제 #11
0
"""DistributedSmoothNode module: contains the DistributedSmoothNode class"""

from panda3d.core import NodePath, ConfigVariableDouble
from panda3d.direct import SmoothMover
from .ClockDelta import *
from . import DistributedNode
from . import DistributedSmoothNodeBase
from direct.task.Task import cont
from direct.task.TaskManagerGlobal import taskMgr
from direct.showbase.PythonUtil import report

# This number defines our tolerance for out-of-sync telemetry packets.
# If a packet appears to have originated from more than MaxFuture
# seconds in the future, assume we're out of sync with the other
# avatar and suggest a resync for both.
MaxFuture = ConfigVariableDouble("smooth-max-future", 0.2)

# How frequently can we suggest a resynchronize with another client?
MinSuggestResync = ConfigVariableDouble("smooth-min-suggest-resync", 15)

# These flags indicate whether global smoothing and/or prediction is
# allowed or disallowed.
EnableSmoothing = ConfigVariableBool("smooth-enable-smoothing", True)
EnablePrediction = ConfigVariableBool("smooth-enable-prediction", True)

# These values represent the amount of time, in seconds, to delay the
# apparent position of other avatars, when non-predictive and
# predictive smoothing is in effect, respectively.  This is in
# addition to the automatic delay of the observed average latency from
# each avatar, which is intended to compensate for relative clock
# skew.
예제 #12
0
 def GetDefaultSpikeThreshold():
     return ConfigVariableDouble('profile-task-spike-threshold', 5.).value
예제 #13
0
파일: main.py 프로젝트: grimfang/owp_ajaw
    def __init__(self):
        ShowBase.__init__(self)
        FSM.__init__(self, "FSM-Game")

        #
        # BASIC APPLICATION CONFIGURATIONS
        #
        self.disableMouse()
        self.setBackgroundColor(0, 0, 0)
        self.camLens.setFov(75)
        self.camLens.setNear(0.8)

        # check if the config file hasn't been created
        base.textWriteSpeed = 0.05
        mute = ConfigVariableBool("audio-mute", False).getValue()
        if mute:
            self.disableAllAudio()
        else:
            self.enableAllAudio()
        particles = ConfigVariableBool("particles-enabled", True).getValue()
        if particles:
            self.enableParticles()
        base.textWriteSpeed = ConfigVariableDouble("text-write-speed",0.05).getValue()
        base.controlType = ConfigVariableString("control-type", "Gamepad").getValue()
        base.mouseSensitivity = ConfigVariableDouble("mouse-sensitivity",1.0).getValue()
        if not os.path.exists(prcFile):
            self.__writeConfig()
            # set window properties
            # clear all properties not previously set
            self.win.clearRejectedProperties()
            # setup new window properties
            props = WindowProperties()
            # Fullscreen
            props.setFullscreen(True)
            # window icon
            print props.hasIconFilename()
            props.setIconFilename(windowicon)
            # get the displays width and height
            w = self.pipe.getDisplayWidth()
            h = self.pipe.getDisplayHeight()
            # set the window size to the screen resolution
            props.setSize(w, h)
            # request the new properties
            self.win.requestProperties(props)
        atexit.register(self.__writeConfig)

        # enable collision handling
        base.cTrav = CollisionTraverser("base collision traverser")
        base.pusher = CollisionHandlerPusher()
        base.pusher.addInPattern('%fn-in-%in')
        base.pusher.addOutPattern('%fn-out-%in')

        self.menu = Menu()
        self.options = OptionsMenu()

        self.musicMenu = loader.loadMusic("MayanJingle6_Menu.ogg")
        self.musicMenu.setLoop(True)

        cm = CardMaker("menuFade")
        cm.setFrameFullscreenQuad()
        self.menuCoverFade = NodePath(cm.generate())
        self.menuCoverFade.setTransparency(TransparencyAttrib.MAlpha)
        self.menuCoverFade.setBin("fixed", 1000)
        self.menuCoverFade.reparentTo(render2d)
        self.menuCoverFade.hide()
        self.menuCoverFadeOutInterval = Sequence(
            Func(self.menuCoverFade.show),
            LerpColorScaleInterval(
                self.menuCoverFade,
                1,
                LVecBase4f(0.0,0.0,0.0,1.0),
                LVecBase4f(0.0,0.0,0.0,0.0)),
            Func(self.menuCoverFade.hide))
        self.menuCoverFadeInInterval = Sequence(
            Func(self.menuCoverFade.show),
            LerpColorScaleInterval(
                self.menuCoverFade,
                1,
                LVecBase4f(0.0,0.0,0.0,0.0),
                LVecBase4f(0.0,0.0,0.0,1.0)),
            Func(self.menuCoverFade.hide))
        self.lerpAudioFadeOut = LerpFunc(
            self.audioFade,
            fromData=1.0,
            toData=0.0,
            duration=0.25,
            extraArgs=[self.musicMenu])
        self.fadeMusicOut = Sequence(
            self.lerpAudioFadeOut,
            Func(self.musicMenu.stop))
        self.lerpAudioFadeIn = LerpFunc(
            self.audioFade,
            fromData=0.0,
            toData=1.0,
            duration=1,
            extraArgs=[self.musicMenu])
        self.fadeMusicIn = Sequence(
                Func(self.musicMenu.play),
                self.lerpAudioFadeIn)

        self.seqFade = None
        self.acceptAll()

        self.request("Intro")
예제 #14
0
    def __init__(self):
        ShowBase.__init__(self)
        FSM.__init__(self, "mainStateMachine")

        # some basic enhancements
        # window background color
        self.setBackgroundColor(0, 0, 0)
        # set antialias for the complete sceen to automatic
        self.render.setAntialias(AntialiasAttrib.MAuto)
        # shader generator
        render.setShaderAuto()
        # Enhance font readability
        DGG.getDefaultFont().setPixelsPerUnit(100)
        # hide the mouse cursor
        hide_cursor()

        #
        # CONFIGURATION LOADING
        #
        # load given variables or set defaults
        # check if audio should be muted
        mute = ConfigVariableBool("audio-mute", False).getValue()
        if mute:
            self.disableAllAudio()
        else:
            self.enableAllAudio()

        base.sfxManagerList[0].setVolume(
            ConfigVariableDouble("audio-volume-sfx", 1.0).getValue())
        base.difficulty = ConfigVariableInt("difficulty", 0).getValue()

        def setFullscreen():
            """Helper function to set the window fullscreen
            with width and height set to the screens size"""
            # get the displays width and height
            w = self.pipe.getDisplayWidth()
            h = self.pipe.getDisplayHeight()
            # set window properties
            # clear all properties not previously set
            base.win.clearRejectedProperties()
            # setup new window properties
            props = WindowProperties()
            # Fullscreen
            props.setFullscreen(True)
            # set the window size to the screen resolution
            props.setSize(w, h)
            # request the new properties
            base.win.requestProperties(props)

        # check if the config file hasn't been created
        if not os.path.exists(prcFile):
            setFullscreen()
        elif base.appRunner:
            # When the application is started as appRunner instance, it
            # doesn't respect our loadPrcFiles configurations specific
            # to the window as the window is already created, hence we
            # need to manually set them here.
            for dec in range(mainConfig.getNumDeclarations()):
                # check if we have the fullscreen variable
                if mainConfig.getVariableName(dec) == "fullscreen":
                    setFullscreen()
        # automatically safe configuration at application exit
        base.exitFunc = self.__writeConfig

        # due to the delayed window resizing and switch to fullscreen
        # we wait some time until everything is set so we can savely
        # proceed with other setups like the menus
        if base.appRunner:
            # this behaviour only happens if run from p3d files and
            # hence the appRunner is enabled
            taskMgr.doMethodLater(0.5,
                                  self.postInit,
                                  "post initialization",
                                  extraArgs=[])
        else:
            self.postInit()
def getConfigDouble(name, default):
    output = ConfigVariableDouble(name, default).getValue()
    if RUNTYPE != 'python':
        if AppRunnerGlobal.appRunner.getTokenFloat(name):
            output = AppRunnerGlobal.appRunner.getTokenFloat(name)
    return output
예제 #16
0
 def getDefaultTimeslice():
     # run for 1/2 millisecond per frame by default
     # config is in milliseconds, this func returns value in seconds
     return ConfigVariableDouble('job-manager-timeslice-ms', .5).value / 1000.