Example #1
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
Example #2
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 )