def add_frame_fixed(self, parent, name, tf=QuatTrans.identity(), geom=None): """Adds a new fixed frame to the scene.""" E = QuatTrans.ensure(tf) name = ensure_cstring(name) parent = ensure_cstring(parent) libamino.aa_rx_sg_add_frame_fixed(self._ptr, parent, name, E.quat, E.trans) self.attach_geom(name, geom)
def __init__(self, title="PyAmino", width=800, height=600, start=True, background=True, scenegraph=None, config=None): """Create a new window. Args: title: the window title width: window width in pixels height: window width in pixels start: whether to immediatly start the window background: whether to run the window in an asynchronous background thread scenegraph: scene to display config: configuration of the scene """ title = ensure_cstring(title) self._ptr = LIBAMINOGL.aa_rx_win_default_create(title, width, height) self._q = None self._scenegraph = None if scenegraph: self.scenegraph = scenegraph if config: self.config = config if start: self.start(background)
def load(self, filename, name, root=""): """Loads a scene plugin into this scene. Args: filname: plugin name, passed directly to dlopen(). name: scene name, as provided to the scene compiler. root: parent frame for the loaded scene. Raises: LookupError: the shared object or named scene could not be found. """ root = ensure_cstring(root) name = ensure_cstring(name) filename = ensure_cstring(filename) r = libamino.aa_rx_dl_sg_at(filename, name, self._ptr, root) if r is None: raise LookupError("Could not load scene %s:%s" % (filename, name))
def add_frame_prismatic(self, parent, name, tf=QuatTrans.identity(), config_name=None, axis=(0, 0, 1), offset=0, geom=None): """Adds a new prismatic frame to the scene.""" E = QuatTrans.ensure(tf) if config_name is None: config_name = name name = ensure_cstring(name) parent = ensure_cstring(parent) config_name = ensure_cstring(config_name) libamino.aa_rx_sg_add_frame_prismatic(self._ptr, parent, name, E.quat, E.trans, config_name, Vec3.ensure(axis), offset) self.attach_geom(name, geom)
def attach_geom(self, name, geom): """Attaches geometry to the named frame.""" name = ensure_cstring(name) if geom is None: return elif isinstance(geom, Geom): libamino.aa_rx_geom_attach(self._ptr, name, geom._ptr) elif isinstance(geom, (list, tuple)): for elt in geom: self.attach_geom(name, elt) else: raise Exception()
def frame_id(self, name): """Returns the frame id for string name.""" name = ensure_cstring(name) return libamino.aa_rx_sg_frame_id(self._ptr, name)
def config_id(self, name): """Returns the config id for string name.""" name = ensure_cstring(name) return libamino.aa_rx_sg_config_id(self._ptr, name)