You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to read an embedded texture (png) in an FBX file. While I can correctly detect an embedded texture; I am not able to read texture->pcData. The relevant ObjC code:
DLog(@" This is an embedded texture ");
embeddedTexture = true;
if(![[texFileName substringWithRange:NSMakeRange(0, 1)] isEqualToString:@"*"]) {
return;
}
int k = [texFileName substringFromIndex:1].intValue;
const struct aiTexture *texture = aiScene->mTextures[k];
NSData *imageData = [NSData dataWithBytes:&texture->pcData length:texture->mWidth];
uint8_t c;
[imageData getBytes:&c length:1];
switch ((c)) {
case 0x89:
DLog(@" This is a PNG");
break;
default:
DLog(@" This is not a PNG");
break;
}
When I run the above code, the output on console is:
2017-08-30 13:40:16.867287+0530 OSX-Example[7674:196288] -[AssimpImporter makeMaterialPropertyForMaterial:inScene:withTextureType:withSCNMaterial:atPath:] [Line 599] has 1 textures
2017-08-30 13:40:16.867356+0530 OSX-Example[7674:196288] -[AssimpImporter makeMaterialPropertyForMaterial:inScene:withTextureType:withSCNMaterial:atPath:] [Line 612] This is an embedded texture
2017-08-30 13:40:16.868097+0530 OSX-Example[7674:196288] -[AssimpImporter makeMaterialPropertyForMaterial:inScene:withTextureType:withSCNMaterial:atPath:] [Line 630] This is not a PNG
As can be seen, the code detects from the raw data first byte, that it is not a PNG.
Is it me that is doing something wrong (hopefully, so :-) ? From the output however it seems the pcData is incorrect.
Is there any importer runtime setting or a build setting to ensure that pcData is populated correctly?
My system specs:
macOS: 10.12
Assimp lib: v4.0.1
The text was updated successfully, but these errors were encountered:
@kimkulling With the following changes in fbx loader related code:
adding a uint_8 to hold raw image data in texture.h:
uint8_t *rawImageData;
Then reinterpret the pcData in FBXConverter.cpp as such:
// steal the data from the Video to avoid an additional copy
out_tex->pcData = reinterpret_cast<aiTexel*>( const_cast<Video&>( video ).RelinquishContent() );
out_tex->rawImageData = reinterpret_cast< uint8_t *>(out_tex->pcData);
fixes the above problem. Without reinterpreting the pcData, in iOS/macOS I get invalid memory address for the memory buffer.
While this fix works, how correct/valid is it? I don't have FBX internals or Assimp internals knowledge in depth to judge; if you think this is valid, I could send a Pull Request with the fix.
With the above fix, generating an image object requires only the following:
I am trying to read an embedded texture (png) in an FBX file. While I can correctly detect an embedded texture; I am not able to read
texture->pcData
. The relevantObjC
code:When I run the above code, the output on console is:
As can be seen, the code detects from the raw data first byte, that it is not a PNG.
Is it me that is doing something wrong (hopefully, so :-) ? From the output however it seems the pcData is incorrect.
Is there any importer runtime setting or a build setting to ensure that pcData is populated correctly?
My system specs:
macOS: 10.12
Assimp lib: v4.0.1
The text was updated successfully, but these errors were encountered: