14 #ifndef hifi_AnimationCache_h
15 #define hifi_AnimationCache_h
17 #include <QtCore/QRunnable>
18 #include <QtCore/QSharedPointer>
20 #include <DependencyManager.h>
22 #include <ResourceCache.h>
26 using AnimationPointer = QSharedPointer<Animation>;
28 class AnimationCache :
public ResourceCache,
public Dependency {
34 Q_INVOKABLE AnimationPointer getAnimation(
const QString& url) {
return getAnimation(QUrl(url)); }
35 Q_INVOKABLE AnimationPointer getAnimation(
const QUrl& url);
38 virtual QSharedPointer<Resource>
createResource(
const QUrl& url)
override;
39 QSharedPointer<Resource> createResourceCopy(
const QSharedPointer<Resource>& resource)
override;
42 explicit AnimationCache(QObject* parent = NULL);
43 virtual ~AnimationCache() { }
47 Q_DECLARE_METATYPE(AnimationPointer)
55 Animation(
const Animation& other) :
Resource(other), _hfmModel(other._hfmModel) {}
56 Animation(
const QUrl& url) :
Resource(url) {}
58 QString getType()
const override {
return "Animation"; }
60 const HFMModel& getHFMModel()
const {
return *_hfmModel; }
62 virtual bool isLoaded()
const override;
64 Q_INVOKABLE QStringList getJointNames()
const;
66 Q_INVOKABLE QVector<HFMAnimationFrame> getFrames()
const;
68 const QVector<HFMAnimationFrame>& getFramesReference()
const;
71 virtual void downloadFinished(
const QByteArray& data)
override;
74 void animationParseSuccess(HFMModel::Pointer hfmModel);
75 void animationParseError(
int error, QString str);
79 HFMModel::Pointer _hfmModel;
88 virtual void run()
override;
91 void onSuccess(HFMModel::Pointer hfmModel);
92 void onError(
int error, QString str);
An animation loaded from the network.
Definition: AnimationCache.h:83
Base class for resource caches.
Definition: ResourceCache.h:196
virtual QSharedPointer< Resource > createResource(const QUrl &url)=0
Creates a new resource.
Base class for resources.
Definition: ResourceCache.h:409
The runtime model format.
Definition: HFM.h:302