示例#1
0
std::unique_ptr<draco::PointCloud> to_draco_point_cloud(Mesh::Ptr mesh,
        bool with_attributes=true) {
    std::unique_ptr<draco::PointCloud> draco_mesh(new draco::PointCloud());
    assert(mesh->get_num_faces() == 0);
    copy_vertices(mesh, draco_mesh);

    if (with_attributes) {
        copy_vertex_attributes(mesh, draco_mesh);
    }

    return draco_mesh;
}
示例#2
0
文件: skin.c 项目: Lenbok/dormin
static void set_geom (State *s, void **ptrs, value vertexa_v, value normala_v,
                      value uva_v, value skin_v, value colors_v)
{
    int i;
    float *p;
    int num_vertices;
    struct skin *skin;

    num_vertices = Wosize_val (vertexa_v) / (Double_wosize * 3);

    copy_vertices (ptrs[V_IDX], num_vertices, vertexa_v);
    copy_vertices (ptrs[N_IDX], num_vertices, normala_v);

    for (i = 0, p = ptrs[UV_IDX]; i < num_vertices * 2; ++i) {
        p[i] = Double_field (uva_v, i);
    }
    memcpy (ptrs[C_IDX], String_val (colors_v), num_vertices * 4);

    skin = s->skin;
    for (i = 0; i < num_vertices; ++i) {
        int j;
        value v;

        v = Field (skin_v, i);
        skin[i].boneinfo = Int_val (Field (v, 3));

        for (j = 0; j < Int_val (Field (v, 3)); ++j) {
            double val;
            int boneindex;
            const int shifts[] = {2,12,22};

            val = Double_val (Bp_val (Field (v, j)));

            boneindex = (int) val;
            skin[i].weights[j] = val - boneindex;
            skin[i].boneinfo |= (boneindex + 1) << shifts[j];
        }
    }
}
示例#3
0
std::unique_ptr<draco::Mesh> to_draco_mesh(Mesh::Ptr mesh,
        bool with_attributes=true) {
    std::unique_ptr<draco::Mesh> draco_mesh(new draco::Mesh());

    const size_t vertex_per_face = mesh->get_vertex_per_face();
    if (vertex_per_face != 3) {
        throw NotImplementedError(
                "Draco encoding only supports triangle mesh.");
    }

    copy_vertices(mesh, draco_mesh);
    copy_faces(mesh, draco_mesh);

    if (with_attributes) {
        copy_vertex_attributes(mesh, draco_mesh);
        //copy_face_attributes(mesh, draco_mesh);
    }

    return draco_mesh;
}