当前位置: 首页>>代码示例>>Python>>正文


Python core.TextureStage类代码示例

本文整理汇总了Python中panda3d.core.TextureStage的典型用法代码示例。如果您正苦于以下问题:Python TextureStage类的具体用法?Python TextureStage怎么用?Python TextureStage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TextureStage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, name, resource):
        """Arguments:
        resource -- name of a directory in assets/skyboxes that contains 6
        images.
        """
        ManagedAsset.__init__(self, "sky")
        self.name = name

        tex = None
        for ext in ("png", "jpg", "tga"):
            f = Filename("skyboxes/{}/0.{}".format(resource, ext))
            if f.resolveFilename(getModelPath().getValue()):
                tex = TexturePool.loadCubeMap("skyboxes/{}/#.{}".format(resource, ext))
                break

        if tex is None:
            raise ResourceLoadError("assets/skyboxes/%s" % resource,
                                 "maybe wrong names or different extensions?")
        
        self.node = loader.loadModel("misc/invcube")
        self.node.clearTexture()
        self.node.clearMaterial()
        self.node.setScale(10000)
        self.node.setTwoSided(True)
        self.node.setBin('background', 0)
        self.node.setDepthTest(False)
        self.node.setDepthWrite(False)
        self.node.setLightOff()
        self.node.setTexGen(TextureStage.getDefault(), TexGenAttrib.MWorldPosition)
        self.node.setTexProjector(TextureStage.getDefault(), render, self.node);
        self.node.setTexture(tex, 1)
        self.node.flattenLight()
        #self.node.setCompass()  # not needed with world-space-UVs
        self.addTask(self.update, "sky repositioning", sort=10,
                     taskChain="world")
开发者ID:hubertgrzeskowiak,项目名称:Azure--Infinite-Skies,代码行数:35,代码来源:sky.py

示例2: setup

    def setup(self):
        self.tex1 = MovieTexture('videos/saturn5_apollo_launch.mp4')
        assert self.tex1.read('videos/saturn5_apollo_launch.mp4')
        self.tex2 = MovieTexture('videos/boards_eye_view.mp4')
        assert self.tex2.read('videos/boards_eye_view.mp4')

        self.cm1 = CardMaker('saturn')
        self.cm1.setFrameFullscreenQuad()
        self.cm1.setUvRange(self.tex1)
        self.card1 = NodePath(self.cm1.generate())
        self.card1.reparentTo(self.path)
        self.card1.setPos(0,0,10)
        self.card1.setP(50)

        self.cm2 = CardMaker('board')
        self.cm2.setFrameFullscreenQuad()
        self.cm2.setUvRange(self.tex2)
        self.card2 = NodePath(self.cm2.generate())
        self.card2.reparentTo(self.path)
        self.card2.setPos(0,0,-10)
        self.card2.setP(-50)

        self.card1.setTexture(self.tex1)
        self.card1.setTexScale(TextureStage.getDefault(), self.tex1.getTexScale())
        self.card2.setTexture(self.tex2)
        self.card2.setTexScale(TextureStage.getDefault(), self.tex2.getTexScale())

        self.card1.setScale(10)
        self.card2.setScale(10)
开发者ID:indygfx,项目名称:opticfoo,代码行数:29,代码来源:firsttry.py

示例3: makeTextureMap

 def makeTextureMap(self):
     '''Citymania function that generates and sets the 4 channel texture map'''
     self.colorTextures = []
     for terrain in self.terrains:
         terrain.getRoot().clearTexture()
         heightmap = terrain.heightfield()
         colormap = PNMImage(heightmap.getXSize()-1, heightmap.getYSize()-1)
         colormap.addAlpha()
         slopemap = terrain.makeSlopeImage()
         for x in range(0, colormap.getXSize()):
             for y in range(0, colormap.getYSize()):
                 # Else if statements used to make sure one channel is used per pixel
                 # Also for some optimization
                 # Snow. We do things funky here as alpha will be 1 already.
                 if heightmap.getGrayVal(x, y) < 200:
                     colormap.setAlpha(x, y, 0)
                 else:
                     colormap.setAlpha(x, y, 1)
                 # Beach. Estimations from http://www.simtropolis.com/omnibus/index.cfm/Main.SimCity_4.Custom_Content.Custom_Terrains_and_Using_USGS_Data
                 if heightmap.getGrayVal(x,y) < 62:
                     colormap.setBlue(x, y, 1)
                 # Rock
                 elif slopemap.getGrayVal(x, y) > 170:
                     colormap.setRed(x, y, 1)
                 else:
                     colormap.setGreen(x, y, 1)
         colorTexture = Texture()
         colorTexture.load(colormap)
         colorTS = TextureStage('color')
         colorTS.setSort(0)
         colorTS.setPriority(1)
         self.colorTextures.append((colorTexture, colorTS))
开发者ID:croxis,项目名称:CityMania,代码行数:32,代码来源:PagedGeoMipTerrain.py

示例4: generateSurfaceTextures

 def generateSurfaceTextures(self):
     # Textureize
     self.grassTexture = loader.loadTexture("Textures/grass.png")
     self.grassTS = TextureStage('grass')
     self.grassTS.setSort(1)
     
     self.rockTexture = loader.loadTexture("Textures/rock.jpg")
     self.rockTS = TextureStage('rock')
     self.rockTS.setSort(2)
     self.rockTS.setCombineRgb(TextureStage.CMAdd, TextureStage.CSLastSavedResult, TextureStage.COSrcColor, TextureStage.CSTexture, TextureStage.COSrcColor)
     
     self.sandTexture = loader.loadTexture("Textures/sand.jpg")
     self.sandTS = TextureStage('sand')
     self.sandTS.setSort(3)
     self.sandTS.setPriority(5)
     
     self.snowTexture = loader.loadTexture("Textures/ice.png")
     self.snowTS = TextureStage('snow')
     self.snowTS.setSort(4)
     self.snowTS.setPriority(0)
     
     # Grid for city placement and guide and stuff
     self.gridTexture = loader.loadTexture("Textures/grid.png")
     self.gridTexture.setWrapU(Texture.WMRepeat)
     self.gridTexture.setWrapV(Texture.WMRepeat)
     self.gridTS = TextureStage('grid')
     self.gridTS.setSort(5)
     self.gridTS.setPriority(10)
开发者ID:croxis,项目名称:CityMania,代码行数:28,代码来源:environment.py

示例5: loadPrisonCrater

def loadPrisonCrater():
    ## Sky color
    base.win.setClearColor(Vec4(.46,.824,.904,1))

    ## Load Ground
    sand = loader.loadModel("data/models/sand.bam")
    sand.reparentTo(render)
    sand.setTexScale(TextureStage.getDefault(),5000,5000)

    craterwalls = loader.loadModel("data/models/craterwalls.bam")
    craterwalls.reparentTo(render)
    craterwalls.setTexScale(TextureStage.getDefault(),500,50)

    ## World Effects
    fog = Fog("Fog")
    fog.setColor(255,215,143)
    fog.setExpDensity(.0000001)
    render.setFog(fog)

    alight = render.attachNewNode(AmbientLight("Abient"))
    alight.node().setColor(Vec4(.9,.9,.9,1))
    render.setLight(alight)

    sun = DirectionalLight('Sun')
    sun.setColor(Vec4(1,1,1,1))
    sunNP = render.attachNewNode(sun)
    sunNP.setPos(0,0,4000)
    sunNP.setHpr(0,-90,0)
    render.setLight(sunNP)
开发者ID:DDH-Harding,项目名称:maleficium,代码行数:29,代码来源:world.py

示例6: __apply_Textures

 def __apply_Textures(self, recipe, tex_dict):
     for i, ter_dict in enumerate(recipe['terrains']):
         tex_img = PNMImage()
         tex_img.read(Filename("{}/tex/{}".format(recipe['planet_path'], ter_dict['texture'])))
         tex = Texture()
         tex.load(tex_img)
         tex.setMinfilter(Texture.FTLinear)
         ts = TextureStage(str(i))
         ts.setSort(i)
         self.NP.setTexture(ts, tex, i*10)
