lighttransport / tinyusdz

Tiny, dependency-free USDZ/USDA/USDC library written in C++14
Other
464 stars 36 forks source link

Some feedback / question #1

Closed UkooLabs closed 4 years ago

UkooLabs commented 4 years ago

Just thought id let you know been doing a c# usdz/usdc parser

https://github.com/UkooLabs/UsdzSharpie

One thing I have found you may find a issue with is some uncompressed tokens data array start with 0

example file in my repo Examples\Huracan-EVO-RWD-Spyder-opt-22.usdz

For some reason I'm also finding token count is always 1 less than the expected token count.

Wondering if you have worked out what data is between offset 64 and the toc start?

syoyo commented 4 years ago

Thanks!

One thing I have found you may find a issue with is some uncompressed tokens data array start with 0

Now fixed and at least now Examples\Huracan-EVO-RWD-Spyder-opt-22.usdz can be parsed correctly.

Also, added UsdzSharpie to related projects: https://github.com/syoyo/tinyusdz#other-related-projects

Wondering if you have worked out what data is between offset 64 and the toc start?

Do you mean bytes in Examples\Huracan-EVO-RWD-Spyder-opt-22.usdz?

It can be reserved bytes and any USDC data: https://github.com/syoyo/tinyusdz/blob/master/doc/usdc_format.md

syoyo commented 4 years ago

FYI here is data layout of Examples\Huracan-EVO-RWD-Spyder-opt-22.usdz

[0] Huracan EVO RWD Spyder_opt_22.usdc : byte range (64, 20820877)
[1] 0/INT_Display_Corsa_kmh_performante_No_ALA.png : byte range (20820992, 21122366)
[2] 0/INT_MicoDisplay_Evo.jpg : byte range (21122432, 21478352)
[3] 0/Lamborghini_HuracanEvoSpyder_2019_Grille2A_DiffuseAOSO.png : byte range (21478464, 21520315)
[4] 0/Lamborghini_HuracanEvoSpyder_2019_Grille2A_Normal.png : byte range (21520448, 21569176)
[5] 0/Lamborghini_HuracanEvoSpyder_2019_Grille4A_DiffuseAOSO.jpg : byte range (21569280, 21587021)
[6] 0/Lamborghini_HuracanEvoSpyder_2019_InteriorTillingA_DiffuseAOSO.jpg : byte range (21587136, 21598144)
[7] 0/Lamborghini_HuracanEvoSpyder_2019_LightA_Diffuse.jpg : byte range (21598272, 21901273)
[8] 0/Lamborghini_HuracanEvoSpyder_2019_LightA_Diffuse_RED.jpg : byte range (21901376, 22687756)
[9] 0/GEN_E34K00_Tire_PirelliPZero-245-35-R19_Black_ultra_N_2020.jpg : byte range (22687872, 24225664)
[10] 0/Reifen_Mantel_05.jpg : byte range (24225728, 24268498)
[11] 0/Reifen_Mantel_Bump_02.jpg : byte range (24268608, 24311485)
[12] 0/logo_neu.jpg : byte range (24311552, 24373089)
[13] 0/brake_disc_spec.jpg : byte range (24373184, 24401106)
[14] 0/GEN_E35K00_Tire_PirelliPZero-305-35-R19_Black_ultra_N_2020.jpg : byte range (24401216, 25945010)
[15] 0/Lamborghini_HuracanEvoSpyder_2019_Grille1A_DiffuseAOSO.png : byte range (25945152, 25996961)
[16] 0/Lamborghini_HuracanEvoSpyder_2019_Grille1A_MaterialOpacity_BW.jpg : byte range (25997120, 26027728)
[17] 0/Lamborghini_HuracanEvoSpyder_2019_Grille1A_Normal.png : byte range (26027840, 26156559)
[18] 0/Headrest_stitched_logo_GialloBelenus_05.png : byte range (26156672, 26631365)
[19] 0/Headrest_stitched_logo_Cutting_02.jpg : byte range (26631488, 26764114)
[20] 0/Lamborghini_HuracanEvoSpyder_2019_BadgeA_DiffuseAOSO.png : byte range (26764224, 27180570)
[21] 0/Lamborghini_HuracanEvoSpyder_2019_BadgeA_MaterialOpacity_BW.jpg : byte range (27180672, 27344324)
[22] 0/Lamborghini_HuracanEvoSpyder_2019_BadgeA_Normal.png : byte range (27344448, 28081941)
[23] 0/Lamborghini_HuracanEvoSpyder_2019_InteriorA_DiffuseAOSO_Rev02 - Copia.png : byte range (28082112, 28290400)
UkooLabs commented 4 years ago

@syoyo sorry I just realized I meant what data is between offset 88 (not 64, the bootstrap header) and toc in the usdc file

syoyo commented 4 years ago

Usually FIELD data(ValueRep). i.e, vertices, normals, matrix data, .etc.

UkooLabs commented 4 years ago

@syoyo looked at your update where you keep the empty token, currently im in the line of thinking it should not be added to list of tokens but currently don't have a way to prove if im correct. Adding of the empty token will as a result create a totally different list of names for fields as every index would be offset by 1.

think you may need to change ....

if (i == 0) { // OK. first char may be null(#1) }

to something like

if (i == 0) { continue; // Skip null character }

syoyo commented 4 years ago

According to USD's implementation:

https://github.com/PixarAnimationStudios/USD/blob/master/pxr/usd/usd/crateFile.cpp#L3291

we should create num_tokens tokens exactly and should not skip null tokens(and they does not consider the content of token string).

Huracan-EVO-RWD-Spyder-opt-22.usdz may be invalid USDZ file. Are you correctly viewing Huracan-EVO-RWD-Spyder-opt-22.usdz?(e.g. with macOS preview, usdviewer)

UkooLabs commented 4 years ago

@syoyo

cool thanks, another finding with same model... and for field sets...

fieldset_index[0] = 0 fieldset_index[1] = 1 fieldset_index[2] = 2 fieldset_index[3] = 4294967295 fieldset_index[4] = 3 fieldset_index[5] = 4 fieldset_index[6] = 5 fieldset_index[7] = 6 fieldset_index[8] = 7 fieldset_index[9] = 4294967295 fieldset_index[10] = 3 fieldset_index[11] = 4 fieldset_index[12] = 6

4294967295 seems to appear a lot and thinking maybe a mistake in routine and should be 0?

syoyo commented 4 years ago

https://qiita.com/syoyo/items/dbfecbc16468e6108d0d#fieldsets