mirror of
https://github.com/overte-org/overte.git
synced 2025-07-05 14:49:18 +02:00
cleanup and expose mapped materials to getScriptableModel
This commit is contained in:
parent
f75a3e1a72
commit
fdbcf4b2ea
5 changed files with 15 additions and 8 deletions
|
@ -155,8 +155,7 @@ namespace baker {
|
||||||
const auto jointIndices = jointInfoOut.getN<PrepareJointsTask::Output>(2);
|
const auto jointIndices = jointInfoOut.getN<PrepareJointsTask::Output>(2);
|
||||||
|
|
||||||
// Parse material mapping
|
// Parse material mapping
|
||||||
const auto materialMappingInputs = ParseMaterialMappingTask::Input(materials, mapping).asVarying();
|
const auto materialMapping = model.addJob<ParseMaterialMappingTask>("ParseMaterialMapping", mapping);
|
||||||
const auto materialMapping = model.addJob<ParseMaterialMappingTask>("ParseMaterialMapping", materialMappingInputs);
|
|
||||||
|
|
||||||
// Combine the outputs into a new hfm::Model
|
// Combine the outputs into a new hfm::Model
|
||||||
const auto buildBlendshapesInputs = BuildBlendshapesTask::Input(blendshapesPerMeshIn, normalsPerBlendshapePerMesh, tangentsPerBlendshapePerMesh).asVarying();
|
const auto buildBlendshapesInputs = BuildBlendshapesTask::Input(blendshapesPerMeshIn, normalsPerBlendshapePerMesh, tangentsPerBlendshapePerMesh).asVarying();
|
||||||
|
|
|
@ -10,10 +10,7 @@
|
||||||
|
|
||||||
#include "ModelBakerLogging.h"
|
#include "ModelBakerLogging.h"
|
||||||
|
|
||||||
void ParseMaterialMappingTask::run(const baker::BakeContextPointer& context, const Input& input, Output& output) {
|
void ParseMaterialMappingTask::run(const baker::BakeContextPointer& context, const Input& mapping, Output& output) {
|
||||||
const auto& materialsIn = input.get0();
|
|
||||||
const auto& mapping = input.get1();
|
|
||||||
|
|
||||||
MaterialMapping materialMapping;
|
MaterialMapping materialMapping;
|
||||||
|
|
||||||
auto mappingIter = mapping.find("materialMap");
|
auto mappingIter = mapping.find("materialMap");
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
class ParseMaterialMappingTask {
|
class ParseMaterialMappingTask {
|
||||||
public:
|
public:
|
||||||
using Input = baker::VaryingSet2<QHash<QString, hfm::Material>, QVariantHash>;
|
using Input = QVariantHash;
|
||||||
using Output = MaterialMapping;
|
using Output = MaterialMapping;
|
||||||
using JobModel = baker::Job::ModelIO<ParseMaterialMappingTask, Input, Output>;
|
using JobModel = baker::Job::ModelIO<ParseMaterialMappingTask, Input, Output>;
|
||||||
|
|
||||||
|
|
|
@ -756,7 +756,16 @@ scriptable::ScriptableModelBase Model::getScriptableModel() {
|
||||||
|
|
||||||
int numParts = (int)mesh->getNumParts();
|
int numParts = (int)mesh->getNumParts();
|
||||||
for (int partIndex = 0; partIndex < numParts; partIndex++) {
|
for (int partIndex = 0; partIndex < numParts; partIndex++) {
|
||||||
result.appendMaterial(graphics::MaterialLayer(getGeometry()->getShapeMaterial(shapeID), 0), shapeID, _modelMeshMaterialNames[shapeID]);
|
auto& materialName = _modelMeshMaterialNames[shapeID];
|
||||||
|
result.appendMaterial(graphics::MaterialLayer(getGeometry()->getShapeMaterial(shapeID), 0), shapeID, materialName);
|
||||||
|
|
||||||
|
auto mappedMaterialIter = _materialMapping.find(shapeID);
|
||||||
|
if (mappedMaterialIter != _materialMapping.end()) {
|
||||||
|
auto mappedMaterials = mappedMaterialIter->second;
|
||||||
|
for (auto& mappedMaterial : mappedMaterials) {
|
||||||
|
result.appendMaterial(mappedMaterial, shapeID, materialName);
|
||||||
|
}
|
||||||
|
}
|
||||||
shapeID++;
|
shapeID++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1546,6 +1555,7 @@ void Model::applyMaterialMapping() {
|
||||||
auto meshIndex = _modelMeshRenderItemShapes[shapeID].meshIndex;
|
auto meshIndex = _modelMeshRenderItemShapes[shapeID].meshIndex;
|
||||||
bool invalidatePayloadShapeKey = shouldInvalidatePayloadShapeKey(meshIndex);
|
bool invalidatePayloadShapeKey = shouldInvalidatePayloadShapeKey(meshIndex);
|
||||||
graphics::MaterialLayer material = graphics::MaterialLayer(networkMaterial, ++_priorityMap[shapeID]);
|
graphics::MaterialLayer material = graphics::MaterialLayer(networkMaterial, ++_priorityMap[shapeID]);
|
||||||
|
_materialMapping[shapeID].push_back(material);
|
||||||
transaction.updateItem<ModelMeshPartPayload>(itemID, [material, renderItemsKey,
|
transaction.updateItem<ModelMeshPartPayload>(itemID, [material, renderItemsKey,
|
||||||
invalidatePayloadShapeKey, primitiveMode, useDualQuaternionSkinning](ModelMeshPartPayload& data) {
|
invalidatePayloadShapeKey, primitiveMode, useDualQuaternionSkinning](ModelMeshPartPayload& data) {
|
||||||
data.addMaterial(material);
|
data.addMaterial(material);
|
||||||
|
|
|
@ -375,6 +375,7 @@ signals:
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
std::unordered_map<unsigned int, quint16> _priorityMap; // only used for materialMapping
|
std::unordered_map<unsigned int, quint16> _priorityMap; // only used for materialMapping
|
||||||
|
std::unordered_map<unsigned int, std::vector<graphics::MaterialLayer>> _materialMapping; // generated during applyMaterialMapping
|
||||||
void applyMaterialMapping();
|
void applyMaterialMapping();
|
||||||
|
|
||||||
void setBlendshapeCoefficients(const QVector<float>& coefficients) { _blendshapeCoefficients = coefficients; }
|
void setBlendshapeCoefficients(const QVector<float>& coefficients) { _blendshapeCoefficients = coefficients; }
|
||||||
|
|
Loading…
Reference in a new issue