示例#1
0
    def __init__(self):
        """ Constructs a new Light, subclasses have to call this """
        DebugObject.__init__(self, "AbstractLight")
        ShaderStructElement.__init__(self)
        self.debugNode = NodePath("LightDebug")
        self.visualizationNumSteps = 32
        self.dataNeedsUpdate = False
        self.castShadows = False
        self.debugEnabled = False
        self.bounds = OmniBoundingVolume()
        self.shadowSources = []
        self.lightType = self.getLightType()
        self.position = Vec3(0)
        self.color = Vec3(1)
        self.posterIndex = -1
        self.radius = 10.0
        self.typeName = ""
        self.sourceIndexes = PTAInt.emptyArray(6)
        self.attached = False
        self.shadowResolution = 512
        self.index = -1
        self.iesProfile = -1
        self.iesProfileName = None
        self.mvp = Mat4()

        # A light can have up to 6 sources
        for i in range(6):
            self.sourceIndexes[i] = -1
示例#2
0
 def startDrop(self, entity):
     if entity and self.dropLoc:
         endPos = self.dropLoc
         dropMdl = entity.find('**/DropMdl')
         startPos = Point3(endPos.getX(), endPos.getY(), endPos.getZ() + 20)
         entity.setPos(startPos.getX(),
                       startPos.getY() + 2, startPos.getZ())
         dropMdl.setScale(5 * 0.85)
         entity.node().setBounds(OmniBoundingVolume())
         entity.node().setFinal(1)
         entity.headsUp(self.avatar)
         self.buildCollisions(entity)
         objectTrack = Sequence()
         animProp = LerpPosInterval(entity,
                                    self.fallDuration,
                                    endPos,
                                    startPos=startPos)
         bounceProp = Effects.createZBounce(entity, 2, endPos, 0.5, 1.5)
         objAnimShrink = Sequence(Func(dropMdl.setScale, 5), Wait(0.5),
                                  Func(entity.reparentTo, render), animProp,
                                  bounceProp)
         objectTrack.append(objAnimShrink)
         dropShadow = CIGlobals.makeDropShadow(1.0)
         dropShadow.reparentTo(hidden)
         dropShadow.setPos(endPos)
         shadowTrack = Sequence(
             Func(dropShadow.reparentTo, render),
             LerpScaleInterval(dropShadow,
                               self.fallDuration + 0.1, (1, 1, 1),
                               startScale=Point3(0.01, 0.01, 0.01)),
             Wait(0.8), Func(dropShadow.removeNode))
         Parallel(
             Sequence(Wait(self.fallDuration), Func(self.completeDrop)),
             objectTrack, shadowTrack).start()
         self.dropLoc = None
示例#3
0
    def equip(self):
        Gag.equip(self)

        base.audio3d.attachSoundToObject(self.fireSound, self.avatar)
        base.audio3d.attachSoundToObject(self.dblFireSound, self.avatar)
        base.audio3d.attachSoundToObject(self.pumpSound, self.avatar)
        base.audio3d.attachSoundToObject(self.emptySound, self.avatar)
        for s in self.reloadSounds:
            base.audio3d.attachSoundToObject(s, self.avatar)

        if self.isLocal():
            self.sgViewModel = Actor(self.sgActorDef[0], self.sgActorDef[1])
            self.sgViewModel.node().setBounds(OmniBoundingVolume())
            self.sgViewModel.node().setFinal(1)
            self.sgViewModel.setBlend(
                frameBlend=base.config.GetBool('interpolate-frames', False))
            self.sgViewModel.setH(180)
            self.sgViewModel.find("**/shell").setBSPMaterial(
                'phase_14/hl2/casing01.mat')

            fpsCam = self.getFPSCam()
            fpsCam.swapViewModel(self.sgViewModel, 54.0)
            self.setAction(self.actionDraw)
            self.accept('r', self.__doReload)

            taskMgr.add(self.__tick, "HL2ShotgunTick")

        self.gag.setPosHprScale(-0.03, 1.19, -0.14, 2.29, 347.01, 45, 2, 2, 2)
        toonTrack = Sequence(Func(self.avatar.setForcedTorsoAnim, 'firehose'),
                             self.getAnimationTrack('firehose', endFrame=30),
                             Func(self.__doBob))
        self.setAnimTrack(toonTrack, startNow=True)