开发者ID:svfgit,项目名称:solex,代码行数:10,代码来源:model.py

示例7: makeRenderState

def makeRenderState(material = None, diffuseTexture=None, normalTexture=None, glowTexture=None):
	n = NodePath("n")
	
	if not material:
		material = makeMaterial((0,0,0,1), (1,1,1,1), (0.01,0.01,0.01,1), 1, (1,1,1,1))
	
	n.setMaterial(material)
	
	if diffuseTexture:
		tsDiffuse = TextureStage('diffuse')
		tsDiffuse.setMode(TextureStage.MModulate)
		n.setTexture(tsDiffuse, diffuseTexture)
		
	if glowTexture:
		tsGlow = TextureStage('glow')
		tsGlow.setMode(TextureStage.MGlow)
		n.setTexture(tsGlow, glowTexture)
		
	if normalTexture:
		tsNormal = TextureStage('normal')
		tsNormal.setMode(TextureStage.MNormal)
		n.setTexture(tsNormal, normalTexture)
	
	# weird bugs :|
	#n.setTransparency(True)
	#n.setColorOff()
	return n.getState()
开发者ID:arikel,项目名称:PPARPG,代码行数:27,代码来源:meshUtils.py

示例8: patchInvertDDSV

def patchInvertDDSV(np,tex,debug=False):
    from panda3d.core import Texture
    from panda3d.core import TextureStage
    cmpr = tex.getCompression()
    if cmpr == Texture.CMDxt1 or cmpr == Texture.CMDxt5:
        scale2d = np.getTexScale( TextureStage.getDefault() )
        scale2d[1] = -scale2d[1]
        np.setTexScale( TextureStage.getDefault(), scale2d )
    else:
        if debug:
            print( " NOT INVERTING.. type was " + str(tex.getCompression()))
开发者ID:aportner,项目名称:panda-zonewalk,代码行数:11,代码来源:polygroup.py

示例9: setOwnerTextures

 def setOwnerTextures(self):
     self.ownerview = True
     root = self.terrain.getRoot()
     root.clearShader()
     root.clearTexture()
     cityTexture = Texture()
     cityTexture.load(self.citymap)
     cityTS = TextureStage('citymap')
     cityTS.setSort(0)
     root.setTexture( self.gridTS, self.gridTexture ) 
     root.setTexScale(self.gridTS, self.terrain.xchunks, self.terrain.ychunks)
     root.setTexture(cityTS, cityTexture, 1)
开发者ID:croxis,项目名称:CityMania,代码行数:12,代码来源:environment.py

示例10: flipTexture

 def flipTexture(self):
     """ Sets the texture coordinates of the texture to the current frame"""
     sU = self.offsetX * self.repeatX
     sV = self.offsetY * self.repeatY
     oU = 0 + self.frames[self.currentFrame].col * self.uSize
     oV = 1 - self.frames[self.currentFrame].row * self.vSize - self.offsetY
     if self.flip['x']:
         sU *= -1
         oU = self.uSize + self.frames[self.currentFrame].col * self.uSize
     if self.flip['y']:
         sV *= -1
         oV = 1 - self.frames[self.currentFrame].row * self.vSize
     self.node.setTexScale(TextureStage.getDefault(), sU, sV)
     self.node.setTexOffset(TextureStage.getDefault(), oU, oV)
开发者ID:gaconkzk,项目名称:tethical,代码行数:14,代码来源:Sprite2d.py

示例11: initSwitchSigns

 def initSwitchSigns(self):
     self.switchSigns = []
     for i in range(11):
         cm = CardMaker('card%d'%i)
         cm.setColor(0,0,0,0)
         cm.setFrame(-0.5, 0.5, -0.5, 0.5)
         card = self.level.attachNewNode(cm.generate())
         card.setAttrib(TransparencyAttrib.make(TransparencyAttrib.M_alpha))
         tex = loader.loadTexture('%d.png'%i)
         ts = TextureStage('ts')
         ts.setMode(TextureStage.MReplace)
         card.setTexture(ts, tex)
         card.setEffect(BillboardEffect.makePointEye())
         card.hide()
         self.switchSigns.append(card)
