mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 09:44:21 +02:00
make changes
This commit is contained in:
parent
d0bff29471
commit
980807c657
3 changed files with 69 additions and 17 deletions
|
@ -355,24 +355,52 @@ void Avatar::relayJointDataToChildren() {
|
|||
auto modelEntity = std::dynamic_pointer_cast<RenderableModelEntityItem>(child);
|
||||
if (modelEntity) {
|
||||
if (modelEntity->getRelayParentJoints()) {
|
||||
QStringList modelJointNames = modelEntity->getJointNames();
|
||||
QStringList avatarJointNames = getJointNames();
|
||||
foreach (const QString& jointName, modelJointNames) {
|
||||
bool containsJoint = avatarJointNames.contains(jointName);
|
||||
glm::quat jointRotation;
|
||||
glm::vec3 jointTranslation;
|
||||
if (!containsJoint) {
|
||||
int jointIndex = modelEntity->getJointIndex(jointName);
|
||||
jointRotation = modelEntity->getAbsoluteJointRotationInObjectFrame(jointIndex);
|
||||
jointTranslation = modelEntity->getAbsoluteJointTranslationInObjectFrame(jointIndex);
|
||||
} else {
|
||||
int jointIndex = getJointIndex(jointName);
|
||||
jointRotation = getJointRotation(jointIndex);
|
||||
jointTranslation = getJointTranslation(jointIndex);
|
||||
qDebug() << modelEntity->getJointMapCompleted();
|
||||
if (!(modelEntity->getJointMapCompleted())) {
|
||||
qDebug() << "constructing map";
|
||||
QStringList modelJointNames = modelEntity->getJointNames();
|
||||
int numJoints = modelJointNames.count();
|
||||
std::vector<int> map;
|
||||
map.reserve(numJoints);
|
||||
for (int jointIndex = 0; jointIndex < numJoints; jointIndex++) {
|
||||
QString jointName = modelJointNames.at(jointIndex);
|
||||
int avatarJointIndex = getJointIndex(jointName);
|
||||
glm::quat jointRotation;
|
||||
glm::vec3 jointTranslation;
|
||||
qDebug() << avatarJointIndex;
|
||||
if (avatarJointIndex < 0) {
|
||||
jointRotation = modelEntity->getAbsoluteJointRotationInObjectFrame(jointIndex);
|
||||
jointTranslation = modelEntity->getAbsoluteJointTranslationInObjectFrame(jointIndex);
|
||||
map.push_back(-1);
|
||||
} else {
|
||||
int jointIndex = getJointIndex(jointName);
|
||||
jointRotation = getJointRotation(jointIndex);
|
||||
jointTranslation = getJointTranslation(jointIndex);
|
||||
map.push_back(avatarJointIndex);
|
||||
}
|
||||
modelEntity->setLocalJointRotation(jointIndex, jointRotation);
|
||||
modelEntity->setLocalJointTranslation(jointIndex, jointTranslation);
|
||||
}
|
||||
modelEntity->setJointMap(map);
|
||||
} else {
|
||||
QStringList modelJointNames = modelEntity->getJointNames();
|
||||
int numJoints = modelJointNames.count();
|
||||
for (int jointIndex = 0; jointIndex < numJoints; jointIndex++) {
|
||||
int avatarJointIndex = modelEntity->avatarJointIndex(jointIndex);
|
||||
int index = modelEntity->getJointIndex(modelJointNames.at(jointIndex));
|
||||
//qDebug() << jointIndex << "------" << index;
|
||||
glm::quat jointRotation;
|
||||
glm::vec3 jointTranslation;
|
||||
if (avatarJointIndex >=0) {
|
||||
jointRotation = getJointRotation(avatarJointIndex);
|
||||
jointTranslation = getJointTranslation(avatarJointIndex);
|
||||
} else {
|
||||
jointRotation = modelEntity->getAbsoluteJointRotationInObjectFrame(jointIndex);
|
||||
jointTranslation = modelEntity->getAbsoluteJointTranslationInObjectFrame(jointIndex);
|
||||
}
|
||||
modelEntity->setLocalJointRotation(jointIndex, jointRotation);
|
||||
modelEntity->setLocalJointTranslation(jointIndex, jointTranslation);
|
||||
}
|
||||
int modelJointIndex = modelEntity->getJointIndex(jointName);
|
||||
modelEntity->setLocalJointRotation(modelJointIndex, jointRotation);
|
||||
modelEntity->setLocalJointTranslation(modelJointIndex, jointTranslation);
|
||||
}
|
||||
modelEntity->simulateRelayedJoints();
|
||||
}
|
||||
|
|
|
@ -708,6 +708,21 @@ void RenderableModelEntityItem::setCollisionShape(const btCollisionShape* shape)
|
|||
}
|
||||
}
|
||||
|
||||
void RenderableModelEntityItem::setJointMap(std::vector<int> jointMap) {
|
||||
_jointMap = jointMap;
|
||||
_jointMapCompleted = true;
|
||||
};
|
||||
|
||||
int RenderableModelEntityItem::avatarJointIndex(int modelJointIndex) {
|
||||
int result = -1;
|
||||
int mapSize = _jointMap.size();
|
||||
if (modelJointIndex >=0 && modelJointIndex < mapSize) {
|
||||
result = _jointMap[modelJointIndex];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool RenderableModelEntityItem::contains(const glm::vec3& point) const {
|
||||
auto model = getModel();
|
||||
if (EntityItem::contains(point) && model && _compoundShapeResource && _compoundShapeResource->isLoaded()) {
|
||||
|
@ -813,6 +828,10 @@ bool RenderableModelEntityItem::setAbsoluteJointTranslationInObjectFrame(int ind
|
|||
return setLocalJointTranslation(index, jointRelativePose.trans());
|
||||
}
|
||||
|
||||
bool RenderableModelEntityItem::getJointMapCompleted() {
|
||||
return _jointMapCompleted;
|
||||
}
|
||||
|
||||
glm::quat RenderableModelEntityItem::getLocalJointRotation(int index) const {
|
||||
auto model = getModel();
|
||||
if (model) {
|
||||
|
|
|
@ -84,6 +84,9 @@ public:
|
|||
|
||||
virtual bool shouldBePhysical() const override;
|
||||
void simulateRelayedJoints();
|
||||
bool getJointMapCompleted();
|
||||
void setJointMap(std::vector<int> jointMap);
|
||||
int avatarJointIndex(int modelJointIndex);
|
||||
|
||||
// these are in the frame of this object (model space)
|
||||
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override;
|
||||
|
@ -119,7 +122,9 @@ private:
|
|||
|
||||
void getCollisionGeometryResource();
|
||||
GeometryResource::Pointer _compoundShapeResource;
|
||||
bool _jointMapCompleted { false };
|
||||
bool _originalTexturesRead { false };
|
||||
std::vector<int> _jointMap;
|
||||
QVariantMap _originalTextures;
|
||||
bool _dimensionsInitialized { true };
|
||||
bool _needsJointSimulation { false };
|
||||
|
|
Loading…
Reference in a new issue