示例#4
0
    def __init__(self, whl_pos, whl_radius, car_h):
        GameObject.__init__(self)
        self.radius = whl_radius
        v_f = GeomVertexFormat.getV3()
        vdata = GeomVertexData('skid', v_f, Geom.UHDynamic)
        prim = GeomTriangles(Geom.UHStatic)
        self.vtx_cnt = 1
        self.last_pos = whl_pos
        geom = Geom(vdata)
        geom.add_primitive(prim)
        self.node = GeomNode('gnode')
        self.node.add_geom(geom)
        nodepath = self.eng.gfx.root.attach_node(self.node)
        nodepath.set_transparency(True)
        nodepath.set_depth_offset(1)
        nodepath.node.set_two_sided(True)  # for self-shadowing issues
        self.__set_material(nodepath)
        nodepath.p3dnode.set_bounds(OmniBoundingVolume())
        self.add_vertices(whl_radius, car_h)
        self.add_vertices(whl_radius, car_h)

        def alpha(time, n_p):
            if not n_p.is_empty:
                n_p.node.set_shader_input('alpha', time)
            # this if seems necessary since, if there are skidmarks and you
            # exit from the race (e.g. back to the menu), then alpha is being
            # called from the interval manager even if the interval manager
            # correctly says that there are 0 intervals.

        self.remove_seq = Sequence(
            Wait(8), LerpFunc(alpha, 8, .5, 0, 'easeInOut', [nodepath]),
            Func(nodepath.remove_node))
        self.remove_seq.start()
示例#5
0
    def load(self):
        Entity.load(self)

        scale = self.getEntityValueFloat("spriteScale")
        color = self.getEntityValueColor("spriteColor")

        sunVec = base.shaderGenerator.getSunVector()
        self.pivotNode = camera.attachNewNode('env_sun-pivot')
        self.pivotNode.lookAt(sunVec)
        self.pivotNode.setCompass()

        cm = CardMaker('sun_sprite')
        cm.setFrame(-0.5, 0.5, -0.5, 0.5)
        self.sunSprite = self.pivotNode.attachNewNode(
            GlowNode(cm.generate(), 32.0 * scale))
        self.sunSprite.setAttrib(
            ColorBlendAttrib.make(ColorBlendAttrib.MAdd, ColorBlendAttrib.OOne,
                                  ColorBlendAttrib.OOne), 1)
        self.sunSprite.setBSPMaterial("phase_14/materials/sun/sunsprite.mat",
                                      1)
        self.sunSprite.setFogOff(10)
        self.sunSprite.setBillboardPointEye()
        self.sunSprite.setDepthTest(False)
        self.sunSprite.setDepthWrite(False)
        self.sunSprite.setScale(scale * 100)
        self.sunSprite.setColorScale(color, 1)
        self.sunSprite.setY(1000)
        self.sunSprite.node().setBounds(OmniBoundingVolume())
        self.sunSprite.node().setFinal(True)
