比較バージョン

キー

  • この行は追加されました。
  • この行は削除されました。
  • 書式設定が変更されました。

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.

Image Removed

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.Agent Typeのイベントを作成するには、Atoms UIを開き、必ず「AgentType Events」タブを選択してください。「Add」をクリックすると、GUIまたはScriptモードでクリップを編集するかどうかを尋ねるダイアログが表示されます。


GUI モード

Agent Typeに名前を付けます(testRobot)。
以前に、エクスポートしたSkeleton FileとGeo Fileを選択します。 "Skeleton File"は、ユーザーのSkeleton Definition fileを指し、 "Geo Path"は、ユーザーのProxy Geo fileを指します。 "Skin Path"は、ユーザーのスキン化されたGeo fileを指します。



State Machineを "robotStateMachine"(前のセクションで作成したもの)に設定するか、フィールドの右側にあるドロップダウンメニューから選択します。
必要に応じて、Agent Typeのスケール乗数を編集できますが、こちらのチュートリアルでは必要ありません。


ユーザーのGUIは、図のように確認することができると思われます。
「Register」ボタンをクリックするか、Ctrl + Sを押します。

ユーザーのAgent Typeは使用可能になりました。

注意

Agent Typeのスケール乗数は、このようなタイプのすべてのエージェントに影響します。特定のエージェントのスケールを変更したい場合は、Agent Scale Behaviourモジュールを使用してください。


Image Added

Script モード

Script モードを選択した場合は、次のようにスクリプトを編集する必要があります。
また、Ctrl + Sを押すか、「Register」ボタンをクリックしてください。 

コード ブロック
languagepy
themeEclipse
firstline1
titleAgentType
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)