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, 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 import AtomsUtils from Atoms import GLOBAL_NAMES class AgentTypeEvent2AgentTypeEvent1(Atoms.SimulationEvent): eventName = 'testRobotagentType1' skelFile = 'C:/projects/atomsDemo/configs/atomsRobotpath/file.atomsskel' geoPath = 'C:/projects/atomsDemo/configs/atomsRobotpath/file.geos' skinPath = 'C:/projects/atomsDemo/configs/atomsRobot_skinpath/file.geos' ragdollSetupPath = 'C:/projects/atomsDemo/configs/atomsRobot.atomsragdollpath/file.atomsragdoll' characterSetupPath = 'path/file.atomscharacter' stateMachine = 'robotStateMachine' scaleMultiplier = 1.0 agentTypeRetargeting drawOptimization = {} pelvises = [] skipIks = [] legs = [] drawOptimizationsanitizeJointNames = {}False def __init__(self): Atoms.SimulationEvent.__init__(self) self.setName(self.eventName) def load(self): AGENT_TYPE = GLOBAL_NAMES.AGENT_TYPE skel = Atoms.loadSkeleton(self.skelFile) if self.sanitizeJointNames: skel.sanitizeJointNames() for p in self.pelvises: id = skel.jointId(p) if id != -1: skel.addPelvis(id) for si in self.skipIks: id = skel.jointId(si) if id != -1: skipIkMeta = AtomsCore.BoolMetadata(True) skel.addJointMetadata(id, "skipIk", skipIkMeta) for f in self.legs: if not isinstance(f, (tuple, list)) or not len(f) == 4: continue root = skel.jointId(f[0]) ik = skel.jointId(f[1]) tip = skel.jointId(f[2]) if root == -1 or tip == -1 or ik == -1: continue skel.addFoot(ik, root, tip) poleVector = AtomsMath.V3d(f[3][0], f[3][1], f[3][2]) poleVectorMeta = AtomsCore.Vector3Metadata(poleVector) skel.addJointMetadata(root, "poleVector", poleVectorMeta) if self.legs or self.pelvises: skel.buildIkData() aType = Atoms.AgentType() aType.setSkeleton(skel) meshMap = Atoms.loadMesh(self.geoPath) if meshMap: aType.metadata()[AGENT_TYPE.LOW_GEO] = meshMap elif self.geoPath != else"": AtomsUtils.Logger.warning("Could not read geo file: " + str(self.geoPath)) skinMap = Atoms.loadMesh(self.skinPath) if skinMap: aType.metadata()[AGENT_TYPE.SKIN_GEO] = skinMap elseelif self.skinPath != "": AtomsUtils.Logger.warning("Could not read skin geo file: " + str(self.skinPath)) ragdoll_setup = AtomsCore.MapMetadata() if self.ragdollSetupPath: ark = AtomsCore.Archive() if ark.readFromFile(AtomsUtils.solvePath(self.ragdollSetupPath)): ragdoll_setup.deserialise(ark) aType.metadata()[AGENT_TYPE.RAGDOLL] = ragdoll_setup character_setup = AtomsCore.MapMetadata() if self.characterSetupPath: ark = AtomsCore.Archive() if ark.readFromFile(AtomsUtils.solvePath(self.characterSetupPath)): character_setup.deserialise(ark) aType.metadata()[AGENT_TYPE.CHARACTER] = character_setup else: character_setup = Atoms.createCharacterizationFromSkeleton(self.skelFile) if character_setup: aType.metadata()[AGENT_TYPE.CHARACTER] = character_setup aType.metadata()[AGENT_TYPE.STATE_MACHINE] = AtomsCore.StringMetadata(self.stateMachine) aType.metadata()[AGENT_TYPE.SCALE_MULTIPLIER] = AtomsCore.DoubleMetadata(self.scaleMultiplier) lod_levels = [0] lod_values = [] for lod_key in ['B', 'C', 'D']: if lod_key in self.drawOptimization: lod_levels.append(self.drawOptimization[lod_key][0]) lod_values.append(self.drawOptimization[lod_key][1]) lod_levels_meta = AtomsCore.IntArrayMetadata() lod_levels_meta.set(lod_levels) aType.metadata()[AGENT_TYPE.LOD_LEVELS] = lod_levels_meta lod_values_meta = AtomsCore.DoubleArrayMetadata() lod_values_meta.set(lod_values) aType.metadata()[AGENT_TYPE.LOD_DISTANCES] = lod_values_meta lod_mode_meta = AtomsCore.IntMetadata(0) if 'mode' in self.drawOptimization: lod_mode_meta.set(self.drawOptimization['mode']) aType.metadata()[AGENT_TYPE.LOD_MODE] = 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) |