Skip to content

Commit 00bd81b

Browse files
committed
using MyAvatar.getTargetAvatar or AvatarList.getAvatar.
1 parent a04e57d commit 00bd81b

File tree

6 files changed

+314
-57
lines changed

6 files changed

+314
-57
lines changed

interface/src/avatar/MyAvatar.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ class MyAvatar : public Avatar {
11831183
/**jsdoc
11841184
* Gets information on the avatar your avatar is currently looking at.
11851185
* @function MyAvatar.getTargetAvatar
1186-
* @returns {AvatarData} Information on the avatar being looked at.
1186+
* @returns {ScriptAvatar} Information on the avatar being looked at, <code>null</code> if no avatar is being looked at.
11871187
*/
11881188
// FIXME: The return type doesn't have a conversion to a script value so the function always returns undefined in
11891189
// JavaScript. Note: When fixed, JSDoc is needed for the return type.

libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -1920,6 +1920,13 @@ void Avatar::setParentJointIndex(quint16 parentJointIndex) {
19201920
}
19211921
}
19221922

1923+
/**jsdoc
1924+
* Information about a joint in an avatar's skeleton hierarchy.
1925+
* @typedef {object} SkeletonJoint
1926+
* @property {string} name - Joint name.
1927+
* @property {number} index - Joint index.
1928+
* @property {number} parentIndex - Index of this joint's parent (-1 if no parent).
1929+
*/
19231930
QList<QVariant> Avatar::getSkeleton() {
19241931
SkeletonModelPointer skeletonModel = _skeletonModel;
19251932
if (skeletonModel) {

libraries/avatars-renderer/src/avatars-renderer/Avatar.h

+1-8
Original file line numberDiff line numberDiff line change
@@ -480,14 +480,7 @@ class Avatar : public AvatarData, public scriptable::ModelProvider, public MetaM
480480
/**jsdoc
481481
* Gets information on all the joints in the avatar's skeleton.
482482
* @function MyAvatar.getSkeleton
483-
* @returns {MyAvatar.SkeletonJoint[]} Information about each joint in the avatar's skeleton.
484-
*/
485-
/**jsdoc
486-
* Information about a single joint in an Avatar's skeleton hierarchy.
487-
* @typedef {object} MyAvatar.SkeletonJoint
488-
* @property {string} name - Joint name.
489-
* @property {number} index - Joint index.
490-
* @property {number} parentIndex - Index of this joint's parent (-1 if no parent).
483+
* @returns {SkeletonJoint[]} Information about each joint in the avatar's skeleton.
491484
*/
492485
Q_INVOKABLE QList<QVariant> getSkeleton();
493486

libraries/avatars-renderer/src/avatars-renderer/ScriptAvatar.h

+169
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,64 @@
1616

1717
#include "Avatar.h"
1818

19+
/**jsdoc
20+
* Information about an avatar.
21+
*
22+
* <p>Created using {@link MyAvatar.getTargetAvatar} or {@link AvatarList.getAvatar}.</p>
23+
*
24+
* @class ScriptAvatar
25+
* @hideconstructor
26+
*
27+
* @hifi-interface
28+
* @hifi-client-entity
29+
* @hifi-avatar
30+
* @hifi-assignment-client
31+
* @hifi-server-entity
32+
*
33+
* @property {Vec3} position - The avatar's position.
34+
* @property {number} scale - The target scale of the avatar without any restrictions on permissible values imposed by the
35+
* domain.
36+
* @property {Vec3} handPosition - A user-defined hand position, in world coordinates. The position moves with the avatar but
37+
* is otherwise not used or changed by Interface.
38+
* @property {number} bodyPitch - The pitch of the avatar's body, in degrees.
39+
* @property {number} bodyYaw - The yaw of the avatar's body, in degrees.
40+
* @property {number} bodyRoll - The roll of the avatar's body, in degrees.
41+
* @property {Quat} orientation - The orientation of the avatar's body.
42+
* @property {Quat} headOrientation - The orientation of the avatar's head.
43+
* @property {number} headPitch - The pitch of the avatar's head relative to the body, in degrees.
44+
* @property {number} headYaw - The yaw of the avatar's head relative to the body, in degrees.
45+
* @property {number} headRoll - The roll of the avatar's head relative to the body, in degrees.
46+
*
47+
* @property {Vec3} velocity - The linear velocity of the avatar.
48+
* @property {Vec3} angularVelocity - The angular velocity of the avatar.
49+
*
50+
* @property {Uuid} sessionUUID - The avatar's session ID.
51+
* @property {string} displayName - The avatar's display name.
52+
* @property {string} sessionDisplayName - The avatar's display name, sanitized and versioned, as defined by the avatar mixer.
53+
* It is unique among all avatars present in the domain at the time.
54+
* @property {boolean} isReplicated - <span class="important">Deprecated: This property is deprecated and will be
55+
* removed.</span>
56+
* @property {boolean} lookAtSnappingEnabled - <code>true</code> if the avatar's eyes snap to look at another avatar's eyes
57+
* when the other avatar is in the line of sight and also has <code>lookAtSnappingEnabled == true</code>.
58+
*
59+
* @property {string} skeletonModelURL - The avatar's FST file.
60+
* @property {AttachmentData[]} attachmentData - Information on the avatar's attachments.
61+
* <p class="important">Deprecated: This property is deprecated and will be removed. Use avatar entities instead.</p>
62+
* @property {string[]} jointNames - The list of joints in the avatar model.
63+
*
64+
* @property {number} audioLoudness - The instantaneous loudness of the audio input that the avatar is injecting into the
65+
* domain.
66+
* @property {number} audioAverageLoudness - The rolling average loudness of the audio input that the avatar is injecting into
67+
* the domain.
68+
*
69+
* @property {Mat4} sensorToWorldMatrix - The scale, rotation, and translation transform from the user's real world to the
70+
* avatar's size, orientation, and position in the virtual world.
71+
* @property {Mat4} controllerLeftHandMatrix - The rotation and translation of the left hand controller relative to the avatar.
72+
* @property {Mat4} controllerRightHandMatrix - The rotation and translation of the right hand controller relative to the
73+
* avatar.
74+
*
75+
* @property {Vec3} skeletonOffset - The rendering offset of the avatar.
76+
*/
1977
class ScriptAvatar : public ScriptAvatarData {
2078
Q_OBJECT
2179

@@ -26,27 +84,138 @@ class ScriptAvatar : public ScriptAvatarData {
2684

2785
public slots:
2886

87+
/**jsdoc
88+
* Gets the default rotation of a joint in the avatar relative to its parent.
89+
* <p>For information on the joint hierarchy used, see
90+
* <a href="https://docs.highfidelity.com/create/avatars/avatar-standards.html">Avatar Standards</a>.</p>
91+
* @function ScriptAvatar.getDefaultJointRotation
92+
* @param {number} index - The joint index.
93+
* @returns {Quat} The default rotation of the joint if avatar data are available and the joint index is valid, otherwise
94+
* {@link Quat(0)|Quat.IDENTITY}.
95+
*/
2996
glm::quat getDefaultJointRotation(int index) const;
97+
98+
/**jsdoc
99+
* Gets the default translation of a joint in the avatar relative to its parent, in model coordinates.
100+
* <p><strong>Warning:</strong> These coordinates are not necessarily in meters.</p>
101+
* <p>For information on the joint hierarchy used, see
102+
* <a href="https://docs.highfidelity.com/create/avatars/avatar-standards.html">Avatar Standards</a>.</p>
103+
* @function ScriptAvatar.getDefaultJointTranslation
104+
* @param {number} index - The joint index.
105+
* @returns {Vec3} The default translation of the joint (in model coordinates) if avatar data are available and the joint
106+
* index is valid, otherwise {@link Vec3(0)|Vec3.ZERO}.
107+
*/
30108
glm::vec3 getDefaultJointTranslation(int index) const;
31109

110+
111+
/**jsdoc
112+
* Gets the offset applied to the avatar for rendering.
113+
* @function ScriptAvatar.getSkeletonOffset
114+
* @returns {Vec3} The skeleton offset if avatar data are available, otherwise {@link Vec3(0)|Vec3.ZERO}.
115+
*/
32116
glm::vec3 getSkeletonOffset() const;
33117

118+
119+
/**jsdoc
120+
* Gets the position of a joint in the avatar.
121+
* @function ScriptAvatar.getJointPosition
122+
* @param {number} index - The index of the joint.
123+
* @returns {Vec3} The position of the joint in world coordinates, or {@link Vec3(0)|Vec3.ZERO} if avatar data aren't
124+
* available.
125+
*/
34126
glm::vec3 getJointPosition(int index) const;
127+
128+
/**jsdoc
129+
* Gets the position of a joint in the current avatar.
130+
* @function ScriptAvatar.getJointPosition
131+
* @param {string} name - The name of the joint.
132+
* @returns {Vec3} The position of the joint in world coordinates, or {@link Vec3(0)|Vec3.ZERO} if avatar data aren't
133+
* available.
134+
*/
35135
glm::vec3 getJointPosition(const QString& name) const;
136+
137+
/**jsdoc
138+
* Gets the position of the current avatar's neck in world coordinates.
139+
* @function ScriptAvatar.getNeckPosition
140+
* @returns {Vec3} The position of the neck in world coordinates, or {@link Vec3(0)|Vec3.ZERO} if avatar data aren't
141+
* available.
142+
*/
36143
glm::vec3 getNeckPosition() const;
37144

145+
146+
/**jsdoc
147+
* Gets the current acceleration of the avatar.
148+
* @function ScriptAvatar.getAcceleration
149+
* @returns {Vec3} The current acceleration of the avatar, or {@link Vec3(0)|Vec3.ZERO} if avatar data aren't available..
150+
*/
38151
glm::vec3 getAcceleration() const;
39152

153+
154+
/**jsdoc
155+
* Gets the ID of the entity of avatar that the avatar is parented to.
156+
* @function ScriptAvatar.getParentID
157+
* @returns {Uuid} The ID of the entity or avatar that the avatar is parented to. {@link Uuid(0)|Uuid.NULL} if not parented
158+
* or avatar data aren't available.
159+
*/
40160
QUuid getParentID() const;
161+
162+
/**jsdoc
163+
* Gets the joint of the entity or avatar that the avatar is parented to.
164+
* @function ScriptAvatar.getParentJointIndex
165+
* @returns {number} The joint of the entity or avatar that the avatar is parented to. <code>65535</code> or
166+
* <code>-1</code> if parented to the entity or avatar's position and orientation rather than a joint, or avatar data
167+
* aren't available.
168+
*/
41169
quint16 getParentJointIndex() const;
42170

171+
172+
/**jsdoc
173+
* Gets information on all the joints in the avatar's skeleton.
174+
* @function ScriptAvatar.getSkeleton
175+
* @returns {SkeletonJoint[]} Information about each joint in the avatar's skeleton.
176+
*/
43177
QVariantList getSkeleton() const;
44178

179+
180+
/**jsdoc
181+
* @function ScriptAvatar.getSimulationRate
182+
* @param {AvatarSimulationRate} [rateName=""] - Rate name.
183+
* @returns {number} Simulation rate in Hz, or <code>0.0</code> if avatar data aren't available.
184+
* @deprecated This function is deprecated and will be removed.
185+
*/
45186
float getSimulationRate(const QString& rateName = QString("")) const;
46187

188+
189+
/**jsdoc
190+
* Gets the position of the left palm in world coordinates.
191+
* @function ScriptAvatar.getLeftPalmPosition
192+
* @returns {Vec3} The position of the left palm in world coordinates, or {@link Vec3(0)|Vec3.ZERO} if avatar data aren't
193+
* available.
194+
*/
47195
glm::vec3 getLeftPalmPosition() const;
196+
197+
/**jsdoc
198+
* Gets the rotation of the left palm in world coordinates.
199+
* @function ScriptAvatar.getLeftPalmRotation
200+
* @returns {Quat} The rotation of the left palm in world coordinates, or {@link Quat(0)|Quat.IDENTITY} if the avatar data
201+
* aren't available.
202+
*/
48203
glm::quat getLeftPalmRotation() const;
204+
205+
/**jsdoc
206+
* Gets the position of the right palm in world coordinates.
207+
* @function ScriptAvatar.getLeftPalmPosition
208+
* @returns {Vec3} The position of the right palm in world coordinates, or {@link Vec3(0)|Vec3.ZERO} if avatar data aren't
209+
* available.
210+
*/
49211
glm::vec3 getRightPalmPosition() const;
212+
213+
/**jsdoc
214+
* Gets the rotation of the right palm in world coordinates.
215+
* @function ScriptAvatar.getLeftPalmRotation
216+
* @returns {Quat} The rotation of the right palm in world coordinates, or {@link Quat(0)|Quat.IDENTITY} if the avatar data
217+
* aren't available.
218+
*/
50219
glm::quat getRightPalmRotation() const;
51220

52221
private:

libraries/avatars/src/AvatarHashMap.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class AvatarHashMap : public QObject, public Dependency {
111111
* Gets information about an avatar.
112112
* @function AvatarList.getAvatar
113113
* @param {Uuid} avatarID - The ID of the avatar.
114-
* @returns {AvatarData} Information about the avatar.
114+
* @returns {ScriptAvatar} Information about the avatar.
115115
*/
116116
// Null/Default-constructed QUuids will return MyAvatar
117117
Q_INVOKABLE virtual ScriptAvatarData* getAvatar(QUuid avatarID) { return new ScriptAvatarData(getAvatarBySessionID(avatarID)); }

0 commit comments

Comments
 (0)