示例#1
0
    def downloadDescFile(self, http):
        """ Downloads the desc file for this particular package,
        synchronously, and then reads it.  Returns true on success,
        false on failure. """

        for token in self.downloadDescFileGenerator(http):
            if token != self.stepContinue:
                break
            Thread.considerYield()

        return (token == self.stepComplete)
示例#2
0
    def downloadDescFile(self, http):
        """ Downloads the desc file for this particular package,
        synchronously, and then reads it.  Returns true on success,
        false on failure. """

        for token in self.downloadDescFileGenerator(http):
            if token != self.stepContinue:
                break
            Thread.considerYield()

        return (token == self.stepComplete)
示例#3
0
    def downloadPackage(self, http):
        """ Downloads the package file, synchronously, then
        uncompresses and unpacks it.  Returns true on success, false
        on failure.

        This assumes that self.installPlans has already been filled
        in, which will have been done by self.__readDescFile().
        """

        for token in self.downloadPackageGenerator(http):
            if token != self.stepContinue:
                break
            Thread.considerYield()

        return (token == self.stepComplete)
示例#4
0
    def downloadPackage(self, http):
        """ Downloads the package file, synchronously, then
        uncompresses and unpacks it.  Returns true on success, false
        on failure.

        This assumes that self.installPlans has already been filled
        in, which will have been done by self.__readDescFile().
        """

        for token in self.downloadPackageGenerator(http):
            if token != self.stepContinue:
                break
            Thread.considerYield()

        return (token == self.stepComplete)
示例#5
0
def test_multiple_renderers(scenario):
    assert p3dThread.isThreadingSupported()
    num_renderers = 3
    rts = [RenderThread(r, scenario) for r in range(num_renderers)]
    for rt in rts:
        rt.start()
    for rt in rts:
        rt.join()
示例#6
0
def test_multiple_renderers(scenario, request):
    assert p3dThread.isThreadingSupported()
    renderer_debug_mode = request.config.getoption("--renderer-debug-mode")
    num_renderers = 3
    rts = [
        RenderThread(r, scenario, renderer_debug_mode)
        for r in range(num_renderers)
    ]
    for rt in rts:
        rt.start()
    for rt in rts:
        rt.join()
示例#7
0
    def setTrianglePointIndex(self, triangleIndex, pointIndex, newVertexIndex):
        triangleArry = self.primitives.modifyVertices()
        triangleArry = triangleArry.modifyHandle(Thread.getCurrentThread())  # releases the array when deleted
        bytesPerVert = triangleArry.getArrayFormat().getTotalBytes()

        # BLOG C string to Python struct conversion https://docs.python.org/2/library/struct.html#format-characters
        fmtStr = triangleArry.getArrayFormat().getFormatString(False)  # True pads the bytes
        if fmtStr[0] != '=':
            fmtStr = '=' + fmtStr  # use standard sizing w/ = or native w/ @

        readerWriter = struct.Struct(fmtStr)  # creating the class instance saves on compiling the format string
        packed = readerWriter.pack(newVertexIndex)
        triangleArry.setSubdata(triangleIndex * bytesPerVert * 3 + pointIndex * bytesPerVert, bytesPerVert, packed)
示例#8
0
def make_cloud_node(pts, col=LColorf(1.0, 0.0, 0.0, 1.0)):
    ptCloudData = GeomVertexData("PointCloudData", GeomVertexFormat.getV3c4(),
                                 GeomEnums.UH_static)
    vertexWriter = GeomVertexWriter(ptCloudData, Thread.getCurrentThread())
    vertexWriter.setColumn("vertex")
    colorWriter = GeomVertexWriter(ptCloudData, Thread.getCurrentThread())
    colorWriter.setColumn("color")

    for (x, y, z) in pts:
        vertexWriter.addData3(x, y, z)
        colorWriter.addData4(col)

    geomPts = GeomPoints(GeomEnums.UH_static)
    geomPts.addConsecutiveVertices(0, len(pts))
    geomPts.closePrimitive()

    geom = Geom(ptCloudData)
    geom.addPrimitive(geomPts)

    node = GeomNode("PointCloudNode")
    node.addGeom(geom, RenderState.makeEmpty())
    return node
