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


Python PandaModules.Texture类代码示例

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


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

示例1: update

    def update(self, task):
        if base.mouseWatcherNode.hasMouse():
            (x, y) = self._translateRelativeCoordinates(
                base.mouseWatcherNode.getMouseX(), base.mouseWatcherNode.getMouseY()
            )
            if self.mx - x != 0 or self.my - y != 0:
                self.webView.injectMouseMove(x, y)
                self.mx = x
                self.my = y

            if self.webView.isDirty():
                self.webView.render(self.imgBuffer.buffer_info()[0], WEB_WIDTH * 4, 4)
                Texture.setTexturesPower2(2)
                textureBuffer = self.guiTex.modifyRamImage()
                textureBuffer.setData(self.imgBuffer.tostring())
                if self.useHalfTexture:
                    self.guiTex.store(self.fullPnmImage)
                    self.leftPnmImage.copySubImage(self.fullPnmImage, 0, 0, 0, 0, WEB_HALF_WIDTH, WEB_HEIGHT)
                    self.rightPnmImage.copySubImage(
                        self.fullPnmImage, 0, 0, WEB_HALF_WIDTH, 0, WEB_HALF_WIDTH, WEB_HEIGHT
                    )
                    self.leftGuiTex.load(self.leftPnmImage)
                    self.rightGuiTex.load(self.rightPnmImage)
                    self.quad.hide()

                Texture.setTexturesPower2(1)

            GlobalWebcore.update()

        return Task.cont
开发者ID:ponyboy837,项目名称:Toontown-2003-Server,代码行数:30,代码来源:HtmlView.py

示例2: make

	def make(self):
		TerrainTile.make(self)
		self.makeSlopeMap()
		textureMapper = self.terrain.texturer.textureMapper
		
		#try to read textureMaps
		readTexMaps = True
		texNum = 0
		for tex in textureMapper.textures:
			texNum += 1
			fileName = "maps/textures/" + self.name + "+_texture" + str(texNum) + ".png"
			if not tex.image.read(Filename(fileName)):
				readTexMaps = False
				
		#otherwise calculate textureMaps
		if not readTexMaps:
			self.terrain.texturer.textureMapper.calculateTextures(self)
			
		#copy textureMaps to this terrainTile and save if necessary
		texNum = 0
		for tex in self.terrain.texturer.textureMapper.textures:
			texNum += 1
			self.textureMaps.append(tex.image)
			if not readTexMaps:
				tex.image.write(Filename("maps/textures/" + self.name + "+_texture" + str(texNum) + ".png"))
				
		#load textureMaps as actual textures for the shaders use
		num = 0
		for tex in self.textureMaps:
			num += 1
			newTexture = Texture()
			newTexture.load(tex)
			ts = TextureStage('alp' + str(num))
			self.getRoot().setTexture(ts, newTexture)
开发者ID:Vetrik,项目名称:python-utils,代码行数:34,代码来源:terraintile.py

示例3: PerlinTest

class PerlinTest(DirectObject):
	
	
	def __init__(self):
		self.myTexture = Texture()
		self.imageObject = OnscreenImage(image = self.myTexture, pos = (0, 0, 0))
		self.run()
		self.accept("arrow_up", self.run)
		
	
	def run(self):
		size = 256
		pb = Perlin.Perlin( persistance = 0.500, smooth = False, seed = random.random() )
		myImage2 = pb.imgNoise2D(size,True)
		
		myImage=PNMImage(size,size)
		myImage.makeGrayscale()
		myImage.setMaxval( (2<<16)-1 )
		myImage.fill(0.5)
		line = lineDrawer.LineDrawer(myImage,(42,180),(13,253),13)
		
		for x in range(size):
			for y in range(size):
				gray = myImage.getGray(x,y) - 0.5
				gray = gray + (myImage2.getGray(x,y) - 0.5)
				myImage.setGray(x,y,gray + 0.5)
		

		self.myTexture.load(myImage)
开发者ID:borgified,项目名称:Hockfire,代码行数:29,代码来源:lineTest.py

示例4: PerlinTest

