本文整理汇总了Python中Resources.texture方法的典型用法代码示例。如果您正苦于以下问题:Python Resources.texture方法的具体用法?Python Resources.texture怎么用?Python Resources.texture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Resources
的用法示例。
在下文中一共展示了Resources.texture方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compileMapSquareList
# 需要导入模块: import Resources [as 别名]
# 或者: from Resources import texture [as 别名]
def compileMapSquareList(self, sq):
if sq.guiData.has_key("listID"):
glDeleteLists(sq.guiData["listID"], 1)
textureNames = sq.texture()
texIDt = Resources.texture(textureNames[0])
sq.guiData['textureID'] = texIDt #fix me: update with the new amount of textures.
texIDl = Resources.texture(textureNames[1])
texIDb = Resources.texture(textureNames[2])
texIDr = Resources.texture(textureNames[3])
texIDf = Resources.texture(textureNames[4])
textureIDs = [texIDt, texIDl, texIDb, texIDr, texIDf]
listID = glGenLists(1)
sq.guiData["listID"] = listID
glNewList(listID, GL_COMPILE)
GLUtil.makeCube(sq.z, sq.cornerHeights,
textureIDs, sq.cornerColors, sq.waterHeight,
sq.waterColor, sq.minHeight())
#glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
#glLineWidth(0.75)
#GLUtil.makeCube(sq.z, (0.0,0.0,0.0,1.0), sq.cornerHeights, False)
#glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
glEndList()
topListID = glGenLists(1)
sq.guiData['topListID'] = topListID
glNewList(topListID, GL_COMPILE)
GLUtil.makeCubeTop(sq.z, sq.cornerHeights)
glEndList()
示例2: compileMapSquareList
# 需要导入模块: import Resources [as 别名]
# 或者: from Resources import texture [as 别名]
def compileMapSquareList(self, sq):
if sq.guiData.has_key("listID"):
glDeleteLists(sq.guiData["listID"], 1)
textureNames = sq.texture()
texIDt = Resources.texture(textureNames[0])
sq.guiData["textureID"] = texIDt # FIXME: update with the new amount of textures.
texIDl = Resources.texture(textureNames[1])
texIDb = Resources.texture(textureNames[2])
texIDr = Resources.texture(textureNames[3])
texIDf = Resources.texture(textureNames[4])
textureIDs = [texIDt, texIDl, texIDb, texIDr, texIDf]
listID = glGenLists(1)
sq.guiData["listID"] = listID
glNewList(listID, GL_COMPILE)
GLUtil.makeCube(
sq.z, sq.cornerHeights, textureIDs, sq.cornerColors, sq.waterHeight, sq.waterColor, sq.minHeight()
)
glEndList()
topListID = glGenLists(1)
sq.guiData["topListID"] = topListID
glNewList(topListID, GL_COMPILE)
GLUtil.makeCubeTop(sq.z, sq.cornerHeights)
glEndList()
示例3: makeCube
# 需要导入模块: import Resources [as 别名]
# 或者: from Resources import texture [as 别名]
def makeCube(z, cornerHeights, texture, cornerColors, waterHeight, waterColor,
minHeight):
if texture[1] != None:
glBindTexture(GL_TEXTURE_2D, texture[1])
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
cc = cornerColors
ulz = (z+cornerHeights[0]) * Z_HEIGHT
urz = (z+cornerHeights[1]) * Z_HEIGHT
llz = (z+cornerHeights[2]) * Z_HEIGHT
lrz = (z+cornerHeights[3]) * Z_HEIGHT
z = z * Z_HEIGHT
# Enable backface culling
glEnable(GL_CULL_FACE)
glCullFace(GL_BACK)
glBegin(GL_QUADS)
# Left
glNormal3f(-1.0, 0.0, 0.0)
glColor4f(cc[1][0][0], cc[1][0][1], cc[1][0][2], cc[1][0][3])
glTexCoord2f(1.0, 0.0); glVertex3f(-0.5, 0.5, 0.0)
glColor4f(cc[1][1][0], cc[1][1][1], cc[1][1][2], cc[1][1][3])
glTexCoord2f(0.0, 0.0); glVertex3f(-0.5, -0.5, 0.0)
glColor4f(cc[1][2][0], cc[1][2][1], cc[1][2][2], cc[1][2][3])
glTexCoord2f(0.0, llz); glVertex3f(-0.5, -0.5, llz)
glColor4f(cc[1][3][0], cc[1][3][1], cc[1][3][2], cc[1][3][3])
glTexCoord2f(1.0, ulz); glVertex3f(-0.5, 0.5, ulz)
glEnd()
if texture[2] != None:
glBindTexture(GL_TEXTURE_2D, texture[2])
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
glBegin(GL_QUADS)
# Back
glNormal3f(0.0, 1.0, 0.0)
glColor4f(cc[2][0][0], cc[2][0][1], cc[2][0][2], cc[2][0][3])
glTexCoord2f(1.0, 0.0); glVertex3f( 0.5, 0.5, 0.0)
glColor4f(cc[2][1][0], cc[2][1][1], cc[2][1][2], cc[2][1][3])
glTexCoord2f(0.0, 0.0); glVertex3f(-0.5, 0.5, 0.0)
glColor4f(cc[2][2][0], cc[2][2][1], cc[2][2][2], cc[2][2][3])
glTexCoord2f(0.0, ulz); glVertex3f(-0.5, 0.5, ulz)
glColor4f(cc[2][3][0], cc[2][3][1], cc[2][3][2], cc[2][3][3])
glTexCoord2f(1.0, urz); glVertex3f( 0.5, 0.5, urz)
# Bottom
# glNormal3f(0.0, 0.0, 1.0)
# glColor4f(cc[0][0], cc[0][1], cc[0][2], 1.0)
# glTexCoord2f(1.0, 0.0); glVertex3f( 0.5, 0.5, 0.0)
# glColor4f(cc[0][0], cc[0][1], cc[0][2], 1.0)
# glTexCoord2f(0.0, 0.0); glVertex3f(-0.5, 0.5, 0.0)
# glColor4f(cc[0][0], cc[0][1], cc[0][2], 1.0)
# glTexCoord2f(0.0, 1.0); glVertex3f(-0.5, -0.5, 0.0)
# glColor4f(cc[0][0], cc[0][1], cc[0][2], 1.0)
# glTexCoord2f(1.0, 1.0); glVertex3f( 0.5, -0.5, 0.0)
glEnd()
if texture[3] != None:
glBindTexture(GL_TEXTURE_2D, texture[3])
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
glCullFace(GL_FRONT)
glBegin(GL_QUADS)
# Right
glNormal3f(1.0, 0.0, 0.0)
glColor4f(cc[3][0][0], cc[3][0][1], cc[3][0][2], cc[3][0][3])
glTexCoord2f(0.0, 0.0); glVertex3f( 0.5,-0.5, 0.0)
glColor4f(cc[3][3][0], cc[3][3][1], cc[3][3][2], cc[3][3][3])
glTexCoord2f(0.0, lrz); glVertex3f( 0.5,-0.5, lrz)
glColor4f(cc[3][2][0], cc[3][2][1], cc[3][2][2], cc[3][2][3])
glTexCoord2f(1.0, urz); glVertex3f( 0.5, 0.5, urz)
glColor4f(cc[3][1][0], cc[3][1][1], cc[3][1][2], cc[3][1][3])
glTexCoord2f(1.0, 0.0); glVertex3f( 0.5, 0.5, 0.0)
glEnd()
if texture[4] != None:
glBindTexture(GL_TEXTURE_2D, texture[4])
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
glBegin(GL_QUADS)
# Front
#.........这里部分代码省略.........
示例4: glPopMatrix
# 需要导入模块: import Resources [as 别名]
# 或者: from Resources import texture [as 别名]
glPopMatrix()
glMatrixMode(GL_MODELVIEW)
glEnable(GL_LIGHTING)
glEnable(GL_DEPTH_TEST)
def drawBar(leftColor, rightColor, barWidth, barHeight, (posx, posy)):
(width, height) = MainWindow.get().size()
# If you want to draw to a specific (x,y) position on screen,
# instead of drawing inside the actual 3D world, you need to
# switch to orthographic mode first.
switchToOrthographicMode()
# Actual drawing code begins here
glTranslate(posx, height-posy, 0.0)
glBindTexture(GL_TEXTURE_2D, Resources.texture('none'))
glBegin(GL_QUADS)
# Draw the colored bar
leftColor[3] = 0.0
glColor4f(*leftColor)
glVertex3f(0.0, 0.0, 0.0)
leftColor[3] = 0.9
glColor4f(*leftColor)
glVertex3f(0.0, -barHeight, 0.0)
rightColor[3] = 0.9
glColor4f(*rightColor)
glVertex3f(barWidth, -barHeight, 0.0)
rightColor[3] = 0.0
glColor4f(*rightColor)
glVertex3f(barWidth, 0.0, 0.0)
示例5: draw
# 需要导入模块: import Resources [as 别名]
# 或者: from Resources import texture [as 别名]
def draw(self):
#glDisable(GL_DEPTH_TEST)
if self._color[3] < 0.0:
return
glDisable(GL_LIGHTING)
glDepthFunc(GL_LEQUAL)
glPushMatrix()
GLUtil.mapTrans(self.x, self.y, self.z)
# Draw the circle around the unit's feet
(r, g, b) = Faction.color(self.__unit.faction())
none = Resources.texture("none")
glBindTexture(GL_TEXTURE_2D, none)
glPushMatrix()
if self.__unit.facing() == Constants.E:
glRotate(-90.0, 0.0, 0.0, 1.0)
elif self.__unit.facing() == Constants.S:
glRotate(180.0, 0.0, 0.0, 1.0)
elif self.__unit.facing() == Constants.W:
glRotate(90.0, 0.0, 0.0, 1.0)
glColor4f(r, g, b, 1.0 * self._color[3])
glBegin(GL_TRIANGLES)
glVertex3f(0.0, 0.0, 0.0)
glVertex3f(-0.15, 0.35, 0.0)
glVertex3f(0.15, 0.35, 0.0)
glEnd()
glPopMatrix()
quad = gluNewQuadric()
gluDisk(quad, 0.3, 0.4, 32, 1)
gluDeleteQuadric(quad)
# Checking for texture and color status
unitStatus = self.__unit.statusEffects()
if len(unitStatus.texture()) == 0 :
self._textureStatus = -1
else:
if time.time() > self._textureTime:
self._textureTime = time.time() +1.1
self._textureStatus += 1
if self._textureStatus >= len(unitStatus.texture()):
self._textureStatus = 0
try:
if engine.Effect.Status.effectTextures[unitStatus.texture()[self._textureStatus]] != None:
GLUtil.makeStatus(engine.Effect.Status.effectTextures[unitStatus.texture()[self._textureStatus]], self._color)
except:
# when the status is over this can happen
pass
statuscolor = None
if len(unitStatus.color()) == 0 :
self._colorStatus = -1
else:
if time.time() > self._colorTime:
self._colorTime = time.time() +1.3
self._colorStatus += 1
if self._colorStatus >= len(unitStatus.color()):
self._colorStatus = 0
try:
if engine.Effect.Status.effectTextures[unitStatus.color()[self._colorStatus]] != None:
statuscolor = engine.Effect.Status.effectTextures[unitStatus.color()[self._colorStatus]]
except :
pass
if statuscolor == None :
if self.isActing() == True:
self._unitStatusColor = self._color
else:
GLUtil.makeUnit(texture = self.__texture,
wtexture = self.__wtexture,
otexture = self.__otexture,
color = self._color,
weaponGrip = self.__weaponGrip,
unitHand = self.__unitHand)
else:
if self.isActing() == True:
self._unitStatusColor = statuscolor
else:
GLUtil.makeUnit(texture = self.__texture,
wtexture = self.__wtexture,
otexture = self.__otexture,
color = statuscolor,
weaponGrip = self.__weaponGrip,
unitHand = self.__unitHand)
for a in self._animations:
a.draw()
glPopMatrix()
glDepthFunc(GL_LESS)
glEnable(GL_LIGHTING)