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 and the "Ragdoll Path" to your ragdoll 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.
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. |
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 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
import os import AtomsMath import AtomsCore import Atoms from Atoms import GLOBAL_NAMES class AgentTypeEvent2(Atoms.SimulationEvent): eventName = 'testRobot' skelFile = 'DC:/projects/atomsDemo/configs/atomsRobot.atomsskel' geoPath = 'DC:/projects/atomsDemo/configs/atomsRobot.geos' skinPath = 'DC:/projects/atomsDemo/configs/atomsRobot_skin.geos' ragdollSetupPath = 'C:/projects/atomsDemo/configs/atomsRobot.atomsragdoll' stateMachine = 'robotStateMachine' scaleMultiplier = 1.0 agentTypeRetargeting = [] drawOptimization = {} def __init__(self): Atoms.SimulationEvent.__init__(self) self.setName(self.eventName) def load(self): AGENT_TYPE = GLOBAL_NAMES.AGENT_TYPE skel = AtomsCoreAtoms.SkeletonloadSkeleton(1self.skelFile) skeletonArchiveaType = AtomsCore.Archive() Atoms.AgentType() aType.setSkeleton(skel) meshMap if= skeletonArchiveAtoms.readFromFileloadMesh(self.skelFile)geoPath) if meshMap: skelaType.deserialisemetadata(skeletonArchive))[AGENT_TYPE.LOW_GEO] = meshMap else: AtomsUtils.Logger.warning("Could not read return" + str(self.geoPath)) aTypeskinMap = Atoms.AgentTypeloadMesh(self.skinPath) if skinMap: aType.setSkeleton(skel.metadata()[AGENT_TYPE.SKIN_GEO] = skinMap else: AtomsUtils.Logger.warning("Could not read " + str(self.skinPath)) meshMapragdoll_setup = AtomsCore.MapMetadata() if self.ragdollSetupPath: typeArchive ark = AtomsCore.Archive() if typeArchiveark.readFromFile(AtomsUtils.solvePath(self.geoPathragdollSetupPath)): meshMapragdoll_setup.deserialise(typeArchive) ark) aType.metadata()[AGENT_TYPE.RAGDOLL] = ragdoll_setup aType.metadata()[AGENT_TYPE.LOWSTATE_GEOMACHINE] = meshMapAtomsCore.StringMetadata(self.stateMachine) skinMapaType.metadata()[AGENT_TYPE.SCALE_MULTIPLIER] = AtomsCore.MapMetadataDoubleMetadata(self.scaleMultiplier) lod_levels = skinArchive = AtomsCore.Archive()[0] lod_values = [] for lod_key in ['B', 'C', 'D']: if lod_key in self.drawOptimization: lod_levels.append(self.drawOptimization[lod_key][0]) if skinArchivelod_values.readFromFileappend(self.skinPath):drawOptimization[lod_key][1]) lod_levels_meta = skinMapAtomsCore.deserialiseIntArrayMetadata(skinArchive) lod_levels_meta.set(lod_levels) aType.metadata()[AGENT_TYPE.SKINLOD_GEOLEVELS] = skinMap lod_levels_meta lod_values_meta = AtomsCore.DoubleArrayMetadata() lod_values_meta.set(lod_values) aType.metadata()[AGENT_TYPE.STATELOD_MACHINE]DISTANCES] = lod_values_meta lod_mode_meta = AtomsCore.StringMetadata(self.stateMachine.IntMetadata(0) if 'mode' in self.drawOptimization: lod_mode_meta.set(self.drawOptimization['mode']) aType.metadata()[AGENT_TYPE.SCALELOD_MULTIPLIERMODE] = AtomsCore.DoubleMetadata(self.scaleMultiplier lod_mode_meta # list of tuples: (agent type name, config file path, retarget method, user factor) for values in self.agentTypeRetargeting: aType.addAgentTypeRetargeting(values[0], values[1], values[2], values[3]) Atoms.AgentTypes.instance().addAgentType(self.eventName, aType) def unload(self): Atoms.AgentTypes.instance().removeAgentType(self.eventName) |