Merge pull request #2969 from LoicFr/master
Import/export of embedded texture names for the glTF/glTF2 formatpull/2971/head
commit
c722061f18
|
@ -353,6 +353,8 @@ void glTFExporter::GetMatColorOrTex(const aiMaterial* mat, glTF::TexProperty& pr
|
|||
if (path[0] == '*') { // embedded
|
||||
aiTexture* tex = mScene->mTextures[atoi(&path[1])];
|
||||
|
||||
prop.texture->source->name = tex->mFilename.C_Str();
|
||||
|
||||
uint8_t* data = reinterpret_cast<uint8_t*>(tex->pcData);
|
||||
prop.texture->source->SetData(data, tex->mWidth, *mAsset);
|
||||
|
||||
|
|
|
@ -680,6 +680,7 @@ void glTFImporter::ImportEmbeddedTextures(glTF::Asset& r)
|
|||
size_t length = img.GetDataLength();
|
||||
void* data = img.StealData();
|
||||
|
||||
tex->mFilename = img.name;
|
||||
tex->mWidth = static_cast<unsigned int>(length);
|
||||
tex->mHeight = 0;
|
||||
tex->pcData = reinterpret_cast<aiTexel*>(data);
|
||||
|
|
|
@ -352,6 +352,8 @@ void glTF2Exporter::GetMatTex(const aiMaterial* mat, Ref<Texture>& texture, aiTe
|
|||
if (path[0] == '*') { // embedded
|
||||
aiTexture* tex = mScene->mTextures[atoi(&path[1])];
|
||||
|
||||
texture->source->name = tex->mFilename.C_Str();
|
||||
|
||||
// The asset has its own buffer, see Image::SetData
|
||||
texture->source->SetData(reinterpret_cast<uint8_t*> (tex->pcData), tex->mWidth, *mAsset);
|
||||
|
||||
|
|
|
@ -1248,6 +1248,7 @@ void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset &r) {
|
|||
size_t length = img.GetDataLength();
|
||||
void *data = img.StealData();
|
||||
|
||||
tex->mFilename = img.name;
|
||||
tex->mWidth = static_cast<unsigned int>(length);
|
||||
tex->mHeight = 0;
|
||||
tex->pcData = reinterpret_cast<aiTexel *>(data);
|
||||
|
|
Loading…
Reference in New Issue