def __init__(self, pos, commandObj): super(CloneVisuals, self).__init__() sourceBox = commandObj.resolveBoundingBox(pos) dest = commandObj.resolveDestination(pos) destBox = BoundingBox(dest, sourceBox.size) sourceColor = (0.3, 0.5, 0.9, 0.6) destColor = (0.0, 0.0, 0.9, 0.6) sourceBoxNode = SelectionBoxNode() sourceBoxNode.filled = False sourceBoxNode.wireColor = sourceColor sourceBoxNode.selectionBox = sourceBox destBoxNode = SelectionBoxNode() destBoxNode.filled = False destBoxNode.wireColor = destColor destBoxNode.selectionBox = destBox lineToSourceNode = LineArcNode( Vector(*pos) + (0.5, 0.5, 0.5), sourceBox.center, sourceColor) lineToDestNode = LineArcNode(sourceBox.center, destBox.center, destColor) self.addChild(sourceBoxNode) self.addChild(destBoxNode) self.addChild(lineToSourceNode) self.addChild(lineToDestNode)
def renderSceneNodes(self): node = SelectionBoxNode() # xxx BoundingBoxNode node.selectionBox = self node.filled = False node.color = 1.0, 1.0, 1.0, 0.7 return [node]
def __init__(self, pos, commandObj): """ Parameters ---------- commandObj : ExecuteCommand Returns ------- """ super(ExecuteVisuals, self).__init__() selector = commandObj.targetSelector if selector.playerName is not None: return selectorPos = [selector.getArg(a) for a in 'xyz'] if None in (selectorPos): log.warn("No selector coordinates for command %s", commandObj) targetPos = commandObj.resolvePosition((0, 0, 0)) else: targetPos = commandObj.resolvePosition(selectorPos) # Draw box at selector pos and draw line from command block to selector pos # xxxx selector pos is a sphere of radius `selector.getArg('r')` boxNode = SelectionBoxNode() boxNode.filled = False boxNode.wireColor = (0.9, 0.2, 0.2, 0.6) boxNode.selectionBox = BoundingBox(selectorPos, (1, 1, 1)) lineNode = LineArcNode( Vector(*pos) + (0.5, 0.5, 0.5), Vector(*selectorPos) + (.5, .5, .5), (0.9, 0.2, 0.2, 0.6)) self.addChild(boxNode) self.addChild(lineNode) if selectorPos != targetPos: # Command block's own coordinates are different from the selected pos, # either relative or absolute. # Draw a box at the target coordinates and a line from # the selected pos to the target boxNode = SelectionBoxNode() boxNode.filled = False boxNode.wireColor = (0.9, 0.2, 0.2, 0.6) boxNode.selectionBox = BoundingBox(targetPos, (1, 1, 1)) lineNode = LineArcNode( Vector(*selectorPos) + (0.5, 0.5, 0.5), Vector(*targetPos) + (.5, .5, .5), (0.9, 0.2, 0.2, 0.6)) self.addChild(boxNode) self.addChild(lineNode) if not isinstance(commandObj.subcommand, UnknownCommand): subvisuals = CommandVisuals(targetPos, commandObj.subcommand) self.addChild(subvisuals)
def __init__(self, pos, commandObj): super(BoundingBoxVisuals, self).__init__() box = commandObj.resolveBoundingBox(pos) boxNode = SelectionBoxNode() boxNode.filled = False boxNode.wireColor = self.boxColor boxNode.selectionBox = box lineToBoxNode = LineArcNode( Vector(*pos) + (0.5, 0.5, 0.5), box.center, self.boxColor) self.addChild(boxNode) self.addChild(lineToBoxNode)
def __init__(self, pos, commandObj): super(BoundingBoxVisuals, self).__init__() box = commandObj.resolveBoundingBox(pos) boxNode = SelectionBoxNode() boxNode.filled = False boxNode.wireColor = self.boxColor boxNode.selectionBox = box lineToBoxNode = LineArcNode(Vector(*pos) + (0.5, 0.5, 0.5), box.center, self.boxColor) self.addChild(boxNode) self.addChild(lineToBoxNode)
def __init__(self, pos, commandObj): super(PositionalVisuals, self).__init__() x, y, z = commandObj.resolvePosition(pos) boxNode = SelectionBoxNode() boxNode.filled = False boxNode.wireColor = self.color boxNode.selectionBox = BoundingBox((x, y, z), (1, 1, 1)) lineNode = LineArcNode(Vector(*pos) + (0.5, 0.5, 0.5), (x+.5, y+.5, z+.5), self.color) self.addChild(boxNode) self.addChild(lineNode)
def __init__(self, pos, commandObj): """ Parameters ---------- commandObj : ExecuteCommand Returns ------- """ super(ExecuteVisuals, self).__init__() selector = commandObj.targetSelector if selector.playerName is not None: return selectorPos = [selector.getArg(a) for a in 'xyz'] if None in (selectorPos): log.warn("No selector coordinates for command %s", commandObj) targetPos = commandObj.resolvePosition((0, 0, 0)) else: targetPos = commandObj.resolvePosition(selectorPos) # Draw box at selector pos and draw line from command block to selector pos # xxxx selector pos is a sphere of radius `selector.getArg('r')` boxNode = SelectionBoxNode() boxNode.filled = False boxNode.wireColor = (0.9, 0.2, 0.2, 0.6) boxNode.selectionBox = BoundingBox(selectorPos, (1, 1, 1)) lineNode = LineArcNode(Vector(*pos) + (0.5, 0.5, 0.5), Vector(*selectorPos) + (.5, .5, .5), (0.9, 0.2, 0.2, 0.6)) self.addChild(boxNode) self.addChild(lineNode) if selectorPos != targetPos: # Command block's own coordinates are different from the selected pos, # either relative or absolute. # Draw a box at the target coordinates and a line from # the selected pos to the target boxNode = SelectionBoxNode() boxNode.filled = False boxNode.wireColor = (0.9, 0.2, 0.2, 0.6) boxNode.selectionBox = BoundingBox(targetPos, (1, 1, 1)) lineNode = LineArcNode(Vector(*selectorPos) + (0.5, 0.5, 0.5), Vector(*targetPos) + (.5, .5, .5), (0.9, 0.2, 0.2, 0.6)) self.addChild(boxNode) self.addChild(lineNode) if not isinstance(commandObj.subcommand, UnknownCommand): subvisuals = CommandVisuals(targetPos, commandObj.subcommand) self.addChild(subvisuals)
def __init__(self, pos, commandObj): super(CloneVisuals, self).__init__() sourceBox = commandObj.resolveBoundingBox(pos) dest = commandObj.resolveDestination(pos) destBox = BoundingBox(dest, sourceBox.size) sourceColor = (0.3, 0.5, 0.9, 0.6) destColor = (0.0, 0.0, 0.9, 0.6) sourceBoxNode = SelectionBoxNode() sourceBoxNode.filled = False sourceBoxNode.wireColor = sourceColor sourceBoxNode.selectionBox = sourceBox destBoxNode = SelectionBoxNode() destBoxNode.filled = False destBoxNode.wireColor = destColor destBoxNode.selectionBox = destBox lineToSourceNode = LineArcNode(Vector(*pos) + (0.5, 0.5, 0.5), sourceBox.center, sourceColor) lineToDestNode = LineArcNode(sourceBox.center, destBox.center, destColor) self.addChild(sourceBoxNode) self.addChild(destBoxNode) self.addChild(lineToSourceNode) self.addChild(lineToDestNode)
def __init__(self, pos, commandObj): super(PositionalVisuals, self).__init__() x, y, z = commandObj.resolvePosition(pos) boxNode = SelectionBoxNode() boxNode.filled = False boxNode.wireColor = self.color boxNode.selectionBox = BoundingBox((x, y, z), (1, 1, 1)) lineNode = LineArcNode( Vector(*pos) + (0.5, 0.5, 0.5), (x + .5, y + .5, z + .5), self.color) self.addChild(boxNode) self.addChild(lineNode)
def updateCursor(self): log.info("Updating brush cursor") if self.cursorWorldScene: self.brushLoader.timer.stop() self.cursorNode.removeChild(self.cursorWorldScene) self.cursorWorldScene = None if self.cursorBoxNode: self.cursorNode.removeChild(self.cursorBoxNode) self.cursorBoxNode = None cursorLevel = self.brushMode.createCursorLevel(self) if cursorLevel is not None: self.cursorWorldScene = worldscene.WorldScene(cursorLevel, self.editorSession.textureAtlas) self.cursorWorldScene.depthOffset.depthOffset = DepthOffsets.PreviewRenderer self.cursorNode.addChild(self.cursorWorldScene) self.brushLoader = WorldLoader(self.cursorWorldScene) self.brushLoader.startLoader() cursorBox = self.brushMode.brushBoxForPoint((0, 0, 0), self.options) if cursorBox is not None: self.cursorBoxNode = SelectionBoxNode() self.cursorBoxNode.selectionBox = cursorBox self.cursorBoxNode.filled = False self.cursorNode.addChild(self.cursorBoxNode)
def __init__(self): """ A drawable, resizable box that can respond to mouse events. Emits boundsChanged whenever its bounding box changes, and emits boundsChangedDone when the mouse button is released. The handle initially has no box; the first mouse action will define the initial box with height=0. If a subsequent mouse action does not intersect the box, a new initial box will be created; otherwise, the existing box will be moved or resized. Mouse events must be forwarded to the handle using mousePress, mouseDrag, and mouseRelease. A modifier can be set (default Shift) to move the box instead of resizing it; or the `resizable` attribute can be set to False to always move the box. When `resizable` is False, new initial boxes cannot be created. :return: :rtype: """ super(BoxHandle, self).__init__() self.boxNode = SelectionBoxNode() self.boxNode.filled = False self.faceDragNode = SelectionFaceNode() self.addChild(self.boxNode) self.addChild(self.faceDragNode)
def setSelectedChunk(self, chunk): if self.selectionNode is None: self.selectionNode = SelectionBoxNode() self.selectionNode.filled = False self.selectionNode.color = (0.3, 0.3, 1, .3) self.overlayNode.addChild(self.selectionNode) self.selectionNode.selectionBox = chunk.bounds self.currentChunk = chunk self.updateChunkWidget() self.updateChunkNBTView()
def __init__(self, editorSession): """ :param editorSession: :type editorSession: mcedit2.editorsession.EditorSession :return: :rtype: """ super(InspectorWidget, self).__init__() self.setupUi(self) self.editorSession = editorSession self.blockNBTEditor.editorSession = self.editorSession self.entityNBTEditor.editorSession = self.editorSession self.chunkNBTEditor.editorSession = self.editorSession self.blockEditorWidget = None self.tileEntity = None self.entity = None self.blockPos = None self.currentChunk = None self.overlayNode = scenenode.Node("inspectorOverlay") self.selectionNode = SelectionBoxNode() self.selectionNode.depth = depths.DepthOffsets.SelectionCursor self.selectionNode.filled = False self.selectionNode.wireColor = (0.2, 0.9, .2, .8) self.overlayNode.addChild(self.selectionNode) self.commandBlockVisualsNode = None self.chunkTabWidget.currentChanged.connect(self.chunkTabDidChange) self.terrainPopulatedInput.toggled.connect( self.terrainPopulatedDidChange) self.lightPopulatedInput.toggled.connect(self.lightPopulatedDidChange) self.inhabitedTimeInput.valueChanged.connect( self.inhabitedTimeDidChange) self.updateTimeInput.valueChanged.connect(self.updateTimeDidChange) self.blockXSpinBox.valueChanged.connect(self.blockXChanged) self.blockYSpinBox.valueChanged.connect(self.blockYChanged) self.blockZSpinBox.valueChanged.connect(self.blockZChanged) self.removeEntityButton.clicked.connect(self.removeEntity) self.addTileEntityButton.clicked.connect(self.addTileEntity) self.removeTileEntityButton.clicked.connect(self.removeTileEntity)
def __init__(self): """ A drawable, resizable box that can respond to mouse events. Emits boundsChanged whenever its bounding box changes, and emits boundsChangedDone when the mouse button is released. :return: :rtype: """ super(BoxHandle, self).__init__() self.boxNode = SelectionBoxNode() self.boxNode.filled = False self.faceDragNode = SelectionFaceNode() self.addChild(self.boxNode) self.addChild(self.faceDragNode)
def __init__(self, pos, commandObj): super(TargetedVisuals, self).__init__() selector = commandObj.targetSelector if selector.playerName is not None: return selectorPos = [selector.getArg(a) for a in 'xyz'] if None in selectorPos: return color = (0.2, 0.9, 0.7, 0.6) boxNode = SelectionBoxNode() boxNode.filled = False boxNode.wireColor = color boxNode.selectionBox = BoundingBox(selectorPos, (1, 1, 1)) lineNode = LineArcNode(Vector(*pos) + (0.5, 0.5, 0.5), Vector(*selectorPos) + (.5, .5, .5), color) self.addChild(boxNode) self.addChild(lineNode)
def __init__(self, pos, commandObj): super(TargetedVisuals, self).__init__() selector = commandObj.targetSelector if selector.playerName is not None: return selectorPos = [selector.getArg(a) for a in 'xyz'] if None in selectorPos: return color = (0.2, 0.9, 0.7, 0.6) boxNode = SelectionBoxNode() boxNode.filled = False boxNode.wireColor = color boxNode.selectionBox = BoundingBox(selectorPos, (1, 1, 1)) lineNode = LineArcNode( Vector(*pos) + (0.5, 0.5, 0.5), Vector(*selectorPos) + (.5, .5, .5), color) self.addChild(boxNode) self.addChild(lineNode)
def setSelectedChunk(self, chunk): if self.selectionNode is None: self.selectionNode = SelectionBoxNode() self.selectionNode.filled = False self.selectionNode.color = (0.3, 0.3, 1, .3) self.overlayNode.addChild(self.selectionNode) self.selectionNode.selectionBox = chunk.bounds self.currentChunk = chunk self.updateChunkWidget() model = NBTTreeModel(chunk.rootTag) self.toolWidget.nbtTreeView.setModel(model) self.toolWidget.cxSpinBox.setValue(chunk.cx) self.toolWidget.czSpinBox.setValue(chunk.cz)
def __init__(self, pendingImport, textureAtlas): super(PendingImportNode, self).__init__() self.pendingImport = pendingImport self.pos = pendingImport.pos dim = pendingImport.schematic.getDimension() self.worldScene = WorldScene(dim, textureAtlas) self.worldScene.depthOffsetNode.depthOffset = DepthOffset.PreviewRenderer self.addChild(self.worldScene) self.outlineNode = SelectionBoxNode() self.outlineNode.filled = False self.outlineNode.selectionBox = dim.bounds self.addChild(self.outlineNode) self.faceHoverNode = SelectionFaceNode() self.faceHoverNode.selectionBox = dim.bounds self.addChild(self.faceHoverNode) self.loader = WorldLoader(self.worldScene) self.loader.timer.start()
def __init__(self, pendingImport, textureAtlas, hasHandle=True): """ A scenegraph node displaying an object that will be imported later, including live and deferred views of the object with transformed items, and a BoxHandle for moving the item. Parameters ---------- pendingImport: PendingImport The object to be imported. The PendingImportNode responds to changes in this object's position, rotation, and scale. textureAtlas: TextureAtlas The textures and block models used to render the preview of the object. Attributes ---------- basePosition: Vector The pre-transform position of the pending import. This is equal to `self.pendingImport.basePosition` except when the node is currently being dragged. transformedPosition: Vector The post-transform position of the pending import. This is equal to `self.pendingImport.importPos` except when the node is currently being dragged, scaled, or rotated. """ super(PendingImportNode, self).__init__() self.textureAtlas = textureAtlas self.pendingImport = pendingImport self.hasHandle = hasHandle dim = pendingImport.sourceDim self.transformedPosition = Vector(0, 0, 0) # positionTranslateNode contains the non-transformed preview of the imported # object, including its world scene. This preview will be rotated model-wise # while the user is dragging the rotate controls. self.positionTranslateNode = TranslateNode() self.rotateNode = Rotate3DNode() self.addChild(self.positionTranslateNode) self.positionTranslateNode.addChild(self.rotateNode) self.rotateNode.setAnchor(self.pendingImport.selection.size * 0.5) # worldSceneTranslateNode is contained by positionTranslateNode, and # serves to translate the world scene back to 0, 0, 0 so the positionTranslateNode # can translate by the current position. self.worldSceneTranslateNode = TranslateNode() self.worldScene = WorldScene(dim, textureAtlas, bounds=pendingImport.selection) self.worldScene.depthOffsetNode.depthOffset = DepthOffset.PreviewRenderer # transformedWorldTranslateNode contains the transformed preview of the imported # object, including a world scene that displays the object wrapped by a # DimensionTransform. self.transformedWorldTranslateNode = TranslateNode() self.transformedWorldScene = None self.addChild(self.transformedWorldTranslateNode) self.worldSceneTranslateNode.translateOffset = -self.pendingImport.selection.origin self.worldSceneTranslateNode.addChild(self.worldScene) self.rotateNode.addChild(self.worldSceneTranslateNode) # handleNode displays a bounding box that can be moved around, and responds # to mouse events. box = BoundingBox(pendingImport.importPos, pendingImport.importBounds.size) if hasHandle: self.handleNode = BoxHandle() self.handleNode.bounds = box self.handleNode.resizable = False self.boxNode = None else: self.boxNode = SelectionBoxNode() self.boxNode.wireColor = (1, 1, 1, .2) self.boxNode.filled = False self.handleNode = None self.addChild(self.boxNode) self.updateTransformedScene() self.basePosition = pendingImport.basePosition if hasHandle: self.handleNode.boundsChanged.connect(self.handleBoundsChanged) self.handleNode.boundsChangedDone.connect( self.handleBoundsChangedDone) self.addChild(self.handleNode) # loads the non-transformed world scene asynchronously. self.loader = WorldLoader( self.worldScene, list(pendingImport.selection.chunkPositions())) self.loader.startLoader(0.1 if self.hasHandle else 0.0) self.pendingImport.positionChanged.connect(self.setPosition) self.pendingImport.rotationChanged.connect(self.setRotation)