Exemplo n.º 1
0
    def test_write_mesh(self, geo_model):
        mesh_header_size = 128
        file_header_size = 86
        ver, tri = geo_model.solutions.vertices[0], geo_model.solutions.edges[0]

        ver_ravel, tri_ravel, n_vtx_coord, n_triangles = gtr.mesh_preprocess(ver, tri)
        data_block_size_no_header = (n_vtx_coord + n_triangles) * 4 + mesh_header_size

        # Write header
        header_bytes = gtr.write_header_block(n_data_blocks=1,
                                              size_data_blocks=data_block_size_no_header+gtr.rexDataBlockHeaderSize,
                                              start_data=file_header_size)

        # Write data block
        data_bytes = gtr.write_data_block_header(size_data=data_block_size_no_header,
                                          data_id=1, data_type=3, version_data=1)

        # Write mesh block
        mesh_header_bytes = gtr.write_mesh_header(n_vtx_coord/3, n_triangles/3,
                                                  start_vtx_coord=gtr.mesh_header_size,
                                                  start_nor_coord=gtr.mesh_header_size + n_vtx_coord*4,
                                                  start_tex_coord=gtr.mesh_header_size + n_vtx_coord*4,
                                                  start_vtx_colors=gtr.mesh_header_size + n_vtx_coord*4,
                                                  start_triangles=gtr.mesh_header_size + n_vtx_coord*4,
                                                  name='test_a')

        mesh_block_bytes = gtr.write_mesh_coordinates(ver_ravel, tri_ravel)

        all_bytes = header_bytes + data_bytes + mesh_header_bytes + mesh_block_bytes

        if False:
            gtr.write_file(all_bytes, './rexfiles/one_mesh_test')
Exemplo n.º 2
0
    def test_write_header(self):

        header_bytes = gtr.write_header_block(3, 1)
        if False:
            gtr.write_file(header_bytes, './rexfiles/header_test')