Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

To build an agent type event, open the Atoms UI and make sure to have the "AgentTypeEvents" tab selected.

Click on "Add" and you will be prompted with a dialog asking if you want to edit your clip in GUI or script mode.


GUI mode

Give a name for your agent type (i.e. testRobot).

Select the skeleton and geo files you exported previously. The "Skeleton File" will point to your skeleton definition file, the "Geo Path" to your proxy geo file and the "Skin Path" to your skinned geo file.

Set the state machine to "robotStateMachine" (you created this in the previous section) or select it from the drop down menu on the right side of the field.

You can edit the Agent Type scale multiplier if you want, but it's not necessary for this tutorial. 

Your GUI should look like the one in the picture.
Click on the "Register" button or press CTRL+S.

Your agent type is now ready to be used.

The Agent Type scale multiplier will affect all agents of this type. If you want to change the scale of a specific agent you should use the agent scale Behaviour Module.


Script mode

In case you selected the script mode, you should edit your script so it looks like the following.

Then hit CTRL+S or click on the "Register" button. 

AgentType
import os
import AtomsMath
import AtomsCore
import Atoms
from Atoms import GLOBAL_NAMES


class AgentTypeEvent2(Atoms.SimulationEvent):
    eventName = 'testRobot'
    skelFile = 'D:/projects/atomsDemo/configs/atomsRobot.atomsskel'
    geoPath = 'D:/projects/atomsDemo/configs/atomsRobot.geos'
    skinPath = 'D:/projects/atomsDemo/configs/atomsRobot_skin.geos'
    stateMachine = 'robotStateMachine'
    scaleMultiplier = 1.0

    def __init__(self):
        Atoms.SimulationEvent.__init__(self)
        self.setName(self.eventName)

    def load(self):
        AGENT_TYPE = GLOBAL_NAMES.AGENT_TYPE
        
        skel = AtomsCore.Skeleton(1)
        skeletonArchive = AtomsCore.Archive()
        if skeletonArchive.readFromFile(self.skelFile):
            skel.deserialise(skeletonArchive)
        else:
            return

        aType = Atoms.AgentType()
        aType.setSkeleton(skel)

        meshMap = AtomsCore.MapMetadata()
        typeArchive = AtomsCore.Archive()
        if typeArchive.readFromFile(self.geoPath):
            meshMap.deserialise(typeArchive)
            aType.metadata()[AGENT_TYPE.LOW_GEO] = meshMap

        skinMap = AtomsCore.MapMetadata()
        skinArchive = AtomsCore.Archive()
        if skinArchive.readFromFile(self.skinPath):
            skinMap.deserialise(skinArchive)
            aType.metadata()[AGENT_TYPE.SKIN_GEO] = skinMap

        aType.metadata()[AGENT_TYPE.STATE_MACHINE] = AtomsCore.StringMetadata(self.stateMachine)
        aType.metadata()[AGENT_TYPE.SCALE_MULTIPLIER] = AtomsCore.DoubleMetadata(self.scaleMultiplier)

        Atoms.AgentTypes.instance().addAgentType(self.eventName, aType)

	def unload(self):
        Atoms.AgentTypes.instance().removeAgentType(self.eventName)
  • No labels