Exemple #1
0
    def drawTerrainReticle(self):
        """
        Draws the white reticle where the cursor is pointing.
        Called by leveleditor.render
        """
        if self.optionBackup != self.options:
            self.saveBrushPreset('__temp__')
            self.optionBackup = copy.copy(self.options)
        if not hasattr(self, 'brushMode'):
            return
        if self.options[getattr(self.brushMode, 'mainBlock', 'Block')] != self.renderedBlock and not getattr(self.brushMode, 'addPasteButton', False):
            self.setupPreview()
            self.renderedBlock = self.options[getattr(self.brushMode, 'mainBlock', 'Block')]

        if self.pickBlockKey == 1:  #Alt is pressed
            self.editor.drawWireCubeReticle(color=(0.2, 0.6, 0.9, 1.0))
        else:
            pos, direction = self.editor.blockFaceUnderCursor
            reticlePoint = self.getReticlePoint(pos, direction)
            self.editor.drawWireCubeReticle(position=reticlePoint)
            if reticlePoint != pos:
                GL.glColor4f(1.0, 1.0, 0.0, 0.7)
                with gl.glBegin(GL.GL_LINES):
                    GL.glVertex3f(*[a + 0.5 for a in reticlePoint])  #Center of reticle block
                    GL.glVertex3f(*map(lambda a, b: a + 0.5 + b * 0.5, pos, direction))  #Top side of surface block
            dirtyBox = self.getDirtyBox(reticlePoint, self)
            self.drawTerrainPreview(dirtyBox.origin)
            if self.lineToolKey and self.lastPosition and getattr(self.brushMode, 'draggableBrush', True):  #If dragging mouse with Linetool pressed.
                GL.glColor4f(1.0, 1.0, 1.0, 0.7)
                with gl.glBegin(GL.GL_LINES):
                    GL.glVertex3f(*[a + 0.5 for a in self.lastPosition])
                    GL.glVertex3f(*[a + 0.5 for a in reticlePoint])
Exemple #2
0
    def drawTerrainReticle(self):
        """
        Draws the white reticle where the cursor is pointing.
        Called by leveleditor.render
        """
        if self.optionBackup != self.options:
            self.saveBrushPreset('__temp__')
            self.optionBackup = copy.copy(self.options)
        if not hasattr(self, 'brushMode'):
            return
        if self.options[getattr(self.brushMode, 'mainBlock', 'Block')] != self.renderedBlock and not getattr(self.brushMode, 'addPasteButton', False):
            self.setupPreview()
            self.renderedBlock = self.options[getattr(self.brushMode, 'mainBlock', 'Block')]

        if self.pickBlockKey == 1:  #Alt is pressed
            self.editor.drawWireCubeReticle(color=(0.2, 0.6, 0.9, 1.0))
        else:
            pos, direction = self.editor.blockFaceUnderCursor
            reticlePoint = self.getReticlePoint(pos, direction)
            self.editor.drawWireCubeReticle(position=reticlePoint)
            if reticlePoint != pos:
                GL.glColor4f(1.0, 1.0, 0.0, 0.7)
                with gl.glBegin(GL.GL_LINES):
                    GL.glVertex3f(*[a + 0.5 for a in reticlePoint])  #Center of reticle block
                    GL.glVertex3f(*map(lambda a, b: a + 0.5 + b * 0.5, pos, direction))  #Top side of surface block
            dirtyBox = self.getDirtyBox(reticlePoint, self)
            self.drawTerrainPreview(dirtyBox.origin)
            if self.lineToolKey and self.lastPosition and getattr(self.brushMode, 'draggableBrush', True):  #If dragging mouse with Linetool pressed.
                GL.glColor4f(1.0, 1.0, 1.0, 0.7)
                with gl.glBegin(GL.GL_LINES):
                    GL.glVertex3f(*[a + 0.5 for a in self.lastPosition])
                    GL.glVertex3f(*[a + 0.5 for a in reticlePoint])