def toggleItemSnaps( self ):
		if self.itemSnapMode == 1:
			self.itemSnapMode = 0
		else:
			self.itemSnapMode = 1
		WorldEditor.setOptionInt( "snaps/itemSnapMode", self.itemSnapMode )
		self.updateItemSnaps()
	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" )
	def startDragSelect( self ):
		# add a drag select tool, which will pop itself and set our
		# selection when done.
		nt = WorldEditor.Tool()
		nt.locator = bd.itemTool.locator.subLocator
		nt.functor = Functor.ScriptedFunctor( DragSelectFunctor(nt, self) )
		WorldEditor.pushTool( nt )
Exemplo n.º 4
0
def doRedo( item ):
	what = WorldEditor.redo(0)
	if what:
		WorldEditor.addCommentaryMsg( "Redoing: " + what )
	WorldEditor.redo()

	bd.itemTool.functor.script.selUpdate()
Exemplo n.º 5
0
def actUndoExecute():
    what = WorldEditor.undo(0)
    if what:
        WorldEditor.addCommentaryMsg("Undoing: " + what)
    WorldEditor.undo()

    bd.itemTool.functor.script.selUpdate()
Exemplo n.º 6
0
	def onMouseEvent( self, mx, my, mz ):
		handled = 0
		if not handled:
			handled = WorldEditor.tool().handleMouseEvent( mx, my, mz )
		if not handled:
			handled = WorldEditor.camera().handleMouseEvent( mx, my, mz )
		return handled
Exemplo n.º 7
0
def doRedo(item):
    what = WorldEditor.redo(0)
    if what:
        WorldEditor.addCommentaryMsg("Redoing: " + what)
    WorldEditor.redo()

    bd.itemTool.functor.script.selUpdate()
def actUndoExecute():
	what = WorldEditor.undo(0)
	if what:
		WorldEditor.addCommentaryMsg( "Undoing: " + what )
	WorldEditor.undo()

	bd.itemTool.functor.script.selUpdate()
Exemplo n.º 9
0
	def onKeyEvent( self, isDown, key, modifiers ):
		handled = WorldEditor.camera().handleKeyEvent( isDown, key, modifiers )

		if not handled and isDown:
			handled = self.ownKeyEvent( key, modifiers )
		if not handled:
			handled = WorldEditor.tool().handleKeyEvent( isDown, key, modifiers )
		return handled
Exemplo n.º 10
0
def doUndo(item):
    """This function performs an undo operation."""
    what = WorldEditor.undo(0)
    if what:
        WorldEditor.addCommentaryMsg("Undoing: " + what)
    WorldEditor.undo()

    bd.itemTool.functor.script.selUpdate()
	def render( self, dTime ):
		"""This function forces World Editor to render everything on the scene. 
		Usually called everyframe, however it still recieves a dTime value which 
		informs the renderer how much time has passed since the last render	call."""
		WorldEditor.camera().render( dTime )
		WorldEditor.render( dTime )
		GUI.draw()
		return 1
Exemplo n.º 12
0
def doUndo( item ):
	"""This function performs an undo operation."""
	what = WorldEditor.undo(0)
	if what:
		WorldEditor.addCommentaryMsg( "Undoing: " + what )
	WorldEditor.undo()

	bd.itemTool.functor.script.selUpdate()
	def onPause( self ):
		self.cc.visible = 0
		self.cc.delAsView()

		if ( WorldEditor.tool() != None ):
			WorldEditor.popTool()

		pass
	def setObjectTab( self, tabName ):
		if self.tabName != "":
			# store the current selection
			currentFilter = WorldEditor.getOptionString( "tools/selectFilter" )
			prevSectionName = "object/" + self.tabName + "/selectFilter"
			WorldEditor.setOptionString( prevSectionName, currentFilter )
		self.tabName = tabName
		currSectionName = "object/" + self.tabName + "/selectFilter"
		return WorldEditor.getOptionString( currSectionName )
	def updateItemSnaps( self ):
		#this method calculates itemSnapMode based on the
		#entries in the options.xml
		if ( WorldEditor.getOptionInt( "snaps/itemSnapMode" ) == 2 ):
			self.itemSnapMode = 2
		elif ( WorldEditor.getOptionInt( "snaps/itemSnapMode" ) == 1 ):
			self.itemSnapMode = 1
		else:
			self.itemSnapMode = 0
		self.enterItemSnapMode()