示例#6
0
 def __init__(self, wheel_pos, radius, heading):
     self.radius = radius
     v_f = GeomVertexFormat.getV3()
     self.vdata = GeomVertexData('skid', v_f, Geom.UHDynamic)
     self.vdata.setNumRows(1)
     self.vertex = GeomVertexWriter(self.vdata, 'vertex')
     self.prim = GeomTriangles(Geom.UHStatic)
     self.cnt = 1
     self.last_pos = wheel_pos
     geom = Geom(self.vdata)
     geom.addPrimitive(self.prim)
     node = GeomNode('gnode')
     node.addGeom(geom)
     nodePath = render.attachNewNode(node)
     nodePath.setTransparency(True)
     nodePath.setDepthOffset(1)
     self.__set_material(nodePath)
     nodePath.node().setBounds(OmniBoundingVolume())
     self.add_vertices(radius, heading)
     self.add_vertices(radius, heading)
     self.remove_seq = Sequence(
         Wait(8),
         LerpFunc(nodePath.setAlphaScale, 8, 1, 0, 'easeInOut'),
         Func(nodePath.remove_node))
     self.remove_seq.start()
示例#7
0
文件: gfx.py 项目: PlumpMath/yyagl
 def end_loading(self, model=None):
     if model:
         self.model = model
     anim_name = '**/%s*%s*' % (self.props.empty_name, self.props.anim_name)
     for model in self.model.findAllMatches(anim_name):
         # bam files don't contain actor info
         new_root = NodePath(model.get_name())
         new_root.reparent_to(model.get_parent())
         new_root.set_pos(model.get_pos())
         new_root.set_hpr(model.get_hpr())
         new_root.set_scale(model.get_scale())
         model_subname = model.get_name()[len(self.props.empty_name):]
         path = '%s/%s' % (self.props.path, model_subname)
         if '.' in path:
             path = path.split('.')[0]
         anim_path = '%s-%s' % (path, self.props.anim_name)
         self.__actors += [Actor(path, {'anim': anim_path})]
         self.__actors[-1].loop('anim')
         self.__actors[-1].setPlayRate(.5, 'anim')
         self.__actors[-1].reparent_to(new_root)
         has_omni = model.has_tag(self.props.omni_tag)
         if has_omni and model.get_tag(self.props.omni_tag):
             new_root.set_tag(self.props.omni_tag, 'True')
             a_n = self.__actors[-1].get_name()
             LogMgr().log('set omni for ' + a_n)
             self.__actors[-1].node().setBounds(OmniBoundingVolume())
             self.__actors[-1].node().setFinal(True)
         model.remove_node()
     self.signs = Signs(self.model, self.props.sign_name, self.props.thanks)
     self.signs.set_signs()
     self.model.prepareScene(eng.base.win.getGsg())
     self.model.premungeScene(eng.base.win.getGsg())
     Gfx.async_bld(self)
示例#8
0
    def loadLevelData(self, inputData):
        """
        processes the level asloaded from the file. it seperates the input data until the data for each tile is ready.
        """
        rigidNode = RigidBodyCombiner("LevelNode")
        levelNode = NodePath(rigidNode)

        #deleting whitespaces and seperating the content for each tile into a list.
        inputData = inputData.replace("\n", "").strip().replace(
            " ", "").lstrip("<").rstrip(">").split("><")

        for tileData in inputData:
            tile = self.loadTile(tileData)
            if tile != None:
                tile.reparentTo(levelNode)
                tile.setPos(self.getPosFromTile(tile))
                tile.setZ(
                    tile, 0.00000001
                )  # workaround for rigid body combiner so it does not assume the (0,0) tile as static
            else:
                print("ERROR, could not load tile with data: ", tileData)
        rigidNode.collect()
        inode = rigidNode.getInternalScene().node(
        )  # workaround for a boundingvolume issue with rigidbodycombiner
        inode.setBounds(OmniBoundingVolume())  # still workaround
        inode.setFinal(True)  # still workaround
        return levelNode
