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 4 Next »

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

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.

Leave the State Machine field blank for now.

You can edit the scale multiplier if you want even if 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.


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 imath
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 = ''
    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