Make spine bones in the middle of bind vertices vertically or horizontally
parent
01b164cdae
commit
73d4676675
|
@ -38,15 +38,15 @@ void AnimalPoser::resolveTranslation()
|
||||||
if (match.hasMatch()) {
|
if (match.hasMatch()) {
|
||||||
QString name = match.captured(1);
|
QString name = match.captured(1);
|
||||||
chains[name].push_back(item.first);
|
chains[name].push_back(item.first);
|
||||||
qDebug() << "chains[" << name << "]:" << item.first;
|
//qDebug() << "chains[" << name << "]:" << item.first;
|
||||||
} else {
|
} else {
|
||||||
match = reSpine.match(item.first);
|
match = reSpine.match(item.first);
|
||||||
if (match.hasMatch()) {
|
if (match.hasMatch()) {
|
||||||
QString name = match.captured(1);
|
QString name = match.captured(1);
|
||||||
chains[name].push_back(item.first);
|
chains[name].push_back(item.first);
|
||||||
qDebug() << "chains[" << name << "]:" << item.first;
|
//qDebug() << "chains[" << name << "]:" << item.first;
|
||||||
} else if (item.first.startsWith("Virtual_")) {
|
} else if (item.first.startsWith("Virtual_")) {
|
||||||
qDebug() << "Ignore connector:" << item.first;
|
//qDebug() << "Ignore connector:" << item.first;
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Unrecognized bone name:" << item.first;
|
qDebug() << "Unrecognized bone name:" << item.first;
|
||||||
}
|
}
|
||||||
|
@ -56,10 +56,10 @@ void AnimalPoser::resolveTranslation()
|
||||||
std::sort(chain.second.begin(), chain.second.end(), [](const QString &first, const QString &second) {
|
std::sort(chain.second.begin(), chain.second.end(), [](const QString &first, const QString &second) {
|
||||||
return first < second;
|
return first < second;
|
||||||
});
|
});
|
||||||
qDebug() << "Chain:";
|
//qDebug() << "Chain:";
|
||||||
for (const auto &chainJoint: chain.second) {
|
//for (const auto &chainJoint: chain.second) {
|
||||||
qDebug() << chainJoint;
|
// qDebug() << chainJoint;
|
||||||
}
|
//}
|
||||||
resolveChainRotation(chain.second);
|
resolveChainRotation(chain.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ void AnimalPoser::resolveChainRotation(const std::vector<QString> &limbBoneNames
|
||||||
|
|
||||||
QVector3D targetMiddleBoneStartPosition;
|
QVector3D targetMiddleBoneStartPosition;
|
||||||
{
|
{
|
||||||
qDebug() << beginBoneName << "Angle:" << angleBetweenDistanceAndMiddleBones;
|
//qDebug() << beginBoneName << "Angle:" << angleBetweenDistanceAndMiddleBones;
|
||||||
auto rotation = QQuaternion::fromAxisAndAngle(matchRotatePlaneNormal, angleBetweenDistanceAndMiddleBones);
|
auto rotation = QQuaternion::fromAxisAndAngle(matchRotatePlaneNormal, angleBetweenDistanceAndMiddleBones);
|
||||||
targetMiddleBoneStartPosition = targetEndBoneStartPosition + rotation.rotatedVector(-matchDirectionBetweenBeginAndEndPones).normalized() * targetMiddleBoneLength;
|
targetMiddleBoneStartPosition = targetEndBoneStartPosition + rotation.rotatedVector(-matchDirectionBetweenBeginAndEndPones).normalized() * targetMiddleBoneLength;
|
||||||
}
|
}
|
||||||
|
|
|
@ -407,6 +407,14 @@ bool AnimalRigger::rig()
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector3D spineBoneHeadPosition = spineNode.position;
|
QVector3D spineBoneHeadPosition = spineNode.position;
|
||||||
|
QVector3D averagePoint = averagePosition(spineBoneVertices);
|
||||||
|
if (isMainBodyVerticalAligned) {
|
||||||
|
//qDebug() << "Update spine position's z from:" << spineBoneHeadPosition.z() << "to:" << averagePoint.z();
|
||||||
|
spineBoneHeadPosition.setZ(averagePoint.z());
|
||||||
|
} else {
|
||||||
|
//qDebug() << "Update spine position's y from:" << spineBoneHeadPosition.y() << "to:" << averagePoint.y();
|
||||||
|
spineBoneHeadPosition.setY(averagePoint.y());
|
||||||
|
}
|
||||||
|
|
||||||
QString spineName = namingSpine(spineGenerateOrder);
|
QString spineName = namingSpine(spineGenerateOrder);
|
||||||
|
|
||||||
|
@ -420,7 +428,7 @@ bool AnimalRigger::rig()
|
||||||
addVerticesToWeights(spineBoneVertices, spineBone.index);
|
addVerticesToWeights(spineBoneVertices, spineBone.index);
|
||||||
boneIndexMap[spineBone.name] = spineBone.index;
|
boneIndexMap[spineBone.name] = spineBone.index;
|
||||||
|
|
||||||
qDebug() << "Added spine:" << spineBone.name << "head:" << spineBone.headPosition << "tail:" << spineBone.tailPosition;
|
//qDebug() << "Added spine:" << spineBone.name << "head:" << spineBone.headPosition << "tail:" << spineBone.tailPosition;
|
||||||
|
|
||||||
if (1 == spineGenerateOrder) {
|
if (1 == spineGenerateOrder) {
|
||||||
m_resultBones[boneIndexMap[Rigger::rootBoneName]].tailPosition = spineBone.headPosition;
|
m_resultBones[boneIndexMap[Rigger::rootBoneName]].tailPosition = spineBone.headPosition;
|
||||||
|
@ -442,7 +450,7 @@ bool AnimalRigger::rig()
|
||||||
ribBone.index = m_resultBones.size() - 1;
|
ribBone.index = m_resultBones.size() - 1;
|
||||||
ribBone.name = namingConnector(spineName, chainName);
|
ribBone.name = namingConnector(spineName, chainName);
|
||||||
ribBone.headPosition = spineBoneHeadPosition;
|
ribBone.headPosition = spineBoneHeadPosition;
|
||||||
qDebug() << "Added connector:" << ribBone.name;
|
//qDebug() << "Added connector:" << ribBone.name;
|
||||||
boneIndexMap[ribBone.name] = ribBone.index;
|
boneIndexMap[ribBone.name] = ribBone.index;
|
||||||
if (1 == spineGenerateOrder) {
|
if (1 == spineGenerateOrder) {
|
||||||
m_resultBones[boneIndexMap[Rigger::rootBoneName]].children.push_back(ribBone.index);
|
m_resultBones[boneIndexMap[Rigger::rootBoneName]].children.push_back(ribBone.index);
|
||||||
|
@ -455,7 +463,7 @@ bool AnimalRigger::rig()
|
||||||
m_jointErrorItems.push_back(chainName);
|
m_jointErrorItems.push_back(chainName);
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Adding chain:" << chainName << " joints:" << jointMarkIndicies.size();
|
//qDebug() << "Adding chain:" << chainName << " joints:" << jointMarkIndicies.size();
|
||||||
|
|
||||||
int jointGenerateOrder = 1;
|
int jointGenerateOrder = 1;
|
||||||
|
|
||||||
|
|
|
@ -178,13 +178,13 @@ void PoseDocument::updateRigBones(const std::vector<RiggerBone> *rigBones, const
|
||||||
auto &bonesPart = partMap[m_bonesPartId];
|
auto &bonesPart = partMap[m_bonesPartId];
|
||||||
bonesPart.id = m_bonesPartId;
|
bonesPart.id = m_bonesPartId;
|
||||||
|
|
||||||
qDebug() << "rigBones size:" << rigBones->size();
|
//qDebug() << "rigBones size:" << rigBones->size();
|
||||||
|
|
||||||
std::vector<std::pair<int, int>> edgePairs;
|
std::vector<std::pair<int, int>> edgePairs;
|
||||||
for (size_t i = m_hideRootAndVirtual ? 1 : 0; i < rigBones->size(); ++i) {
|
for (size_t i = m_hideRootAndVirtual ? 1 : 0; i < rigBones->size(); ++i) {
|
||||||
const auto &bone = (*rigBones)[i];
|
const auto &bone = (*rigBones)[i];
|
||||||
for (const auto &child: bone.children) {
|
for (const auto &child: bone.children) {
|
||||||
qDebug() << "Add pair:" << bone.name << "->" << (*rigBones)[child].name;
|
//qDebug() << "Add pair:" << bone.name << "->" << (*rigBones)[child].name;
|
||||||
edgePairs.push_back({i, child});
|
edgePairs.push_back({i, child});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ void PoseDocument::updateRigBones(const std::vector<RiggerBone> *rigBones, const
|
||||||
nodeMap[firstNodeId].edgeIds.push_back(edge.id);
|
nodeMap[firstNodeId].edgeIds.push_back(edge.id);
|
||||||
nodeMap[node.id].edgeIds.push_back(edge.id);
|
nodeMap[node.id].edgeIds.push_back(edge.id);
|
||||||
|
|
||||||
qDebug() << "Add pair:" << bone.name << "->" << "~";
|
//qDebug() << "Add pair:" << bone.name << "->" << "~";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (const auto &child: bone.children) {
|
for (const auto &child: bone.children) {
|
||||||
|
|
Loading…
Reference in New Issue