示例#9
0
    def load(self):
        DistributedPartyFireworksActivity.notify.debug('load')
        DistributedPartyActivity.load(self)
        self.eventId = PartyGlobals.FireworkShows.Summer
        self.launchPadModel = loader.loadModel('phase_13/models/parties/launchPad')
        self.launchPadModel.setH(90.0)
        self.launchPadModel.setPos(0.0, -18.0, 0.0)
        self.launchPadModel.reparentTo(self.root)
        railingsCollection = self.launchPadModel.findAllMatches('**/launchPad_mesh/*railing*')
        for i in xrange(railingsCollection.getNumPaths()):
            railingsCollection[i].setAttrib(AlphaTestAttrib.make(RenderAttrib.MGreater, 0.75))

        leverLocator = self.launchPadModel.find('**/RocketLever_locator')
        self.lever.setPosHpr(Vec3.zero(), Vec3.zero())
        self.lever.reparentTo(leverLocator)
        self.toonPullingLeverInterval = None
        self.sign.reparentTo(self.launchPadModel.find('**/launchPad_sign_locator'))
        self.rocketActor = Actor('phase_13/models/parties/rocket_model', {'launch': 'phase_13/models/parties/rocket_launch'})
        rocketLocator = self.launchPadModel.find('**/rocket_locator')
        self.rocketActor.reparentTo(rocketLocator)
        self.rocketActor.node().setBound(OmniBoundingVolume())
        self.rocketActor.node().setFinal(True)
        effectsLocator = self.rocketActor.find('**/joint1')
        self.rocketExplosionEffect = RocketExplosion(effectsLocator, rocketLocator)
        self.rocketParticleSeq = None
        self.launchSound = base.loader.loadSfx('phase_13/audio/sfx/rocket_launch.ogg')
        self.activityFSM = FireworksActivityFSM(self)
        self.activityFSM.request('Idle')
        return
示例#10
0
    def __init__(self, name, format = GeomVertexFormat.getV3()):
        self.views = []
        self.vertexBuffer = GeomVertexData(name + "-vdata", format, GeomEnums.UHDynamic)

        self.np = NodePath(name)
        self.np.node().setBounds(OmniBoundingVolume())
        self.np.node().setFinal(1)
示例#11
0
 def _make_fullscreen_tri(self):
     """ Creates the oversized triangle used for rendering """
     vformat = GeomVertexFormat.get_v3()
     vdata = GeomVertexData("vertices", vformat, Geom.UH_static)
     vdata.set_num_rows(3)
     vwriter = GeomVertexWriter(vdata, "vertex")
     vwriter.add_data3f(-1, 0, -1)
     vwriter.add_data3f(3, 0, -1)
     vwriter.add_data3f(-1, 0, 3)
     gtris = GeomTriangles(Geom.UH_static)
     gtris.add_next_vertices(3)
     geom = Geom(vdata)
     geom.add_primitive(gtris)
     geom_node = GeomNode("gn")
     geom_node.add_geom(geom)
     geom_node.set_final(True)
     geom_node.set_bounds(OmniBoundingVolume())
     tri = NodePath(geom_node)
     tri.set_depth_test(False)
     tri.set_depth_write(False)
     tri.set_attrib(TransparencyAttrib.make(TransparencyAttrib.M_none), 10000)
     tri.set_color(Vec4(1))
     tri.set_bin("unsorted", 10)
     tri.reparent_to(self._node)
     self._tri = tri