class PerlinTest(DirectObject):
	
	
	def __init__(self):
		self.myTexture = Texture()
		self.imageObject = OnscreenImage(image = self.myTexture, pos = (0, 0, 0))
		self.run()
		self.accept("arrow_up", self.run)
		
	
	def run(self):
		size = 1024
		j = random.random()
		p1 = Perlin.Perlin( persistance = 0.500, smooth = False, seed = j )
		p2 = Perlin.Perlin( persistance = 0.000, smooth = False, seed = j )
		pb = Perlin.Perlin( persistance = 0.500, smooth = False, seed = random.random() )
		myImage = p1.imgNoise2D(size,True)
		myImage2 = p2.imgNoise2D(size,True)
		myImage3 = pb.imgNoise2D(size,True)
		
		for x in range(size):
			for y in range(size):
				gray = (myImage.getGray(x,y) - 0.5) * myImage3.getGray(x,y)
				gray = gray + (myImage2.getGray(x,y) - 0.5) * (1.0 - myImage3.getGray(x,y))
				myImage.setGray(x,y,gray + 0.5)
		
		self.myTexture.load(myImage)
开发者ID:borgified,项目名称:Hockfire,代码行数:27,代码来源:PerlinTest.py

示例5: get_heightmap_tex

    def get_heightmap_tex(self, size, filename = None):
        """Generate texture of map
        """
        mod = self.world_size / size
        image = PNMImage(size, size)
        for x in xrange(size):
            for y in xrange(size):
                px = x * mod
                py = y * mod
                height = self[px, py]
                color = height / 50
                r = 0
                g = 0
                b = 0
                if color > 255:
                    color = 255
                if color < 0:
                    color = abs(color)
                    b = color
                else:
                    g = color
                image.setPixel(x, y, (r, g, b))

        if filename != None:
            image.write(filename)

        #for x in xrange(-1, 2):
            #for y in xrange(-1, 2):
               #image.setPixel(int(world.chunks_map.charX)+x, int(world.chunks_map.charY)+y, (255, 0, 0))

        texture = Texture()
        texture.load(image)
        return texture
开发者ID:viatoriche,项目名称:suber,代码行数:33,代码来源:map3d.py

示例6: generate_map_texture

def generate_map_texture(map_tree, factor):
    map_world = map_tree.map3d
    size = map_world.size / factor
    image = PNMImage(size, size)
    #image.fill(0,0,0)
    for x in xrange(size):
        for y in xrange(size):
            px = x * factor
            py = y * factor
            if map_world[(px, py)] <= map_world.water_z:
                image.setPixel(x, y, (0, 0, 100))
            else:
                image.setPixel(x, y, (0, 100, 0))
    char_x, char_y, char_z = map_tree.coords
    char_x = char_x / factor
    char_y = char_y / factor
    image.setPixel(char_x, char_y, (255, 0, 0))
    #if factor>2:
        #image.setPixel(char_x, char_y, (255, 0, 0))
    #else:
        #for x in xrange(char_x - 1, char_x+2):
            #cx = x
            #if cx > size-1: cx = size-1
            #if cx < 0: cx = 0
            #for y in xrange(char_y - 1, char_y+2):
                #cy = y
                #if cy > size-1: cy = size-1
                #if cy < 0: cy = 0
                #image.setPixel(cx, cy, (255, 0, 0))
    texture = Texture()
    texture.load(image)
    return texture
开发者ID:viatoriche,项目名称:suber,代码行数:32,代码来源:world.py

示例7: add_render_texture

    def add_render_texture(output, mode=None, bitplane=None):
        """ Similar to GraphicsOutput's addRenderTexture. 

        ** Possible mode values **
        GraphicsOutput.RTMNone
        GraphicsOutput.RTMBindOrCopy
        GraphicsOutput.RTMCopyTexture
        GraphicsOutput.RTMCopyRam
        GraphicsOutput.RTMTriggeredCopyTexture
        GraphicsOutput.RTMTriggeredCopyRam

        ** Possible bitplane values **
        GraphicsOutput.RTPStencil 	
        GraphicsOutput.RTPDepthStencil 	
        GraphicsOutput.RTPColor 	
        GraphicsOutput.RTPAuxRgba0 	
        GraphicsOutput.RTPAuxRgba1 	
        GraphicsOutput.RTPAuxRgba2 	
        GraphicsOutput.RTPAuxRgba3 	
        GraphicsOutput.RTPAuxHrgba0 	
        GraphicsOutput.RTPAuxHrgba1 	
        GraphicsOutput.RTPAuxHrgba2 	
        GraphicsOutput.RTPAuxHrgba3 	
        GraphicsOutput.RTPAuxFloat0 	
        GraphicsOutput.RTPAuxFloat1 	
        GraphicsOutput.RTPAuxFloat2 	
        GraphicsOutput.RTPAuxFloat3 	
        GraphicsOutput.RTPDepth 	
        GraphicsOutput.RTPCOUNT

        """

        if mode is None:
            mode = GraphicsOutput.RTMBindOrCopy
        elif isinstance(mode, str):
            mode = getattr(GraphicsOutput, mode)

        if bitplane is None:
            bitplane = GraphicsOutput.RTPColor
        elif isinstance(bitplane, str):
            bitplane = getattr(GraphicsOutput, bitplane)

        tex = Texture()
        tex.setFormat(Texture.FLuminance)
            
        # Add the texture to the buffer
        output.addRenderTexture(tex, mode, bitplane)
        # Get a handle to the texture
        assert tex == output.getTexture(), "Texture wasn't created properly."

        return tex