Exemplo n.º 16
0
def edtMiscSnapsZExit(value):
    if value[-2:] == "cm":
        floatValue = float(value[:-2]) / 100.0
    elif value[-1] == "m":
        floatValue = float(value[:-1])
    else:
        floatValue = float(value)

    ns = WorldEditor.getOptionVector3("snaps/movement")
    WorldEditor.setOptionVector3("snaps/movement", (ns[0], ns[1], floatValue))
Exemplo n.º 17
0
def edtFarPlaneExit( value ):
	"""This function allows the farPlane distance to be set in centimetres and metres."""
	if value[-2:] == "cm":
		floatValue = float(value[:-2])/100.0
	elif value[-1] == "m":
		floatValue = float(value[:-1])
	else:
		floatValue = float(value)

	WorldEditor.farPlane( floatValue )
Exemplo n.º 18
0
def edtMiscSnapsXExit( value ):
	if value[-2:] == "cm":
		floatValue = float(value[:-2])/100.0
	elif value[-1] == "m":
		floatValue = float(value[:-1])
	else:
		floatValue = float(value)

	ns = WorldEditor.getOptionVector3( "snaps/movement" )
	WorldEditor.setOptionVector3( "snaps/movement", ( floatValue, ns[1], ns[2] ) )
Exemplo n.º 19
0
def edtFarPlaneExit(value):
    """This function allows the farPlane distance to be set in centimetres and metres."""
    if value[-2:] == "cm":
        floatValue = float(value[:-2]) / 100.0
    elif value[-1] == "m":
        floatValue = float(value[:-1])
    else:
        floatValue = float(value)

    WorldEditor.farPlane(floatValue)
	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
Exemplo n.º 21
0
 def _onInput(self, fov):
     if fov <= 0.017:
         LOG_ERROR('[VSE] Wrong Camera FOV: {0}'.format(fov))
     elif fov >= 3.1416:
         LOG_ERROR('[VSE] Wrong Camera FOV: {0}'.format(fov))
     elif IS_CLIENT:
         BigWorld.projection().fov = fov
     else:
         import WorldEditor
         WorldEditor.setCameraFOV(fov)
     return 'out'
Exemplo n.º 22
0
def pgcTerrainTabSelect(value):
    if value == "tabTerrainTextures":
        bd.enterMode("TerrainTexture")
    elif value == "tabTerrainBrushes":
        bd.enterMode("TerrainHeight")
    elif value == "tabTerrainFilters":
        bd.enterMode("TerrainFilter")
    elif value == "tabTerrainTools":
        bd.enterMode("TerrainHoleCut")
    else:
        WorldEditor.addCommentaryMsg(value + " unknown tab", 1)
def pgcTerrainTabSelect( value ):
	if value == "tabTerrainTextures":
		bd.enterMode( "TerrainTexture" )
	elif value == "tabTerrainBrushes":
		bd.enterMode( "TerrainHeight" )
	elif value == "tabTerrainFilters":
		bd.enterMode( "TerrainFilter" )
	elif value == "tabTerrainTools":
		bd.enterMode( "TerrainHoleCut" )
	else:
		WorldEditor.addCommentaryMsg( value + " unknown tab", 1 )
