当前位置: 首页>>代码示例>>Python>>正文


Python WorldEditor.rotateSnap方法代码示例

本文整理汇总了Python中WorldEditor.rotateSnap方法的典型用法代码示例。如果您正苦于以下问题:Python WorldEditor.rotateSnap方法的具体用法?Python WorldEditor.rotateSnap怎么用?Python WorldEditor.rotateSnap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WorldEditor的用法示例。


在下文中一共展示了WorldEditor.rotateSnap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: onMouseEvent

# 需要导入模块: import WorldEditor [as 别名]
# 或者: from WorldEditor import rotateSnap [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
开发者ID:siredblood,项目名称:tree-bumpkin-project,代码行数:67,代码来源:WorldEditorDirector.py


注:本文中的WorldEditor.rotateSnap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。