How to use the pyrender.node.Node function in pyrender

To help you get started, we’ve selected a few pyrender examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mmatl / pyrender / pyrender / node.py View on Github external
def _m_from_tqs(t, q, s):
        S = np.eye(4)
        S[:3,:3] = np.diag(s)

        R = np.eye(4)
        R[:3,:3] = Node._r_from_q(q)

        T = np.eye(4)
        T[:3,3] = t

        return T.dot(R.dot(S))
github musyoku / gqn-dataset-renderer / pyrender / node.py View on Github external
def matrix(self, value):
        value = np.asanyarray(value)
        if value.shape != (4, 4):
            raise ValueError('Matrix must be a 4x4 numpy ndarray')
        if not np.allclose(value[3, :], np.array([0.0, 0.0, 0.0, 1.0])):
            raise ValueError('Bottom row of matrix must be [0,0,0,1]')
        self._matrix = value
        self.rotation = Node._q_from_m(value)
        self.scale = Node._s_from_m(value)
        self.translation = Node._t_from_m(value)
github mmatl / pyrender / pyrender / node.py View on Github external
def _q_from_m(m):
        M = np.eye(4)
        M[:3,:3] = Node._r_from_m(m)
        q_wxyz = transformations.quaternion_from_matrix(M)
        return np.roll(q_wxyz, -1)
github mmatl / pyrender / pyrender / scene.py View on Github external
The parent of this Node. If None, the new node is a root node.
        parent_name : str
            The name of the parent node, can be specified instead of
            `parent_node`.

        Returns
        -------
        node : :class:`Node`
            The newly-created and inserted node.
        """
        if isinstance(obj, Mesh):
            node = Node(name=name, matrix=pose, mesh=obj)
        elif isinstance(obj, Light):
            node = Node(name=name, matrix=pose, light=obj)
        elif isinstance(obj, Camera):
            node = Node(name=name, matrix=pose, camera=obj)
        else:
            raise TypeError('Unrecognized object type')

        if parent_node is None and parent_name is not None:
            parent_nodes = self.get_nodes(name=parent_name)
            if len(parent_nodes) == 0:
                raise ValueError('No parent node with name {} found'
                                 .format(parent_name))
            elif len(parent_nodes) > 1:
                raise ValueError('More than one parent node with name {} found'
                                 .format(parent_name))
            parent_node = list(parent_nodes)[0]

        self.add_node(node, parent_node=parent_node)

        return node
github mmatl / pyrender / pyrender / viewer.py View on Github external
xmag = ymag = 1.0
            self._default_orth_cam = OrthographicCamera(
                xmag=xmag, ymag=ymag,
                znear=znear,
                zfar=zfar
            )
        if self._default_camera_pose is None:
            self._default_camera_pose = self._compute_initial_camera_pose()

        # Pick camera
        if self.viewer_flags['use_perspective_cam']:
            camera = self._default_persp_cam
        else:
            camera = self._default_orth_cam

        self._camera_node = Node(
            matrix=self._default_camera_pose, camera=camera
        )
        scene.add_node(self._camera_node)
        scene.main_camera_node = self._camera_node
        self._reset_view()

        #######################################################################
        # Initialize OpenGL context and renderer
        #######################################################################
        self._renderer = Renderer(
            self._viewport_size[0], self._viewport_size[1],
            self.render_flags['point_size']
        )
        self._is_active = True

        if self.run_in_thread:
github mmatl / pyrender / pyrender / scene.py View on Github external
The local pose of this node relative to its parent node.
        parent_node : :class:`Node`
            The parent of this Node. If None, the new node is a root node.
        parent_name : str
            The name of the parent node, can be specified instead of
            `parent_node`.

        Returns
        -------
        node : :class:`Node`
            The newly-created and inserted node.
        """
        if isinstance(obj, Mesh):
            node = Node(name=name, matrix=pose, mesh=obj)
        elif isinstance(obj, Light):
            node = Node(name=name, matrix=pose, light=obj)
        elif isinstance(obj, Camera):
            node = Node(name=name, matrix=pose, camera=obj)
        else:
            raise TypeError('Unrecognized object type')

        if parent_node is None and parent_name is not None:
            parent_nodes = self.get_nodes(name=parent_name)
            if len(parent_nodes) == 0:
                raise ValueError('No parent node with name {} found'
                                 .format(parent_name))
            elif len(parent_nodes) > 1:
                raise ValueError('More than one parent node with name {} found'
                                 .format(parent_name))
            parent_node = list(parent_nodes)[0]

        self.add_node(node, parent_node=parent_node)
github musyoku / gqn-dataset-renderer / pyrender / node.py View on Github external
def matrix(self, value):
        value = np.asanyarray(value)
        if value.shape != (4, 4):
            raise ValueError('Matrix must be a 4x4 numpy ndarray')
        if not np.allclose(value[3, :], np.array([0.0, 0.0, 0.0, 1.0])):
            raise ValueError('Bottom row of matrix must be [0,0,0,1]')
        self._matrix = value
        self.rotation = Node._q_from_m(value)
        self.scale = Node._s_from_m(value)
        self.translation = Node._t_from_m(value)
github musyoku / gqn-dataset-renderer / pyrender / node.py View on Github external
def _m_from_tqs(t, q, s):
        S = np.eye(4)
        S[:3, :3] = np.diag(s)

        R = np.eye(4)
        R[:3, :3] = Node._r_from_q(q)

        T = np.eye(4)
        T[:3, 3] = t

        return T.dot(R.dot(S))