示例#12
0
文件: sun.py 项目: karlexceed/naith
  def __init__(self,manager,xml):
    self.updateTask = None

    self.sun = base.cam.attachNewNode('sun')
    loader.loadModel(manager.get('paths').getConfig().find('misc').get('path')+'/sphere').reparentTo(self.sun)
    self.sun.setScale(0.1)
    self.sun.setTwoSided(True)
    self.sun.setColorScale(10.0, 10.0, 10.0, 1.0, 10001)
    self.sun.setLightOff(1)
    self.sun.setShaderOff(1)
    self.sun.setFogOff(1)
    self.sun.setCompass()
    self.sun.setBin('background', 10)
    self.sun.setDepthWrite(False)
    self.sun.setDepthTest(False)
    # Workaround an annoyance in Panda. No idea why it's needed.
    self.sun.node().setBounds(OmniBoundingVolume())
    isa = xml.find('isa')
    inst = xml.find('instance')
    if isa != None or inst != None:
      if inst != None:
        orig = Vec3(float(inst.get('x', '0')), float(inst.get('y', '0')), float(inst.get('z', '0')))
      else:
        level = manager.get(isa.get('source'))
        orig = Vec3(level.getByIsA(isa.get('name'))[0].getPos(render))
      orig.normalize()
      self.sun.setPos(orig)
    
    godrays = xml.find('godrays')
    if godrays != None:
      self.vlbuffer = base.win.makeTextureBuffer('volumetric-lighting', base.win.getXSize()/2, base.win.getYSize()/2)
      self.vlbuffer.setClearColor(Vec4(0, 0, 0, 1))
      cam = base.makeCamera(self.vlbuffer)
      cam.node().setLens(base.camLens)
      cam.reparentTo(base.cam)
      initstatenode = NodePath('InitialState')
      initstatenode.setColorScale(0, 0, 0, 1, 10000)
      initstatenode.setShaderOff(10000)
      initstatenode.setLightOff(10000)
      initstatenode.setMaterialOff(10000)
      initstatenode.setTransparency(TransparencyAttrib.MBinary, 10000)
      cam.node().setCameraMask(BitMask32.bit(2))
      cam.node().setInitialState(initstatenode.getState())
      self.vltexture = self.vlbuffer.getTexture()
      self.vltexture.setWrapU(Texture.WMClamp)
      self.vltexture.setWrapV(Texture.WMClamp)
      card = CardMaker('VolumetricLightingCard')
      card.setFrameFullscreenQuad()
      self.finalQuad = render2d.attachNewNode(card.generate())
      self.finalQuad.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd, ColorBlendAttrib.OIncomingColor, ColorBlendAttrib.OFbufferColor))
      self.finalQuad.setShader(Shader.load(posixpath.join(manager.get('paths').getConfig().find('shaders').get('path'), 'filter-vlight.cg')))
      self.finalQuad.setShaderInput('src', self.vltexture)
      self.finalQuad.setShaderInput('vlparams', 32, 0.9/32.0, 0.97, 0.5) # Note - first 32 is now hardcoded into shader for cards that don't support variable sized loops.
      self.finalQuad.setShaderInput('casterpos', 0.5, 0.5, 0, 0)
      # Last parameter to vlcolor is the exposure
      vlcolor = Vec4(float(godrays.get('r', '1')), float(godrays.get('g', '1')), float(godrays.get('b', '1')), 0.04)
      self.finalQuad.setShaderInput('vlcolor', vlcolor)
    else:
      self.finalQuad = None
    def __init__(self):
        Light.__init__(self)
        DebugObject.__init__(self, "DirectionalLight")

        self._spacing = 0.6
        self.radius = 99999999999.0
        self.position = Vec3(0)
        self.bounds = OmniBoundingVolume()
示例#14
0
 def create_holder_instance(self):
     self.holder = NodePath('tile')
     self.holder.set_pos(self.x0, self.y0, 0.0)
     self.holder.set_scale(*self.get_scale())
     if settings.debug_lod_show_bb:
         self.bounds_shape.create_instance()
     self.holder.node().setBounds(OmniBoundingVolume())
     self.holder.node().setFinal(1)
