def handleWheelCameraSpeed( self, mz ):
		# look at the rotator for changing the camera speed
		c = WorldEditor.camera()
		currentValue = WorldEditor.getOptionString( "camera/speed" )
		speeds = ["Slow", "Medium", "Fast", "SuperFast"]

		iSpeed = 0
		if currentValue == speeds[1]:
			iSpeed = 1
		elif currentValue == speeds[2]:
			iSpeed = 2
		elif currentValue == speeds[3]:
			iSpeed = 3

		if mz > 0:
			iSpeed = iSpeed + 1
			if iSpeed > 3:
				iSpeed = 3
		elif mz < 0:
			iSpeed = iSpeed - 1
			if iSpeed < 0:
				iSpeed = 0

		value = speeds[iSpeed]

		handled = 0
		if value != currentValue:
			c = WorldEditor.camera()
			WorldEditor.setOptionString( "camera/speed", value )
			c.speed = WorldEditor.getOptionFloat( "camera/speed/" + value )
			c.turboSpeed = WorldEditor.getOptionFloat( "camera/speed/" + value + "/turbo" )
			handled = 1
			WorldEditor.addCommentaryMsg( "New camera speed %s" % value, 1 )

		return handled
예제 #2
0
	def onStart( self ):
		c = WorldEditor.camera()
		c.speed = WorldEditor.getOptionFloat( "app/cameraSpeed" )
		c.turboSpeed = WorldEditor.getOptionFloat( "app/cameraSpeed2" )

		
		self.alphafunc = Functor.TerrainTextureFunctor()
		self.guiview = View.AlphaGUITextureToolView( self.alphafunc )

		viewmap = ""
		try:
			viewmap = WorldEditor.getOptionString( "tools/alphaTool" )
		except:
			pass
		if viewmap == "": viewmap = "resources/maps/gizmo/disc.bmp"
		
		self.alphatool = WorldEditor.Tool(
			Locator.TerrainToolLocator(),
			View.TerrainTextureToolView( viewmap ),
			self.alphafunc )


		vismap = ""
		try:
			vismap = WorldEditor.getOptionString( "tools/chunkVisualisation" )
		except:
			pass
		if vismap == "": vismap = "resources/maps/gizmo/square.bmp"

		self.chunkvis = View.TerrainChunkTextureToolView( vismap )

		scv = WorldEditor.getOptionString( "tools/showChunkVisualisation" )
		if scv == "true":
			self.alphatool.addView( self.chunkvis, "chunkVisualisation" )

		self.alphatool.addView( self.guiview, "alphaGUI" )
		self.guiview.visible = 1

		self.alphatool.size = WorldEditor.getOptionFloat( "tools/alphaToolSize" )
		self.alphatool.strength = WorldEditor.getOptionFloat( "tools/alphaToolStrength" )

		self.heightfunc = Functor.TerrainHeightFilterFunctor()

		# Create the ecotype tool
		self.ecotool = WorldEditor.Tool(
				Locator.TerrainChunkLocator(),
				View.TerrainChunkTextureToolView( vismap ),
				Functor.HeightPoleEcotypeFunctor() );
		self.ecotool.size = 10000

		# Create the object manipulation tool
		self.objtool = WorldEditor.Tool()
		self.objtool.functor = Functor.ScriptedFunctor(
			ChunkItemFunctor( self.objtool, self.objInfo ) )

		# Make the closed captions commentary viewer
		self.cc = GUI.ClosedCaptions( WorldEditor.getOptionInt( "consoles/numMessageLines" ) )

		self.onResume( 0 )
예제 #3
0
def actShellSnapsExecute():
    WorldEditor.setOptionVector3(
        "snaps/movement", WorldEditor.getOptionVector3("shellSnaps/movement"))
    WorldEditor.setOptionFloat("snaps/angle",
                               WorldEditor.getOptionFloat("shellSnaps/angle"))
    newSnaps = WorldEditor.getOptionVector3("snaps/movement")
    WorldEditor.addCommentaryMsg("Movement snaps are %f,%f,%f" %
                                 (newSnaps[0], newSnaps[1], newSnaps[2]))
    WorldEditor.addCommentaryMsg("Rotation snaps are %f" %
                                 WorldEditor.getOptionFloat("snaps/angle"))