开发者ID:acs1903,项目名称:genthor,代码行数:51,代码来源:lightbase.py

示例8: __init__

    def __init__(self, scene=base.render, ambient=0.2, hardness=16, fov=40, near=10, far=100):
        """Create an instance of this class to initiate shadows.
    Also, a shadow casting 'light' is created when this class is called.
    The first parameter is the nodepath in the scene where you
    want to apply your shadows on, by default this is render."""

        # Read and store the function parameters
        self.scene = scene
        self.__ambient = ambient
        self.__hardness = hardness

        # By default, mark every object as textured.
        self.flagTexturedObject(self.scene)

        # Create the buffer plus a texture to store the output in
        buffer = createOffscreenBuffer(-3)
        depthmap = Texture()
        buffer.addRenderTexture(depthmap, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPColor)

        # Set the shadow filter if it is supported
        if base.win.getGsg().getSupportsShadowFilter():
            depthmap.setMinfilter(Texture.FTShadow)
            depthmap.setMagfilter(Texture.FTShadow)

        # Make the camera
        self.light = base.makeCamera(buffer)
        self.light.node().setScene(self.scene)
        self.light.node().getLens().setFov(fov)
        self.light.node().getLens().setNearFar(near, far)

        # Put a shader on the Light camera.
        lci = NodePath(PandaNode("lightCameraInitializer"))
        lci.setShader(loader.loadShader("caster.sha"))
        self.light.node().setInitialState(lci.getState())

        # Put a shader on the Main camera.
        mci = NodePath(PandaNode("mainCameraInitializer"))
        mci.setShader(loader.loadShader("softshadow.sha"))
        base.cam.node().setInitialState(mci.getState())

        # Set up the blurring buffers, one that blurs horizontally, the other vertically
        # blurXBuffer = makeFilterBuffer(buffer, "Blur X", -2, loader.loadShader("blurx.sha"))
        # blurYBuffer = makeFilterBuffer(blurXBuffer, "Blur Y", -1, loader.loadShader("blury.sha"))

        # Set the shader inputs
        self.scene.setShaderInput("light", self.light)
        # self.scene.setShaderInput("depthmap", blurYBuffer.getTexture())
        self.scene.setShaderInput("depthmap", buffer.getTexture())
        self.scene.setShaderInput("props", ambient, hardness, 0, 1)
开发者ID:Williangalvani,项目名称:panda_robot_thing_again,代码行数:49,代码来源:shadowManager.py

示例9: PandaHandler

class PandaHandler(DirectObject):

    def __init__(self):
        DirectObject.__init__(self)
        # base.disableMouse()
        # base.cam.setPos(0, -28, 6)
        self.testModel = loader.loadModel('panda')
        self.testModel.reparentTo(render)
        # print self.testModel.getPos()
        self.rotateInterval = LerpHprInterval(self.testModel, 3, Point3(360, 0, 0))
        self.rotateInterval.loop()

        self.screenTexture = Texture()
        self.screenTexture.setMinfilter(Texture.FTLinear)
        base.win.addRenderTexture(self.screenTexture, GraphicsOutput.RTMCopyRam)
开发者ID:kit-ipe,项目名称:sensorsEditor,代码行数:15,代码来源:m.py