示例#15
0
def precacheScene(scene, reset=True):
    if reset:
        oldp = scene.getParent()

    rHidden = False
    if render.isHidden():
        rHidden = True
        render.show()

    stashed = NodePathCollection()
    for np in scene.findAllMatches("**;+s"):
        if np.isStashed():
            stashed.addPath(np)
            np.unstash()

    if not scene.isAncestorOf(render):
        # if it's parented to camera,
        # camera will always see it
        scene.reparentTo(render)

    # this says that the scene takes up infinite space,
    # making it always intersect the view frustum,
    # guaranteed to be rendered
    scene.node().setBounds(OmniBoundingVolume())
    scene.node().setFinal(1)

    # Always render if it's a BSP level, even if outside of PVS
    scene.setAttrib(BSPFaceAttrib.makeIgnorePvs(), 1)

    try:
        scene.premungeScene(base.win.getGsg())
        scene.prepareScene(base.win.getGsg())
        base.graphicsEngine.renderFrame()
        base.graphicsEngine.renderFrame()
        base.graphicsEngine.syncFrame()
        base.musicManager.update()

        if reset:
            scene.node().setFinal(0)
            scene.node().clearBounds()

            scene.reparentTo(oldp)

            if rHidden:
                render.hide()

        # restash
        for np in stashed:
            np.stash()
    except:
        # The program might have exited prematurely.
        # This will prevent the game from yelling at us.
        print("precacheScene failed")

    scene.clearAttrib(BSPFaceAttrib)

    return rHidden
 def _makeFullscreenCam(self):
     bufferCam = Camera("BufferCamera")
     lens = OrthographicLens()
     lens.setFilmSize(2, 2)
     lens.setFilmOffset(0, 0)
     lens.setNearFar(-1000, 1000)
     bufferCam.setLens(lens)
     bufferCam.setCullBounds(OmniBoundingVolume())
     return bufferCam
示例#17
0
 def create_instance(self, patch):
     if self.template is None:
         GpuPatchTerrainLayer.template = geometry.Patch(0.5)
     self.instance = NodePath('tile')
     bounds = OmniBoundingVolume()
     self.instance.node().setBounds(bounds)
     self.instance.node().setFinal(1)
     self.template.instanceTo(self.instance)
     self.instance.reparent_to(patch.instance)
示例#18
0
 def __init__(self):
     """ Constructs a new directional light. You have to set a
     direction for this light to work properly"""
     Light.__init__(self)
     DebugObject.__init__(self, "GIHelperLight")
     self.typeName = "GIHelperLight"
     self.targetLight = None
     self.filmSize = 50
     self.bounds = OmniBoundingVolume()
示例#19
0
 def create_instance(self):
     self.instance = NodePath("card")
     card_maker = CardMaker("card")
     card_maker.set_frame(-1, 1, -1, 1)
     node = card_maker.generate()
     self.card_instance = self.instance.attach_new_node(node)
     self.card_instance.setBillboardPointWorld()
     TransparencyBlend.apply(self.blend, self.instance)
     self.instance.node().setBounds(OmniBoundingVolume())
     self.instance.node().setFinal(True)
     return self.instance
示例#20
0
 def __node(self):
     # this function creates and returns particles' GeomNode
     points = GeomPoints(GeomEnums.UH_static)
     points.addNextVertices(self.__numPart)
     format_ = GeomVertexFormat.getEmpty()
     geom = Geom(GeomVertexData("abc", format_, GeomEnums.UH_static))
     geom.addPrimitive(points)
     geom.setBounds(OmniBoundingVolume())  # always render it
     node = GeomNode("node")
     node.addGeom(geom)
     return node
示例#21
0
 def _make_fullscreen_cam(self):
     """ Creates an orthographic camera for the buffer """
     buffer_cam = Camera("BufferCamera")
     lens = OrthographicLens()
     lens.set_film_size(2, 2)
     lens.set_film_offset(0, 0)
     lens.set_near_far(-100, 100)
     buffer_cam.set_lens(lens)
     buffer_cam.set_cull_bounds(OmniBoundingVolume())
     self._camera = self._node.attach_new_node(buffer_cam)
     self._region.set_camera(self._camera)
