mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
gltf color attribute
This commit is contained in:
parent
bcaad3092b
commit
e112bf19cb
1 changed files with 21 additions and 1 deletions
22
libraries/fbx/src/GLTFSerializer.cpp
Normal file → Executable file
22
libraries/fbx/src/GLTFSerializer.cpp
Normal file → Executable file
|
@ -831,6 +831,27 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const QUrl& url) {
|
|||
for (int n = 0; n < normals.size(); n = n + 3) {
|
||||
mesh.normals.push_back(glm::vec3(normals[n], normals[n + 1], normals[n + 2]));
|
||||
}
|
||||
} else if (key == "COLOR_0") {
|
||||
QVector<float> colors;
|
||||
success = addArrayOfType(buffer.blob,
|
||||
bufferview.byteOffset + accBoffset,
|
||||
accessor.count,
|
||||
colors,
|
||||
accessor.type,
|
||||
accessor.componentType);
|
||||
if (!success) {
|
||||
qWarning(modelformat) << "There was a problem reading glTF COLOR_0 data for model " << _url;
|
||||
continue;
|
||||
}
|
||||
if (accessor.type == 3) {
|
||||
for (int n = 0; n < colors.size(); n = n + 4) {
|
||||
mesh.colors.push_back(glm::vec3(colors[n], colors[n + 1], colors[n + 2]));
|
||||
}
|
||||
} else {
|
||||
for (int n = 0; n < colors.size(); n = n + 3) {
|
||||
mesh.colors.push_back(glm::vec3(colors[n], colors[n + 1], colors[n + 2]));
|
||||
}
|
||||
}
|
||||
} else if (key == "TEXCOORD_0") {
|
||||
QVector<float> texcoords;
|
||||
success = addArrayOfType(buffer.blob,
|
||||
|
@ -926,7 +947,6 @@ HFMModel::Pointer GLTFSerializer::read(const QByteArray& data, const QVariantHas
|
|||
//_file.dump();
|
||||
auto hfmModelPtr = std::make_shared<HFMModel>();
|
||||
HFMModel& hfmModel = *hfmModelPtr;
|
||||
|
||||
buildGeometry(hfmModel, _url);
|
||||
|
||||
//hfmDebugDump(data);
|
||||
|
|
Loading…
Reference in a new issue