예제 #4
0
def actFreeSnapsExecute():
    newSnaps = (0.1, 0.1, 0.1)
    WorldEditor.setOptionVector3("snaps/movement", newSnaps)
    WorldEditor.setOptionFloat("snaps/angle", 1)
    WorldEditor.addCommentaryMsg("Movement snaps are %f,%f,%f" %
                                 (newSnaps[0], newSnaps[1], newSnaps[2]))
    WorldEditor.addCommentaryMsg("Rotation snaps are %f" %
                                 WorldEditor.getOptionFloat("snaps/angle"))
예제 #5
0
def updateCamera( value ):
	c = WorldEditor.camera()
	c.speed = WorldEditor.getOptionFloat( "camera/speed/" + value )
	c.turboSpeed = WorldEditor.getOptionFloat( "camera/speed/" + value + "/turbo" )
예제 #6
0
def updateCamera():
    value = WorldEditor.getOptionString("camera/speed")
    c = WorldEditor.camera()
    c.speed = WorldEditor.getOptionFloat("camera/speed/" + value, 60)
    c.turboSpeed = WorldEditor.getOptionFloat(
        "camera/speed/" + value + "/turbo", 120)
	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
	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
					t.size = size
					WorldEditor.setOptionFloat( sizeSection, size )
					WorldEditor.addCommentaryMsg( "Tool size %0.1f" % size )
			elif key == KEY_LBRACKET:
				if not ( modifiers & MODIFIER_SHIFT ):
					size = size * 0.8 - 1
					if size < minSize:
						size = minSize
					t.size = size
					WorldEditor.setOptionFloat( sizeSection, size )
					WorldEditor.addCommentaryMsg( "Tool size %0.1f" % size )
		if strengthSection:
			strength = WorldEditor.getOptionFloat( strengthSection )
			minStrength = WorldEditor.getOptionFloat( minStrengthSection )
			maxStrength = WorldEditor.getOptionFloat( maxStrengthSection )
			if key == KEY_RBRACKET and strength >= 0 or key == KEY_LBRACKET and strength < 0:
				if modifiers & MODIFIER_SHIFT:
					if strength >= 0:
						strength = strength * 1.25 + 1
					else:
						strength = strength * 1.25 - 1
					if strength > maxStrength:
						strength = maxStrength
					t.strength = strength
					WorldEditor.setOptionFloat( strengthSection, strength )
					WorldEditor.addCommentaryMsg( "Tool strength %0.1f" % strength )
			elif key == KEY_LBRACKET and strength >= 0 or key == KEY_RBRACKET and strength < 0:
				if modifiers & MODIFIER_SHIFT:
					if strength >= 0:
						strength = strength * 0.8 - 1
					else:
						strength = strength * 0.8 + 1
					if strength < minStrength:
						strength = minStrength
					t.strength = strength
					WorldEditor.setOptionFloat( strengthSection, strength )
					WorldEditor.addCommentaryMsg( "Tool strength %0.1f" % strength )
def actFreeSnapsExecute():
	newSnaps = ( 0.1, 0.1, 0.1 )
	WorldEditor.setOptionVector3( "snaps/movement", newSnaps )
	WorldEditor.setOptionFloat( "snaps/angle", 1 )
	WorldEditor.addCommentaryMsg( "Movement snaps are %f,%f,%f" % (newSnaps[0],newSnaps[1],newSnaps[2]) )
	WorldEditor.addCommentaryMsg( "Rotation snaps are %f" % WorldEditor.getOptionFloat( "snaps/angle" ) )
def actShellSnapsExecute():
	WorldEditor.setOptionVector3( "snaps/movement", WorldEditor.getOptionVector3( "shellSnaps/movement" ) )
	WorldEditor.setOptionFloat( "snaps/angle", WorldEditor.getOptionFloat( "shellSnaps/angle" ) )
	newSnaps = WorldEditor.getOptionVector3( "snaps/movement" )
	WorldEditor.addCommentaryMsg( "Movement snaps are %f,%f,%f" % (newSnaps[0],newSnaps[1],newSnaps[2]) )
	WorldEditor.addCommentaryMsg( "Rotation snaps are %f" % WorldEditor.getOptionFloat( "snaps/angle" ) )
예제 #11
0
def updateCamera():
	value = WorldEditor.getOptionString( "camera/speed" )
	c = WorldEditor.camera()
	c.speed = WorldEditor.getOptionFloat( "camera/speed/" + value, 60 )
	c.turboSpeed = WorldEditor.getOptionFloat( "camera/speed/" + value + "/turbo", 120 )