示例#22
0
 def __init__(self, water_options):
     self.water_options = water_options
     self.water_level = 0.0
     self.model = Globals.base.loader.load_model(
         "/$$rp/data/builtin_models/water/water_grid.bam")
     self.model.reparent_to(Globals.base.render)
     self.model.node().set_final(True)
     self.model.node().set_bounds(OmniBoundingVolume())
     self.model.set_two_sided(True)
     self.model.set_shader_input("waterHeight", self.water_level)
     self.model.set_mat(Mat4.identMat())
     self.model.clear_transform()
    def __init__(self, pipeline):
        DebugObject.__init__(self, "ProjectedWaterGrid")
        self.debug("Creating water grid")

        self.waterLevel = 0.0

        self.model = Globals.loader.loadModel(
            "Data/InternalModels/ScreenSpaceGrid.bam")
        self.model.reparentTo(Globals.base.render)
        self.model.node().setFinal(True)
        self.model.node().setBounds(OmniBoundingVolume())
        self.model.setTwoSided(True)
        self.model.setShaderInput("waterHeight", self.waterLevel)
        self.model.setMat(Mat4.identMat())
        self.model.clearTransform()

        foam = Globals.loader.loadTexture("Data/Textures/WaterFoam.png")
        self.model.setShaderInput("waterFoam", foam)

        self.manager = WaterManager()
        self.manager.setup()
        self.manager.update()

        self.model.setShaderInput("waterHeightfield",
                                  self.manager.getDisplacementTexture())
        self.model.setShaderInput("waterNormal",
                                  self.manager.getNormalTexture())

        # Set texture filter modes
        for tex in [
                foam,
                self.manager.getDisplacementTexture(),
                self.manager.getNormalTexture()
        ]:
            tex.setWrapU(SamplerState.WMRepeat)
            tex.setWrapU(SamplerState.WMRepeat)
            tex.setMinfilter(SamplerState.FTLinearMipmapLinear)
            tex.setMagfilter(SamplerState.FTLinearMipmapLinear)

        self.pipeline = pipeline

        self.pipeline.setEffect(
            self.model,
            "Effects/Water/ProjectedWater.effect",
            {
                # "transparent": True
                "castShadows": False
                # "tesselated": True
            })

        # pipeline.convertToPatches(self.model)
        pipeline.showbase.addTask(self.updateTask, "updateWater")
    def _makeFullscreenQuad(self):
        cm = CardMaker("BufferQuad")
        cm.setFrameFullscreenQuad()
        quad = NodePath(cm.generate())
        quad.setDepthTest(0)
        quad.setDepthWrite(0)
        quad.setAttrib(TransparencyAttrib.make(TransparencyAttrib.MNone))
        quad.setColor(Vec4(1, 0.5, 0.5, 1))

        # No culling check
        quad.node().setFinal(True)
        quad.node().setBounds(OmniBoundingVolume())
        quad.setBin("unsorted", 10)
        return quad
示例#25
0
    def loadViewModel(self):
        self.unloadViewModel()

        if self.SpecialVM and self.SpecialVMActor:
            modelName, anims = self.SpecialVMActor
            self.specialViewModel = Actor(modelName, anims)
            self.specialViewModel.setPos(self.SpecialVMOrigin)
            self.specialViewModel.setHpr(self.SpecialVMAngles)
            self.specialViewModel.setScale(self.SpecialVMScale)
            self.specialViewModel.setBlend(
                frameBlend=base.config.GetBool('interpolate-frames', False))
            if not self.SpecialVMCull:
                self.specialViewModel.node().setBounds(OmniBoundingVolume())
                self.specialViewModel.node().setFinal(1)
示例#26
0
    def __init__(self):
        """ Constructs a new directional light. You have to set a
        direction for this light to work properly"""
        Light.__init__(self)
        DebugObject.__init__(self, "DirectionalLight")
        self.typeName = "DirectionalLight"
        self.splitCount = 4
        self.pssmTargetCam = None
        self.pssmTargetLens = None
        self.pssmFarPlane = 100.0
        self.pssmSplitPow = 2.0
        self.updateIndex = 0

        # A directional light is always visible
        self.bounds = OmniBoundingVolume()