示例10: setupTexture

 def setupTexture(self):
     cm = CardMaker('quadMaker')
     cm.setColor(1.0, 1.0, 1.0, 1.0)
     aspect = base.camLens.getAspectRatio()
     htmlWidth = 2.0 * aspect * WEB_WIDTH_PIXELS / float(WIN_WIDTH)
     htmlHeight = 2.0 * float(WEB_HEIGHT_PIXELS) / float(WIN_HEIGHT)
     cm.setFrame(-htmlWidth / 2.0, htmlWidth / 2.0, -htmlHeight / 2.0, htmlHeight / 2.0)
     bottomRightX = WEB_WIDTH_PIXELS / float(WEB_WIDTH + 1)
     bottomRightY = WEB_HEIGHT_PIXELS / float(WEB_HEIGHT + 1)
     cm.setUvRange(Point2(0, 1 - bottomRightY), Point2(bottomRightX, 1))
     card = cm.generate()
     self.quad = NodePath(card)
     self.quad.reparentTo(self.parent)
     self.guiTex = Texture('guiTex')
     self.guiTex.setupTexture(Texture.TT2dTexture, WEB_WIDTH, WEB_HEIGHT, 1, Texture.TUnsignedByte, Texture.FRgba)
     self.guiTex.setMinfilter(Texture.FTLinear)
     self.guiTex.setKeepRamImage(True)
     self.guiTex.makeRamImage()
     self.guiTex.setWrapU(Texture.WMRepeat)
     self.guiTex.setWrapV(Texture.WMRepeat)
     ts = TextureStage('webTS')
     self.quad.setTexture(ts, self.guiTex)
     self.quad.setTexScale(ts, 1.0, -1.0)
     self.quad.setTransparency(0)
     self.quad.setTwoSided(True)
     self.quad.setColor(1.0, 1.0, 1.0, 1.0)
     self.calcMouseLimits()
开发者ID:AdrianF98,项目名称:Toontown-Rewritten,代码行数:27,代码来源:HtmlView.py

示例11: get_map_2d_tex

 def get_map_2d_tex(self, map2d, factor = 1):
     """Generate texture for map2d, factor - for size [size / factor]
     """
     size = map2d.size / factor
     image = PNMImage(size, size)
     for x in xrange(size):
         for y in xrange(size):
             px = x * factor
             py = y * factor
             if map2d[(px, py)] <= map2d.water_z:
                 image.setPixel(x, y, (0, 0, 100))
             else:
                 image.setPixel(x, y, (0, 100, 0))
     texture = Texture()
     texture.load(image)
     return texture
开发者ID:viatoriche,项目名称:suber,代码行数:16,代码来源:textures.py

示例12: makeTextureBuffer

 def makeTextureBuffer(name, xSize, ySize, tex = None, toRam = False, fbp = None):
   """Copied from graphicsOutput.cxx and pythonified."""
   if fbp == None:
     fbp = FrameBufferProperties()
     fbp.setRgbColor(1)
     fbp.setDepthBits(1)
   
   flags = GraphicsPipe.BFRefuseWindow;
   if hasattr(GraphicsPipe, "BFSizePower2") and Texture.getTexturesPower2() != ATSNone:
     flags |= GraphicsPipe.BFSizePower2
   if tex != None and tex.getTextureType() == Texture.TTCubeMap:
     flags |= GraphicsPipe.BFSizeSquare
   
   buffer = WindowManager.gsg.getEngine().makeOutput(base.pipe, name, 0,
              fbp, WindowProperties.size(xSize, ySize), flags, WindowManager.gsg)
   if WindowManager.gsg == None:
     WindowManager.gsg = buffer.getGsg()
   
   if buffer != None:
     if toRam:
       buffer.addRenderTexture(tex, RTMCopyRam);
     else:
       buffer.addRenderTexture(tex, RTMBindOrCopy);
     return buffer
   
   return None
开发者ID:KillerGoldFisch,项目名称:panda3d-editor,代码行数:26,代码来源:pWindow.py

示例13: get_map_3d_tex

    def get_map_3d_tex(self, size, filename = None, charPos = None):
        """Generate texture of map
        """
        mod = self.world_size / size
        image = PNMImage(size, size)
        for x in xrange(size):
            for y in xrange(size):
                px = x * mod
                py = y * mod
                height = self[px, py]
                if height <= 0:
                    color = (abs(height) / 50) + 50
                    if color > 255:
                        color = 255
                    image.setPixel(x, y, (0, 0, 255-color))
                else:
                    if height <= self.config.low_mount_level[1]:
                        color = height / 20
                        r = 0
                        g = 50+color
                        b = 0
                        image.setPixel(x, y, (r, g, b))
                    elif height > self.config.low_mount_level[1]:
                        color = height / 50
                        r = color
                        g = color
                        b = color
                        if r > 255:
                            r = 255
                        if g > 255:
                            r = 255
                        if b > 255:
                            b = 255
                        image.setPixel(x, y, (r, g, b))

        if filename != None:
            image.write(filename)

        if charPos != None:
            charX, charY = charPos
            for x in xrange(-1, 2):
                for y in xrange(-1, 2):
                   image.setPixel(int(charX/mod)+x, int(charY/mod)+y, (255, 0, 0))

        texture = Texture()
        texture.load(image)
        return texture
