本文整理汇总了Python中WorldEditor.tool方法的典型用法代码示例。如果您正苦于以下问题:Python WorldEditor.tool方法的具体用法?Python WorldEditor.tool怎么用?Python WorldEditor.tool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorldEditor
的用法示例。
在下文中一共展示了WorldEditor.tool方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onKeyEvent
# 需要导入模块: import WorldEditor [as 别名]
# 或者: from WorldEditor import tool [as 别名]
def onKeyEvent( self, isDown, key, modifiers ):
if not WorldEditor.cursorOverGraphicsWnd():
return 0
if key == KEY_RIGHTMOUSE:
if ( not self.rightMouseButtonDown ) and isDown:
self.rightMouseButtonDown = 1
self.mouseMoved = 0
elif self.rightMouseButtonDown and not isDown:
self.rightMouseButtonDown = 0
if not self.mouseMoved:
self.onRightMouse()
handled = 0
if self.avatarMode and key == KEY_Q:
self.qDown = isDown
self.eDown = 0
handled = 1
if self.avatarMode and key == KEY_E:
self.eDown = isDown
self.qDown = 0
handled = 1
if not handled:
handled = WorldEditor.camera().handleKeyEvent( isDown, key, modifiers )
if not handled and isDown:
handled = self.ownKeyEvent( key, modifiers )
if not handled and WorldEditor.tool() != None:
handled = WorldEditor.tool().handleKeyEvent( isDown, key, modifiers )
if not handled and isDown and key == KEY_LEFTMOUSE and self.objInfo.overGizmo:
WorldEditor.gizmoClick()
handled = 1
return handled
示例2: enterChunkVizMode
# 需要导入模块: import WorldEditor [as 别名]
# 或者: from WorldEditor import tool [as 别名]
def enterChunkVizMode( self ):
t = WorldEditor.tool()
if ( t != None ):
curr = WorldEditor.getOptionInt( "render/chunk/vizMode" )
t.delView( "chunkViz" )
vizRes = 0;
if t.functor == self.alphaTool.functor:
vizRes = WorldEditor.terrainBlendsRes()
elif t.functor == self.itemTool.functor or t.functor == self.heightTool.functor or t.functor == self.filterTool.functor:
vizRes = WorldEditor.terrainHeightMapRes()
elif t.functor == self.holeTool.functor:
vizRes = WorldEditor.terrainHoleMapRes()
if vizRes == 0:
self.needsChunkVizUpdate = True
vizRes = 1 # set it to some sensible value
else:
self.needsChunkVizUpdate = False
if curr == 1:
t.addView( self.chunkViz, "chunkViz" )
elif curr == 2:
self.vertexViz.numPerChunk = vizRes
t.addView( self.vertexViz, "chunkViz" )
elif curr == 3:
self.meshViz.numPerChunk = vizRes
t.addView( self.meshViz, "chunkViz" )
示例3: onPause
# 需要导入模块: import WorldEditor [as 别名]
# 或者: from WorldEditor import tool [as 别名]
def onPause( self ):
self.cc.visible = 0
self.cc.delAsView()
if ( WorldEditor.tool() != None ):
WorldEditor.popTool()
pass
示例4: enterMode
# 需要导入模块: import WorldEditor [as 别名]
# 或者: from WorldEditor import tool [as 别名]
def enterMode( self, modeName, forceUpdate = 0 ):
#print "enterMode - current %s, new %s, terrainMode %s" % (self.modeName, modeName, self.terrainModeName )
if (self.modeName == modeName) and (not forceUpdate):
return
t = WorldEditor.tool()
oldTool = t
if t != None and modeName != "Object":
if self.itemTool.functor.script.selection.size:
self.itemTool.functor.script.selection.rem( self.itemTool.functor.script.selection )
self.itemTool.functor.script.selUpdate()
WorldEditor.popTool()
# Remove the project or height module if we're coming out of project or height mode
if self.modeName in ("Project", "Height"):
self.modeStack.pop()
self.modeName = self.modeStack[ len( self.modeStack ) - 1 ]
WorldEditor.pop()
if ( modeName == "TerrainTexture" ):
WorldEditor.pushTool( self.alphaTool )
self.terrainModeName = modeName
elif ( modeName == "TerrainHeight" ):
WorldEditor.pushTool( self.heightTool )
self.terrainModeName = modeName
elif ( modeName == "TerrainFilter" ):
WorldEditor.pushTool( self.filterTool )
self.terrainModeName = modeName
elif ( modeName == "TerrainHoleCut" ):
WorldEditor.pushTool( self.holeTool )
self.terrainModeName = modeName
elif ( modeName == "Terrain" ):
self.modeName = modeName
self.enterMode( self.terrainModeName )
self.modeStack.append( modeName )
return
elif ( modeName == "Object" ):
WorldEditor.pushTool( self.itemTool )
self.modeStack.append( modeName )
elif ( modeName == "Project" ):
WorldEditor.push( "ProjectModule" )
self.modeStack.append( modeName )
elif ( modeName == "Height" ):
WorldEditor.push( "HeightModule" )
self.modeStack.append( modeName )
else:
WorldEditor.addCommentaryMsg( "%s mode not yet implemented" % modeName, 1 )
self.enterChunkVizMode()
WorldEditor.addCommentaryMsg( "entered " + modeName + " mode" )
self.modeName = modeName
newTool = WorldEditor.tool()
if oldTool != None and oldTool != newTool:
oldTool.endUsing()
if newTool != None:
newTool.beginUsing()
示例5: updateState
# 需要导入模块: import WorldEditor [as 别名]
# 或者: from WorldEditor import tool [as 别名]
def updateState( self, dTime ):
"""This function forces an update to be called in World Editor.
Usually called everyframe, however it still recieves a dTime
value which informs the update function how much time has passed
since the last update call."""
# detect a change of space, and act accordingly
if self.currentSpace != WorldEditor.getOptionString( "space/mru0" ):
self.currentSpace = WorldEditor.getOptionString( "space/mru0" )
# make sure the chunk viz resolution is set correctly
self.enterChunkVizMode()
GUI.update( dTime )
self.cc.update( dTime )
WorldEditor.camera().update( dTime )
if ( WorldEditor.tool() != None and not WorldEditor.tool().applying ):
self.objInfo.overGizmo = WorldEditor.gizmoUpdate( WorldEditor.worldRay() )
# update the WorldEditor
WorldEditor.update( dTime )
# update tool views
base = dTime / 5
self.alphaToolTextureView.rotation += base * (1 + (self.alphaTool.strength / 650))
self.heightView.rotation += base * (1 + (self.heightTool.strength / 650))
self.filterToolTextureView.rotation += base
if self.nextTimeDoSelUpdate == 2:
self.itemTool.functor.script.restoreOldSelection()
self.nextTimeDoSelUpdate = 0
elif self.nextTimeDoSelUpdate == 1:
self.itemTool.functor.script.clearAndSaveSelection()
self.nextTimeDoSelUpdate = 2
if WorldEditor.isInPlayerPreviewMode() and not self.avatarMode:
WorldEditor.addCommentaryMsg( "entered avatar walkthrough mode." )
self.avatarMode = 1
if self.avatarMode and not WorldEditor.isInPlayerPreviewMode():
self.qDown = 0
self.eDown = 0
self.avatarMode = 0
if self.avatarMode:
value = WorldEditor.getOptionString( "camera/speed" )
speed = 1
if value == "Medium":
speed = 2
if value == "Fast":
speed = 3
if value == "SuperFast":
speed = 4
if self.qDown and WorldEditor.getOptionInt( "graphics/cameraHeight" ) - speed <= 2:
WorldEditor.setOptionInt( "graphics/cameraHeight", 2 )
if self.qDown and WorldEditor.getOptionInt( "graphics/cameraHeight" ) > 2:
WorldEditor.setOptionInt( "graphics/cameraHeight", WorldEditor.getOptionInt( "graphics/cameraHeight" ) - speed )
if self.eDown:
WorldEditor.setOptionInt( "graphics/cameraHeight", WorldEditor.getOptionInt( "graphics/cameraHeight" ) + speed )
WorldEditor.snapCameraToTerrain()
if WorldEditor.tool() == bd.alphaTool:
bd.alphaTool.size = WorldEditor.getOptionFloat ( "terrain/texture/size" )
bd.alphaTool.strength = WorldEditor.getOptionFloat ( "terrain/texture/strength" )
bd.alphaTool.functor.displayOverlay = WorldEditor.getOptionInt ( "terrain/texture/maskoverlay" )
WorldEditor.setPaintLayer(bd.alphaTool.functor.lastPaintedLayer)
WorldEditor.setPaintPos(bd.alphaTool.functor.lastPaintedPos)
if bd.alphaTool.functor.hadEscapeKey != 0:
WorldEditor.setTerrainPaintEscKey(bd.alphaTool.functor.hadEscapeKey)
bd.alphaTool.functor.hadEscapeKey = 0
bd.heightTool.size = WorldEditor.getOptionFloat ( "terrain/height/size" )
bd.heightTool.strength = WorldEditor.getOptionFloat ( "terrain/height/strength" )
bd.setHeightFunctor.height = WorldEditor.getOptionFloat ( "terrain/height/height" )
bd.setHeightFunctor.relative = WorldEditor.getOptionInt ( "terrain/height/relative" )
bd.heightFunctor.falloff = WorldEditor.getOptionInt ( "terrain/height/brushFalloff" )
bd.filterTool.size = WorldEditor.getOptionFloat ( "terrain/filter/size" )
bd.filterTool.functor.index = WorldEditor.getOptionInt ( "terrain/filter/index" )
bd.holeTool.size = WorldEditor.getOptionFloat ( "terrain/cutRepair/size" )
bd.holeTool.functor.fillNotCut = WorldEditor.getOptionInt ( "terrain/cutRepair/brushMode" )
if self.needsChunkVizUpdate:
self.enterChunkVizMode()
return 1
示例6: onMouseEvent
# 需要导入模块: import WorldEditor [as 别名]
# 或者: from WorldEditor import tool [as 别名]
def onMouseEvent( self, mx, my, mz ):
handled = 0
if mx or my:
self.mouseMoved = 1
legacyMouse = WorldEditor.getOptionInt( "input/legacyMouseWheel" )
itemsRotated = 0
cameraSpeedChanged = False
if legacyMouse != 0:
# if using legacy mouse
if WorldEditor.isKeyDown( KEY_MOUSE1 ):
# Change camera speed with right click
self.handleWheelCameraSpeed( mz )
cameraSpeedChanged = True
elif WorldEditor.tool():
# handle the tool
handled = WorldEditor.tool().handleMouseEvent( mx, my, mz )
itemsRotated = self.itemTool.functor.script.selection.size
else:
# if using new mouse
if WorldEditor.tool() and mz == 0:
# handle the tool
handled = WorldEditor.tool().handleMouseEvent( mx, my, mz )
elif WorldEditor.isKeyDown( KEY_SPACE ):
# Change camera speed with space
self.handleWheelCameraSpeed( mz )
cameraSpeedChanged = True
elif ( WorldEditor.isKeyDown( KEY_LSHIFT ) or WorldEditor.isKeyDown( KEY_RSHIFT ) ) and WorldEditor.tool():
# handle the tool with shift
handled = WorldEditor.tool().handleMouseEvent( mx, my, mz )
itemsRotated = self.itemTool.functor.script.selection.size
elif mz != 0 and \
( WorldEditor.isKeyDown( KEY_LCONTROL ) or WorldEditor.isKeyDown( KEY_RCONTROL ) ) and \
self.itemTool.functor.script.selection.size > 0:
WorldEditor.rotateSnap( self.itemTool.functor.script.selection, mz, self.itemTool.functor.script.mouseRevealer )
itemsRotated = self.itemTool.functor.script.selection.size
if not handled:
handled = WorldEditor.camera().handleMouseEvent( mx, my, mz )
if not handled and ( mz != 0 ) and not itemsRotated and not cameraSpeedChanged:
# zoom using scroll wheel
handled = 1
view = WorldEditor.camera().view
view.invert()
mult = mz / 1200.0
if WorldEditor.isCapsLockOn():
mult = mult * WorldEditor.camera().turboSpeed
else:
mult = mult * WorldEditor.camera().speed
forward = view.applyToAxis( 2 )
view.translation = (
view.translation[0] + forward[0] * mult,
view.translation[1] + forward[1] * mult,
view.translation[2] + forward[2] * mult )
view.invert()
WorldEditor.camera().view = view
return handled
示例7: onRightMouse
# 需要导入模块: import WorldEditor [as 别名]
# 或者: from WorldEditor import tool [as 别名]
def onRightMouse( self ):
if WorldEditor.tool() != None:
WorldEditor.tool().handleContextMenu()
示例8: ownKeyEvent
# 需要导入模块: import WorldEditor [as 别名]
# 或者: from WorldEditor import tool [as 别名]
def ownKeyEvent( self, key, modifiers ):
if key == KEY_B:
if (modifiers & MODIFIER_CTRL) == 0:
curr = WorldEditor.getOptionInt( "drawBSP" )
curr = ( curr + 1 ) % 2
WorldEditor.setOptionInt( "drawBSP", curr )
self.showBSPMsg( curr )
elif key == KEY_M:
curr = WorldEditor.getOptionInt( "dragOnSelect" )
curr = ( curr + 1 ) % 2
WorldEditor.setOptionInt( "dragOnSelect", curr )
self.dragOnSelectMsg( curr )
elif key == KEY_F8:
curr = WorldEditor.getOptionString( "tools/coordFilter" )
if curr == "World":
curr = "Local"
elif curr == "Local":
curr = "View"
elif curr == "View":
curr = "World"
WorldEditor.setOptionString( "tools/coordFilter", curr )
WorldEditor.addCommentaryMsg( "Reference Coordinate System: %s" % curr )
elif key == KEY_L:
if modifiers & MODIFIER_CTRL:
curr = WorldEditor.getOptionInt( "render/lighting" )
curr = ( curr + 1 ) % 3
WorldEditor.setOptionInt( "render/lighting", curr )
self.lightingModeMsg( curr )
elif key == KEY_G:
curr = WorldEditor.getOptionInt( "snaps/xyzEnabled" )
curr = ( curr + 1 )% 2
WorldEditor.setOptionInt( "snaps/xyzEnabled", curr )
self.objectSnapMsg( curr )
elif key == KEY_1 and not modifiers:
WorldEditor.setToolMode( "Objects" )
elif key == KEY_2 and not modifiers:
WorldEditor.setToolMode( "TerrainTexture" )
elif key == KEY_3 and not modifiers:
WorldEditor.setToolMode( "TerrainHeight" )
elif key == KEY_4 and not modifiers:
WorldEditor.setToolMode( "TerrainFilter" )
elif key == KEY_5 and not modifiers:
WorldEditor.setToolMode( "TerrainMesh" )
elif key == KEY_6 and not modifiers:
WorldEditor.setToolMode( "TerrainImpExp" )
elif key == KEY_7 and not modifiers:
WorldEditor.setToolMode( "Project" )
t = WorldEditor.tool()
sizeSection = ''
strengthSection = ''
minSizeSection = ''
maxSizeSection = ''
minStrengthSection = ''
maxStrengthSection = ''
if t == self.alphaTool:
sizeSection = 'terrain/texture/size'
minSizeSection = 'terrain/texture/minsizelimit'
maxSizeSection = 'terrain/texture/maxsizelimit'
strengthSection = 'terrain/texture/strength'
minStrengthSection = 'terrain/texture/minstrengthlimit'
maxStrengthSection = 'terrain/texture/maxstrengthlimit'
elif t == self.heightTool:
sizeSection = 'terrain/height/size'
minSizeSection = 'terrain/height/minsizelimit'
maxSizeSection = 'terrain/height/maxsizelimit'
strengthSection = 'terrain/height/strength'
minStrengthSection = 'terrain/height/minstrengthlimit'
maxStrengthSection = 'terrain/height/maxstrengthlimit'
elif t == self.filterTool:
sizeSection = 'terrain/filter/size'
minSizeSection = 'terrain/filter/minsizelimit'
maxSizeSection = 'terrain/filter/maxsizelimit'
elif t == self.holeTool:
sizeSection = 'terrain/cutRepair/size'
minSizeSection = 'terrain/cutRepair/minsizelimit'
maxSizeSection = 'terrain/cutRepair/maxsizelimit'
if sizeSection:
size = WorldEditor.getOptionFloat( sizeSection )
minSize = WorldEditor.getOptionFloat( minSizeSection )
maxSize = WorldEditor.getOptionFloat( maxSizeSection )
if key == KEY_RBRACKET:
if not ( modifiers & MODIFIER_SHIFT ):
size = size * 1.25 + 1
if size > maxSize:
size = maxSize
#.........这里部分代码省略.........
示例9: itemMode
# 需要导入模块: import WorldEditor [as 别名]
# 或者: from WorldEditor import tool [as 别名]
def itemMode():
return ( WorldEditor.tool() == bd.itemTool )