Terrev / 3DXML-to-OBJ

https://www.eurobricks.com/forum/index.php?/forums/topic/153050-software-3dxml-to-obj-converts-ldd-model-captures-to-obj/
MIT License
33 stars 0 forks source link

UnityException: LoadRawTextureData: not enough data provided (will result in overread). #5

Closed MichaelGatesDev closed 4 years ago

MichaelGatesDev commented 4 years ago

Great job with this project. It seems to be the only way to convert a 3DXML file into another format. Unfortunately, I'm unable to get it to work. Here's what happens when I try to use it:

UnityException: LoadRawTextureData: not enough data provided (will result in overread).
  at (wrapper managed-to-native) UnityEngine.Texture2D:LoadRawTextureData_ImplArray (byte[])
  at UnityEngine.Texture2D.LoadRawTextureData (System.Byte[] data) [0x00000] in <filename unknown>:0 
  at Manager.Load3dxml () [0x00000] in <filename unknown>:0 
  at Manager.DoStuff (Boolean exportModel, Boolean weldModel) [0x00000] in <filename unknown>:0 
  at Manager.OnGUI () [0x00000] in <filename unknown>:0 

(Filename:  Line: -1)

I captured with 3D Via Printscreen. I also checked that the model actually opens up in the previewer and it looks good to me. When trying to use this tool, I get this exception thrown. I have tried turning off 'capture textures' but still have the same issue.

Here's the file i'm trying to use

Any help is greatly appreciated. This is my last resort for saving some models from a project that died almost a decade ago.

MichaelGatesDev commented 4 years ago

I tried disabling texture loading in the code and expected something like this

Instead I get this

(Note: this is a different file than I included in the original post)

Terrev commented 4 years ago

Oh, didn't see this til now. This project isn't very general purpose; it's really only geared towards captures of LEGO Digital Designer models, and it makes a lot of assumptions based on that.

For example, I'm pretty sure what's going on in the first error you describe is you've got an RGB texture in there (no alpha; less data) while this tool assumes they're all RGBA. As it turns out, LDD has exactly one (very uncommonly used) texture that's RGB, so I just added a check for that earlier today, so that at least should be resolved now.

As for missing geometry (I think that's what's happening in the later screenshots?), there's multiple ways for geometry to be stored in 3DXML files and I only implemented reading of one of them - the one that captures of the LEGO pieces are stored in. That actually ended up being convenient for me - LDD also has a grid plane that I didn't want to export, but the geometry for that is stored differently than the bricks, so I just didn't even bother reading it.

If you want to get stuff from other programs besides LDD, your best bet is to take this work as a base and customize it/expand on it for your own needs. I unfortunately don't really have the time or resources to make a fully fleshed out conversion tool that covers all aspects of the 3DXML format.