Exemplo n.º 24
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"))
	def onStop( self ):
		self.selEditor = None
		WorldEditor.setCurrentEditors()
		
		# Remove the closed captions commentary viewer
		self.cc.visible = 0
		self.cc.delAsView()
		del self.cc

		# Remove options entries that are messy and transient
		WorldEditor.saveOptions()

		return 0
	def update( self, dTime, tool ):
		if self.currentSpace_ != WorldEditor.getOptionString( "space/mru0" ):
			self.currentSpace_ = WorldEditor.getOptionString( "space/mru0" )
			set_clear( self.selection )
			self.selUpdate()
		if self.objInfo.overGizmo:
			self.mouseView.revealer = None
		else:
			self.mouseView.revealer = self.mouseRevealer

		# TODO: Check if mouse button down and threshold crossed.
		# If so start a drag with the current object
		pass
	def enterItemSnapMode( self ):
		newLoc = None
		t = self.itemTool
		if self.itemSnapMode == 0:
			newLoc = self.itemToolXZLocator
			t.delView( "stdView" )
			t.addView( self.itemToolPlaneView, "stdView" )
			t.size = 1
			WorldEditor.addCommentaryMsg( "Entering free snap mode" )
		elif self.itemSnapMode == 1:
			newLoc = Locator.TerrainToolLocator()
			t.delView( "stdView" )
			t.addView( self.itemToolTextureView, "stdView" )
			t.size = 1
			WorldEditor.addCommentaryMsg( "Entering terrain snap mode" )
		elif self.itemSnapMode == 2:
			newLoc = Locator.ChunkObstacleToolLocator()
			t.delView( "stdView" )
			t.addView( self.itemToolModelView, "stdView" )
			t.size = 1
			WorldEditor.addCommentaryMsg( "Entering obstacle snap mode" )
		else:
			WorldEditor.addCommentaryMsg( "Unknown snap mode" )

		#finally, recreate the functor
		self.itemTool.locator.subLocator = newLoc
	def onMiddleMouse( self ):
		# ensure that we both have a selection and something under the mouse
		if not self.selection.size or not self.mouseRevealer.size:
			return

		# ensure that we're in shell mode
		if not WorldEditor.isChunkSelected():
			return

		# If v is held down, clone and snap the shell under the cursor
		if WorldEditor.isKeyDown( KEY_V ):
			group = WorldEditor.cloneAndAutoSnap( self.mouseRevealer, self.selection )
			if ( group != None ):
				set_assign( self.selection, group )
				self.selUpdate()
			else:
				WorldEditor.addCommentaryMsg( "No matching portals", 2 )

			return

		# if the selection is different to what's under the mouse,
		if set_difference_new( self.selection, self.mouseRevealer ).size:
			# auto snap the shells together
			if not WorldEditor.autoSnap( self.selection, self.mouseRevealer ):
				WorldEditor.addCommentaryMsg( "No matching portals" )
Exemplo n.º 29
0
def doSelectAll( item ):
	"""This function selects all editable items in all loaded chunks."""
	group = WorldEditor.selectAll()
	if ( group != None ):
		bd.itemTool.functor.script.selection.rem( bd.itemTool.functor.script.selection )
		bd.itemTool.functor.script.selection.add( group )
		bd.itemTool.functor.script.selUpdate()
Exemplo n.º 30
0
 def _onInput(self, position, yaw, pitch, roll):
     self._parent.setRotateYPR(Math.Vector3(yaw, pitch, roll))
     self._parent.translation = position
     if IS_CLIENT:
         if g_hangarSpace is not None:
             clientHangarSpace = g_hangarSpace.space
             if clientHangarSpace:
                 strategy = clientHangarSpace.hangarCamera.getStateStrategy(
                 )
                 if strategy and isinstance(
                         strategy, BigWorld.CameraStrategySuperFree):
                     direction = Math.Vector3(self._parent.get(2, 0),
                                              self._parent.get(2, 1),
                                              self._parent.get(2, 2))
                     fakeTarget = Math.Vector3(position.x + direction.x,
                                               position.y + direction.y,
                                               position.z + direction.z)
                     self._source.setTranslate(position)
                     self._target.setTranslate(fakeTarget)
                     strategy.sourceProvider = self._source
                     strategy.targetProvider = self._target
                     BigWorld.camera().parentMatrix = self._parent
     else:
         import WorldEditor
         self._parent.invert()
         WorldEditor.camera(0).view = self._parent
     return 'out'
Exemplo n.º 31
0
def actSelectAllExecute():
	"""This function selects all editable items in all loaded chunks."""
	group = WorldEditor.selectAll()
	if ( group != None ):
		bd.itemTool.functor.script.selection.rem( bd.itemTool.functor.script.selection )
		bd.itemTool.functor.script.selection.add( group )
		bd.itemTool.functor.script.selUpdate()
Exemplo n.º 32
0
	def updateState( self, dTime ):
		GUI.update( dTime )
		self.cc.update( dTime )
		WorldEditor.camera().update( dTime )
		if not WorldEditor.tool().applying:
			self.objInfo.overGizmo = WorldEditor.gizmoUpdate( WorldEditor.worldRay() )
		WorldEditor.update( dTime )
		return 1
Exemplo n.º 33
0
 def _onInput(self, position, targetPos):
     localPos = targetPos - position
     localPos.normalise()
     yawOnTarget = math.atan2(localPos.x, localPos.z)
     pitchOnTarget = -math.asin(clamp(-1.0, localPos.y, 1.0))
     if self.prevYaw:
         alternativeYaw = yawOnTarget - math.pi if yawOnTarget > 0 else yawOnTarget + math.pi
         if math.fabs(alternativeYaw -
                      self.prevYaw) < math.fabs(yawOnTarget - self.prevYaw):
             yawOnTarget = alternativeYaw
             pitchOnTarget = math.pi - pitchOnTarget if pitchOnTarget > 0 else -math.pi - pitchOnTarget
     self.prevYaw = yawOnTarget
     self._matrix.setRotateYPR((yawOnTarget, pitchOnTarget, 0))
     self._matrix.translation = position
     if self.prevMatrixYaw:
         if math.fabs(self.prevMatrixYaw - self._matrix.yaw) > 0.1:
             self.skipFrames = SetCameraPosAndTarget.FRAMES_TO_SKIP
         elif math.fabs(self.prevMatrixPitch - self._matrix.pitch) > 0.1:
             self.skipFrames = SetCameraPosAndTarget.FRAMES_TO_SKIP
         elif math.fabs(self.prevMatrixRoll - self._matrix.roll) > 0.1:
             self.skipFrames = SetCameraPosAndTarget.FRAMES_TO_SKIP
     else:
         self.prevMatrixYaw = self._matrix.yaw
         self.prevMatrixPitch = self._matrix.pitch
         self.prevMatrixRoll = self._matrix.roll
     if self.skipFrames > 0:
         self.skipFrames = self.skipFrames - 1
         self._parent.translation = self._matrix.translation
     else:
         self._parent.set(self._matrix)
         if math.fabs(
                 math.fabs(self.prevMatrixYaw) -
                 math.fabs(self._matrix.yaw)) < 0.05 and math.fabs(
                     math.fabs(self.prevMatrixPitch) -
                     math.fabs(self._matrix.pitch)) < 0.05:
             self.prevMatrixYaw = self._matrix.yaw
             self.prevMatrixPitch = self._matrix.pitch
             self.prevMatrixRoll = self._matrix.roll
     if IS_CLIENT:
         if g_hangarSpace is not None:
             clientHangarSpace = g_hangarSpace.space
             if clientHangarSpace:
                 strategy = clientHangarSpace.hangarCamera.getStateStrategy(
                 )
                 if strategy and isinstance(
                         strategy, BigWorld.CameraStrategySuperFree):
                     strategy.parentProvider = self._parent
                     BigWorld.camera().parentMatrix = self._parent
                     clientHangarSpace.hangarCamera.setDirectAngle(
                         yawOnTarget, pitchOnTarget)
     else:
         import WorldEditor
         self._inverted.set(self._parent)
         self._inverted.invert()
         WorldEditor.camera(0).view = self._inverted
     return 'out'
	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
Exemplo n.º 35
0
	def selUpdate( self ):
		if self.selection.size:
			if WorldEditor.isKeyDown( KEY_C ):
				self.selEditor = WorldEditor.ChunkEditor( self.selection )
			else:
				self.selEditor = WorldEditor.ChunkItemEditor( self.selection )
			WorldEditor.setCurrentEditors( self.selEditor )
			print "Selected a", self.selEditor.description
		else:
			self.selEditor = None
			WorldEditor.setCurrentEditors()
	def __init__( self ):
		global bd
		bd = self
		self.objInfo = ObjInfo()
		global oi
		oi = self.objInfo
		self.modeName = "Object"
		self.terrainModeName = "TerrainTexture"
		self.itemSnapMode = 0
		self.nextTimeDoSelUpdate = 0
		self.currentTerrainFilter = -1
		self.rightMouseButtonDown = 0
		self.mouseMoved = 0
		self.eDown = 0
		self.qDown = 0
		self.avatarMode = 0
		self.modeStack = []
		self.needsChunkVizUpdate = False
		self.currentSpace = ""

		WorldEditor.setNoSelectionFilter( "portal" )
		WorldEditor.setOptionInt( "render/chunk/vizMode", 0 );
	def addChunkModel( self ):
		#If we are adding a model file, then simply
		#add the resource name to the chunk at the locator.
		bp = self.objInfo.getBrowsePath()
		if len(bp)>6 and bp[-6:] == ".model":
			d = ResMgr.DataSection( "model" )
			d.writeString( "resource", bp )
			group = WorldEditor.createChunkItem( d, self.mouseLocator.subLocator, 2 )
			if ( group != None ):
				self.chunkItemAdded( d.name );
		if len(bp)>4 and bp[-4:] == ".spt":
			d = ResMgr.DataSection( "speedtree" )
			d.writeString( "spt", bp )
			d.writeInt( "seed", 1 )
			group = WorldEditor.createChunkItem( d, self.mouseLocator.subLocator, 2 )
			if ( group != None ):
				self.chunkItemAdded( d.name );


		# if it's a .xml file in the particles directory, add a ChunkParticles chunk item
		if bp.find("particles/") != -1 and (len(bp)>4 and bp[-4:] == ".xml"):
			d = ResMgr.DataSection( "particles" )
			d.writeString( "resource", bp )
			group = WorldEditor.createChunkItem( d, self.mouseLocator.subLocator, 2 )
			if ( group != None ):
				self.chunkItemAdded( d.name );

		#XML files represent completely generic additions to the chunk,
		#and so all the information must be deep-copied and added
		#to the chunk.
		elif len(bp)>4 and bp[-4:] == ".xml":
			s = ResMgr.openSection( bp ).values()[0]
			if ( s != None ):
				d = ResMgr.DataSection( s.name )
				deepCopy( d, s )
				group = WorldEditor.createChunkItem( d, self.mouseLocator.subLocator )
				if ( group != None ):
					self.chunkItemAdded( d.name );

		# If it's a .py file, add an entity with the same name
		elif len(bp)>3 and bp[-3:] == ".py":
			d = ResMgr.DataSection( "entity" )
			d.writeString( "type", bp[ bp.rfind("/")+1 : -3 ] )
			group = WorldEditor.createChunkItem( d, self.mouseLocator.subLocator )
			if ( group != None ):
				self.chunkItemAdded( d.name );

		# If it's a .def file, add an entity with the same name
		elif len(bp)>4 and bp[-4:] == ".def":
			if bp.find("user_data_object") == -1:
				d = ResMgr.DataSection( "entity" )
				d.writeString( "type", bp[ bp.rfind("/")+1 : -4 ] )
			else:
				d = ResMgr.DataSection( "UserDataObject" )
				d.writeString( "type", bp[ bp.rfind("/")+1 : -4 ] )
			group = WorldEditor.createChunkItem( d, self.mouseLocator.subLocator )
			if ( group != None ):
				self.chunkItemAdded( d.name );
Exemplo n.º 38
0
def brwObjectUalItemSelect(value, dblClick):
    if dblClick == 0:
        global oi
        if value.find("/shells") == -1 and value[:7] != "shells/":
            oi.setShellMode(0)
            ualSelectFilterChange("All Except Terrain and Shells")
        else:
            oi.setShellMode(1)
            ualSelectFilterChange("Shells + Contents")

        oi.setBrowsePath(value)
        oi.showBrowse()
    else:
        if value[-6:] == ".brush":
            WorldEditor.setToolMode("TerrainTexture")
            WorldEditor.setCurrentBrush(value)
        elif WorldEditor.isTerrainTexture(value):
            WorldEditor.setToolMode("TerrainTexture")
            WorldEditor.setCurrentTexture(value)
Exemplo n.º 39
0
def brwObjectUalItemSelect( value, dblClick ):
	if dblClick == 0:
		global oi
		if value.find( "/shells" ) == -1 and value[:7] != "shells/":
			oi.setShellMode( 0 )
			ualSelectFilterChange( "All Except Terrain and Shells" )
		else:
			oi.setShellMode( 1 )
			ualSelectFilterChange( "Shells + Contents" )

		oi.setBrowsePath( value )
		oi.showBrowse()
	else:
		if value[-6:] == ".brush":
			WorldEditor.setToolMode( "TerrainTexture" )
			WorldEditor.setCurrentBrush( value )
		elif WorldEditor.isTerrainTexture( value ):
			WorldEditor.setToolMode( "TerrainTexture" )
			WorldEditor.setCurrentTexture( value )
	def update( self, dTime, tool ):
		# must use update to check for this, key events aren't reliable
		if not WorldEditor.isKeyDown( KEY_LEFTMOUSE ):
			if (WorldEditor.isKeyDown( KEY_LCONTROL ) or WorldEditor.isKeyDown( KEY_RCONTROL )):
				# add the set
				set_union( self.chunkItemFunctor.selection, self.mouseRevealer )
			elif WorldEditor.isKeyDown( KEY_LALT ) or WorldEditor.isKeyDown( KEY_RALT ):
				# remove the set
				self.chunkItemFunctor.selection.rem( self.mouseRevealer )
			else:
				# set the selection to our mouse revaler
				set_assign( self.chunkItemFunctor.selection, self.mouseRevealer )

			if not WorldEditor.isKeyDown( KEY_LALT ) and not WorldEditor.isKeyDown( KEY_RALT ):
				# not removing, so also add whatever is under the cursor
				set_union( self.chunkItemFunctor.selection, self.chunkItemFunctor.mouseRevealer )

			self.chunkItemFunctor.selUpdate()

			WorldEditor.popTool( )
Exemplo n.º 41
0
	def __init__( self, tool, oi ):
		# set up the tool we are part of
		self.mouseLocator = Locator.ChunkItemLocator(
			Locator.TerrainToolLocator() )
		self.mouseRevealer = self.mouseLocator.revealer
		self.selection = WorldEditor.ChunkItemGroup()

		self.mouseView = View.ChunkItemBounds( self.mouseRevealer, 0xff0000ff )
		self.selView = View.ChunkItemBounds( self.selection, 0xff00ff00 )

		tool.locator = self.mouseLocator
		tool.addView( self.mouseView )
		tool.addView( self.selView )

		# store a reference to the object info class
		self.objInfo = oi
	def onLeftMouse( self ):
		self.clickX = 0
		self.clickY = 0
		
		# first see if there's a gizmo in the house
		if self.objInfo.overGizmo:
			# if so, let it take care of things
			WorldEditor.gizmoClick()
			return

		if not self.mouseRevealer.size:
			# nothing to click on, start a marquee selection. This will take
			# care of clearing the selection if it's only a click.
			self.startDragSelect()
			return

		# Check if control is held down, it indicates that we want to toggle
		# what's pointed to in/out of the selection
		if (WorldEditor.isKeyDown( KEY_LCONTROL ) or WorldEditor.isKeyDown( KEY_RCONTROL )):
			# if we're pointing at a subset of the selection
			if set_issubset( self.selection, self.mouseRevealer):
				# remove the subset
				self.selection.rem( self.mouseRevealer )
				self.selUpdate()
				return
			else:
				# add the mouseRevealer to the selection
				set_union( self.selection, self.mouseRevealer )
				self.selUpdate()
				return
		else:
			# if the selection is totally different to what's under the mouse
			# specifically, if we're only pointing at a subset of the
			# selection, we don't want to set the selection to that, we want
			# to drag it instead (which happens below )
			#if not set_intersection_new( self.selection, self.mouseRevealer).size:
			if not set_issubset( self.selection, self.mouseRevealer ):
				# set the selection to what's under the mouse
				set_assign( self.selection, self.mouseRevealer )
				self.selUpdate()



		# nothing under the mouse, bail
		if not self.selection.size:
			return

		if not WorldEditor.getOptionInt( "dragOnSelect" ):
			if not WorldEditor.isKeyDown( KEY_V ):
				return

		# ok, it's drag time
		self.dragging = 1
