本文整理汇总了Python中pandac.PandaModules.Texture.store方法的典型用法代码示例。如果您正苦于以下问题:Python Texture.store方法的具体用法?Python Texture.store怎么用?Python Texture.store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandac.PandaModules.Texture
的用法示例。
在下文中一共展示了Texture.store方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TexturePainter
# 需要导入模块: from pandac.PandaModules import Texture [as 别名]
# 或者: from pandac.PandaModules.Texture import store [as 别名]
#.........这里部分代码省略.........
del self.modelColorCam
self.colorPickerScene.removeNode()
del self.colorPickerScene
# remove cam
self.colorPickerCam.removeNode()
del self.colorPickerCam
# Destroy the buffer
base.graphicsEngine.removeWindow(self.colorPickerBuffer)
self.colorPickerBuffer = None
del self.colorPickerTex
del self.colorPickerImage
def __startEditor(self, editModel, editTexture, backgroundShader=MODEL_COLOR_SHADER):
print "I: TexturePainter.__startEditor"
# this is needed as on startup the editor may not have had a window etc.
self.__windowEvent()
if not editModel or not editTexture:
print "W: TexturePainter.__startEditor: model or texture invalid", editModel, editTexture
return False
self.editModel = editModel
self.editTexture = editTexture
self.editImage = None
self.backgroundShader = backgroundShader
if type(self.editTexture) == Texture:
# if the image to modify is a texture, create a pnmImage which we modify
self.editImage = PNMImage()
# copy the image from the texture to the working layer
self.editTexture.store(self.editImage)
else:
self.editImage = self.editTexture
# create the brush for painting
self.painter = PNMPainter(self.editImage)
self.setBrushSettings( *self.getBrushSettings() )
self.__updateModel()
# start edit
messenger.send(EVENT_TEXTUREPAINTER_STARTEDIT)
for startEvent in TEXTUREPAINTER_START_PAINT_EVENTS:
self.accept(startEvent, self.__startPaint)
for stopEvent in TEXTUREPAINTER_STOP_PAINT_EVENTS:
self.accept(stopEvent, self.__stopPaint)
self.modelColorCam.node().copyLens(WindowManager.activeWindow.camera.node().getLens())
taskMgr.add(self.__paintTask, 'paintTask')
#modelModificator.toggleEditmode(False)
self.isPainting = False
def __stopEditor(self):
print "I: TexturePainter.__stopEditor"
for startEvent in TEXTUREPAINTER_START_PAINT_EVENTS:
self.ignore(startEvent)
for stopEvent in TEXTUREPAINTER_STOP_PAINT_EVENTS:
self.ignore(stopEvent)
示例2: HtmlView
# 需要导入模块: from pandac.PandaModules import Texture [as 别名]
# 或者: from pandac.PandaModules.Texture import store [as 别名]
#.........这里部分代码省略.........
ll.setZ(ll.getZ() + offset.getZ())
ur.setZ(ur.getZ() + offset.getZ())
self.notify.debug('new LL=%s, UR=%s' % (ll, ur))
relPointll = self.quad.getRelativePoint(aspect2d, ll)
self.notify.debug('relPoint = %s' % relPointll)
self.mouseLL = (aspect2d.getScale()[0] * ll[0], aspect2d.getScale()[2] * ll[2])
self.mouseUR = (aspect2d.getScale()[0] * ur[0], aspect2d.getScale()[2] * ur[2])
self.notify.debug('original mouseLL=%s, mouseUR=%s' % (self.mouseLL, self.mouseUR))
def writeTex(self, filename = 'guiText.png'):
self.notify.debug('writing texture')
self.guiTex.generateRamMipmapImages()
self.guiTex.write(filename)
def toggleRotation(self):
if self.interval.isPlaying():
self.interval.finish()
else:
self.interval.loop()
def mouseDown(self, button):
messenger.send('wakeup')
self.webView.injectMouseDown(button)
def mouseUp(self, button):
self.webView.injectMouseUp(button)
def reload(self):
pass
def zoomIn(self):
self.webView.zoomIn()
def zoomOut(self):
self.webView.zoomOut()
def toggleTransparency(self):
self.transparency = not self.transparency
self.webView.setTransparent(self.transparency)
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, self.my = x, 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
def _translateRelativeCoordinates(self, x, y):
sx = int((x - self.mouseLL[0]) / (self.mouseUR[0] - self.mouseLL[0]) * WEB_WIDTH_PIXELS)
sy = WEB_HEIGHT_PIXELS - int((y - self.mouseLL[1]) / (self.mouseUR[1] - self.mouseLL[1]) * WEB_HEIGHT_PIXELS)
return (sx, sy)
def unload(self):
self.ignoreAll()
self.webView.destroy()
self.webView = None
return
def onCallback(self, name, args):
if name == 'requestFPS':
pass
def onBeginNavigation(self, url, frameName):
pass
def onBeginLoading(self, url, frameName, statusCode, mimeType):
pass
def onFinishLoading(self):
self.notify.debug('finished loading')
def onReceiveTitle(self, title, frameName):
pass
def onChangeTooltip(self, tooltip):
pass
def onChangeCursor(self, cursor):
pass
def onChangeKeyboardFocus(self, isFocused):
pass
def onChangeTargetURL(self, url):
pass
示例3: GXOStar
# 需要导入模块: from pandac.PandaModules import Texture [as 别名]
# 或者: from pandac.PandaModules.Texture import store [as 别名]
#.........这里部分代码省略.........
## this function returns the aspect2d position of a light source, if it enters the cameras field of view
def _get2D(self, nodePath):
#get the position of the light source relative to the cam
p3d = base.cam.getRelativePoint(nodePath, Point3(0,0,0))
p2d = Point2()
#project the light source into the viewing plane and return 2d coordinates, if it is in the visible area(read: not behind the cam)
if base.cam.node().getLens().project(p3d, p2d):
return p2d
return None
def _getObscured(self, color):
# This originally looked for the radius of the light but that caused
# assertion errors. Now I use the radius of the hdr model.
bounds = self.starcard.getBounds()
#print ("bounds=%s rad=%s"%(bounds,bounds.getRadius()))
if not bounds.isEmpty():
r = bounds.getRadius()
# Setting the film size sets the field-of-view and the aspect ratio
# Maybe this should be done with setAspectRation() and setFov()
self.ortlens.setFilmSize(r * self.radius, r * self.radius)
# Point the flarecamera at the sun so we can determine if anything
# is obscurring the sun
self.flarecamera.lookAt(self.baseNode)
# Renders the next frame in all the registered windows, and flips
# all of the frame buffers. This will populate flaretexture since
# it's attached to the flarebuffer.
# Save the rendered frame in flaredata
base.graphicsEngine.renderFrame()
self.flaretexture.store(self.flaredata)
#print ("flaredata=%s | color=%s"%(self.flaredata.getXel(5,5), color))
# Initialize the obscured factor
obscured = 100.0
color = VBase3D(color[0],color[1],color[2])
for x in xrange(0,9):
for y in xrange(0,9):
if color.almostEqual(self.flaredata.getXel(x,y), self.threshold):
obscured -= 1.0
else:
obscured = 0
return obscured
def _flareTask(self, task):
#going through the list of lightNodePaths
#for index in xrange(0, len(self.lightNodes)):
pos2d = self._get2D(self.sunlight)
#if the light source is visible from the cam's point of view,
# display the lens-flare
if pos2d:
#print ("Flare visible")
# The the obscured factor
obscured = self._getObscured(self.suncardcolor)
# Scale it to [0,1]
self.obscured = obscured/100
##print obscured
# Length is the length of the vector that goes from the screen