def drawOnImage(self, img): ''' Draws the quadtree on the given image. @param img: A PNMImage instance. ''' painter = PNMPainter(img) painter.setFill(PNMBrush.makeTransparent()) self._drawImpl(painter, self.quadTree.root, 0, 0, 1)
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
# Add a plane to collide with cm = CardMaker("ground") cm.setFrame(-20, 20, -20, 20) cm.setUvRange((0, 1), (1, 0)) ground = render.attachNewNode(cm.generate()) ground.setPos(0, 0, 0); ground.lookAt(0, 0, -1) groundGeom = OdePlaneGeom(space, (0, 0, 1, 0)) groundGeom.setCollideBits(BitMask32(0x00000001)) groundGeom.setCategoryBits(BitMask32(0x00000001)) # Add a texture to the ground groundImage = PNMImage(512, 512) groundImage.fill(1, 1, 1) groundBrush = PNMBrush.makeSpot((0, 0, 0, 1), 8, True) groundPainter = PNMPainter(groundImage) groundPainter.setPen(groundBrush) groundTexture = Texture("ground") ground.setTexture(groundTexture) groundImgChanged = False # Set the camera position base.disableMouse() # Just to show off panda auto-converts tuples, now: base.camera.setPos((40, 40, 20)) base.camera.lookAt((0, 0, 0)) # Setup collision event def onCollision(entry): global groundImgChanged geom1 = entry.getGeom1()