mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 03:58:07 +02:00
std::vector-ize joints and materials in hfm::Model
This commit is contained in:
parent
c4db6c78d8
commit
b944db3e79
10 changed files with 26 additions and 22 deletions
|
@ -99,12 +99,12 @@ void AvatarDoctor::startDiagnosing() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// RIG
|
// RIG
|
||||||
if (avatarModel.joints.isEmpty()) {
|
if (avatarModel.joints.empty()) {
|
||||||
addError("Avatar has no rig.", "no-rig");
|
addError("Avatar has no rig.", "no-rig");
|
||||||
} else {
|
} else {
|
||||||
auto jointNames = avatarModel.getJointNames();
|
auto jointNames = avatarModel.getJointNames();
|
||||||
|
|
||||||
if (avatarModel.joints.length() > NETWORKED_JOINTS_LIMIT) {
|
if (avatarModel.joints.size() > NETWORKED_JOINTS_LIMIT) {
|
||||||
addError(tr( "Avatar has over %n bones.", "", NETWORKED_JOINTS_LIMIT), "maximum-bone-limit");
|
addError(tr( "Avatar has over %n bones.", "", NETWORKED_JOINTS_LIMIT), "maximum-bone-limit");
|
||||||
}
|
}
|
||||||
// Avatar does not have Hips bone mapped
|
// Avatar does not have Hips bone mapped
|
||||||
|
|
|
@ -312,7 +312,7 @@ void SkeletonModel::computeBoundingShape() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const HFMModel& hfmModel = getHFMModel();
|
const HFMModel& hfmModel = getHFMModel();
|
||||||
if (hfmModel.joints.isEmpty() || _rig.indexOfJoint("Hips") == -1) {
|
if (hfmModel.joints.empty() || _rig.indexOfJoint("Hips") == -1) {
|
||||||
// rootJointIndex == -1 if the avatar model has no skeleton
|
// rootJointIndex == -1 if the avatar model has no skeleton
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,7 +258,7 @@ void MaterialBaker::addTexture(const QString& materialName, image::TextureUsage:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void MaterialBaker::setMaterials(const QHash<QString, hfm::Material>& materials, const QString& baseURL) {
|
void MaterialBaker::setMaterials(const std::vector<hfm::Material>& materials, const QString& baseURL) {
|
||||||
_materialResource = NetworkMaterialResourcePointer(new NetworkMaterialResource(), [](NetworkMaterialResource* ptr) { ptr->deleteLater(); });
|
_materialResource = NetworkMaterialResourcePointer(new NetworkMaterialResource(), [](NetworkMaterialResource* ptr) { ptr->deleteLater(); });
|
||||||
for (auto& material : materials) {
|
for (auto& material : materials) {
|
||||||
_materialResource->parsedMaterials.names.push_back(material.name.toStdString());
|
_materialResource->parsedMaterials.names.push_back(material.name.toStdString());
|
||||||
|
|
|
@ -32,7 +32,7 @@ public:
|
||||||
bool isURL() const { return _isURL; }
|
bool isURL() const { return _isURL; }
|
||||||
QString getBakedMaterialData() const { return _bakedMaterialData; }
|
QString getBakedMaterialData() const { return _bakedMaterialData; }
|
||||||
|
|
||||||
void setMaterials(const QHash<QString, hfm::Material>& materials, const QString& baseURL);
|
void setMaterials(const std::vector<hfm::Material>& materials, const QString& baseURL);
|
||||||
void setMaterials(const NetworkMaterialResourcePointer& materialResource);
|
void setMaterials(const NetworkMaterialResourcePointer& materialResource);
|
||||||
|
|
||||||
NetworkMaterialResourcePointer getNetworkMaterialResource() const { return _materialResource; }
|
NetworkMaterialResourcePointer getNetworkMaterialResource() const { return _materialResource; }
|
||||||
|
|
|
@ -259,7 +259,7 @@ void ModelBaker::bakeSourceCopy() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_hfmModel->materials.isEmpty()) {
|
if (!_hfmModel->materials.empty()) {
|
||||||
_materialBaker = QSharedPointer<MaterialBaker>(
|
_materialBaker = QSharedPointer<MaterialBaker>(
|
||||||
new MaterialBaker(_modelURL.fileName(), true, _bakedOutputDir),
|
new MaterialBaker(_modelURL.fileName(), true, _bakedOutputDir),
|
||||||
&MaterialBaker::deleteLater
|
&MaterialBaker::deleteLater
|
||||||
|
|
|
@ -1357,11 +1357,11 @@ HFMModel* FBXSerializer::extractHFMModel(const hifi::VariantHash& mapping, const
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
hfmModel.joints.append(joint);
|
hfmModel.joints.push_back(joint);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: shapeVertices are in joint-frame
|
// NOTE: shapeVertices are in joint-frame
|
||||||
hfmModel.shapeVertices.resize(std::max(1, hfmModel.joints.size()) );
|
hfmModel.shapeVertices.resize(std::max((size_t)1, hfmModel.joints.size()) );
|
||||||
|
|
||||||
hfmModel.bindExtents.reset();
|
hfmModel.bindExtents.reset();
|
||||||
hfmModel.meshExtents.reset();
|
hfmModel.meshExtents.reset();
|
||||||
|
@ -1400,7 +1400,10 @@ HFMModel* FBXSerializer::extractHFMModel(const hifi::VariantHash& mapping, const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
hfmModel.materials = _hfmMaterials;
|
|
||||||
|
for (auto materialIt = _hfmMaterials.cbegin(); materialIt != _hfmMaterials.cend(); ++materialIt) {
|
||||||
|
hfmModel.materials.push_back(materialIt.value());
|
||||||
|
}
|
||||||
|
|
||||||
// see if any materials have texture children
|
// see if any materials have texture children
|
||||||
bool materialsHaveTextures = checkMaterialsHaveTextures(_hfmMaterials, _textureFilenames, _connectionChildMap);
|
bool materialsHaveTextures = checkMaterialsHaveTextures(_hfmMaterials, _textureFilenames, _connectionChildMap);
|
||||||
|
|
|
@ -1002,8 +1002,8 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::VariantHash&
|
||||||
|
|
||||||
for (int i = 0; i < materialIDs.size(); ++i) {
|
for (int i = 0; i < materialIDs.size(); ++i) {
|
||||||
QString& matid = materialIDs[i];
|
QString& matid = materialIDs[i];
|
||||||
hfmModel.materials[matid] = HFMMaterial();
|
hfmModel.materials.emplace_back();
|
||||||
HFMMaterial& hfmMaterial = hfmModel.materials[matid];
|
HFMMaterial& hfmMaterial = hfmModel.materials.back();
|
||||||
hfmMaterial._material = std::make_shared<graphics::Material>();
|
hfmMaterial._material = std::make_shared<graphics::Material>();
|
||||||
hfmMaterial.name = hfmMaterial.materialID = matid;
|
hfmMaterial.name = hfmMaterial.materialID = matid;
|
||||||
setHFMMaterial(hfmMaterial, _file.materials[i]);
|
setHFMMaterial(hfmMaterial, _file.materials[i]);
|
||||||
|
@ -2036,7 +2036,7 @@ void GLTFSerializer::hfmDebugDump(const HFMModel& hfmModel) {
|
||||||
qCDebug(modelformat) << " meshExtents.size() = " << hfmModel.meshExtents.size();
|
qCDebug(modelformat) << " meshExtents.size() = " << hfmModel.meshExtents.size();
|
||||||
|
|
||||||
qCDebug(modelformat) << " jointIndices.size() =" << hfmModel.jointIndices.size();
|
qCDebug(modelformat) << " jointIndices.size() =" << hfmModel.jointIndices.size();
|
||||||
qCDebug(modelformat) << " joints.count() =" << hfmModel.joints.count();
|
qCDebug(modelformat) << " joints.count() =" << hfmModel.joints.size();
|
||||||
qCDebug(modelformat) << "---------------- Meshes ----------------";
|
qCDebug(modelformat) << "---------------- Meshes ----------------";
|
||||||
qCDebug(modelformat) << " meshes.count() =" << hfmModel.meshes.size();
|
qCDebug(modelformat) << " meshes.count() =" << hfmModel.meshes.size();
|
||||||
qCDebug(modelformat) << " blendshapeChannelNames = " << hfmModel.blendshapeChannelNames;
|
qCDebug(modelformat) << " blendshapeChannelNames = " << hfmModel.blendshapeChannelNames;
|
||||||
|
|
|
@ -892,11 +892,12 @@ HFMModel::Pointer OBJSerializer::read(const hifi::ByteArray& data, const hifi::V
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
HFMMaterial& hfmMaterial = hfmModel.materials[materialID] = HFMMaterial(objMaterial.diffuseColor,
|
hfmModel.materials.emplace_back(objMaterial.diffuseColor,
|
||||||
objMaterial.specularColor,
|
objMaterial.specularColor,
|
||||||
objMaterial.emissiveColor,
|
objMaterial.emissiveColor,
|
||||||
objMaterial.shininess,
|
objMaterial.shininess,
|
||||||
objMaterial.opacity);
|
objMaterial.opacity);
|
||||||
|
HFMMaterial& hfmMaterial = hfmModel.materials.back();
|
||||||
|
|
||||||
hfmMaterial.name = materialID;
|
hfmMaterial.name = materialID;
|
||||||
hfmMaterial.materialID = materialID;
|
hfmMaterial.materialID = materialID;
|
||||||
|
@ -1046,7 +1047,7 @@ void hfmDebugDump(const HFMModel& hfmModel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
qCDebug(modelformat) << " jointIndices =" << hfmModel.jointIndices;
|
qCDebug(modelformat) << " jointIndices =" << hfmModel.jointIndices;
|
||||||
qCDebug(modelformat) << " joints.count() =" << hfmModel.joints.count();
|
qCDebug(modelformat) << " joints.count() =" << hfmModel.joints.size();
|
||||||
|
|
||||||
foreach (HFMJoint joint, hfmModel.joints) {
|
foreach (HFMJoint joint, hfmModel.joints) {
|
||||||
|
|
||||||
|
|
|
@ -316,12 +316,12 @@ public:
|
||||||
|
|
||||||
std::vector<Mesh> meshes;
|
std::vector<Mesh> meshes;
|
||||||
|
|
||||||
QVector<Joint> joints;
|
std::vector<Joint> joints;
|
||||||
QHash<QString, int> jointIndices; ///< 1-based, so as to more easily detect missing indices
|
QHash<QString, int> jointIndices; ///< 1-based, so as to more easily detect missing indices
|
||||||
bool hasSkeletonJoints;
|
bool hasSkeletonJoints;
|
||||||
QVector<QString> scripts;
|
QVector<QString> scripts;
|
||||||
|
|
||||||
QHash<QString, Material> materials;
|
std::vector<Material> materials;
|
||||||
|
|
||||||
glm::mat4 offset; // This includes offset, rotation, and scale as specified by the FST file
|
glm::mat4 offset; // This includes offset, rotation, and scale as specified by the FST file
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace baker {
|
||||||
for (int i = 0; i < hfmModelIn->meshes.size(); i++) {
|
for (int i = 0; i < hfmModelIn->meshes.size(); i++) {
|
||||||
blendshapesPerMesh.push_back(hfmModelIn->meshes[i].blendshapes.toStdVector());
|
blendshapesPerMesh.push_back(hfmModelIn->meshes[i].blendshapes.toStdVector());
|
||||||
}
|
}
|
||||||
output.edit4() = hfmModelIn->joints.toStdVector();
|
output.edit4() = hfmModelIn->joints;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ namespace baker {
|
||||||
void run(const BakeContextPointer& context, const Input& input, Output& output) {
|
void run(const BakeContextPointer& context, const Input& input, Output& output) {
|
||||||
auto hfmModelOut = input.get0();
|
auto hfmModelOut = input.get0();
|
||||||
hfmModelOut->meshes = input.get1();
|
hfmModelOut->meshes = input.get1();
|
||||||
hfmModelOut->joints = QVector<hfm::Joint>::fromStdVector(input.get2());
|
hfmModelOut->joints = input.get2();
|
||||||
hfmModelOut->jointRotationOffsets = input.get3();
|
hfmModelOut->jointRotationOffsets = input.get3();
|
||||||
hfmModelOut->jointIndices = input.get4();
|
hfmModelOut->jointIndices = input.get4();
|
||||||
hfmModelOut->flowData = input.get5();
|
hfmModelOut->flowData = input.get5();
|
||||||
|
|
Loading…
Reference in a new issue