Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

To build an agent type event, open the Atoms UI and make sure to have selected 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" 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.

Note

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.


Image RemovedImage Added

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. 

Code Block
languagepy
themeEclipse
firstline1
titleAgentType
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 = '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)