示例#27
0
    def _makeFullscreenQuad(self):
        """ Create a quad which fills the whole screen """
        cm = CardMaker("BufferQuad")
        cm.setFrameFullscreenQuad()
        quad = NodePath(cm.generate())

        quad.setDepthTest(False)
        quad.setDepthWrite(False)
        quad.setAttrib(TransparencyAttrib.make(TransparencyAttrib.MNone), 1000)
        quad.setColor(Vec4(1, 0.5, 0.5, 1))

        # Disable culling
        quad.node().setFinal(True)
        quad.node().setBounds(OmniBoundingVolume())
        quad.setBin("unsorted", 10)
        return quad
示例#28
0
    def load(self):
        self.fireSound = base.audio3d.loadSfx(self.sgFirePath)
        self.emptySound = base.audio3d.loadSfx(self.sgEmptyPath)
        self.reloadSound = base.audio3d.loadSfx(self.sgReloadPath)
        base.audio3d.attachSoundToObject(self.fireSound, self.avatar)
        base.audio3d.attachSoundToObject(self.emptySound, self.avatar)
        base.audio3d.attachSoundToObject(self.reloadSound, self.avatar)

        if self.isLocal():
            self.sgViewModel = Actor(self.sgActorDef[0], self.sgActorDef[1])
            self.sgViewModel.setPlayRate(self.Speed, "idle")
            self.sgViewModel.node().setBounds(OmniBoundingVolume())
            self.sgViewModel.node().setFinal(1)
            self.sgViewModel.setBlend(
                frameBlend=base.config.GetBool('interpolate-frames', False))
            self.sgViewModel.setH(180)
            self.fpMuzzleAttach = self.sgViewModel.exposeJoint(
                None, "modelRoot", "ValveBiped.muzzle")
示例#29
0
    def __init__(self,
                 use_sprites=True,
                 use_sizes=True,
                 points_size=2,
                 sprite=None,
                 background=None,
                 shader=None):
        self.gnode = GeomNode('starfield')
        self.use_sprites = use_sprites
        self.use_sizes = use_sizes
        self.background = background
        if shader is None:
            shader = BasicShader(lighting_model=FlatLightingModel(),
                                 point_shader=False)
        self.shader = shader

        self.reset()

        self.geom = self.makeGeom([], [], [])
        self.gnode.addGeom(self.geom)
        self.instance = NodePath(self.gnode)
        if self.use_sprites:
            if sprite is None:
                sprite = RoundDiskPointSprite()
            self.sprite = sprite
        else:
            self.sprite = SimplePoint(points_size)
        self.min_size = self.sprite.get_min_size()
        self.sprite.apply(self.instance)
        self.instance.setCollideMask(GeomNode.getDefaultCollideMask())
        self.instance.node().setPythonTag('owner', self)
        #TODO: Should not use ModelAppearance !
        self.appearance = ModelAppearance(vertex_color=True)
        if self.appearance is not None:
            self.appearance.bake()
            self.appearance.apply(self, self)
        if self.shader is not None:
            self.shader.apply(self, self.appearance)
        if self.use_sprites:
            self.instance.node().setBounds(OmniBoundingVolume())
            self.instance.node().setFinal(True)
        if self.background is not None:
            self.instance.setBin('background', self.background)
        self.instance.set_depth_write(False)
示例#30
0
 def apply_instance(self, instance):
     #print("Apply", self.get_name())
     if instance != self.instance:
         if self.instance is not None:
             self.instance.remove_node()
         self.instance = instance
     self.shape.set_clickable(self.clickable)
     self.shape.apply_owner()
     self.instance.reparentTo(self.context.world)
     instance.hide(self.AllCamerasMask)
     instance.show(self.default_camera_mask)
     if self.appearance is not None:
         #TODO: should be done somewhere else
         self.appearance.bake()
     if self.context.observer.has_scattering:
         self.context.observer.scattering.add_attenuated_object(self)
     self.instance.node().setBounds(OmniBoundingVolume())
     self.instance.node().setFinal(True)
     self.schedule_jobs()