メタデータの末尾にスキップ
メタデータの先頭に移動

このページの古いバージョンを表示しています。現在のバージョンを表示します。

現在のバージョンとの相違点 ページ履歴を表示

バージョン 1 次のバージョン »

import os
import sys

sys.path.insert(0,"/opt/Toolchefs/AtomsMaya/python/2017/")
sys.path.insert(0,"/opt/Toolchefs/AtomsMaya/scripts")

os.environ["LD_LIBRARY_PATH"] += "/opt/Toolchefs/AtomsMaya/lib/2017;"
os.environ["LD_LIBRARY_PATH"] += "/opt/Toolchefs/AtomsMaya/lib:"
os.environ["ATOMS_DATA"] = "/opt/Toolchefs/AtomsMaya/data"

import imath
import json
import AtomsUtils
import AtomsCore
import Atoms
import AtomsModules


from Atoms.hostbridge.atomsnode import BaseAtomsNodeHostBridge
from Atoms.constants import JSON_KEYS, JSON_VERSION

class SimAtomsNodeHostBridge(BaseAtomsNodeHostBridge):
    def __init__(self, scene_config_file):
        self.config_file = scene_config_file
        super(SimAtomsNodeHostBridge, self).__init__()
        simulation = Atoms.AgentsSimulation()
        Atoms.AgentsSimulations.instance().addAgentsSimulation("main", simulation)

    @classmethod
    def get_json_data(cls):
        return {}

    @classmethod
    def set_json_data(cls, data):
        return

    @staticmethod
    def get_agents_simulation():
        return Atoms.AgentsSimulations.instance().agentsSimulation("main")

    def load_config_data(self):
        with open(self.config_file) as f:
            json_data = json.load(f)
            if isinstance(json_data, dict):
                self.import_data(json_data)


data_path = os.environ["ATOMS_DATA"] + "/atomsRobot.json"
host = SimAtomsNodeHostBridge(data_path)
host.load_config_data()

simulation = host.get_agents_simulation()

modulesFactory = Atoms.BehaviourModules.instance()
agGroup = simulation.createAgentGroup()
agGroup.setMultithread(True)

agGroup.addBehaviourModule("gridLayout","gridLayout")
agGroup.addBehaviourModule("stateMachine","stateMachine")

gridLayout = agGroup.behaviourModule("gridLayout")
gridLayout.attributes()["agentType"].set("atomsRobot")
gridLayout.attributes()["size"].set(imath.V3d(50,0,50))
stateMachine = agGroup.behaviourModule("stateMachine")
stateMachine.attributes()["state"].set(1)

atomsTime = Atoms.SimulationTime.instance()
atomsTime.set(0)
atomsTime.setFps(24.0)

simulation.initSimulation()

for i in range(0, 50):
    atomsTime.set(i)
    simulation.initFrame()
    simulation.computeFrame()
    simulation.endFrame()
    print "Frame",i
    
simulation.endSimulation()


  • ラベルがありません