mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 04:08:13 +02:00
Merge pull request #10078 from hyperlogic/feature/avatar-skeleton
Expose Avatar Skeleton to JavaScript
This commit is contained in:
commit
0f936f7511
2 changed files with 49 additions and 0 deletions
|
@ -1395,6 +1395,30 @@ void Avatar::setParentJointIndex(quint16 parentJointIndex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<QVariant> Avatar::getSkeleton() {
|
||||||
|
SkeletonModelPointer skeletonModel = _skeletonModel;
|
||||||
|
if (skeletonModel) {
|
||||||
|
RigPointer rig = skeletonModel->getRig();
|
||||||
|
if (rig) {
|
||||||
|
AnimSkeleton::ConstPointer skeleton = rig->getAnimSkeleton();
|
||||||
|
if (skeleton) {
|
||||||
|
QList<QVariant> list;
|
||||||
|
list.reserve(skeleton->getNumJoints());
|
||||||
|
for (int i = 0; i < skeleton->getNumJoints(); i++) {
|
||||||
|
QVariantMap obj;
|
||||||
|
obj["name"] = skeleton->getJointName(i);
|
||||||
|
obj["index"] = i;
|
||||||
|
obj["parentIndex"] = skeleton->getParentIndex(i);
|
||||||
|
list.push_back(obj);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QList<QVariant>();
|
||||||
|
}
|
||||||
|
|
||||||
void Avatar::addToScene(AvatarSharedPointer myHandle) {
|
void Avatar::addToScene(AvatarSharedPointer myHandle) {
|
||||||
render::ScenePointer scene = qApp->getMain3DScene();
|
render::ScenePointer scene = qApp->getMain3DScene();
|
||||||
if (scene) {
|
if (scene) {
|
||||||
|
|
|
@ -55,6 +55,16 @@ class Texture;
|
||||||
|
|
||||||
class Avatar : public AvatarData {
|
class Avatar : public AvatarData {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* An avatar is representation of yourself or another user. The Avatar API can be used to query or manipulate the avatar of a user.
|
||||||
|
* NOTE: Avatar extends AvatarData, see those namespace for more properties/methods.
|
||||||
|
*
|
||||||
|
* @namespace Avatar
|
||||||
|
* @augments AvatarData
|
||||||
|
*
|
||||||
|
* @property skeletonOffset {Vec3} can be used to apply a translation offset between the avatar's position and the registration point of the 3d model.
|
||||||
|
*/
|
||||||
Q_PROPERTY(glm::vec3 skeletonOffset READ getSkeletonOffset WRITE setSkeletonOffset)
|
Q_PROPERTY(glm::vec3 skeletonOffset READ getSkeletonOffset WRITE setSkeletonOffset)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -169,6 +179,21 @@ public:
|
||||||
Q_INVOKABLE virtual quint16 getParentJointIndex() const override { return SpatiallyNestable::getParentJointIndex(); }
|
Q_INVOKABLE virtual quint16 getParentJointIndex() const override { return SpatiallyNestable::getParentJointIndex(); }
|
||||||
Q_INVOKABLE virtual void setParentJointIndex(quint16 parentJointIndex) override;
|
Q_INVOKABLE virtual void setParentJointIndex(quint16 parentJointIndex) override;
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Information about a single joint in an Avatar's skeleton hierarchy.
|
||||||
|
* @typedef Avatar.SkeletonJoint
|
||||||
|
* @property {string} name - name of joint
|
||||||
|
* @property {number} index - joint index
|
||||||
|
* @property {number} parentIndex - index of this joint's parent (-1 if no parent)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Returns an array of joints, where each joint is an object containing name, index and parentIndex fields.
|
||||||
|
* @function Avatar.getSkeleton
|
||||||
|
* @returns {Avatar.SkeletonJoint[]} returns a list of information about each joint in this avatar's skeleton.
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE QList<QVariant> getSkeleton();
|
||||||
|
|
||||||
// NOT thread safe, must be called on main thread.
|
// NOT thread safe, must be called on main thread.
|
||||||
glm::vec3 getUncachedLeftPalmPosition() const;
|
glm::vec3 getUncachedLeftPalmPosition() const;
|
||||||
glm::quat getUncachedLeftPalmRotation() const;
|
glm::quat getUncachedLeftPalmRotation() const;
|
||||||
|
|
Loading…
Reference in a new issue