mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 01:03:38 +02:00
progress toward having things be children of specific joints rather than just of other objects
This commit is contained in:
parent
abfc3e994a
commit
a0c1f9a1f9
3 changed files with 26 additions and 11 deletions
|
@ -403,6 +403,10 @@ public:
|
|||
|
||||
QList<EntityActionPointer> getActionsOfType(EntityActionType typeToGet);
|
||||
|
||||
// these are in the frame of this object
|
||||
virtual glm::quat getJointRotation(int index) const { return glm::quat(); }
|
||||
virtual glm::vec3 getJointTranslation(int index) const { return glm::vec3(0.0f); }
|
||||
|
||||
protected:
|
||||
|
||||
const QByteArray getActionDataInternal() const;
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#include "DependencyManager.h"
|
||||
#include "SpatiallyNestable.h"
|
||||
|
||||
// TODO -- make use of parent joint index
|
||||
|
||||
|
||||
SpatiallyNestable::SpatiallyNestable(NestableTypes::NestableType nestableType, QUuid id) :
|
||||
_nestableType(nestableType),
|
||||
|
@ -28,7 +26,7 @@ Transform SpatiallyNestable::getParentTransform() const {
|
|||
Transform result;
|
||||
SpatiallyNestablePointer parent = getParentPointer();
|
||||
if (parent) {
|
||||
Transform parentTransform = parent->getTransform();
|
||||
Transform parentTransform = parent->getTransform(_parentJointIndex);
|
||||
result = parentTransform.setScale(1.0f);
|
||||
}
|
||||
return result;
|
||||
|
@ -123,8 +121,10 @@ const glm::vec3& SpatiallyNestable::getPosition() const {
|
|||
|
||||
const glm::vec3& SpatiallyNestable::getPosition(int jointIndex) const {
|
||||
getTransform(); // update _worldTransformCache
|
||||
// XXX ... something with joints
|
||||
return _absolutePositionCache;
|
||||
getJointTransformInObjectFrame(jointIndex); // update _jointInObjectFrameCache
|
||||
_jointInWorldFrameCache.resize(jointIndex);
|
||||
Transform::mult(_jointInWorldFrameCache[jointIndex], _worldTransformCache, _jointInObjectFrameCache[jointIndex]);
|
||||
return _jointInWorldFrameCache[jointIndex].getTranslation();
|
||||
}
|
||||
|
||||
void SpatiallyNestable::setPosition(const glm::vec3& position) {
|
||||
|
@ -142,8 +142,11 @@ const glm::quat& SpatiallyNestable::getOrientation() const {
|
|||
}
|
||||
|
||||
const glm::quat& SpatiallyNestable::getOrientation(int jointIndex) const {
|
||||
// XXX something with joints...
|
||||
return getOrientation();
|
||||
getTransform(); // update _worldTransformCache
|
||||
getJointTransformInObjectFrame(jointIndex); // update _jointInObjectFrameCache
|
||||
_jointInWorldFrameCache.resize(jointIndex + 1);
|
||||
Transform::mult(_jointInWorldFrameCache[jointIndex], _worldTransformCache, _jointInObjectFrameCache[jointIndex]);
|
||||
return _jointInWorldFrameCache[jointIndex].getRotation();
|
||||
}
|
||||
|
||||
void SpatiallyNestable::setOrientation(const glm::quat& orientation) {
|
||||
|
@ -162,8 +165,10 @@ const Transform& SpatiallyNestable::getTransform() const {
|
|||
|
||||
const Transform& SpatiallyNestable::getTransform(int jointIndex) const {
|
||||
getTransform(); // update _worldTransformCache
|
||||
// XXX ... something with joints
|
||||
return _worldTransformCache;
|
||||
getJointTransformInObjectFrame(jointIndex); // update _jointInObjectFrameCache
|
||||
_jointInWorldFrameCache.resize(jointIndex + 1);
|
||||
Transform::mult(_jointInWorldFrameCache[jointIndex], _worldTransformCache, _jointInObjectFrameCache[jointIndex]);
|
||||
return _jointInWorldFrameCache[jointIndex];
|
||||
}
|
||||
|
||||
void SpatiallyNestable::setTransform(const Transform& transform) {
|
||||
|
@ -229,8 +234,11 @@ QList<SpatiallyNestablePointer> SpatiallyNestable::getChildren() const {
|
|||
|
||||
|
||||
const Transform& SpatiallyNestable::getJointTransformInObjectFrame(int jointIndex) const {
|
||||
_jointInObjectFrameCache.resize(jointIndex);
|
||||
// XXX
|
||||
_jointInObjectFrameCache.resize(jointIndex + 1);
|
||||
_jointInObjectFrameCache[jointIndex] = Transform();
|
||||
glm::vec3 position = getJointTranslation(jointIndex);
|
||||
glm::quat orientation = getJointRotation(jointIndex);
|
||||
_jointInObjectFrameCache[jointIndex].setRotation(orientation);
|
||||
_jointInObjectFrameCache[jointIndex].setTranslation(position);
|
||||
return _jointInObjectFrameCache[jointIndex];
|
||||
}
|
||||
|
|
|
@ -88,6 +88,8 @@ public:
|
|||
|
||||
// this object's frame
|
||||
virtual const Transform& getJointTransformInObjectFrame(int jointIndex) const;
|
||||
virtual glm::quat getJointRotation(int index) const = 0;
|
||||
virtual glm::vec3 getJointTranslation(int index) const = 0;
|
||||
|
||||
protected:
|
||||
NestableTypes::NestableType _nestableType; // EntityItem or an AvatarData
|
||||
|
@ -112,6 +114,7 @@ private:
|
|||
mutable Transform _worldTransformCache;
|
||||
mutable bool _parentKnowsMe = false;
|
||||
mutable QVector<Transform> _jointInObjectFrameCache;
|
||||
mutable QVector<Transform> _jointInWorldFrameCache;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue