Example #1
0
	def agent(self, agentName, id, agentSpec):
		'''If the given agent already exists, return it. Otherwise guess
		   its agent type and id based on its name, and build a new agent
		   with the appropriate AgentSpec. If no AgentSpec exists for that
		   type, raise an error. This method also handles filtering out
		   agents that do not exist in the user specified "selections"'''
			
		if not self._selectionGroup.contains( id ):
			# Filter out non-selected agents
			#
			return None
		
		try:
			agent = self._agents[agentName]
		except:
			# agentName does not already exist (probably no callsheet was
			# provided) - build one *if* the agentType is defined. The
			# agentType should have already been defined if a CDL file
			# was specified in the MAS file for the agentType.
			#
			if not agentSpec:
				agentSpec = self.scene.agentSpec(self._agentType(agentName))
			
			agent = Agent.Agent()
			agent.name = agentName
			agent.id = id
			agent.agentSpec = agentSpec
			self._agents[agentName] = agent
		return agent
Example #2
0
    def build(self, scene, agentOptions):
        if scene.mas().terrainFile:
            self._factory.importObj(scene.mas().terrainFile, "terrain")

        MayaPlacement.build(self._factory, scene.mas())

        for agentSpec in scene.agentSpecs():
            agent = Agent.Agent(instanced=False)
            agent.agentSpec = agentSpec
            agent.name = agentSpec.agentType
            mayaAgent = MayaSceneAgent.MayaSceneAgent(agent, self._factory,
                                                      scene)
            mayaAgent.build(agentOptions)
            self._factory.addAgent(mayaAgent)

        self._factory.cleanup()

        # The layers are off by default to speed up load, turn them on
        # now.
        #
        MayaAgent.showLayers()