How to use the payton.scene.geometry.md2.MD2Frame function in Payton

To help you get started, we’ve selected a few Payton 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 sinanislekdemir / payton / payton / scene / geometry / md2.py View on Github external
name = read_block(f, "< 16s", 1)[0][0]
        name = str(name).split("\x00")[0].split("\\")[0].replace("b'", "")

        frame_vertex_data = np.array(read_block(f, "<4B", self.header.num_vertices), dtype=np.uint8)

        frame_vertex_data.shape = (-1, 4)

        vertices_short = frame_vertex_data[:, :3]
        vertices = vertices_short.astype(np.float)
        vertices.shape = (-1, 3)

        vertices *= scale
        vertices += (translation[0], translation[1], 0)
        vertices /= 20.0

        return MD2Frame(name=name, vertices=vertices)
github sinanislekdemir / payton / payton / scene / geometry / md2.py View on Github external
def __init__(self, filename: str = "", texture_filename: str = "", **kwargs: Any):
        """Initialize the MD2 Object

        Args:
          filename: Filename to load
        """
        super().__init__(**kwargs)
        self.header: MD2Header = MD2Header()
        self.triangle_layout = MD2TriangleLayout()
        self.skins: List[str] = []
        self.texture_filename = texture_filename
        self.frames: List[MD2Frame] = []
        self._frame_children: Dict[str, Mesh] = {}
        self.animation: str = ""
        self.animations: Dict[str, List] = {}

        self._active_frame: int = 0
        self._frame_rate: float = 0
        self._from_frame: int = 0
        self._to_frame: int = 0
        self._time: float = 0
        self._path: str = ""
        self._loop: bool = False

        if os.path.exists(filename):
            self.load_file(filename)