Exemplo n.º 43
0
	def handleEvent( self, type, key, modifiers, c ):

		if ( WorldEditor.isKeyDown( key ) ):

			if ( key == Keys.KEY_LEFTMOUSE ) :
				c.textureName = self.textureMouseDown
				self.clickState = 1
				return 1

		else:
			
			if ( key == Keys.KEY_LEFTMOUSE ) :
				c.textureName = self.textureFocus
				if ( self.clickState == 1 ):
					if ( self.eventHandler != None ):
						self.eventHandler.onClick( self.buttonEvent )
				return 1
		
		return 0
Exemplo n.º 44
0
    def handleEvent(self, type, key, modifiers, c):

        if (WorldEditor.isKeyDown(key)):

            if (key == Keys.KEY_LEFTMOUSE):
                c.textureName = self.textureMouseDown
                self.clickState = 1
                return 1

        else:

            if (key == Keys.KEY_LEFTMOUSE):
                c.textureName = self.textureFocus
                if (self.clickState == 1):
                    if (self.eventHandler != None):
                        self.eventHandler.onClick(self.buttonEvent)
                return 1

        return 0
Exemplo n.º 45
0
def doSaveCameraPosition(item):
    dir = WorldEditor.getOptionString("space/mru0")
    dirDS = ResMgr.openSection(dir)
    if not dirDS:
        WorldEditor.addCommentaryMsg("Unable to open local directory " + dir)
        return

    ds = dirDS["space.localsettings"]
    if ds == None:
        ds = dirDS.createSection("space.localsettings")

    if ds == None:
        WorldEditor.addCommentaryMsg("Unable to create space.localsettings")
        return

    m = WorldEditor.camera(0).view
    m.invert()
    ds.writeVector3("startPosition", m.translation)
    ds.writeVector3("startDirection", (m.roll, m.pitch, m.yaw))
    ds.save()

    WorldEditor.addCommentaryMsg("Camera position saved")
	def selUpdate( self ):
		try:
			# tell big bang what the current selection is
			WorldEditor.revealSelection( self.selection )

			if self.selection.size:

				self.selEditor = WorldEditor.ChunkItemEditor( self.selection )

				WorldEditor.setCurrentEditors( self.selEditor )
				#if hasattr(self.selEditor, "description"):
				#	print "Selected a", str(self.selEditor.description)
				#else:
				#	print "Selected a group"

				# inform the user of stats about the selection
				#if ( self.objInfo.shellMode == 1 and self.selection.size > 1):
				#	WorldEditor.showChunkReport( self.selection )
			else:
				self.selEditor = None
				WorldEditor.setCurrentEditors()
		except EnvironmentError, e:
			WorldEditor.addCommentaryMsg( e.args[0], 1 )			
Exemplo n.º 47
0
def actSaveCameraPositionExecute():
	dir = WorldEditor.getOptionString( "space/mru0" )
	dirDS = ResMgr.openSection( dir )
	if not dirDS:
		WorldEditor.addCommentaryMsg( "Unable to open local directory " + dir )
		return

	ds = dirDS["space.localsettings"]
	if ds == None:
		ds = dirDS.createSection( "space.localsettings" )

	if ds == None:
		WorldEditor.addCommentaryMsg( "Unable to create space.localsettings" )
		return


	m = WorldEditor.camera(0).view
	m.invert()
	ds.writeVector3( "startPosition", m.translation )
	ds.writeVector3( "startDirection", (m.roll, m.pitch, m.yaw) )
	ds.save()

	WorldEditor.addCommentaryMsg( "Camera position saved" )
