本文整理汇总了Python中pandac.PandaModules.TextureStage类的典型用法代码示例。如果您正苦于以下问题:Python TextureStage类的具体用法?Python TextureStage怎么用?Python TextureStage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextureStage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
self.sphere = loader.loadModel("InvertedSphere.egg")
# Load a sphere with a radius of 1 unit and the faces directed inward.
self.sphere.setTexGen(TextureStage.getDefault(), TexGenAttrib.MWorldPosition)
self.sphere.setTexProjector(TextureStage.getDefault(), render, self.sphere)
self.sphere.setTexPos(TextureStage.getDefault(), 0, 0, 0)
self.sphere.setTexScale(TextureStage.getDefault(), .5)
# Create some 3D texture coordinates on the sphere. For more info on this, check the Panda3D manual.
tex = loader.loadCubeMap("BlueGreenNebula_#.png")
self.sphere.setTexture(tex)
# Load the cube map and apply it to the sphere.
self.sphere.setLightOff()
# Tell the sphere to ignore the lighting.
self.sphere.setScale(1000)
# Increase the scale of the sphere so it will be larger than the scene.
self.sphere.reparentTo(render)
# Reparent the sphere to render so you can see it.
result = self.sphere.writeBamFile("SkySphere.bam")
# Save out the bam file.
print(result)
示例2: __initSceneGraph
def __initSceneGraph(self):
#load various texture stages of the planet
self.forge_tex = TextureStage('forge')
self.forge_tex.setMode(TextureStage.MDecal)
self.nexus_tex = TextureStage('nexus')
self.nexus_tex.setMode(TextureStage.MDecal)
self.extractor_phylon_ge_tex = TextureStage('extractor_phylon_ge')
self.extractor_phylon_ge_tex.setMode(TextureStage.MDecal)
# Parent node for relative position (no scaling)
self.point_path = self.parent_star.point_path.attachNewNode("planet_node")
self.point_path.setPos(self.position)
#Models & textures
self.model_path = loader.loadModel("models/planets/planet_sphere")
self.model_path.setTexture(SphericalBody.dead_planet_tex, 1)
self.model_path.reparentTo(self.point_path)
self.model_path.setScale(self.radius)
self.model_path.setPythonTag('pyPlanet', self);
cnode = CollisionNode("coll_sphere_node")
cnode.setTag('planet', str(id(self)))
#We use no displacement (0,0,0) and no scaling factor (1)
cnode.addSolid(CollisionSphere(0,0,0,1))
cnode.setIntoCollideMask(BitMask32.bit(1))
# Reparenting the collision sphere so that it
# matches the planet perfectly.
self.cnode_path = self.model_path.attachNewNode(cnode)
self.lines = LineNodePath(parent = self.parent_star.point_path, thickness = 4.0, colorVec = Vec4(1.0, 1.0, 1.0, 0.2))
self.quad_path = None
示例3: SkyDome1
class SkyDome1(Att_base):
def __init__(self, scene, dynamic=True, rate=(0.005,0.05),
texturescale=(1000,1000),
scale=(40,40,10), texturefile=None):
Att_base.__init__(self,False, "Sky Dome 1")
self.skybox = loader.loadModel("../media/models/dome2")
self.skybox.setCollideMask(BitMask32().allOff())
self.skybox.setTwoSided(False)
self.skybox.setScale(scale[0],scale[1],scale[2])
self.skybox.setLightOff()
if texturefile == None:
texturefile = "../media/textures/concrete.jpg"
texture = loader.loadTexture(texturefile)
self.textureStage0 = TextureStage("stage0")
self.textureStage0.setMode(TextureStage.MReplace)
self.skybox.setTexture(self.textureStage0,texture,1)
self.skybox.setTexScale(self.textureStage0, texturescale[0], texturescale[1])
self.skybox.reparentTo(scene)
def setTextureScale(self, texturescale):
self.skybox.setTexScale(self.textureStage0, texturescale[0], texturescale[1])
def Destroy(self):
self.skybox.removeNode()
def setPos(self, v):
self.skybox.setPos(v)
def show(self):
self.skybox.show()
def hide(self):
self.skybox.hide()
示例4: DetailTexturer
class DetailTexturer(TerrainTexturer):
"""adds a texture + detail texture to TerrainTiles"""
def load(self):
self.ts1 = TextureStage('ts2')
tex = self.loadTexture("snow.jpg")
tex.setWrapU(Texture.WMMirror)
tex.setWrapV(Texture.WMMirror)
self.monoTexture = tex
self.loadDetail()
def loadDetail(self):
self.detailTS = TextureStage('ts')
tex = self.loadTexture("Detail_COLOR.jpg")
tex.setWrapU(Texture.WMMirror)
tex.setWrapV(Texture.WMMirror)
self.detailTexture = tex
self.textureBlendMode = self.detailTS.MHeight
self.detailTS.setMode(self.textureBlendMode)
def apply(self, input):
"""Apply textures and shaders to the input."""
input.setTexture(self.ts1, self.monoTexture)
input.setTexScale(self.ts1, 5, 5)
input.setTexture(self.detailTS, self.detailTexture)
input.setTexScale(self.detailTS, 120, 120)
def setDetailBlendMode(self, num):
"""Set the blending mode of the detail texture."""
if (not self.detailTexture):
return
self.textureBlendMode = num
#for pos, tile in self.tiles.items():
# if tile.detailTS:
# tile.detailTS.setMode(self.textureBlendMode)
self.detailTS.setMode(self.textureBlendMode)
def incrementDetailBlendMode(self):
"""Set the blending mode of the detail texture."""
if (not self.detailTexture):
return
self.textureBlendMode += 1
self.setDetailBlendMode(self.textureBlendMode)
def decrementDetailBlendMode(self):
"""Set the blending mode of the detail texture."""
if (not self.detailTexture):
return
self.textureBlendMode -= 1
self.setDetailBlendMode(self.textureBlendMode)
示例5: UpdateTexture
def UpdateTexture(self):
if(not self.model):
self.LoadContent()
(u, v) = BlockGeometryGenerator.BlockIdToUV(self.currentBlockIdToPlace + 1) # Add 1 to offset from Air Id = 0
ts = TextureStage('ts')
ts.setMode(TextureStage.MReplace)
self.model.clearTexture()
self.model.setTexture(ts, self.blockTexture)
self.model.setTexOffset(ts, u[0], v[0])
self.model.setTexScale(ts, 0.0625, 0.0625)
示例6: loadAndSetCubeTexture2
def loadAndSetCubeTexture2( self, nodePath1, nodePath2, fileName, textureStageName, texCoordName, sort ):
#load texture from file
texture = loader.loadCubeMap(fileName)
#set texture stage
textureStage=TextureStage(textureStageName)
textureStage.setTexcoordName(texCoordName)
textureStage.setSort(sort)
#set texture and texture stage
nodePath1.setTexture(textureStage,texture)
nodePath2.setTexture(textureStage,texture)
示例7: loadAndSetTexture
def loadAndSetTexture(self,nodePath,fileName,textureStageName,texCoordName,sort):
#load texture from file
texture=loader.loadTexture(fileName)
texture.setWrapU(Texture.WMClamp)
texture.setWrapV(Texture.WMClamp)
#set texture stage
textureStage=TextureStage(textureStageName)
textureStage.setTexcoordName(texCoordName)
textureStage.setSort(sort)
#set texture and texture stage
nodePath.setTexture(textureStage,texture)
示例8: 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)
示例9: SetGeomTexture
def SetGeomTexture(geom, geomId, node, blockTexture):
""" Applies the texture to the visible geometry of the Chunk."""
ts = TextureStage('ts')
ts.setMode(TextureStage.MDecal)
ts.setTexcoordName('light')
# Setup the block texture
attrib = TextureAttrib.make(blockTexture)
# Add the light overlay
#attrib = attrib.addOnStage(ts, geom['lighttexture'])
# Apply the texture to the node
node.setGeomState(geomId,
node.getGeomState(geomId).addAttrib(attrib))
示例10: makeFadeIn
def makeFadeIn(self, nodePath):
# make a fade in of the new objects
# our alpha gradient texture
transTex = loader.loadTexture("data/textures/transSlider.tif")
transTex.setWrapU(Texture.WMClamp)
# our texture stage. By default it's set to modulate.
# we give it a high sort value since it needs to be
# 'above' the rest.
ts = TextureStage("alpha")
ts.setSort(1000)
# apply the texture
nodePath.setTexture(ts, transTex)
nodePath.setTexScale(ts, Vec2(0))
nodePath.setTransparency(1)
self.fadingNodepaths[nodePath] = [time.time(), ts]
示例11: __init__
def __init__(self, scene, dynamic=True, rate=Vec4(0.004, 0.002, 0.008, 0.010),
skycolor=Vec4(0.25, 0.5, 1, 0),
texturescale=Vec4(1,1,1,1),
scale=(4000,4000,1000),
texturefile=None):
Att_base.__init__(self,False, "Sky Dome 2")
self.skybox = loader.loadModel("./media/models/dome2")
self.skybox.reparentTo(scene)
self.skybox.setScale(scale[0],scale[1],scale[2])
self.skybox.setLightOff()
if texturefile == None:
texturefile = "./media/textures/clouds_bw.png"
texture = loader.loadTexture(texturefile)
self.textureStage0 = TextureStage("stage0")
self.textureStage0.setMode(TextureStage.MReplace)
self.skybox.setTexture(self.textureStage0,texture,1)
#self.skybox.setTexScale(self.textureStage0, texturescale[0], texturescale[1])
self.rate = rate
self.textureScale = texturescale
self.skycolor = skycolor
self.dynamic = dynamic
if self.dynamic:
self.skybox.setShader( loader.loadShader( './media/shaders/skydome2.sha' ) )
self.setShaderInput()
示例12: __init__
def __init__(self):
tex1 = loader.loadTexture('textures/clouds.jpg')
tex1.setMagfilter(Texture.FTLinearMipmapLinear)
tex1.setMinfilter(Texture.FTLinearMipmapLinear)
tex1.setAnisotropicDegree(2)
tex1.setWrapU(Texture.WMRepeat)
tex1.setWrapV(Texture.WMRepeat)
tex1.setFormat(Texture.FAlpha)
self.ts1 = TextureStage('clouds')
#self.ts1.setMode(TextureStage.MBlend)
self.ts1.setColor(Vec4(1, 1, 1, 1))
#self.plane(-2000, -2000, 2000, 2000, 100)
self.sphere(10000, -9600)
self.clouds.setTransparency(TransparencyAttrib.MDual)
self.clouds.setTexture(self.ts1, tex1)
self.clouds.setBin('background', 3)
self.clouds.setDepthWrite(False)
self.clouds.setDepthTest(False)
self.clouds.setTwoSided(True)
self.clouds.setLightOff(1)
self.clouds.setShaderOff(1)
self.clouds.setFogOff(1)
self.clouds.hide(BitMask32.bit(2)) # Hide from the volumetric lighting camera
self.speed = 0.003
self.time = 0
self.dayColor = Vec4(0.98, 0.98, 0.95, 1.0)
self.nightColor = Vec4(-0.5, -0.3, .0, 1.0)
self.sunsetColor = Vec4(0.75, .60, .65, 1.0)
ColoredByTime.__init__(self)
self.setColor = self.clouds.setColor
示例13: __setupLevel
def __setupLevel(self):
"""
Originally planned to have multiple levels, that never happened.
"""
level1 = render.attachNewNode("level 1 node path")
execfile("rooms/room.py")
self.room = loader.loadModel("rooms/room")
self.room.findTexture("*").setMinfilter(Texture.FTLinearMipmapLinear)
self.room.setScale(10,10,5)
self.room.setTexScale(TextureStage.getDefault(), 10)
self.room.reparentTo(render)
self.room.find("**/Cube;+h").setTag("Room", "1")
gate = loader.loadModel("models/box")
gateTo2 = self.room.attachNewNode("gateTo2")
gate.instanceTo(gateTo2)
gateTo2.setPos(8, -10, 0)
gateTo2.hide()
self.physicsCollisionHandler.addInPattern("%fn-into-%in")
self.physicsCollisionHandler.addOutPattern("%fn-out-%in")
#messenger.toggleVerbose()
self.gate = gate
示例14: updateHeightField
def updateHeightField( self ):
''' recalculate heightfield
'''
if self.mHeightFieldNode != None:
self.mHeightFieldNode.removeNode()
posX, posY = self.world2MapPos( ( self.cameraPos.getX(), self.cameraPos.getY() ) )
self.mHeightFieldTesselator.setFocalPoint( int(posX), int(posY) )
self.mHeightFieldNode = self.mHeightFieldTesselator.generate()
self.mHeightFieldNode.setPos( MAPSIZE/2, MAPSIZE/2, 0 )
self.mHeightFieldNode.setHpr( 270, 0, 0 )
self.mHeightFieldNode.reparentTo(render)
self.mHeightFieldNode.setTexGen( TextureStage.getDefault(), TexGenAttrib.MWorldPosition )
scale = 1.0/8.0
self.mHeightFieldNode.setTexScale( TextureStage.getDefault(), scale, scale );
self.mHeightFieldNode.setTexture( self.tex0, 1 )
示例15: ry_floor
def ry_floor(self, gso):
tex = self.loader.loadTexture("wood_floor_tex_0.jpg")
ts = TextureStage.getDefault()
gso.setTexGen(ts, TexGenAttrib.MWorldPosition)
gso.setTexProjector(ts, self.render, gso)
gso.setTexture(ts, tex)
gso.setTexScale(ts, Vec2(0.25, 0.25) * 10.)
gso.setColor((0.99, 0.99, 0.99, 1.))