if not isinstance(cell, Cell): continue points.append(cell.origin) vertexArray = VertexArrayBuffer(len(points), GL.GL_LINE_STRIP, False, False) vertexArray.vertex[:] = points vertexArray.vertex[:] += 0.5 # draw using box centers vertexArray.rgba[:] = [(255, 0, 255, 255)] node = VertexNode([vertexArray]) # xxx LineNode return [node] def _renderBlocks(self, symbol_list): for cell1, cell2 in zip(symbol_list[:-1], symbol_list[1:]): if not isinstance(cell1, Cell): continue for p in bresenham.bresenham(cell1.origin, cell2.origin): yield p + (self.blockTypeButton.block, ) #xxx line def renderBlocks(self, symbol_list): return list(self._renderBlocks(symbol_list)) def boundsChanged(self, bounds): size = (bounds.width + bounds.length) / 2 maxiter = math.log(size, 2) + 2 self.iterationsSlider.setMaximum(maxiter) displayName = "Hilbert Curve" registerGeneratePlugin(HilbertCurvePlugin)
self.edgeBlockButton.editorSession = self.editorSession self.edgeBlockButton.block = "minecraft:quartz_block" self.edgeBlockButton.blocksChanged.connect(self.updatePreview) self.lightBlockButton = BlockTypeButton() self.lightBlockButton.editorSession = self.editorSession self.lightBlockButton.block = "minecraft:glass" self.lightBlockButton.blocksChanged.connect(self.updatePreview) self.seedInput = QtGui.QSpinBox() self.seedInput.setMinimum(-(1 << 30)) self.seedInput.setMaximum((1 << 30)) self.seedInput.setValue(0) self.seedInput.valueChanged.connect(self.updatePreview) layout = QtGui.QFormLayout() layout.addRow(self.tr("Iterations"), self.iterationsSlider) layout.addRow(self.tr("Seed"), self.seedInput) layout.addRow(self.tr("Fill"), self.fillBlockButton) layout.addRow(self.tr("Edge"), self.edgeBlockButton) layout.addRow(self.tr("Light"), self.lightBlockButton) widget.setLayout(layout) self.optionsWidget = widget return widget registerGeneratePlugin(CityGeneratePlugin) displayName = "GFX: City"
widget = self._optionsWidget = QtGui.QWidget() self.blockTypeButton = BlockTypeButton() self.blockTypeButton.editorSession = self.editorSession self.blockTypeButton.block = "minecraft:stone" self.blockTypeButton.blocksChanged.connect(self.updatePreview) layout = QtGui.QFormLayout() layout.addRow(self.tr("Iterations"), self.iterationsSlider) layout.addRow(self.tr("Block"), self.blockTypeButton) widget.setLayout(layout) return widget def createInitialSymbol(self, bounds): symbol = Snowflake(bounds, blocktype=self.blockTypeButton.block) return symbol def boundsChanged(self, bounds): if bounds is None: return # no selection size = (bounds.width + bounds.length) / 2 maxiter = math.log(size, 4) + 2 self.iterationsSlider.setMaximum(maxiter) displayName = "Koch Snowflake" registerGeneratePlugin(KochSnowflakePlugin)
points.append(cell.origin) vertexArray = VertexArrayBuffer(len(points), GL.GL_LINE_STRIP, False, False) vertexArray.vertex[:] = points vertexArray.vertex[:] += 0.5 # draw using box centers vertexArray.rgba[:] = [(255, 0, 255, 255)] node = VertexNode([vertexArray]) # xxx LineNode return [node] def _renderBlocks(self, symbol_list): for cell1, cell2 in zip(symbol_list[:-1], symbol_list[1:]): if not isinstance(cell1, Cell): continue for p in bresenham.bresenham(cell1.origin, cell2.origin): yield p + (self.blockTypeButton.block, ) #xxx line def renderBlocks(self, symbol_list): return list(self._renderBlocks(symbol_list)) def boundsChanged(self, bounds): size = (bounds.width + bounds.length) / 2 maxiter = math.log(size, 2) + 2 self.iterationsSlider.setMaximum(maxiter) displayName = "Hilbert Curve" registerGeneratePlugin(HilbertCurvePlugin)
self.blockTypeButton = BlockTypeButton() self.blockTypeButton.editorSession = self.editorSession self.blockTypeButton.block = "minecraft:stone" self.blockTypeButton.blocksChanged.connect(self.updatePreview) layout = QtGui.QFormLayout() layout.addRow(self.tr("Iterations"), self.iterationsSlider) layout.addRow(self.tr("Block"), self.blockTypeButton) widget.setLayout(layout) return widget def createInitialSymbol(self, bounds): symbol = Snowflake(bounds, blocktype=self.blockTypeButton.block) return symbol def boundsChanged(self, bounds): if bounds is None: return # no selection size = (bounds.width + bounds.length) / 2 maxiter = math.log(size, 4) + 2 self.iterationsSlider.setMaximum(maxiter) displayName = "Koch Snowflake" registerGeneratePlugin(KochSnowflakePlugin)
def generate(self, bounds, blocktypes): # self.systemsBox.value() schematic = createSchematic(bounds.size, blocktypes) dim = schematic.getDimension() system = koch.Snowflake(dim.bounds, blocktype=self.blocktypeButton.block) symbol_list = [system] max_iterations = self.iterationsSlider.value() def process(_symbol_list): for iteration, _symbol_list in applyReplacementsIterated(_symbol_list, max_iterations): yield iteration, max_iterations yield _symbol_list symbol_list = showProgress("Generating...", process(symbol_list), cancel=True) if symbol_list is False: return import pprint pprint.pprint(symbol_list) rendering = renderBlocks(symbol_list) print("Rendering %d blocks" % len(rendering)) for x, y, z, blockType in rendering: dim.setBlock(x, y, z, blockType) return schematic registerGeneratePlugin(LSystemPlugin)