Add method to check entities joint hierarchy

This commit is contained in:
luiscuenca 2018-12-01 12:32:29 -07:00
parent 2586811e76
commit ad42f6a590
6 changed files with 22 additions and 1 deletions

View file

@ -774,6 +774,14 @@ bool RenderableModelEntityItem::shouldBePhysical() const {
}
}
int RenderableModelEntityItem::getJointParent(int index) const {
auto model = getModel();
if (model) {
return model->getRig().getJointParentIndex(index);
}
return -1;
}
glm::quat RenderableModelEntityItem::getAbsoluteJointRotationInObjectFrame(int index) const {
auto model = getModel();
if (model) {

View file

@ -94,6 +94,7 @@ public:
// these are in the frame of this object (model space)
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override;
virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override;
virtual int getJointParent(int index) const override;
virtual bool setAbsoluteJointRotationInObjectFrame(int index, const glm::quat& rotation) override;
virtual bool setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) override;

View file

@ -455,6 +455,7 @@ public:
// these are in the frame of this object
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override { return glm::quat(); }
virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override { return glm::vec3(0.0f); }
virtual int getJointParent(int index) const override { return -1; }
virtual bool setLocalJointRotation(int index, const glm::quat& rotation) override { return false; }
virtual bool setLocalJointTranslation(int index, const glm::vec3& translation) override { return false; }

View file

@ -1806,6 +1806,15 @@ glm::vec3 EntityScriptingInterface::localCoordsToVoxelCoords(const QUuid& entity
}
}
int EntityScriptingInterface::getJointParent(const QUuid& entityID, int index) {
if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) {
auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity);
return modelEntity->getJointParent(index);
} else {
return -1;
}
}
glm::vec3 EntityScriptingInterface::getAbsoluteJointTranslationInObjectFrame(const QUuid& entityID, int jointIndex) {
if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) {
auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity);

View file

@ -980,7 +980,7 @@ public slots:
*/
// FIXME move to a renderable entity interface
Q_INVOKABLE glm::vec3 getAbsoluteJointTranslationInObjectFrame(const QUuid& entityID, int jointIndex);
Q_INVOKABLE int getJointParent(const QUuid& entityID, int index);
/**jsdoc
* Get the translation of a joint in a {@link Entities.EntityType|Model} entity relative to the entity's position and
* orientation.

View file

@ -163,6 +163,8 @@ public:
virtual glm::vec3 getAbsoluteJointScaleInObjectFrame(int index) const { return glm::vec3(1.0f); }
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const { return glm::quat(); }
virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const { return glm::vec3(); }
virtual int getJointParent(int index) const { return -1; }
virtual bool setAbsoluteJointRotationInObjectFrame(int index, const glm::quat& rotation) { return false; }
virtual bool setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) {return false; }