コード例 #1
0
def view(scene, hdf5_file=None, hdf5_group="/", daenim_path=None):
    """Display a collada file, generating the animation if necessary.

    Usage::

        view(world)
        view(collada_scene_file)
        view(collada_scene_file, hdf5_file, [hdf5_group])

    If only the `scene` is given (World or collada file), it is displayed.
    If both `scene` and `hdf5_file` are given, they are combined into
    a collada animation file, which is displayed.

    This function is a Wrapper around the ``daenim`` external commands.
    It should be installed for the function to work.

    """
    if daenim_path is None:
        daenim_path = get_daenim_path()

    if isinstance(scene, World):
        scene_file = tempfile.mkstemp(suffix='anim.dae', text=True)[1]
        write_collada_scene(scene, scene_file)
        subprocess.check_call((daenim_path, scene_file))
        os.remove(scene_file)
    else:
        if hdf5_file is None:
            subprocess.check_call((daenim_path, scene))
        else:
            anim_file = tempfile.mkstemp(suffix='anim.dae', text=True)[1]
            write_collada_animation(anim_file, scene, hdf5_file, hdf5_group)
            subprocess.check_call((daenim_path, anim_file))
            os.remove(anim_file)
コード例 #2
0
def view(scene, hdf5_file=None, hdf5_group="/", daenim_path=None):
    """Display a collada file, generating the animation if necessary.

    Usage::

        view(world)
        view(collada_scene_file)
        view(collada_scene_file, hdf5_file, [hdf5_group])

    If only the `scene` is given (World or collada file), it is displayed.
    If both `scene` and `hdf5_file` are given, they are combined into
    a collada animation file, which is displayed.

    This function is a Wrapper around the ``daenim`` external commands.
    It should be installed for the function to work.

    """
    if daenim_path is None:
        daenim_path = get_daenim_path()


    if isinstance(scene, World):
        scene_file = tempfile.mkstemp(suffix='anim.dae', text=True)[1]
        write_collada_scene(scene, scene_file)
        subprocess.check_call((daenim_path, scene_file))
        os.remove(scene_file)
    else:
        if hdf5_file is None:
            subprocess.check_call((daenim_path, scene))
        else:
            anim_file = tempfile.mkstemp(suffix='anim.dae', text=True)[1]
            write_collada_animation(anim_file, scene, hdf5_file, hdf5_group)
            subprocess.check_call((daenim_path, anim_file))
            os.remove(anim_file)
コード例 #3
0
]
add_shapes_to_dae("./scene.dae", shapes_info)     # add argument output_file="out.dae" if you want to keep original dae file


obs = []
pobs = PerfMonitor(True)
dobs = pydaenimCom("./scene.dae", flat=flat)
h5obs = Hdf5Logger("sim.h5", mode="w", flat=flat)
obs.append(pobs)
obs.append(dobs)
obs.append(h5obs)



##### Simulate
from arboris.core import simulate
from numpy import arange

timeline = arange(0, 5., 0.005)
simulate(w, timeline, obs)


##### Results

print pobs.get_summary()

write_collada_animation("anim.dae", "scene.dae", "sim.h5")



コード例 #4
0
ファイル: sim_minimal.py プロジェクト: mitkof6/arboris-python
write_collada_scene(w, "scene.dae", flat=True)
obs.append(pydaenimCom("scene.dae", flat=True))

from arboris.visu.visu_collada import write_collada_scene as visu_collada_scene
from arboris.visu.visu_collada import DaenimCom             # ... or with daenim program if installed
visu_collada_scene(w, "scene_daenim.dae", flat=True)
obs.append(DaenimCom("scene_daenim.dae", flat=True))


########################################################
## SIMULATION
########################################################
dt = 5e-3
simulate(w, arange(0, 1., dt), obs)


########################################################
## RESULTS
########################################################

print(obs[0].get_summary())

from arboris.visu.dae_writer import write_collada_animation
write_collada_animation("anim_h5.dae", "scene.dae", "sim.h5")
write_collada_animation("anim_pkl.dae", "scene.dae", "sim.pkl")

from arboris.visu.visu_collada import write_collada_animation as visu_collada_animation
visu_collada_animation("anim_daenim_h5.dae", "scene_daenim.dae", "sim.h5")
visu_collada_animation("anim_daenim_pkl.dae", "scene_daenim.dae", "sim.pkl")

コード例 #5
0
ファイル: sim_minimal.py プロジェクト: efim/arboris-python
from arboris.visu.dae_writer import write_collada_scene
from arboris.visu import pydaenimCom  # visualize with pydaenim ...
write_collada_scene(w, "scene.dae", flat=True)
obs.append(pydaenimCom("scene.dae", flat=True))

from arboris.visu.visu_collada import write_collada_scene as visu_collada_scene
from arboris.visu.visu_collada import DaenimCom  # ... or with daenim program if installed
visu_collada_scene(w, "scene_daenim.dae", flat=True)
obs.append(DaenimCom("scene_daenim.dae", flat=True))

########################################################
## SIMULATION
########################################################
dt = 5e-3
simulate(w, arange(0, 1., dt), obs)

########################################################
## RESULTS
########################################################

print(obs[0].get_summary())

from arboris.visu.dae_writer import write_collada_animation
write_collada_animation("anim_h5.dae", "scene.dae", "sim.h5")
write_collada_animation("anim_pkl.dae", "scene.dae", "sim.pkl")

from arboris.visu.visu_collada import write_collada_animation as visu_collada_animation
visu_collada_animation("anim_daenim_h5.dae", "scene_daenim.dae", "sim.h5")
visu_collada_animation("anim_daenim_pkl.dae", "scene_daenim.dae", "sim.pkl")