mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 07:12:40 +02:00
Expose Avatar skeletons to JavaScript
This commit is contained in:
parent
76ef2b5d9f
commit
22901a40c8
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) {
|
||||
render::ScenePointer scene = qApp->getMain3DScene();
|
||||
if (scene) {
|
||||
|
|
|
@ -55,6 +55,16 @@ class Texture;
|
|||
|
||||
class Avatar : public AvatarData {
|
||||
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)
|
||||
|
||||
public:
|
||||
|
@ -169,6 +179,21 @@ public:
|
|||
Q_INVOKABLE virtual quint16 getParentJointIndex() const override { return SpatiallyNestable::getParentJointIndex(); }
|
||||
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.
|
||||
glm::vec3 getUncachedLeftPalmPosition() const;
|
||||
glm::quat getUncachedLeftPalmRotation() const;
|
||||
|
|
Loading…
Reference in a new issue