Unified · Split
| @@ -1017,6 +1017,40 @@ glm::vec3 RenderableModelEntityItem::getAbsoluteJointTranslationInObjectFrame(in · 1016 unmodified lines | |||
| 1017 | return glm::vec3(0.0f); | 1017 | return glm::vec3(0.0f); |
| 1018 | } | 1018 | } |
| 1019 | 1019 | ||
| 1020 | bool RenderableModelEntityItem::setAbsoluteJointRotationInObjectFrame(int index, const glm::quat& rotation) { | ||
| 1021 | // TODO -- write this | ||
| 1022 | assert(false); | ||
| 1023 | abort(); | ||
| 1024 | return false; | ||
| 1025 | } | ||
| 1026 | |||
| 1027 | bool RenderableModelEntityItem::setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) { | ||
| 1028 | // TODO -- write this | ||
| 1029 | assert(false); | ||
| 1030 | abort(); | ||
| 1031 | return false; | ||
| 1032 | } | ||
| 1033 | |||
| 1034 | glm::quat RenderableModelEntityItem::getLocalJointRotation(int index) const { | ||
| 1035 | if (_model) { | ||
| 1036 | glm::quat result; | ||
| 1037 | if (_model->getJointRotation(index, result)) { | ||
| 1038 | return result; | ||
| 1039 | } | ||
| 1040 | } | ||
| 1041 | return glm::quat(); | ||
| 1042 | } | ||
| 1043 | |||
| 1044 | glm::vec3 RenderableModelEntityItem::getLocalJointTranslation(int index) const { | ||
| 1045 | if (_model) { | ||
| 1046 | glm::vec3 result; | ||
| 1047 | if (_model->getJointTranslation(index, result)) { | ||
| 1048 | return result; | ||
| 1049 | } | ||
| 1050 | } | ||
| 1051 | return glm::vec3(); | ||
| 1052 | } | ||
| 1053 | |||
| 1020 | bool RenderableModelEntityItem::setLocalJointRotation(int index, const glm::quat& rotation) { | 1054 | bool RenderableModelEntityItem::setLocalJointRotation(int index, const glm::quat& rotation) { |
| 1021 | bool result = false; | 1055 | bool result = false; |
| 1022 | _jointDataLock.withWriteLock([&] { | 1056 | _jointDataLock.withWriteLock([&] { |
| @@ -71,6 +71,12 @@ public: · 70 unmodified lines | |||
| 71 | // these are in the frame of this object (model space) | 71 | // these are in the frame of this object (model space) |
| 72 | virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override; | 72 | virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override; |
| 73 | virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override; | 73 | virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override; |
| 74 | virtual bool setAbsoluteJointRotationInObjectFrame(int index, const glm::quat& rotation) override; | ||
| 75 | virtual bool setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) override; | ||
| 76 | |||
| 77 | |||
| 78 | virtual glm::quat getLocalJointRotation(int index) const override; | ||
| 79 | virtual glm::vec3 getLocalJointTranslation(int index) const override; | ||
| 74 | virtual bool setLocalJointRotation(int index, const glm::quat& rotation) override; | 80 | virtual bool setLocalJointRotation(int index, const glm::quat& rotation) override; |
| 75 | virtual bool setLocalJointTranslation(int index, const glm::vec3& translation) override; | 81 | virtual bool setLocalJointTranslation(int index, const glm::vec3& translation) override; |
| 76 | 82 | ||
| @@ -1110,6 +1110,68 @@ glm::quat EntityScriptingInterface::getAbsoluteJointRotationInObjectFrame(const · 1109 unmodified lines | |||
| 1110 | } | 1110 | } |
| 1111 | } | 1111 | } |
| 1112 | 1112 | ||
| 1113 | bool EntityScriptingInterface::setAbsoluteJointTranslationInObjectFrame(const QUuid& entityID, | ||
| 1114 | int jointIndex, glm::vec3 translation) { | ||
| 1115 | if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) { | ||
| 1116 | auto now = usecTimestampNow(); | ||
| 1117 | auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity); | ||
| 1118 | bool result = modelEntity->setAbsoluteJointTranslationInObjectFrame(jointIndex, translation); | ||
| 1119 | if (result) { | ||
| 1120 | EntityItemProperties properties; | ||
| 1121 | _entityTree->withWriteLock([&] { | ||
| 1122 | properties = entity->getProperties(); | ||
| 1123 | entity->setLastBroadcast(now); | ||
| 1124 | }); | ||
| 1125 | |||
| 1126 | properties.setJointTranslationsDirty(); | ||
| 1127 | properties.setLastEdited(now); | ||
| 1128 | queueEntityMessage(PacketType::EntityEdit, entityID, properties); | ||
| 1129 | return true; | ||
| 1130 | } | ||
| 1131 | } | ||
| 1132 | return false; | ||
| 1133 | } | ||
| 1134 | |||
| 1135 | bool EntityScriptingInterface::setAbsoluteJointRotationInObjectFrame(const QUuid& entityID, | ||
| 1136 | int jointIndex, glm::quat rotation) { | ||
| 1137 | if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) { | ||
| 1138 | auto now = usecTimestampNow(); | ||
| 1139 | auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity); | ||
| 1140 | bool result = modelEntity->setAbsoluteJointRotationInObjectFrame(jointIndex, rotation); | ||
| 1141 | if (result) { | ||
| 1142 | EntityItemProperties properties; | ||
| 1143 | _entityTree->withWriteLock([&] { | ||
| 1144 | properties = entity->getProperties(); | ||
| 1145 | entity->setLastBroadcast(now); | ||
| 1146 | }); | ||
| 1147 | |||
| 1148 | properties.setJointRotationsDirty(); | ||
| 1149 | properties.setLastEdited(now); | ||
| 1150 | queueEntityMessage(PacketType::EntityEdit, entityID, properties); | ||
| 1151 | return true; | ||
| 1152 | } | ||
| 1153 | } | ||
| 1154 | return false; | ||
| 1155 | } | ||
| 1156 | |||
| 1157 | glm::vec3 EntityScriptingInterface::getLocalJointTranslation(const QUuid& entityID, int jointIndex) { | ||
| 1158 | if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) { | ||
| 1159 | auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity); | ||
| 1160 | return modelEntity->getLocalJointTranslation(jointIndex); | ||
| 1161 | } else { | ||
| 1162 | return glm::vec3(0.0f); | ||
| 1163 | } | ||
| 1164 | } | ||
| 1165 | |||
| 1166 | glm::quat EntityScriptingInterface::getLocalJointRotation(const QUuid& entityID, int jointIndex) { | ||
| 1167 | if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) { | ||
| 1168 | auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity); | ||
| 1169 | return modelEntity->getLocalJointRotation(jointIndex); | ||
| 1170 | } else { | ||
| 1171 | return glm::quat(); | ||
| 1172 | } | ||
| 1173 | } | ||
| 1174 | |||
| 1113 | bool EntityScriptingInterface::setLocalJointTranslation(const QUuid& entityID, int jointIndex, glm::vec3 translation) { | 1175 | bool EntityScriptingInterface::setLocalJointTranslation(const QUuid& entityID, int jointIndex, glm::vec3 translation) { |
| 1114 | if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) { | 1176 | if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) { |
| 1115 | auto now = usecTimestampNow(); | 1177 | auto now = usecTimestampNow(); |
| @@ -184,8 +184,14 @@ public slots: · 183 unmodified lines | |||
| 184 | 184 | ||
| 185 | Q_INVOKABLE glm::vec3 getAbsoluteJointTranslationInObjectFrame(const QUuid& entityID, int jointIndex); | 185 | Q_INVOKABLE glm::vec3 getAbsoluteJointTranslationInObjectFrame(const QUuid& entityID, int jointIndex); |
| 186 | Q_INVOKABLE glm::quat getAbsoluteJointRotationInObjectFrame(const QUuid& entityID, int jointIndex); | 186 | Q_INVOKABLE glm::quat getAbsoluteJointRotationInObjectFrame(const QUuid& entityID, int jointIndex); |
| 187 | Q_INVOKABLE bool setAbsoluteJointTranslationInObjectFrame(const QUuid& entityID, int jointIndex, glm::vec3 translation); | ||
| 188 | Q_INVOKABLE bool setAbsoluteJointRotationInObjectFrame(const QUuid& entityID, int jointIndex, glm::quat rotation); | ||
| 189 | |||
| 190 | Q_INVOKABLE glm::vec3 getLocalJointTranslation(const QUuid& entityID, int jointIndex); | ||
| 191 | Q_INVOKABLE glm::quat getLocalJointRotation(const QUuid& entityID, int jointIndex); | ||
| 187 | Q_INVOKABLE bool setLocalJointTranslation(const QUuid& entityID, int jointIndex, glm::vec3 translation); | 192 | Q_INVOKABLE bool setLocalJointTranslation(const QUuid& entityID, int jointIndex, glm::vec3 translation); |
| 188 | Q_INVOKABLE bool setLocalJointRotation(const QUuid& entityID, int jointIndex, glm::quat rotation); | 193 | Q_INVOKABLE bool setLocalJointRotation(const QUuid& entityID, int jointIndex, glm::quat rotation); |
| 194 | |||
| 189 | Q_INVOKABLE bool setLocalJointRotations(const QUuid& entityID, const QVector<glm::quat>& rotations); | 195 | Q_INVOKABLE bool setLocalJointRotations(const QUuid& entityID, const QVector<glm::quat>& rotations); |
| 190 | Q_INVOKABLE bool setLocalJointTranslations(const QUuid& entityID, const QVector<glm::vec3>& translations); | 196 | Q_INVOKABLE bool setLocalJointTranslations(const QUuid& entityID, const QVector<glm::vec3>& translations); |
| 191 | Q_INVOKABLE bool setLocalJointsData(const QUuid& entityID, | 197 | Q_INVOKABLE bool setLocalJointsData(const QUuid& entityID, |
| @@ -117,8 +117,8 @@ public: · 116 unmodified lines | |||
| 117 | 117 | ||
| 118 | virtual bool shouldBePhysical() const override; | 118 | virtual bool shouldBePhysical() const override; |
| 119 | 119 | ||
| 120 | virtual glm::vec3 getJointPosition(int jointIndex) const { return glm::vec3(); } | 120 | // virtual glm::vec3 getJointPosition(int jointIndex) const { return glm::vec3(); } |
| 121 | virtual glm::quat getJointRotation(int jointIndex) const { return glm::quat(); } | 121 | // virtual glm::quat getJointRotation(int jointIndex) const { return glm::quat(); } |
| 122 | 122 | ||
| 123 | virtual void setJointRotations(const QVector<glm::quat>& rotations); | 123 | virtual void setJointRotations(const QVector<glm::quat>& rotations); |
| 124 | virtual void setJointRotationsSet(const QVector<bool>& rotationsSet); | 124 | virtual void setJointRotationsSet(const QVector<bool>& rotationsSet); |
| @@ -144,6 +144,8 @@ public: · 143 unmodified lines | |||
| 144 | virtual bool setAbsoluteJointRotationInObjectFrame(int index, const glm::quat& rotation) { return false; } | 144 | virtual bool setAbsoluteJointRotationInObjectFrame(int index, const glm::quat& rotation) { return false; } |
| 145 | virtual bool setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) {return false; } | 145 | virtual bool setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) {return false; } |
| 146 | 146 | ||
| 147 | virtual glm::quat getLocalJointRotation(int index) const {return glm::quat(); } | ||
| 148 | virtual glm::vec3 getLocalJointTranslation(int index) const {return glm::vec3(); } | ||
| 147 | virtual bool setLocalJointRotation(int index, const glm::quat& rotation) { return false; } | 149 | virtual bool setLocalJointRotation(int index, const glm::quat& rotation) { return false; } |
| 148 | virtual bool setLocalJointTranslation(int index, const glm::vec3& translation) { return false; } | 150 | virtual bool setLocalJointTranslation(int index, const glm::vec3& translation) { return false; } |
| 149 | 151 | ||