ddiakopoulos / tinyply

:earth_africa: C++11 ply 3d mesh format importer & exporter
598 stars 118 forks source link

request_properties_from_element crash #25

Closed dybiszb closed 4 years ago

dybiszb commented 6 years ago

Hey!

I just stumble upon crash that happens when I try to load all properties to one buffer as: file.request_properties_from_element("vertex", { "x", "y", "z", "nx", "ny", "nz", "s", "t", "red", "green", "blue" });

I checked and it crashes only when non uniform types are present on the list (colors are uint8, while the others float32). Is it on purpose? If that is the case, could you consider making a feature that copes with that? (maybe bytes stride inferred from listed properties types could give a hint for further processing and interpreting the data).

Best, Bartek

ddiakopoulos commented 6 years ago

Thanks for the bug report @dybiszb

I'll take a look for the next release. I don't think it should be too hard to add :)

forlinchow commented 5 years ago

i got the same problem, while the color is uchar, but I cannot get the right data in this wat try { vertices = file.request_properties_from_element("vertex", { "x", "y", "z" , "red", "green", "blue" }); } catch (const std::exception & e) { std::cerr << "tinyply exception: " << e.what() << std::endl; } ,unless I use this way // try { vertices = file.request_properties_from_element("vertex", { "x", "y", "z" }); } // catch (const std::exception & e) { std::cerr << "tinyply exception: " << e.what() << std::endl; }

// try { vertices = file.request_properties_from_element("vertex", { "red", "green", "blue" }); } // catch (const std::exception & e) { std::cerr << "tinyply exception: " << e.what() << std::endl; }

NPatch commented 5 years ago

Unfortunately not everyone treats the information the same. uint8/uchar means 0-255 value range for each channel, while float means the normalized 0.0-1.0 range. There is another possibility though I have yet to encounter it. Packed uint8 colors in uint32. Good for compressing information(especially from the float32 4 channel info).