seung-lab / DracoPy

Python wrapper for Google's Draco mesh compression library.
Apache License 2.0
86 stars 24 forks source link

Encoding does not return resulting faces and points count #18

Open cansik opened 3 years ago

cansik commented 3 years ago

I think it would make sense to be able to get the resulting faces and points count from the encode_mesh_to_buffer method.

Currently I am writing a tool to create gltf files from mesh sequences and there I am adding mesh compression with this library. To correctly set the faces and vertices count, I need to know them after the compression. What I do as a workaround is just decode it after encoding, but this is a bit a waste of time and resources:

encoded_blob = bytearray(DracoPy.encode_mesh_to_buffer(encoded_points, encoded_triangles))

# workaorund to get point & faces size back
decoded = DracoPy.decode_buffer_to_mesh(encoded_blob)
triangles_size = len(decoded.faces)
pts_size = int(len(decoded.points) / 3)

Would it be possible to somehow return them?

cansik commented 3 years ago

It should be simple, if we could be able to call this method directly from python.

EncodedObject encode_mesh(const std::vector<float> &points, const std::vector<unsigned int> &faces,
      int quantization_bits, int compression_level, float quantization_range, const float *quantization_origin, bool create_metadata)
farunurisonmez commented 3 years ago

17 You Can Check Here