Overte C++ Documentation
SkeletonModel.h
1 //
2 // SkeletonModel.h
3 // interface/src/avatar
4 //
5 // Created by Andrzej Kapolka on 10/17/13.
6 // Copyright 2013 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_SkeletonModel_h
13 #define hifi_SkeletonModel_h
14 
15 #include "CauterizedModel.h"
16 
17 class Avatar;
18 class MuscleConstraint;
19 
20 class SkeletonModel;
21 using SkeletonModelPointer = std::shared_ptr<SkeletonModel>;
22 using SkeletonModelWeakPointer = std::weak_ptr<SkeletonModel>;
23 
25 class SkeletonModel : public CauterizedModel {
26  using Parent = CauterizedModel;
27  Q_OBJECT
28 
29 public:
30 
31  SkeletonModel(Avatar* owningAvatar, QObject* parent = nullptr);
32  ~SkeletonModel();
33 
34  Q_INVOKABLE void setURL(const QUrl& url) override;
35  Q_INVOKABLE void setTextures(const QVariantMap& textures) override;
36 
37  void initJointStates() override;
38 
39  void simulate(float deltaTime, bool fullUpdate = true) override;
40  glm::vec3 avoidCrossedEyes(const glm::vec3& lookAt);
41  void updateRig(float deltaTime, glm::mat4 parentTransform) override;
42  void updateAttitude(const glm::quat& orientation);
43 
44  bool getIsJointOverridden(int jointIndex) const;
45 
47  int getLeftHandJointIndex() const { return isLoaded() ? _rig.indexOfJoint("LeftHand") : -1; }
48 
50  int getRightHandJointIndex() const { return isLoaded() ? _rig.indexOfJoint("RightHand") : -1; }
51 
52  bool getLeftGrabPosition(glm::vec3& position) const;
53  bool getRightGrabPosition(glm::vec3& position) const;
54 
57  bool getLeftHandPosition(glm::vec3& position) const;
58 
61  bool getRightHandPosition(glm::vec3& position) const;
62 
64  float getLeftArmLength() const;
65 
68  bool getHeadPosition(glm::vec3& headPosition) const;
69 
72  bool getNeckPosition(glm::vec3& neckPosition) const;
73 
74  bool getLocalNeckPosition(glm::vec3& neckPosition) const;
75 
78  bool getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const;
79 
82  glm::vec3 getDefaultEyeModelPosition() const;
83 
84  void renderBoundingCollisionShapes(RenderArgs* args, gpu::Batch& batch, float scale, float alpha);
85  float getBoundingCapsuleRadius() const { return _boundingCapsuleRadius; }
86  float getBoundingCapsuleHeight() const { return _boundingCapsuleHeight; }
87  const glm::vec3 getBoundingCapsuleOffset() const { return _boundingCapsuleLocalOffset; }
88 
89  bool hasSkeleton();
90 
91  float getHeadClipDistance() const { return _headClipDistance; }
92 
93  void onInvalidate() override;
94 
95 signals:
96 
97  void skeletonLoaded();
98 
99 protected:
100 
101  void computeBoundingShape();
102 
103  bool getEyeModelPositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const;
104 
105  Avatar* _owningAvatar;
106 
107  glm::vec3 _boundingCapsuleLocalOffset;
108  float _boundingCapsuleRadius;
109  float _boundingCapsuleHeight;
110 
111  glm::vec3 _defaultEyeModelPosition;
112 
113  float _headClipDistance; // Near clip distance to use if no separate head model
114 
115 private:
116  bool _texturesLoaded { false };
117 };
118 
119 #endif // hifi_SkeletonModel_h
A skeleton loaded from a model.
Definition: SkeletonModel.h:25
bool getLeftHandPosition(glm::vec3 &position) const
Definition: SkeletonModel.cpp:245
glm::vec3 getDefaultEyeModelPosition() const
Definition: SkeletonModel.cpp:310
float getLeftArmLength() const
Returns the extended length from the left hand to its last free ancestor.
bool getEyePositions(glm::vec3 &firstEyePosition, glm::vec3 &secondEyePosition) const
Definition: SkeletonModel.cpp:301
bool getNeckPosition(glm::vec3 &neckPosition) const
Definition: SkeletonModel.cpp:257
bool getRightHandPosition(glm::vec3 &position) const
Definition: SkeletonModel.cpp:249
int getRightHandJointIndex() const
Returns the index of the right hand joint, or -1 if not found.
Definition: SkeletonModel.h:50
bool getHeadPosition(glm::vec3 &headPosition) const
Definition: SkeletonModel.cpp:253
Q_INVOKABLE void setURL(const QUrl &url) override
Sets the URL of the model to render.
Definition: SkeletonModel.cpp:46
int getLeftHandJointIndex() const
Returns the index of the left hand joint, or -1 if not found.
Definition: SkeletonModel.h:47