开发者ID:viatoriche,项目名称:suber,代码行数:47,代码来源:map3d.py

示例14: __createBuffer

 def __createBuffer(self):
   ''' create the buffer we render in the background into '''
   print "I: TexturePainter.__createBuffer"
   # the window has been modified
   if WindowManager.activeWindow:
     # on window resize there seems to be never a active window
     win = WindowManager.activeWindow.win
   else:
     win = base.win
   
   # get the window size
   self.windowSizeX = win.getXSize()
   self.windowSizeY = win.getYSize()
   
   # create a buffer in which we render the model using a shader
   self.paintMap = Texture()
   # 1.5.4 cant handle non power of 2 buffers
   self.modelColorBuffer = createOffscreenBuffer(-3, TEXTUREPAINTER_BACKGROUND_BUFFER_RENDERSIZE[0], TEXTUREPAINTER_BACKGROUND_BUFFER_RENDERSIZE[1]) #self.windowSizeX, self.windowSizeY)
   self.modelColorBuffer.addRenderTexture(self.paintMap, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPColor)
   self.modelColorCam = base.makeCamera(self.modelColorBuffer, lens=base.cam.node().getLens(), sort=1)
   
   # Create a small buffer for the shader program that will fetch the point from the texture made
   # by the self.modelColorBuffer
   self.colorPickerImage = PNMImage()
   self.colorPickerTex = Texture()
   self.colorPickerBuffer = base.win.makeTextureBuffer("color picker buffer", 2, 2, self.colorPickerTex, True)
   
   self.colorPickerScene = NodePath('color picker scene')
   
   self.colorPickerCam = base.makeCamera(self.colorPickerBuffer, lens=base.cam.node().getLens(), sort=2)
   self.colorPickerCam.reparentTo(self.colorPickerScene)
   self.colorPickerCam.setY(-2)
   
   cm = CardMaker('color picker scene card')
   cm.setFrameFullscreenQuad()
   pickerCard = self.colorPickerScene.attachNewNode(cm.generate())
   
   loadPicker = NodePath(PandaNode('pointnode'))
   loadPicker.setShader(Shader.make(COLOR_PICKER_SHADER), 10001)
   
   # Feed the paintmap from the paintBuffer to the shader and initial mouse positions
   self.colorPickerScene.setShaderInput('paintmap', self.paintMap)
   self.colorPickerScene.setShaderInput('mousepos', 0, 0, 0, 1)
   self.colorPickerCam.node().setInitialState(loadPicker.getState())
开发者ID:KillerGoldFisch,项目名称:panda3d-editor,代码行数:44,代码来源:pTexturePainter.py

示例15: _createMaskTextureCard

    def _createMaskTextureCard(self):
        self._maskImage = PNMImage(self._maskResolution, self._maskResolution, 4)
        for x in xrange(self._maskResolution):
            for y in xrange(self._maskResolution):
                self._maskImage.setXelA(x, y, 0, 0, 0, 1)

        self.maskTexture = Texture('maskTexture')
        self.maskTexture.setupTexture(Texture.TT2dTexture, self._maskResolution, self._maskResolution, 1, Texture.TUnsignedByte, Texture.FRgba)
        self.maskTexture.setMinfilter(Texture.FTLinear)
        self.maskTexture.setWrapU(Texture.WMClamp)
        self.maskTexture.setWrapV(Texture.WMClamp)
        self.maskTexture.load(self._maskImage)
        base.graphicsEngine.renderFrame()
        cm = CardMaker('mask_cardMaker')
        cm.setFrame(-1.1, 1.1, -1.1, 1.1)
        mask = self.attachNewNode(cm.generate())
        mask.setTexture(self.maskTexture, 1)
        mask.setTransparency(1)
        return mask
开发者ID:Keithybub,项目名称:ToonTownReviveOld,代码行数:19,代码来源:MazeMapGui.py


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