mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 05:37:22 +02:00
Moved AnimationObject to separate source files.
This commit is contained in:
parent
197127fbde
commit
15d4f59ceb
5 changed files with 84 additions and 49 deletions
|
@ -10,7 +10,6 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <QRunnable>
|
#include <QRunnable>
|
||||||
#include <QScriptEngine>
|
|
||||||
#include <QThreadPool>
|
#include <QThreadPool>
|
||||||
|
|
||||||
#include "AnimationCache.h"
|
#include "AnimationCache.h"
|
||||||
|
@ -101,22 +100,3 @@ void Animation::downloadFinished(QNetworkReply* reply) {
|
||||||
QThreadPool::globalInstance()->start(new AnimationReader(_self, reply));
|
QThreadPool::globalInstance()->start(new AnimationReader(_self, reply));
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList AnimationObject::getJointNames() const {
|
|
||||||
return qscriptvalue_cast<AnimationPointer>(thisObject())->getJointNames();
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<FBXAnimationFrame> AnimationObject::getFrames() const {
|
|
||||||
return qscriptvalue_cast<AnimationPointer>(thisObject())->getFrames();
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<glm::quat> AnimationFrameObject::getRotations() const {
|
|
||||||
return qscriptvalue_cast<FBXAnimationFrame>(thisObject()).rotations;
|
|
||||||
}
|
|
||||||
|
|
||||||
void registerAnimationTypes(QScriptEngine* engine) {
|
|
||||||
qScriptRegisterSequenceMetaType<QVector<FBXAnimationFrame> >(engine);
|
|
||||||
engine->setDefaultPrototype(qMetaTypeId<FBXAnimationFrame>(), engine->newQObject(
|
|
||||||
new AnimationFrameObject(), QScriptEngine::ScriptOwnership));
|
|
||||||
engine->setDefaultPrototype(qMetaTypeId<AnimationPointer>(), engine->newQObject(
|
|
||||||
new AnimationObject(), QScriptEngine::ScriptOwnership));
|
|
||||||
}
|
|
||||||
|
|
|
@ -12,14 +12,10 @@
|
||||||
#ifndef hifi_AnimationCache_h
|
#ifndef hifi_AnimationCache_h
|
||||||
#define hifi_AnimationCache_h
|
#define hifi_AnimationCache_h
|
||||||
|
|
||||||
#include <QScriptable>
|
|
||||||
|
|
||||||
#include <ResourceCache.h>
|
#include <ResourceCache.h>
|
||||||
|
|
||||||
#include <FBXReader.h>
|
#include <FBXReader.h>
|
||||||
|
|
||||||
class QScriptEngine;
|
|
||||||
|
|
||||||
class Animation;
|
class Animation;
|
||||||
|
|
||||||
typedef QSharedPointer<Animation> AnimationPointer;
|
typedef QSharedPointer<Animation> AnimationPointer;
|
||||||
|
@ -69,29 +65,4 @@ private:
|
||||||
FBXGeometry _geometry;
|
FBXGeometry _geometry;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Scriptable wrapper for animation pointers.
|
|
||||||
class AnimationObject : public QObject, protected QScriptable {
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(QStringList jointNames READ getJointNames)
|
|
||||||
Q_PROPERTY(QVector<FBXAnimationFrame> frames READ getFrames)
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Q_INVOKABLE QStringList getJointNames() const;
|
|
||||||
|
|
||||||
Q_INVOKABLE QVector<FBXAnimationFrame> getFrames() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Scriptable wrapper for animation frames.
|
|
||||||
class AnimationFrameObject : public QObject, protected QScriptable {
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(QVector<glm::quat> rotations READ getRotations)
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Q_INVOKABLE QVector<glm::quat> getRotations() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
void registerAnimationTypes(QScriptEngine* engine);
|
|
||||||
|
|
||||||
#endif // hifi_AnimationCache_h
|
#endif // hifi_AnimationCache_h
|
||||||
|
|
36
libraries/script-engine/src/AnimationObject.cpp
Normal file
36
libraries/script-engine/src/AnimationObject.cpp
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
//
|
||||||
|
// AnimationObject.cpp
|
||||||
|
// libraries/script-engine/src/
|
||||||
|
//
|
||||||
|
// Created by Andrzej Kapolka on 4/17/14.
|
||||||
|
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <QScriptEngine>
|
||||||
|
|
||||||
|
#include "AnimationCache.h"
|
||||||
|
#include "AnimationObject.h"
|
||||||
|
|
||||||
|
QStringList AnimationObject::getJointNames() const {
|
||||||
|
return qscriptvalue_cast<AnimationPointer>(thisObject())->getJointNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<FBXAnimationFrame> AnimationObject::getFrames() const {
|
||||||
|
return qscriptvalue_cast<AnimationPointer>(thisObject())->getFrames();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<glm::quat> AnimationFrameObject::getRotations() const {
|
||||||
|
return qscriptvalue_cast<FBXAnimationFrame>(thisObject()).rotations;
|
||||||
|
}
|
||||||
|
|
||||||
|
void registerAnimationTypes(QScriptEngine* engine) {
|
||||||
|
qScriptRegisterSequenceMetaType<QVector<FBXAnimationFrame> >(engine);
|
||||||
|
engine->setDefaultPrototype(qMetaTypeId<FBXAnimationFrame>(), engine->newQObject(
|
||||||
|
new AnimationFrameObject(), QScriptEngine::ScriptOwnership));
|
||||||
|
engine->setDefaultPrototype(qMetaTypeId<AnimationPointer>(), engine->newQObject(
|
||||||
|
new AnimationObject(), QScriptEngine::ScriptOwnership));
|
||||||
|
}
|
||||||
|
|
47
libraries/script-engine/src/AnimationObject.h
Normal file
47
libraries/script-engine/src/AnimationObject.h
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
//
|
||||||
|
// AnimationObject.h
|
||||||
|
// libraries/script-engine/src/
|
||||||
|
//
|
||||||
|
// Created by Andrzej Kapolka on 4/17/14.
|
||||||
|
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// 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_AnimationObject_h
|
||||||
|
#define hifi_AnimationObject_h
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QScriptable>
|
||||||
|
|
||||||
|
#include <FBXReader.h>
|
||||||
|
|
||||||
|
class QScriptEngine;
|
||||||
|
|
||||||
|
/// Scriptable wrapper for animation pointers.
|
||||||
|
class AnimationObject : public QObject, protected QScriptable {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QStringList jointNames READ getJointNames)
|
||||||
|
Q_PROPERTY(QVector<FBXAnimationFrame> frames READ getFrames)
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Q_INVOKABLE QStringList getJointNames() const;
|
||||||
|
|
||||||
|
Q_INVOKABLE QVector<FBXAnimationFrame> getFrames() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Scriptable wrapper for animation frames.
|
||||||
|
class AnimationFrameObject : public QObject, protected QScriptable {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QVector<glm::quat> rotations READ getRotations)
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Q_INVOKABLE QVector<glm::quat> getRotations() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
void registerAnimationTypes(QScriptEngine* engine);
|
||||||
|
|
||||||
|
#endif // hifi_AnimationObject_h
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include <Sound.h>
|
#include <Sound.h>
|
||||||
|
|
||||||
|
#include "AnimationObject.h"
|
||||||
#include "MenuItemProperties.h"
|
#include "MenuItemProperties.h"
|
||||||
#include "LocalVoxels.h"
|
#include "LocalVoxels.h"
|
||||||
#include "ScriptEngine.h"
|
#include "ScriptEngine.h"
|
||||||
|
|
Loading…
Reference in a new issue