本文整理汇总了Python中mcedit2.rendering.scenegraph.scenenode.Node.removeChild方法的典型用法代码示例。如果您正苦于以下问题:Python Node.removeChild方法的具体用法?Python Node.removeChild怎么用?Python Node.removeChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mcedit2.rendering.scenegraph.scenenode.Node
的用法示例。
在下文中一共展示了Node.removeChild方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PendingImportNode
# 需要导入模块: from mcedit2.rendering.scenegraph.scenenode import Node [as 别名]
# 或者: from mcedit2.rendering.scenegraph.scenenode.Node import removeChild [as 别名]
#.........这里部分代码省略.........
self.basePosition = point
self.importIsMoving.emit(point)
def getBaseFromTransformed(self, point):
return point - self.pendingImport.transformOffset
def setPreviewRotation(self, rots):
self.plainSceneNode.visible = True
self.transformedSceneNode.visible = False
self.rotateNode.setRotation(rots)
def setRotation(self, rots):
self.updateTransformedScene()
self.updateBoxHandle()
self.rotateNode.setRotation(rots)
def setPreviewScale(self, scale):
self.plainSceneNode.visible = True
self.transformedSceneNode.visible = False
self.scaleNode.setScale(scale)
def setScale(self, scale):
self.updateTransformedScene()
self.updateBoxHandle()
self.scaleNode.setScale(scale)
def updateTransformedScene(self):
if self.pendingImport.transformedDim is not None:
log.info("Showing transformed scene")
self.plainSceneNode.visible = False
self.transformedSceneNode.visible = True
if self.transformedWorldScene:
self.transformedSceneNode.removeChild(self.transformedWorldScene)
self.transformedWorldScene = WorldScene(self.pendingImport.transformedDim,
self.textureAtlas)
self.transformedWorldScene.depthOffset.depthOffset = DepthOffsets.PreviewRenderer
self.transformedSceneNode.addChild(self.transformedWorldScene)
self.updateTransformedPosition()
cPos = list(self.pendingImport.transformedDim.chunkPositions())
self.loader = WorldLoader(self.transformedWorldScene,
cPos)
# ALERT!: self.hasHandle is overloaded with the meaning:
# "not the first clone in a repeated clone"
self.loader.startLoader(0.1 if self.hasHandle else 0.0)
else:
log.info("Hiding transformed scene")
self.plainSceneNode.visible = True
self.transformedSceneNode.visible = False
if self.transformedWorldScene:
self.transformedSceneNode.removeChild(self.transformedWorldScene)
self.transformedWorldScene = None
def updateTransformedPosition(self):
self.transformedPosition = self.basePosition + self.pendingImport.transformOffset
self.transformedSceneTranslate.translateOffset = self.transformedPosition - self.pendingImport.importDim.bounds.origin
def updateBoxHandle(self):
if self.transformedWorldScene is None:
bounds = BoundingBox(self.basePosition, self.pendingImport.bounds.size)
else:
示例2: BrushTool
# 需要导入模块: from mcedit2.rendering.scenegraph.scenenode import Node [as 别名]
# 或者: from mcedit2.rendering.scenegraph.scenenode.Node import removeChild [as 别名]
#.........这里部分代码省略.........
def setY(self, val):
x, y, z = self.brushSize
y = float(val)
self.brushSize = x, y, z
def setZ(self, val):
x, y, z = self.brushSize
z = float(val)
self.brushSize = x, y, z
def hoverPosition(self, event):
if event.blockPosition:
vector = (event.blockFace.vector * self.hoverDistance)
pos = event.blockPosition + vector
return pos
def mousePress(self, event):
self.dragPoints[:] = []
pos = self.hoverPosition(event)
if pos:
self.dragPoints.append(pos)
def mouseMove(self, event):
pos = self.hoverPosition(event)
if pos:
self.cursorTranslate.translateOffset = pos
def mouseDrag(self, event):
p2 = self.hoverPosition(event)
if p2:
if len(self.dragPoints):
p1 = self.dragPoints.pop(-1)
points = list(bresenham.bresenham(p1, p2))
self.dragPoints.extend(points)
else:
self.dragPoints.append(p2)
def mouseRelease(self, event):
if not len(self.dragPoints):
pos = self.hoverPosition(event)
if pos:
self.dragPoints.append(pos)
if len(self.dragPoints):
dragPoints = sorted(set(self.dragPoints))
self.dragPoints[:] = []
command = BrushCommand(self.editorSession, dragPoints, self.options)
self.editorSession.pushCommand(command)
@property
def options(self):
options = {'brushSize': self.brushSize,
'brushShape': self.brushShape,
'brushMode': self.brushMode,
'brushHollow': self.brushHollow}
options.update(self.brushMode.getOptions())
return options
def modeSettingChanged(self, value):
self.brushMode = self.brushModesByName[value]
stack = self.toolWidget.modeOptionsStack
while stack.count():
stack.removeWidget(stack.widget(0))
if self.brushMode.optionsWidget:
stack.addWidget(self.brushMode.optionsWidget)
@property
def brushShape(self):
return self.toolWidget.brushShapeInput.currentShape
@property
def brushHollow(self):
return self.toolWidget.hollowCheckBox.isChecked()
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)
示例3: WorldView
# 需要导入模块: from mcedit2.rendering.scenegraph.scenenode import Node [as 别名]
# 或者: from mcedit2.rendering.scenegraph.scenenode.Node import removeChild [as 别名]
#.........这里部分代码省略.........
return worldscene.WorldScene(self.dimension, self.textureAtlas, self.geometryCache)
def createSceneGraph(self):
sceneGraph = scenenode.Node("WorldView SceneGraph")
self.worldScene = self.createWorldScene()
self.worldScene.setVisibleLayers(self.layerToggleGroup.getVisibleLayers())
clearNode = ClearNode()
self.skyNode = sky.SkyNode()
self.loadableChunksNode = loadablechunks.LoadableChunksNode(self.dimension)
self.worldNode = Node("World Container")
self.matrixState = MatrixState()
self.worldNode.addState(self.matrixState)
self._updateMatrices()
self.worldNode.addChild(self.loadableChunksNode)
self.worldNode.addChild(self.worldScene)
self.worldNode.addChild(self.overlayNode)
sceneGraph.addChild(clearNode)
sceneGraph.addChild(self.skyNode)
sceneGraph.addChild(self.worldNode)
sceneGraph.addChild(self.compassNode)
if self.cursorNode:
self.worldNode.addChild(self.cursorNode)
return sceneGraph
# --- Tool support ---
def setToolCursor(self, cursorNode):
if self.cursorNode:
self.worldNode.removeChild(self.cursorNode)
self.cursorNode = cursorNode
if cursorNode:
self.worldNode.addChild(cursorNode)
def setToolOverlays(self, overlayNodes):
self.overlayNode.clear()
for node in overlayNodes:
self.overlayNode.addChild(node)
# --- View settings ---
def setLayerVisible(self, layerName, visible):
self.worldScene.setLayerVisible(layerName, visible)
self.resetLoadOrder()
def setDayTime(self, value):
if self.skyNode:
self.skyNode.setDayTime(value)
def _updateMatrices(self):
self.updateMatrices()
self.updateFrustum()
#min = self.unprojectPoint(0, 0)[0]
#max = self.unprojectPoint(self.width(), self.height())[0]
#self.visibleBox = BoundingBox(min, (0, 0, 0)).union(BoundingBox(max, (0, 0, 0)))
def updateMatrices(self):
"""
Subclasses must implement updateMatrices to set the projection and modelview matrices.
Should set self.worldNode.projection and self.worldNode.modelview
"""
示例4: GenerateTool
# 需要导入模块: from mcedit2.rendering.scenegraph.scenenode import Node [as 别名]
# 或者: from mcedit2.rendering.scenegraph.scenenode.Node import removeChild [as 别名]
#.........这里部分代码省略.........
def mousePress(self, event):
self.boxHandleNode.mousePress(event)
def mouseMove(self, event):
self.boxHandleNode.mouseMove(event)
def mouseRelease(self, event):
self.boxHandleNode.mouseRelease(event)
def boundsDidChange(self, bounds):
# box still being resized
if not self.currentGenerator:
return
if not self.livePreview:
return
self.previewBounds = bounds
self.currentGenerator.boundsChanged(bounds)
self.updatePreview()
def boundsDidChangeDone(self, bounds, oldBounds):
# box finished resize
if not self.currentGenerator:
return
self.previewBounds = bounds
self.schematicBounds = bounds
self.currentGenerator.boundsChanged(bounds)
self.updatePreview()
def clearNode(self):
if self.previewNode:
self.overlayNode.removeChild(self.previewNode)
self.previewNode = None
def updatePreview(self):
if self.blockPreview:
self.updateBlockPreview()
else:
self.clearSchematic()
if self.glPreview:
self.updateNodePreview()
else:
self.clearNode()
def updateBlockPreview(self):
bounds = self.previewBounds
if bounds is not None and bounds.volume > 0:
self.generateNextSchematic(bounds)
else:
self.clearSchematic()
def updateNodePreview(self):
bounds = self.previewBounds
if self.currentGenerator is None:
return
if bounds is not None and bounds.volume > 0:
try:
node = self.currentGenerator.getPreviewNode(bounds)
except Exception:
log.exception("Error while getting scene nodes from generator:")
else:
示例5: BrushTool
# 需要导入模块: from mcedit2.rendering.scenegraph.scenenode import Node [as 别名]
# 或者: from mcedit2.rendering.scenegraph.scenenode.Node import removeChild [as 别名]
#.........这里部分代码省略.........
self.fillBlock = editorSession.worldEditor.blocktypes["stone"]
self.brushSize = BrushSizeSetting.value(QtGui.QVector3D(5, 5, 5)).toTuple() # calls updateCursor
self.toolWidget.xSpinSlider.setValue(self.brushSize[0])
self.toolWidget.ySpinSlider.setValue(self.brushSize[1])
self.toolWidget.zSpinSlider.setValue(self.brushSize[2])
@property
def hoverDistance(self):
return self.toolWidget.hoverSpinSlider.value()
_brushSize = (0, 0, 0)
@property
def brushSize(self):
return self._brushSize
@brushSize.setter
def brushSize(self, value):
self._brushSize = value
BrushSizeSetting.setValue(QtGui.QVector3D(*self.brushSize))
self.updateCursor()
def setX(self, val):
x, y, z = self.brushSize
x = float(val)
self.brushSize = x, y, z
def setY(self, val):
x, y, z = self.brushSize
y = float(val)
self.brushSize = x, y, z
def setZ(self, val):
x, y, z = self.brushSize
z = float(val)
self.brushSize = x, y, z
def setBlocktypes(self, types):
if len(types) == 0:
return
self.fillBlock = types[0]
self.updateCursor()
def mousePress(self, event):
pos = event.blockPosition
vector = (event.blockFace.vector * self.hoverDistance)
command = BrushCommand(self.editorSession, [pos + vector], self.options)
self.editorSession.pushCommand(command)
def mouseMove(self, event):
if event.blockPosition:
vector = (event.blockFace.vector * self.hoverDistance)
assert isinstance(vector, Vector), "vector isa %s" % type(vector)
self.cursorTranslate.translateOffset = event.blockPosition + vector
@property
def options(self):
options = {'brushSize': self.brushSize,
'brushShape': self.brushShape,
'brushMode': self.brushMode}
options.update(self.brushMode.getOptions())
return options
def modeSettingChanged(self, value):
self.brushMode = self.brushModesByName[value]
stack = self.toolWidget.modeOptionsStack
while stack.count():
stack.removeWidget(stack.widget(0))
widget = self.brushMode.createOptionsWidget(self)
if widget:
stack.addWidget(widget)
@property
def brushShape(self):
return self.toolWidget.brushShapeInput.currentShape
def updateCursor(self):
log.info("Updating brush cursor")
if self.cursorWorldScene:
self.brushLoader.timer.stop()
self.cursorNode.removeChild(self.cursorWorldScene)
self.cursorNode.removeChild(self.cursorBoxNode)
cursorLevel = self.brushMode.createCursorLevel(self)
cursorBox = self.brushMode.brushBoxForPoint((0, 0, 0), self.options)
self.cursorBoxNode = SelectionBoxNode()
self.cursorBoxNode.selectionBox = cursorBox
self.cursorBoxNode.filled = False
self.cursorWorldScene = worldscene.WorldScene(cursorLevel, self.editorSession.textureAtlas)
self.cursorWorldScene.depthOffset.depthOffset = DepthOffsets.PreviewRenderer
self.cursorNode.addChild(self.cursorWorldScene)
self.cursorNode.addChild(self.cursorBoxNode)
self.brushLoader = WorldLoader(self.cursorWorldScene)
self.brushLoader.startLoader()