I’m in the process of creating a tool to generate statistics for mesh models. What I’m trying to achieve at the moment is to find the size ratio of the mesh to its textures.
Is this possible? Can I achieve this for binary models? How can I find the size in bytes of all the texture associated to a model?
Or would the best thing to do would be read the file stream and decode and check headers for texture files (png/jpg for example)
It looks like this is possible using Assimp: unreal engine4 - How can i convert FBX embedded texture to TArray<uint8> Data? - Stack Overflow
Thanks,
Tom
OK looks like I can get the embedded texture size as follows:
var diffuseSize = node.Materials.Aggregate(0, (acc, x) => (x.GetTexture(Material.MapDiffuse) as Texture)?.Content.Length ?? 0 + acc);
This value of .Content returns null for binary fbx files with external textures - is this possible through Aspose or will I have to read via the file system?
And can I safely assume that if .Content is null then textures must be external? And I can then use texture.filePath to get the texture?
@TPovey2
Can you please share the sample files and the code snippet for our reference so that we can further proceed to assist you accordingly?
@TPovey2
Yes, it’s possible for the .Content
to be null in certain cases. This typically occurs when the FBX file defines a texture but doesn’t associate it with embedded texture data. Instead, the texture is specified by an external file using the .FileName
property.
In such scenarios, the .Content
property would not contain the actual texture data but would be null. The information about the texture and its location would be available through the .FileName
property, allowing you to reference and load the texture from an external file when needed.
In certain extreme cases, it is possible for both the .Content
and .FileName
properties to be null. This situation usually occurs when dealing with malformed or improperly structured files.
1 Like
That’s great thanks for the info - all sorted now