开发者ID:grimfang,项目名称:owp_ajaw,代码行数:15,代码来源:level01.py

示例12: setupTexture

    def setupTexture(self):
        """
        This is the overlay/decal/etc. which contains the typed characters.

        The texture size and the font size are currently tied together.
        :return:
        """
        self.texImage = PNMImage(1024, 1024)
        self.texImage.addAlpha()
        self.texImage.fill(1.0)
        self.texImage.alphaFill(1.0)

        self.tex = Texture('typing')
        self.tex.setMagfilter(Texture.FTLinear)
        self.tex.setMinfilter(Texture.FTLinear)

        self.typingStage = TextureStage('typing')
        self.typingStage.setMode(TextureStage.MModulate)

        self.tex.load(self.texImage)

        # ensure we can quickly update subimages
        self.tex.setKeepRamImage(True)

        # temp for drawing chars
        self.chImage = PNMImage(*self.fontCharSize)
开发者ID:eswartz,项目名称:panda3d-stuff,代码行数:26,代码来源:typist.py

示例13: on_pick

	def on_pick(self):
		if not self._update_pick_ray(): return

		# traverse scene graph and determine nearest selection (if pickable)
		self.pick_traverser.traverse(self.board_renderer.base.render)
		self.pick_queue.sortEntries()
		if not self.pick_queue.getNumEntries(): return
		node = self.pick_queue.getEntry(0).getIntoNodePath().findNetTag('pickable')
		if node.isEmpty() or node.getTag('pickable') == 'False': return

		# add some color
		ts = TextureStage('ts')
		ts.setMode(TextureStage.MModulate)
		colors = list(Game.player_colors)
		colors.remove('white')
		node.setTexture(ts, self.board_renderer.tileset.load_texture('textures/player%s.png' % random.choice(colors).capitalize()))
开发者ID:mbr,项目名称:project-bamboo,代码行数:16,代码来源:boardtest.py

示例14: playVideo

    def playVideo(self, video):
        # check if it is loadable
        try:
            # load the video texture
            self.tex = MovieTexture("MovieTexture")
            #print video
            self.tex.read(video)
            # Set up a fullscreen card to set the video texture on it.
            cm = CardMaker("Movie Card")
            cm.setFrameFullscreenQuad()
            cm.setUvRange(self.tex)
            self.card = NodePath(cm.generate())
            self.card.reparentTo(base.render2d)
            self.card.setTexture(self.tex)
            self.card.setTexScale(TextureStage.getDefault(),
                                  self.tex.getTexScale())

            # load the video
            self.sound = loader.loadSfx(video)

            # Synchronize the video to the sound.
            self.tex.synchronizeTo(self.sound)

            # play the video and audio
            self.sound.play()
            # start the task which checks if the video is finished
            taskMgr.add(self.isVideoFinish, "task_isVideoFinised")
        except:
            logging.error("Failed to load video: %s %s", video, sys.exc_info())
            self.stopVideo()
            base.messenger.send(self.vidFinEvt)
开发者ID:grimfang,项目名称:rising_reloaded,代码行数:31,代码来源:movieManager.py

示例15: createFadeableImage

 def createFadeableImage(img, tsName, big=False):
     cm = CardMaker("FadableCard")
     cm.setFrame(-1, 1, -1, 1)
     image = NodePath(cm.generate())
     image.setTransparency(TransparencyAttrib.MAlpha)
     imageTex = loader.loadTexture(img)
     imageTs = TextureStage(tsName)
     imageTs.setMode(TextureStage.MReplace)
     image.setTexture(imageTs, imageTex)
     image.reparentTo(render2d)
     if big:
         image.setScale(0.75)
     else:
         image.setScale(0.5)
     image.setPos(0, 0, 0.25)
     image.hide()
     return image
开发者ID:grimfang,项目名称:pyweek21,代码行数:17,代码来源:world.py


注:本文中的panda3d.core.TextureStage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。