mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 12:08:54 +02:00
give SkeletonModel created by MyAvatar a Rig pointer
This commit is contained in:
parent
4ec5f4c5b6
commit
d287817829
6 changed files with 23 additions and 17 deletions
|
@ -79,7 +79,7 @@ const float MyAvatar::ZOOM_MAX = 25.0f;
|
||||||
const float MyAvatar::ZOOM_DEFAULT = 1.5f;
|
const float MyAvatar::ZOOM_DEFAULT = 1.5f;
|
||||||
|
|
||||||
MyAvatar::MyAvatar() :
|
MyAvatar::MyAvatar() :
|
||||||
Avatar(),
|
Avatar(),
|
||||||
_gravity(0.0f, 0.0f, 0.0f),
|
_gravity(0.0f, 0.0f, 0.0f),
|
||||||
_wasPushing(false),
|
_wasPushing(false),
|
||||||
_isPushing(false),
|
_isPushing(false),
|
||||||
|
@ -102,7 +102,8 @@ MyAvatar::MyAvatar() :
|
||||||
_eyeContactTarget(LEFT_EYE),
|
_eyeContactTarget(LEFT_EYE),
|
||||||
_realWorldFieldOfView("realWorldFieldOfView",
|
_realWorldFieldOfView("realWorldFieldOfView",
|
||||||
DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES),
|
DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES),
|
||||||
_firstPersonSkeletonModel(this),
|
_rig(),
|
||||||
|
_firstPersonSkeletonModel(this, nullptr, _rig),
|
||||||
_prevShouldDrawHead(true)
|
_prevShouldDrawHead(true)
|
||||||
{
|
{
|
||||||
_firstPersonSkeletonModel.setIsFirstPerson(true);
|
_firstPersonSkeletonModel.setIsFirstPerson(true);
|
||||||
|
@ -488,7 +489,7 @@ void MyAvatar::loadLastRecording() {
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimationHandlePointer MyAvatar::addAnimationHandle() {
|
AnimationHandlePointer MyAvatar::addAnimationHandle() {
|
||||||
AnimationHandlePointer handle = _rig.createAnimationHandle();
|
AnimationHandlePointer handle = _rig->createAnimationHandle();
|
||||||
_animationHandles.append(handle);
|
_animationHandles.append(handle);
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
@ -506,7 +507,7 @@ void MyAvatar::startAnimation(const QString& url, float fps, float priority,
|
||||||
Q_ARG(float, lastFrame), Q_ARG(const QStringList&, maskedJoints));
|
Q_ARG(float, lastFrame), Q_ARG(const QStringList&, maskedJoints));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AnimationHandlePointer handle = _rig.createAnimationHandle();
|
AnimationHandlePointer handle = _rig->createAnimationHandle();
|
||||||
handle->setURL(url);
|
handle->setURL(url);
|
||||||
handle->setFPS(fps);
|
handle->setFPS(fps);
|
||||||
handle->setPriority(priority);
|
handle->setPriority(priority);
|
||||||
|
@ -534,7 +535,7 @@ void MyAvatar::startAnimationByRole(const QString& role, const QString& url, flo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// no joy; use the parameters provided
|
// no joy; use the parameters provided
|
||||||
AnimationHandlePointer handle = _rig.createAnimationHandle();
|
AnimationHandlePointer handle = _rig->createAnimationHandle();
|
||||||
handle->setRole(role);
|
handle->setRole(role);
|
||||||
handle->setURL(url);
|
handle->setURL(url);
|
||||||
handle->setFPS(fps);
|
handle->setFPS(fps);
|
||||||
|
|
|
@ -286,7 +286,7 @@ private:
|
||||||
QString _bodyModelName;
|
QString _bodyModelName;
|
||||||
QString _fullAvatarModelName;
|
QString _fullAvatarModelName;
|
||||||
|
|
||||||
Rig _rig;
|
RigPointer _rig;
|
||||||
// used for rendering when in first person view or when in an HMD.
|
// used for rendering when in first person view or when in an HMD.
|
||||||
SkeletonModel _firstPersonSkeletonModel;
|
SkeletonModel _firstPersonSkeletonModel;
|
||||||
bool _prevShouldDrawHead;
|
bool _prevShouldDrawHead;
|
||||||
|
|
|
@ -29,8 +29,8 @@ enum StandingFootState {
|
||||||
NO_FOOT
|
NO_FOOT
|
||||||
};
|
};
|
||||||
|
|
||||||
SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent) :
|
SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent, RigPointer rig) :
|
||||||
Model(parent),
|
Model(parent, rig),
|
||||||
_triangleFanID(DependencyManager::get<GeometryCache>()->allocateID()),
|
_triangleFanID(DependencyManager::get<GeometryCache>()->allocateID()),
|
||||||
_owningAvatar(owningAvatar),
|
_owningAvatar(owningAvatar),
|
||||||
_boundingShape(),
|
_boundingShape(),
|
||||||
|
|
|
@ -25,7 +25,7 @@ class SkeletonModel : public Model {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SkeletonModel(Avatar* owningAvatar, QObject* parent = NULL);
|
SkeletonModel(Avatar* owningAvatar, QObject* parent = nullptr, RigPointer rig = nullptr);
|
||||||
~SkeletonModel();
|
~SkeletonModel();
|
||||||
|
|
||||||
virtual void initJointStates(QVector<JointState> states);
|
virtual void initJointStates(QVector<JointState> states);
|
||||||
|
|
|
@ -62,7 +62,7 @@ static int weakNetworkGeometryPointerTypeId = qRegisterMetaType<QWeakPointer<Net
|
||||||
static int vec3VectorTypeId = qRegisterMetaType<QVector<glm::vec3> >();
|
static int vec3VectorTypeId = qRegisterMetaType<QVector<glm::vec3> >();
|
||||||
float Model::FAKE_DIMENSION_PLACEHOLDER = -1.0f;
|
float Model::FAKE_DIMENSION_PLACEHOLDER = -1.0f;
|
||||||
|
|
||||||
Model::Model(QObject* parent) :
|
Model::Model(QObject* parent, RigPointer rig) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
_scale(1.0f, 1.0f, 1.0f),
|
_scale(1.0f, 1.0f, 1.0f),
|
||||||
_scaleToFit(false),
|
_scaleToFit(false),
|
||||||
|
@ -83,7 +83,8 @@ Model::Model(QObject* parent) :
|
||||||
_calculatedMeshTrianglesValid(false),
|
_calculatedMeshTrianglesValid(false),
|
||||||
_meshGroupsKnown(false),
|
_meshGroupsKnown(false),
|
||||||
_isWireframe(false),
|
_isWireframe(false),
|
||||||
_renderCollisionHull(false) {
|
_renderCollisionHull(false),
|
||||||
|
_rig(rig) {
|
||||||
|
|
||||||
// we may have been created in the network thread, but we live in the main thread
|
// we may have been created in the network thread, but we live in the main thread
|
||||||
if (_viewState) {
|
if (_viewState) {
|
||||||
|
@ -1518,8 +1519,9 @@ void Model::updateVisibleJointStates() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Model::setJointPosition(int jointIndex, const glm::vec3& position, const glm::quat& rotation, bool useRotation,
|
bool Model::setJointPosition(int jointIndex, const glm::vec3& position, const glm::quat& rotation,
|
||||||
int lastFreeIndex, bool allIntermediatesFree, const glm::vec3& alignment, float priority) {
|
bool useRotation, int lastFreeIndex, bool allIntermediatesFree, const glm::vec3& alignment,
|
||||||
|
float priority) {
|
||||||
if (jointIndex == -1 || _jointStates.isEmpty()) {
|
if (jointIndex == -1 || _jointStates.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1604,7 +1606,8 @@ bool Model::setJointPosition(int jointIndex, const glm::vec3& position, const gl
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::inverseKinematics(int endIndex, glm::vec3 targetPosition, const glm::quat& targetRotation, float priority) {
|
void Model::inverseKinematics(int endIndex, glm::vec3 targetPosition,
|
||||||
|
const glm::quat& targetRotation, float priority) {
|
||||||
// NOTE: targetRotation is from bind- to model-frame
|
// NOTE: targetRotation is from bind- to model-frame
|
||||||
|
|
||||||
if (endIndex == -1 || _jointStates.isEmpty()) {
|
if (endIndex == -1 || _jointStates.isEmpty()) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ public:
|
||||||
|
|
||||||
static void setAbstractViewStateInterface(AbstractViewStateInterface* viewState) { _viewState = viewState; }
|
static void setAbstractViewStateInterface(AbstractViewStateInterface* viewState) { _viewState = viewState; }
|
||||||
|
|
||||||
Model(QObject* parent = NULL);
|
Model(QObject* parent = NULL, RigPointer rig = nullptr);
|
||||||
virtual ~Model();
|
virtual ~Model();
|
||||||
|
|
||||||
/// enables/disables scale to fit behavior, the model will be automatically scaled to the specified largest dimension
|
/// enables/disables scale to fit behavior, the model will be automatically scaled to the specified largest dimension
|
||||||
|
@ -296,8 +296,8 @@ protected:
|
||||||
/// \param alignment
|
/// \param alignment
|
||||||
/// \return true if joint exists
|
/// \return true if joint exists
|
||||||
bool setJointPosition(int jointIndex, const glm::vec3& position, const glm::quat& rotation = glm::quat(),
|
bool setJointPosition(int jointIndex, const glm::vec3& position, const glm::quat& rotation = glm::quat(),
|
||||||
bool useRotation = false, int lastFreeIndex = -1, bool allIntermediatesFree = false,
|
bool useRotation = false, int lastFreeIndex = -1, bool allIntermediatesFree = false,
|
||||||
const glm::vec3& alignment = glm::vec3(0.0f, -1.0f, 0.0f), float priority = 1.0f);
|
const glm::vec3& alignment = glm::vec3(0.0f, -1.0f, 0.0f), float priority = 1.0f);
|
||||||
|
|
||||||
/// Restores the indexed joint to its default position.
|
/// Restores the indexed joint to its default position.
|
||||||
/// \param fraction the fraction of the default position to apply (i.e., 0.25f to slerp one fourth of the way to
|
/// \param fraction the fraction of the default position to apply (i.e., 0.25f to slerp one fourth of the way to
|
||||||
|
@ -524,6 +524,8 @@ private:
|
||||||
QMap<render::ItemID, render::PayloadPointer> _renderItems;
|
QMap<render::ItemID, render::PayloadPointer> _renderItems;
|
||||||
bool _readyWhenAdded = false;
|
bool _readyWhenAdded = false;
|
||||||
bool _needsReload = true;
|
bool _needsReload = true;
|
||||||
|
|
||||||
|
RigPointer _rig;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QPointer<Model>)
|
Q_DECLARE_METATYPE(QPointer<Model>)
|
||||||
|
|
Loading…
Reference in a new issue