mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-16 14:12:35 +02:00
getLocalJointRotation getLocalJointTranslation, started on getLocalJointTranslation getLocalJointRotation
This commit is contained in:
parent
ee9ed6da17
commit
339d6a55cf
6 changed files with 112 additions and 2 deletions
|
@ -1017,6 +1017,40 @@ glm::vec3 RenderableModelEntityItem::getAbsoluteJointTranslationInObjectFrame(in
|
|||
return glm::vec3(0.0f);
|
||||
}
|
||||
|
||||
bool RenderableModelEntityItem::setAbsoluteJointRotationInObjectFrame(int index, const glm::quat& rotation) {
|
||||
// TODO -- write this
|
||||
assert(false);
|
||||
abort();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RenderableModelEntityItem::setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) {
|
||||
// TODO -- write this
|
||||
assert(false);
|
||||
abort();
|
||||
return false;
|
||||
}
|
||||
|
||||
glm::quat RenderableModelEntityItem::getLocalJointRotation(int index) const {
|
||||
if (_model) {
|
||||
glm::quat result;
|
||||
if (_model->getJointRotation(index, result)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return glm::quat();
|
||||
}
|
||||
|
||||
glm::vec3 RenderableModelEntityItem::getLocalJointTranslation(int index) const {
|
||||
if (_model) {
|
||||
glm::vec3 result;
|
||||
if (_model->getJointTranslation(index, result)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return glm::vec3();
|
||||
}
|
||||
|
||||
bool RenderableModelEntityItem::setLocalJointRotation(int index, const glm::quat& rotation) {
|
||||
bool result = false;
|
||||
_jointDataLock.withWriteLock([&] {
|
||||
|
|
|
@ -71,6 +71,12 @@ 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 bool setAbsoluteJointRotationInObjectFrame(int index, const glm::quat& rotation) override;
|
||||
virtual bool setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) override;
|
||||
|
||||
|
||||
virtual glm::quat getLocalJointRotation(int index) const override;
|
||||
virtual glm::vec3 getLocalJointTranslation(int index) const override;
|
||||
virtual bool setLocalJointRotation(int index, const glm::quat& rotation) override;
|
||||
virtual bool setLocalJointTranslation(int index, const glm::vec3& translation) override;
|
||||
|
||||
|
|
|
@ -1110,6 +1110,68 @@ glm::quat EntityScriptingInterface::getAbsoluteJointRotationInObjectFrame(const
|
|||
}
|
||||
}
|
||||
|
||||
bool EntityScriptingInterface::setAbsoluteJointTranslationInObjectFrame(const QUuid& entityID,
|
||||
int jointIndex, glm::vec3 translation) {
|
||||
if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) {
|
||||
auto now = usecTimestampNow();
|
||||
auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity);
|
||||
bool result = modelEntity->setAbsoluteJointTranslationInObjectFrame(jointIndex, translation);
|
||||
if (result) {
|
||||
EntityItemProperties properties;
|
||||
_entityTree->withWriteLock([&] {
|
||||
properties = entity->getProperties();
|
||||
entity->setLastBroadcast(now);
|
||||
});
|
||||
|
||||
properties.setJointTranslationsDirty();
|
||||
properties.setLastEdited(now);
|
||||
queueEntityMessage(PacketType::EntityEdit, entityID, properties);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EntityScriptingInterface::setAbsoluteJointRotationInObjectFrame(const QUuid& entityID,
|
||||
int jointIndex, glm::quat rotation) {
|
||||
if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) {
|
||||
auto now = usecTimestampNow();
|
||||
auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity);
|
||||
bool result = modelEntity->setAbsoluteJointRotationInObjectFrame(jointIndex, rotation);
|
||||
if (result) {
|
||||
EntityItemProperties properties;
|
||||
_entityTree->withWriteLock([&] {
|
||||
properties = entity->getProperties();
|
||||
entity->setLastBroadcast(now);
|
||||
});
|
||||
|
||||
properties.setJointRotationsDirty();
|
||||
properties.setLastEdited(now);
|
||||
queueEntityMessage(PacketType::EntityEdit, entityID, properties);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
glm::vec3 EntityScriptingInterface::getLocalJointTranslation(const QUuid& entityID, int jointIndex) {
|
||||
if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) {
|
||||
auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity);
|
||||
return modelEntity->getLocalJointTranslation(jointIndex);
|
||||
} else {
|
||||
return glm::vec3(0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
glm::quat EntityScriptingInterface::getLocalJointRotation(const QUuid& entityID, int jointIndex) {
|
||||
if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) {
|
||||
auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity);
|
||||
return modelEntity->getLocalJointRotation(jointIndex);
|
||||
} else {
|
||||
return glm::quat();
|
||||
}
|
||||
}
|
||||
|
||||
bool EntityScriptingInterface::setLocalJointTranslation(const QUuid& entityID, int jointIndex, glm::vec3 translation) {
|
||||
if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) {
|
||||
auto now = usecTimestampNow();
|
||||
|
|
|
@ -184,8 +184,14 @@ public slots:
|
|||
|
||||
Q_INVOKABLE glm::vec3 getAbsoluteJointTranslationInObjectFrame(const QUuid& entityID, int jointIndex);
|
||||
Q_INVOKABLE glm::quat getAbsoluteJointRotationInObjectFrame(const QUuid& entityID, int jointIndex);
|
||||
Q_INVOKABLE bool setAbsoluteJointTranslationInObjectFrame(const QUuid& entityID, int jointIndex, glm::vec3 translation);
|
||||
Q_INVOKABLE bool setAbsoluteJointRotationInObjectFrame(const QUuid& entityID, int jointIndex, glm::quat rotation);
|
||||
|
||||
Q_INVOKABLE glm::vec3 getLocalJointTranslation(const QUuid& entityID, int jointIndex);
|
||||
Q_INVOKABLE glm::quat getLocalJointRotation(const QUuid& entityID, int jointIndex);
|
||||
Q_INVOKABLE bool setLocalJointTranslation(const QUuid& entityID, int jointIndex, glm::vec3 translation);
|
||||
Q_INVOKABLE bool setLocalJointRotation(const QUuid& entityID, int jointIndex, glm::quat rotation);
|
||||
|
||||
Q_INVOKABLE bool setLocalJointRotations(const QUuid& entityID, const QVector<glm::quat>& rotations);
|
||||
Q_INVOKABLE bool setLocalJointTranslations(const QUuid& entityID, const QVector<glm::vec3>& translations);
|
||||
Q_INVOKABLE bool setLocalJointsData(const QUuid& entityID,
|
||||
|
|
|
@ -117,8 +117,8 @@ public:
|
|||
|
||||
virtual bool shouldBePhysical() const override;
|
||||
|
||||
virtual glm::vec3 getJointPosition(int jointIndex) const { return glm::vec3(); }
|
||||
virtual glm::quat getJointRotation(int jointIndex) const { return glm::quat(); }
|
||||
// virtual glm::vec3 getJointPosition(int jointIndex) const { return glm::vec3(); }
|
||||
// virtual glm::quat getJointRotation(int jointIndex) const { return glm::quat(); }
|
||||
|
||||
virtual void setJointRotations(const QVector<glm::quat>& rotations);
|
||||
virtual void setJointRotationsSet(const QVector<bool>& rotationsSet);
|
||||
|
|
|
@ -144,6 +144,8 @@ public:
|
|||
virtual bool setAbsoluteJointRotationInObjectFrame(int index, const glm::quat& rotation) { return false; }
|
||||
virtual bool setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) {return false; }
|
||||
|
||||
virtual glm::quat getLocalJointRotation(int index) const {return glm::quat(); }
|
||||
virtual glm::vec3 getLocalJointTranslation(int index) const {return glm::vec3(); }
|
||||
virtual bool setLocalJointRotation(int index, const glm::quat& rotation) { return false; }
|
||||
virtual bool setLocalJointTranslation(int index, const glm::vec3& translation) { return false; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue