// // AvatarManager.h // interface/src/avatar // // Created by Stephen Birarda on 1/23/2014. // Copyright 2014 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef hifi_AvatarManager_h #define hifi_AvatarManager_h #include #include #include #include #include #include #include #include "Avatar.h" #include "AvatarMotionState.h" class MyAvatar; class AvatarManager : public AvatarHashMap { Q_OBJECT SINGLETON_DEPENDENCY public: /// Registers the script types associated with the avatar manager. static void registerMetaTypes(QScriptEngine* engine); void init(); MyAvatar* getMyAvatar() { return _myAvatar.get(); } AvatarSharedPointer getAvatarBySessionID(const QUuid& sessionID); void updateMyAvatar(float deltaTime); void updateOtherAvatars(float deltaTime); void clearOtherAvatars(); bool shouldShowReceiveStats() const { return _shouldShowReceiveStats; } class LocalLight { public: glm::vec3 color; glm::vec3 direction; }; Q_INVOKABLE void setLocalLights(const QVector& localLights); Q_INVOKABLE QVector getLocalLights() const; // Currently, your own avatar will be included as the null avatar id. Q_INVOKABLE QVector getAvatarIdentifiers(); Q_INVOKABLE AvatarData* getAvatar(QUuid avatarID); void getObjectsToDelete(VectorOfMotionStates& motionStates); void getObjectsToAdd(VectorOfMotionStates& motionStates); void getObjectsToChange(VectorOfMotionStates& motionStates); void handleOutgoingChanges(const VectorOfMotionStates& motionStates); void handleCollisionEvents(const CollisionEvents& collisionEvents); void updateAvatarPhysicsShape(Avatar* avatar); public slots: void setShouldShowReceiveStats(bool shouldShowReceiveStats) { _shouldShowReceiveStats = shouldShowReceiveStats; } void updateAvatarRenderStatus(bool shouldRenderAvatars); private: AvatarManager(QObject* parent = 0); AvatarManager(const AvatarManager& other); void simulateAvatarFades(float deltaTime); // virtual overrides virtual AvatarSharedPointer newSharedAvatar(); virtual AvatarSharedPointer addAvatar(const QUuid& sessionUUID, const QWeakPointer& mixerWeakPointer); void removeAvatarMotionState(AvatarSharedPointer avatar); virtual void removeAvatar(const QUuid& sessionUUID); virtual void handleRemovedAvatar(const AvatarSharedPointer& removedAvatar); QVector _avatarFades; std::shared_ptr _myAvatar; quint64 _lastSendAvatarDataTime = 0; // Controls MyAvatar send data rate. QVector _localLights; bool _shouldShowReceiveStats = false; SetOfAvatarMotionStates _avatarMotionStates; SetOfMotionStates _motionStatesToAdd; VectorOfMotionStates _motionStatesToDelete; }; Q_DECLARE_METATYPE(AvatarManager::LocalLight) Q_DECLARE_METATYPE(QVector) #endif // hifi_AvatarManager_h