示例#9
0
def make_patch_node(pts, col=LColorf(0.0, 1.0, 0.0, 1.0)):
    splinePatchData = GeomVertexData("SplinePatchData",
                                     GeomVertexFormat.getV3c4(),
                                     GeomEnums.UH_static)
    vertexWriter = GeomVertexWriter(splinePatchData, Thread.getCurrentThread())
    vertexWriter.setColumn("vertex")
    colorWriter = GeomVertexWriter(splinePatchData, Thread.getCurrentThread())
    colorWriter.setColumn("color")

    for (x, y, z) in pts:
        vertexWriter.addData3(x, y, z)
        colorWriter.addData4(col)

    geomLines = GeomLines(GeomEnums.UH_static)
    geomLines.addConsecutiveVertices(0, len(pts))
    geomLines.addVertex(0)
    geomLines.closePrimitive()

    geom = Geom(splinePatchData)
    geom.addPrimitive(geomLines)

    node = GeomNode("SplinePatchNode")
    node.addGeom(geom, RenderState.makeEmpty())
    return node
示例#10
0
    def setTrianglePointIndex(self, triangleIndex, pointIndex, newVertexIndex):
        triangleArry = self.primitives.modifyVertices()
        triangleArry = triangleArry.modifyHandle(
            Thread.getCurrentThread())  # releases the array when deleted
        bytesPerVert = triangleArry.getArrayFormat().getTotalBytes()

        # BLOG C string to Python struct conversion https://docs.python.org/2/library/struct.html#format-characters
        fmtStr = triangleArry.getArrayFormat().getFormatString(
            False)  # True pads the bytes
        if fmtStr[0] != '=':
            fmtStr = '=' + fmtStr  # use standard sizing w/ = or native w/ @

        readerWriter = struct.Struct(
            fmtStr
        )  # creating the class instance saves on compiling the format string
        packed = readerWriter.pack(newVertexIndex)
        triangleArry.setSubdata(
            triangleIndex * bytesPerVert * 3 + pointIndex * bytesPerVert,
            bytesPerVert, packed)
from src.coginvasion.globals import CIGlobals
CIGlobals.SettingsMgr = sm
sm.loadFile(jsonFile)
sm.doSunriseFor(sunrise=SHOWBASE_PREINIT)
notify.info("Applying pre-ShowBase initialization settings.")

from CIBase import CIBase
base = CIBase()

sm.doSunriseFor(sunrise=SHOWBASE_POSTINIT)
notify.info("Applying post-ShowBase initialization settings.")

base.initStuff()

notify.info("Using Panda3D version {0}".format(PandaSystem.getVersionString()))
notify.info("True threading: " + str(Thread.isTrueThreads()))

# Use our shader generator extension
#import ccoginvasion
#shGen = ccoginvasion.CIShaderGenerator(base.win.getGsg(), base.win)
#base.win.getGsg().setShaderGenerator(shGen)

#import AnisotropicFiltering
#AnisotropicFiltering.startApplying()

display = base.config.GetString('load-display')
audio = base.config.GetString('audio-library-name').replace('p3', '').replace(
    '_audio', '')

if display == 'pandagl':
    display = 'OpenGL'
print 'CIStart: Reading settings file ' + jsonfile
sm = SettingsManager()


class game:
    name = 'coginvasion'
    process = 'client'
    version = os.environ.get('GAME_VERSION')
    serverAddress = os.environ.get('GAME_SERVER')


__builtin__.game = game()
print 'CIStart: Starting the game.'
print('CIStart: Using Panda3D version {0}').format(
    PandaSystem.getVersionString())
print 'CIStart: True threading: ' + str(Thread.isTrueThreads())
try:
    import aes, niraidata
    prc = niraidata.CONFIG
    iv, key, prc = prc[:16], prc[16:32], prc[32:]
    prc = aes.decrypt(prc, key, iv)
    for line in prc.split('\n'):
        line = line.strip()
        if line:
            loadPrcFileData('coginvasion config', line)

    print 'CIStart: Running production'
except:
    loadPrcFile('config/Confauto.prc')
    loadPrcFile('config/config_client.prc')
    print 'CIStart: Running dev'
示例#13
0
    def render_patch(self, pts):
        nodePath = NodePath(make_patch_node(pts), Thread.getCurrentThread())
        nodePath.reparentTo(self.render)

        nodePath.setRenderModeThickness(0.2)
        nodePath.setRenderModePerspective(True)
示例#14
0
    def render_cloud(self, pts):
        nodePath = NodePath(make_cloud_node(pts), Thread.getCurrentThread())
        nodePath.reparentTo(self.render)

        nodePath.setRenderModeThickness(0.15)
        nodePath.setRenderModePerspective(False)