Пример #1
0
    def create_line(self, start, end, color, name=""):
        if self.dae.geometries.get("line_geometry-mesh") is None:
            self.dae.geometries.append(self.shapes_dae.geometries.get("line_geometry-mesh"))
        line_geom = self.dae.geometries.get("line_geometry-mesh")
        
        node = _get_void_node()
        vector = (array(end) - array(start))
        vector_norm = linalg.norm(vector)
        assert vector_norm > 0.
        n_vector = vector/vector_norm
        H = zaligned(n_vector)
        H[0:3, 3] = start
        
        node = self._add_new_geometry(name, color, line_geom)
        node.transforms.append(collada.scene.ScaleTransform(vector_norm, vector_norm, vector_norm))
        node.transforms.append(collada.scene.MatrixTransform(H.flatten()))

        self._add_osg_description(node, "link")

        return node
Пример #2
0
    def create_inertia(self, inertia, color, name=""):
        """Generate a representation of inertia as an ellipsoid."""
        pydaenimColladaDriver.create_inertia(self, inertia, color)
        H_body_com  = principalframe(inertia)
        Mcom        = transport(inertia, H_body_com)
        mass        = Mcom[5,5]
        m_o_inertia = Mcom[[0,1,2], [0,1,2]] * self._options['inertia factor']
        
        node = _get_void_node()
        node.transforms.append( collada.scene.MatrixTransform(H_body_com.flatten()) )
        
        inertia_node = self.create_ellipsoid(m_o_inertia, color, name+".inertia")
        node.children.append(inertia_node)
        
        for c in inertia_node.children:
            if isinstance(c, collada.scene.ExtraNode):
                inertia_node.children.remove(c)

        self._add_osg_description(inertia_node, "inertia")

        return node
Пример #3
0
    def create_line(self, start, end, color, name=""):
        if self.dae.geometries.get("line_geometry-mesh") is None:
            self.dae.geometries.append(
                self.shapes_dae.geometries.get("line_geometry-mesh"))
        line_geom = self.dae.geometries.get("line_geometry-mesh")

        node = _get_void_node()
        vector = (array(end) - array(start))
        vector_norm = linalg.norm(vector)
        assert vector_norm > 0.
        n_vector = vector / vector_norm
        H = zaligned(n_vector)
        H[0:3, 3] = start

        node = self._add_new_geometry(name, color, line_geom)
        node.transforms.append(
            collada.scene.ScaleTransform(vector_norm, vector_norm,
                                         vector_norm))
        node.transforms.append(collada.scene.MatrixTransform(H.flatten()))

        self._add_osg_description(node, "link")

        return node
Пример #4
0
    def create_inertia(self, inertia, color, name=""):
        """Generate a representation of inertia as an ellipsoid."""
        pydaenimColladaDriver.create_inertia(self, inertia, color)
        H_body_com = principalframe(inertia)
        Mcom = transport(inertia, H_body_com)
        mass = Mcom[5, 5]
        m_o_inertia = Mcom[[0, 1, 2],
                           [0, 1, 2]] * self._options['inertia factor']

        node = _get_void_node()
        node.transforms.append(
            collada.scene.MatrixTransform(H_body_com.flatten()))

        inertia_node = self.create_ellipsoid(m_o_inertia, color,
                                             name + ".inertia")
        node.children.append(inertia_node)

        for c in inertia_node.children:
            if isinstance(c, collada.scene.ExtraNode):
                inertia_node.children.remove(c)

        self._add_osg_description(inertia_node, "inertia")

        return node