Exemplo n.º 48
0
class ChunkItemFunctor:
	def __init__( self, tool, oi ):
		# set up the tool we are part of
		self.mouseLocator = Locator.ChunkItemLocator(
			Locator.TerrainToolLocator() )
		self.mouseRevealer = self.mouseLocator.revealer
		self.selection = WorldEditor.ChunkItemGroup()

		self.mouseView = View.ChunkItemBounds( self.mouseRevealer, 0xff0000ff )
		self.selView = View.ChunkItemBounds( self.selection, 0xff00ff00 )

		tool.locator = self.mouseLocator
		tool.addView( self.mouseView )
		tool.addView( self.selView )

		# store a reference to the object info class
		self.objInfo = oi



	# key event entry point
	def onKeyEvent( self, (isDown, key, modifiers), tool ):
		handled = 0
		if isDown:
			if key == KEY_LEFTMOUSE:
				self.onLeftMouse()
				handled = 1
			elif key == KEY_INSERT:
				bp = self.objInfo.getBrowsePath()
				if len(bp)>6 and bp[-6:] == ".model":
					d = ResMgr.DataSection( "model" )
					d.writeString( "resource", bp )
					# WorldEditor.createChunkItem( d, self.mouseLocator.subLocator )
			elif key == KEY_DELETE:
				if self.selection.size:
					WorldEditor.deleteChunkItem( self.selection )
					self.selection.rem( self.selection )

		return handled
Exemplo n.º 49
0
	def onLeftMouse( self ):
		# first see if there's a gizmo in the house
		if self.objInfo.overGizmo:
			# if so, let it take care of things
			WorldEditor.gizmoClick()
			return

		# we have to compare what's under the cursor to our selection

		# if there's no selection then (for now) set it to that
		#  and do nothing more
		if not self.selection.size:
			self.selection.add( self.mouseRevealer )
			self.selUpdate()
			return

		# if there's a selection but nothing under the mouse,
		#  clear the selection
		if self.selection.size and not self.mouseRevealer.size:
			self.selection.rem( self.selection )
			self.selUpdate()
			return

		# if the selection is different to what's under the mouse,
		#  change the selection
		diff = WorldEditor.ChunkItemGroup()
		diff.add( self.selection )
		diff.rem( self.mouseRevealer )	# cumbersome I know
		if diff.size:
			self.selection.rem( self.selection )
			self.selection.add( self.mouseRevealer )
			self.selUpdate()
			return

		# ok the selection and what's under the mouse are the same,
		#  start a drag of the selection

		# first make the tool
		nt = WorldEditor.Tool()
		nt.locator = self.mouseLocator
		nt.functor = Functor.MatrixMover( self.selection )

		# and then push it onto the stack. it'll pop itself off when done
		WorldEditor.pushTool( nt )
Exemplo n.º 50
0
def actImportExecute():
	WorldEditor.importDataGUI()
Exemplo n.º 51
0
def actSaveChunkTemplateExecute():
	if bd.itemTool.functor.script.selection.size:
		WorldEditor.saveChunkTemplate( bd.itemTool.functor.script.selection )
	else:
		WorldEditor.addCommentaryMsg( "Nothing selected" )
	def addChunkPrefab( self ):
		group = WorldEditor.loadChunkPrefab( self.objInfo.getBrowsePath(), self.mouseLocator.subLocator )
		if ( group != None ):
			self.chunkItemAdded( self.objInfo.getBrowsePath() );
	def chunkItemAdded( self, name ):
		WorldEditor.addItemToHistory( self.objInfo.getBrowsePath(), "FILE" );
		WorldEditor.addCommentaryMsg( "Added " + name )