mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-09 02:42:19 +02:00
rename frameIndex to currentFrame
This commit is contained in:
parent
57cc7adbfe
commit
7a85e5b7a7
20 changed files with 115 additions and 112 deletions
|
@ -61,17 +61,17 @@ void ScriptableAvatar::update(float deltatime) {
|
|||
_jointData.resize(modelJoints.size());
|
||||
}
|
||||
|
||||
float frameIndex = _animationDetails.frameIndex + deltatime * _animationDetails.fps;
|
||||
if (_animationDetails.loop || frameIndex < _animationDetails.lastFrame) {
|
||||
while (frameIndex >= _animationDetails.lastFrame) {
|
||||
frameIndex -= (_animationDetails.lastFrame - _animationDetails.firstFrame);
|
||||
float currentFrame = _animationDetails.currentFrame + deltatime * _animationDetails.fps;
|
||||
if (_animationDetails.loop || currentFrame < _animationDetails.lastFrame) {
|
||||
while (currentFrame >= _animationDetails.lastFrame) {
|
||||
currentFrame -= (_animationDetails.lastFrame - _animationDetails.firstFrame);
|
||||
}
|
||||
_animationDetails.frameIndex = frameIndex;
|
||||
_animationDetails.currentFrame = currentFrame;
|
||||
|
||||
const int frameCount = _animation->getFrames().size();
|
||||
const FBXAnimationFrame& floorFrame = _animation->getFrames().at((int)glm::floor(frameIndex) % frameCount);
|
||||
const FBXAnimationFrame& ceilFrame = _animation->getFrames().at((int)glm::ceil(frameIndex) % frameCount);
|
||||
const float frameFraction = glm::fract(frameIndex);
|
||||
const FBXAnimationFrame& floorFrame = _animation->getFrames().at((int)glm::floor(currentFrame) % frameCount);
|
||||
const FBXAnimationFrame& ceilFrame = _animation->getFrames().at((int)glm::ceil(currentFrame) % frameCount);
|
||||
const float frameFraction = glm::fract(currentFrame);
|
||||
|
||||
for (int i = 0; i < modelJoints.size(); i++) {
|
||||
int mapping = animationJoints.indexOf(modelJoints[i]);
|
||||
|
|
|
@ -19,7 +19,7 @@ Agent.isAvatar = true;
|
|||
|
||||
var jointMapping;
|
||||
|
||||
var frameIndex = 0.0;
|
||||
var currentFrame = 0.0;
|
||||
|
||||
var FRAME_RATE = 30.0; // frames per second
|
||||
|
||||
|
@ -35,9 +35,9 @@ Script.update.connect(function(deltaTime) {
|
|||
jointMapping[i] = animationJointNames.indexOf(avatarJointNames[i]);
|
||||
}
|
||||
}
|
||||
frameIndex += deltaTime * FRAME_RATE;
|
||||
currentFrame += deltaTime * FRAME_RATE;
|
||||
var frames = animation.frames;
|
||||
var rotations = frames[Math.floor(frameIndex) % frames.length].rotations;
|
||||
var rotations = frames[Math.floor(currentFrame) % frames.length].rotations;
|
||||
for (var j = 0; j < jointMapping.length; j++) {
|
||||
var rotationIndex = jointMapping[j];
|
||||
if (rotationIndex != -1) {
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
this.leaveEntity = function(entityID) {
|
||||
Entities.editEntity(entityID, {
|
||||
animation: { url: animationURL, frameIndex: 1, running: false }
|
||||
animation: { url: animationURL, currentFrame: 1, running: false }
|
||||
});
|
||||
|
||||
playSound();
|
||||
|
@ -40,7 +40,7 @@
|
|||
|
||||
this.hoverEnterEntity = function(entityID) {
|
||||
Entities.editEntity(entityID, {
|
||||
animation: { url: animationURL, fps: 24, firstFrame: 1, lastFrame: 25, frameIndex: 1, running: true, hold: true }
|
||||
animation: { url: animationURL, fps: 24, firstFrame: 1, lastFrame: 25, currentFrame: 1, running: true, hold: true }
|
||||
});
|
||||
};
|
||||
})
|
|
@ -18,7 +18,7 @@ function displayAnimationDetails(deltaTime) {
|
|||
print("count =" + count + " deltaTime=" + deltaTime);
|
||||
count++;
|
||||
var animationDetails = MyAvatar.getAnimationDetailsByRole("idle");
|
||||
print("animationDetails.frameIndex=" + animationDetails.frameIndex);
|
||||
print("animationDetails.currentFrame=" + animationDetails.currentFrame);
|
||||
}
|
||||
|
||||
function scriptEnding() {
|
||||
|
|
|
@ -113,7 +113,7 @@ function moveModel(deltaTime) {
|
|||
|
||||
if (resetFrame) {
|
||||
print("resetting the frame!");
|
||||
newProperties.animation.frameIndex = 0;
|
||||
newProperties.animation.currentFrame = 0;
|
||||
resetFrame = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ function addButterfly() {
|
|||
url: "http://public.highfidelity.io/models/content/butterfly/butterfly.fbx",
|
||||
firstFrame: 0,
|
||||
fps: newFrameRate,
|
||||
frameIndex: 0,
|
||||
currentFrame: 0,
|
||||
hold: false,
|
||||
lastFrame: 10000,
|
||||
loop: true,
|
||||
|
|
|
@ -522,7 +522,7 @@
|
|||
elModelAnimationURL.value = properties.animation.url;
|
||||
elModelAnimationPlaying.checked = properties.animation.running;
|
||||
elModelAnimationFPS.value = properties.animation.fps;
|
||||
elModelAnimationFrame.value = properties.animation.frameIndex;
|
||||
elModelAnimationFrame.value = properties.animation.currentFrame;
|
||||
elModelAnimationFirstFrame.value = properties.animation.firstFrame;
|
||||
elModelAnimationLastFrame.value = properties.animation.lastFrame;
|
||||
elModelAnimationLoop.checked = properties.animation.loop;
|
||||
|
@ -777,7 +777,7 @@
|
|||
elModelAnimationURL.addEventListener('change', createEmitGroupTextPropertyUpdateFunction('animation', 'url'));
|
||||
elModelAnimationPlaying.addEventListener('change', createEmitGroupCheckedPropertyUpdateFunction('animation','running'));
|
||||
elModelAnimationFPS.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('animation','fps'));
|
||||
elModelAnimationFrame.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('animation', 'frameIndex'));
|
||||
elModelAnimationFrame.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('animation', 'currentFrame'));
|
||||
elModelAnimationFirstFrame.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('animation', 'firstFrame'));
|
||||
elModelAnimationLastFrame.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('animation', 'lastFrame'));
|
||||
elModelAnimationLoop.addEventListener('change', createEmitGroupCheckedPropertyUpdateFunction('animation', 'loop'));
|
||||
|
|
|
@ -26,7 +26,7 @@ EntityPropertyDialogBox = (function () {
|
|||
var rescalePercentage;
|
||||
var editModelID = -1;
|
||||
var previousAnimationIsPlaying;
|
||||
var previousAnimationFrameIndex;
|
||||
var previousAnimationCurrentFrame;
|
||||
|
||||
that.cleanup = function () {
|
||||
};
|
||||
|
@ -62,8 +62,8 @@ EntityPropertyDialogBox = (function () {
|
|||
index++;
|
||||
array.push({ label: "Animation FPS:", value: properties.animation.fps });
|
||||
index++;
|
||||
array.push({ label: "Animation Frame:", value: properties.animation.frameIndex });
|
||||
previousAnimationFrameIndex = properties.animation.frameIndex;
|
||||
array.push({ label: "Animation Frame:", value: properties.animation.currentFrame });
|
||||
previousAnimationCurrentFrame = properties.animation.currentFrame;
|
||||
index++;
|
||||
array.push({ label: "Textures:", value: properties.textures });
|
||||
index++;
|
||||
|
@ -319,11 +319,11 @@ EntityPropertyDialogBox = (function () {
|
|||
|
||||
properties.animation.fps = array[index++].value;
|
||||
|
||||
var newAnimationFrameIndex = array[index++].value;
|
||||
if (previousAnimationFrameIndex != newAnimationFrameIndex) {
|
||||
properties.animation.frameIndex = newAnimationFrameIndex;
|
||||
var newAnimationCurrentFrame = array[index++].value;
|
||||
if (previousAnimationCurrentFrame != newAnimationCurrentFrame) {
|
||||
properties.animation.currentFrame = newAnimationCurrentFrame;
|
||||
} else {
|
||||
delete properties.animation.frameIndex;
|
||||
delete properties.animation.currentFrame;
|
||||
}
|
||||
|
||||
properties.textures = array[index++].value;
|
||||
|
|
|
@ -35,8 +35,10 @@
|
|||
|
||||
startNearGrab: function() {
|
||||
Entities.editEntity(this.entityID, {
|
||||
animationURL: "https://hifi-public.s3.amazonaws.com/models/Bboys/zombie_scream.fbx",
|
||||
animationFrameIndex: 0
|
||||
animation: {
|
||||
url: "https://hifi-public.s3.amazonaws.com/models/Bboys/zombie_scream.fbx",
|
||||
currentFrame: 0
|
||||
}
|
||||
});
|
||||
|
||||
Entities.editEntity(_this.entityID, {
|
||||
|
@ -65,11 +67,10 @@
|
|||
if (this.isGrabbed === true && this.hand === this.initialHand) {
|
||||
this.audioInjector.stop();
|
||||
Entities.editEntity(this.entityID, {
|
||||
animationFrameIndex: 0
|
||||
});
|
||||
|
||||
Entities.editEntity(this.entityID, {
|
||||
animationURL: "http://hifi-public.s3.amazonaws.com/models/Bboys/bboy2/bboy2.fbx"
|
||||
animation: {
|
||||
url: "http://hifi-public.s3.amazonaws.com/models/Bboys/bboy2/bboy2.fbx",
|
||||
currentFrame: 0
|
||||
}
|
||||
});
|
||||
|
||||
this.isGrabbed = false;
|
||||
|
|
|
@ -130,15 +130,15 @@ void Animation::animationParseError(int error, QString str) {
|
|||
|
||||
AnimationDetails::AnimationDetails() :
|
||||
role(), url(), fps(0.0f), priority(0.0f), loop(false), hold(false),
|
||||
startAutomatically(false), firstFrame(0.0f), lastFrame(0.0f), running(false), frameIndex(0.0f)
|
||||
startAutomatically(false), firstFrame(0.0f), lastFrame(0.0f), running(false), currentFrame(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
AnimationDetails::AnimationDetails(QString role, QUrl url, float fps, float priority, bool loop,
|
||||
bool hold, bool startAutomatically, float firstFrame, float lastFrame, bool running, float frameIndex) :
|
||||
bool hold, bool startAutomatically, float firstFrame, float lastFrame, bool running, float currentFrame) :
|
||||
role(role), url(url), fps(fps), priority(priority), loop(loop), hold(hold),
|
||||
startAutomatically(startAutomatically), firstFrame(firstFrame), lastFrame(lastFrame),
|
||||
running(running), frameIndex(frameIndex)
|
||||
running(running), currentFrame(currentFrame)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ QScriptValue animationDetailsToScriptValue(QScriptEngine* engine, const Animatio
|
|||
obj.setProperty("firstFrame", details.firstFrame);
|
||||
obj.setProperty("lastFrame", details.lastFrame);
|
||||
obj.setProperty("running", details.running);
|
||||
obj.setProperty("frameIndex", details.frameIndex);
|
||||
obj.setProperty("currentFrame", details.currentFrame);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ class AnimationDetails {
|
|||
public:
|
||||
AnimationDetails();
|
||||
AnimationDetails(QString role, QUrl url, float fps, float priority, bool loop,
|
||||
bool hold, bool startAutomatically, float firstFrame, float lastFrame, bool running, float frameIndex);
|
||||
bool hold, bool startAutomatically, float firstFrame, float lastFrame, bool running, float currentFrame);
|
||||
|
||||
QString role;
|
||||
QUrl url;
|
||||
|
@ -109,7 +109,7 @@ public:
|
|||
float firstFrame;
|
||||
float lastFrame;
|
||||
bool running;
|
||||
float frameIndex;
|
||||
float currentFrame;
|
||||
};
|
||||
Q_DECLARE_METATYPE(AnimationDetails);
|
||||
QScriptValue animationDetailsToScriptValue(QScriptEngine* engine, const AnimationDetails& event);
|
||||
|
|
|
@ -53,7 +53,7 @@ void AnimationHandle::setMaskedJoints(const QStringList& maskedJoints) {
|
|||
void AnimationHandle::setRunning(bool running, bool doRestoreJoints) {
|
||||
if (running && isRunning() && (getFadePerSecond() >= 0.0f)) {
|
||||
// if we're already running, this is the same as a restart -- unless we're fading out.
|
||||
setFrameIndex(getFirstFrame());
|
||||
setCurrentFrame(getFirstFrame());
|
||||
return;
|
||||
}
|
||||
_animationLoop.setRunning(running);
|
||||
|
@ -82,7 +82,7 @@ AnimationHandle::AnimationHandle(RigPointer rig) :
|
|||
|
||||
AnimationDetails AnimationHandle::getAnimationDetails() const {
|
||||
AnimationDetails details(_role, _url, getFPS(), _priority, getLoop(), getHold(),
|
||||
getStartAutomatically(), getFirstFrame(), getLastFrame(), isRunning(), getFrameIndex());
|
||||
getStartAutomatically(), getFirstFrame(), getLastFrame(), isRunning(), getCurrentFrame());
|
||||
return details;
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ void AnimationHandle::setAnimationDetails(const AnimationDetails& details) {
|
|||
setFirstFrame(details.firstFrame);
|
||||
setLastFrame(details.lastFrame);
|
||||
setRunning(details.running);
|
||||
setFrameIndex(details.frameIndex);
|
||||
setCurrentFrame(details.currentFrame);
|
||||
|
||||
// NOTE: AnimationDetails doesn't support maskedJoints
|
||||
//setMaskedJoints(const QStringList& maskedJoints);
|
||||
|
@ -160,19 +160,19 @@ void AnimationHandle::simulate(float deltaTime) {
|
|||
}
|
||||
|
||||
// blend between the closest two frames
|
||||
applyFrame(getFrameIndex());
|
||||
applyFrame(getCurrentFrame());
|
||||
}
|
||||
|
||||
void AnimationHandle::applyFrame(float frameIndex) {
|
||||
void AnimationHandle::applyFrame(float currentFrame) {
|
||||
if (!_animation || !_animation->isLoaded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const FBXGeometry& animationGeometry = _animation->getGeometry();
|
||||
int frameCount = animationGeometry.animationFrames.size();
|
||||
const FBXAnimationFrame& floorFrame = animationGeometry.animationFrames.at((int)glm::floor(frameIndex) % frameCount);
|
||||
const FBXAnimationFrame& ceilFrame = animationGeometry.animationFrames.at((int)glm::ceil(frameIndex) % frameCount);
|
||||
float frameFraction = glm::fract(frameIndex);
|
||||
const FBXAnimationFrame& floorFrame = animationGeometry.animationFrames.at((int)glm::floor(currentFrame) % frameCount);
|
||||
const FBXAnimationFrame& ceilFrame = animationGeometry.animationFrames.at((int)glm::ceil(currentFrame) % frameCount);
|
||||
float frameFraction = glm::fract(currentFrame);
|
||||
|
||||
for (int i = 0; i < _jointMappings.size(); i++) {
|
||||
int mapping = _jointMappings.at(i);
|
||||
|
|
|
@ -94,8 +94,8 @@ public:
|
|||
void setRunning(bool running, bool restoreJoints = true);
|
||||
bool isRunning() const { return _animationLoop.getRunning(); }
|
||||
|
||||
void setFrameIndex(float frameIndex) { _animationLoop.setFrameIndex(frameIndex); }
|
||||
float getFrameIndex() const { return _animationLoop.getFrameIndex(); }
|
||||
void setCurrentFrame(float currentFrame) { _animationLoop.setCurrentFrame(currentFrame); }
|
||||
float getCurrentFrame() const { return _animationLoop.getCurrentFrame(); }
|
||||
|
||||
AnimationDetails getAnimationDetails() const;
|
||||
void setAnimationDetails(const AnimationDetails& details);
|
||||
|
@ -103,7 +103,7 @@ public:
|
|||
void setJointMappings(QVector<int> jointMappings);
|
||||
QVector<int> getJointMappings(); // computing if necessary
|
||||
void simulate(float deltaTime);
|
||||
void applyFrame(float frameIndex);
|
||||
void applyFrame(float currentFrame);
|
||||
void replaceMatchingPriorities(float newPriority);
|
||||
void restoreJoints();
|
||||
void clearJoints() { _jointMappings.clear(); }
|
||||
|
|
|
@ -24,7 +24,7 @@ AnimationLoop::AnimationLoop() :
|
|||
_firstFrame(0.0f),
|
||||
_lastFrame(MAXIMUM_POSSIBLE_FRAME),
|
||||
_running(false),
|
||||
_frameIndex(0.0f),
|
||||
_currentFrame(0.0f),
|
||||
_maxFrameIndexHint(MAXIMUM_POSSIBLE_FRAME),
|
||||
_resetOnRunning(true),
|
||||
_lastSimulated(usecTimestampNow())
|
||||
|
@ -39,14 +39,14 @@ AnimationLoop::AnimationLoop(const AnimationDetails& animationDetails) :
|
|||
_firstFrame(animationDetails.firstFrame),
|
||||
_lastFrame(animationDetails.lastFrame),
|
||||
_running(animationDetails.running),
|
||||
_frameIndex(animationDetails.frameIndex),
|
||||
_currentFrame(animationDetails.currentFrame),
|
||||
_resetOnRunning(true),
|
||||
_lastSimulated(usecTimestampNow())
|
||||
{
|
||||
}
|
||||
|
||||
AnimationLoop::AnimationLoop(float fps, bool loop, bool hold, bool startAutomatically, float firstFrame,
|
||||
float lastFrame, bool running, float frameIndex) :
|
||||
float lastFrame, bool running, float currentFrame) :
|
||||
_fps(fps),
|
||||
_loop(loop),
|
||||
_hold(hold),
|
||||
|
@ -54,7 +54,7 @@ AnimationLoop::AnimationLoop(float fps, bool loop, bool hold, bool startAutomati
|
|||
_firstFrame(firstFrame),
|
||||
_lastFrame(lastFrame),
|
||||
_running(running),
|
||||
_frameIndex(frameIndex),
|
||||
_currentFrame(currentFrame),
|
||||
_resetOnRunning(true),
|
||||
_lastSimulated(usecTimestampNow())
|
||||
{
|
||||
|
@ -67,25 +67,25 @@ void AnimationLoop::simulateAtTime(quint64 now) {
|
|||
}
|
||||
|
||||
void AnimationLoop::simulate(float deltaTime) {
|
||||
_frameIndex += deltaTime * _fps;
|
||||
_currentFrame += deltaTime * _fps;
|
||||
|
||||
// If we knew the number of frames from the animation, we'd consider using it here
|
||||
// animationGeometry.animationFrames.size()
|
||||
float maxFrame = _maxFrameIndexHint;
|
||||
float endFrameIndex = qMin(_lastFrame, maxFrame - (_loop ? 0.0f : 1.0f));
|
||||
float startFrameIndex = qMin(_firstFrame, endFrameIndex);
|
||||
if ((!_loop && (_frameIndex < startFrameIndex || _frameIndex > endFrameIndex)) || startFrameIndex == endFrameIndex) {
|
||||
if ((!_loop && (_currentFrame < startFrameIndex || _currentFrame > endFrameIndex)) || startFrameIndex == endFrameIndex) {
|
||||
// passed the end; apply the last frame
|
||||
_frameIndex = glm::clamp(_frameIndex, startFrameIndex, endFrameIndex);
|
||||
_currentFrame = glm::clamp(_currentFrame, startFrameIndex, endFrameIndex);
|
||||
if (!_hold) {
|
||||
stop();
|
||||
}
|
||||
} else {
|
||||
// wrap within the the desired range
|
||||
if (_frameIndex < startFrameIndex) {
|
||||
_frameIndex = endFrameIndex - glm::mod(endFrameIndex - _frameIndex, endFrameIndex - startFrameIndex);
|
||||
} else if (_frameIndex > endFrameIndex) {
|
||||
_frameIndex = startFrameIndex + glm::mod(_frameIndex - startFrameIndex, endFrameIndex - startFrameIndex);
|
||||
if (_currentFrame < startFrameIndex) {
|
||||
_currentFrame = endFrameIndex - glm::mod(endFrameIndex - _currentFrame, endFrameIndex - startFrameIndex);
|
||||
} else if (_currentFrame > endFrameIndex) {
|
||||
_currentFrame = startFrameIndex + glm::mod(_currentFrame - startFrameIndex, endFrameIndex - startFrameIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ void AnimationLoop::setRunning(bool running) {
|
|||
// If we just set running to true, then also reset the frame to the first frame
|
||||
if (running && (_resetOnRunning)) {
|
||||
// move back to the beginning
|
||||
_frameIndex = _firstFrame;
|
||||
_currentFrame = _firstFrame;
|
||||
}
|
||||
|
||||
// If we just started running, set our
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
AnimationLoop();
|
||||
AnimationLoop(const AnimationDetails& animationDetails);
|
||||
AnimationLoop(float fps, bool loop, bool hold, bool startAutomatically, float firstFrame,
|
||||
float lastFrame, bool running, float frameIndex);
|
||||
float lastFrame, bool running, float currentFrame);
|
||||
|
||||
void setFPS(float fps) { _fps = fps; }
|
||||
float getFPS() const { return _fps; }
|
||||
|
@ -48,8 +48,8 @@ public:
|
|||
void setRunning(bool running);
|
||||
bool getRunning() const { return _running; }
|
||||
|
||||
void setFrameIndex(float frameIndex) { _frameIndex = glm::clamp(frameIndex, _firstFrame, _lastFrame); }
|
||||
float getFrameIndex() const { return _frameIndex; }
|
||||
void setCurrentFrame(float currentFrame) { _currentFrame = glm::clamp(currentFrame, _firstFrame, _lastFrame); }
|
||||
float getCurrentFrame() const { return _currentFrame; }
|
||||
|
||||
void setMaxFrameIndexHint(float value) { _maxFrameIndexHint = glm::clamp(value, 0.0f, MAXIMUM_POSSIBLE_FRAME); }
|
||||
float getMaxFrameIndexHint() const { return _maxFrameIndexHint; }
|
||||
|
@ -68,7 +68,7 @@ private:
|
|||
float _firstFrame;
|
||||
float _lastFrame;
|
||||
bool _running;
|
||||
float _frameIndex;
|
||||
float _currentFrame;
|
||||
float _maxFrameIndexHint;
|
||||
bool _resetOnRunning;
|
||||
quint64 _lastSimulated;
|
||||
|
|
|
@ -35,7 +35,7 @@ void AnimationPropertyGroup::copyToScriptValue(const EntityPropertyFlags& desire
|
|||
|
||||
if (_animationLoop) {
|
||||
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_ANIMATION_FPS, Animation, animation, FPS, fps, _animationLoop->getFPS);
|
||||
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_ANIMATION_FRAME_INDEX, Animation, animation, FrameIndex, frameIndex, _animationLoop->getFPS);
|
||||
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_ANIMATION_FRAME_INDEX, Animation, animation, CurrentFrame, currentFrame, _animationLoop->getFPS);
|
||||
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_ANIMATION_PLAYING, Animation, animation, Running, running, _animationLoop->getRunning);
|
||||
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_ANIMATION_LOOP, Animation, animation, Loop, loop, _animationLoop->getLoop);
|
||||
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_ANIMATION_FIRST_FRAME, Animation, animation, FirstFrame, firstFrame, _animationLoop->getFirstFrame);
|
||||
|
@ -44,7 +44,7 @@ void AnimationPropertyGroup::copyToScriptValue(const EntityPropertyFlags& desire
|
|||
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_ANIMATION_START_AUTOMATICALLY, Animation, animation, StartAutomatically, startAutomatically, _animationLoop->getStartAutomatically);
|
||||
} else {
|
||||
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_ANIMATION_FPS, Animation, animation, FPS, fps);
|
||||
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_ANIMATION_FRAME_INDEX, Animation, animation, FrameIndex, frameIndex);
|
||||
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_ANIMATION_FRAME_INDEX, Animation, animation, CurrentFrame, currentFrame);
|
||||
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_ANIMATION_PLAYING, Animation, animation, Running, running);
|
||||
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_ANIMATION_LOOP, Animation, animation, Loop, loop);
|
||||
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_ANIMATION_FIRST_FRAME, Animation, animation, FirstFrame, firstFrame);
|
||||
|
@ -64,7 +64,7 @@ void AnimationPropertyGroup::copyFromScriptValue(const QScriptValue& object, boo
|
|||
|
||||
if (_animationLoop) {
|
||||
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(animation, fps, float, _animationLoop->setFPS);
|
||||
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(animation, frameIndex, float, _animationLoop->setFrameIndex);
|
||||
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(animation, currentFrame, float, _animationLoop->setCurrentFrame);
|
||||
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(animation, running, bool, _animationLoop->setRunning);
|
||||
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(animation, loop, bool, _animationLoop->setLoop);
|
||||
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(animation, firstFrame, float, _animationLoop->setFirstFrame);
|
||||
|
@ -75,11 +75,11 @@ void AnimationPropertyGroup::copyFromScriptValue(const QScriptValue& object, boo
|
|||
// legacy property support
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(animationFPS, float, _animationLoop->setFPS, _animationLoop->getFPS);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(animationIsPlaying, bool, _animationLoop->setRunning, _animationLoop->getRunning);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(animationFrameIndex, float, _animationLoop->setFrameIndex, _animationLoop->getFrameIndex);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(animationFrameIndex, float, _animationLoop->setCurrentFrame, _animationLoop->getCurrentFrame);
|
||||
|
||||
} else {
|
||||
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(animation, fps, float, setFPS);
|
||||
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(animation, frameIndex, float, setFrameIndex);
|
||||
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(animation, currentFrame, float, setCurrentFrame);
|
||||
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(animation, running, bool, setRunning);
|
||||
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(animation, loop, bool, setLoop);
|
||||
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(animation, firstFrame, float, setFirstFrame);
|
||||
|
@ -90,18 +90,18 @@ void AnimationPropertyGroup::copyFromScriptValue(const QScriptValue& object, boo
|
|||
// legacy property support
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(animationFPS, float, setFPS, getFPS);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(animationIsPlaying, bool, setRunning, getRunning);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(animationFrameIndex, float, setFrameIndex, getFrameIndex);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(animationFrameIndex, float, setCurrentFrame, getCurrentFrame);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AnimationPropertyGroup::setFromOldAnimationSettings(const QString& value) {
|
||||
// the animations setting is a JSON string that may contain various animation settings.
|
||||
// if it includes fps, frameIndex, or running, those values will be parsed out and
|
||||
// if it includes fps, currentFrame, or running, those values will be parsed out and
|
||||
// will over ride the regular animation settings
|
||||
|
||||
float fps = _animationLoop ? _animationLoop->getFPS() : getFPS();
|
||||
float frameIndex = _animationLoop ? _animationLoop->getFrameIndex() : getFrameIndex();
|
||||
float currentFrame = _animationLoop ? _animationLoop->getCurrentFrame() : getCurrentFrame();
|
||||
bool running = _animationLoop ? _animationLoop->getRunning() : getRunning();
|
||||
float firstFrame = _animationLoop ? _animationLoop->getFirstFrame() : getFirstFrame();
|
||||
float lastFrame = _animationLoop ? _animationLoop->getLastFrame() : getLastFrame();
|
||||
|
@ -117,8 +117,9 @@ void AnimationPropertyGroup::setFromOldAnimationSettings(const QString& value) {
|
|||
fps = settingsMap["fps"].toFloat();
|
||||
}
|
||||
|
||||
// old settings had frameIndex
|
||||
if (settingsMap.contains("frameIndex")) {
|
||||
frameIndex = settingsMap["frameIndex"].toFloat();
|
||||
currentFrame = settingsMap["frameIndex"].toFloat();
|
||||
}
|
||||
|
||||
if (settingsMap.contains("running")) {
|
||||
|
@ -126,11 +127,11 @@ void AnimationPropertyGroup::setFromOldAnimationSettings(const QString& value) {
|
|||
}
|
||||
|
||||
if (settingsMap.contains("firstFrame")) {
|
||||
frameIndex = settingsMap["firstFrame"].toFloat();
|
||||
firstFrame = settingsMap["firstFrame"].toFloat();
|
||||
}
|
||||
|
||||
if (settingsMap.contains("lastFrame")) {
|
||||
frameIndex = settingsMap["lastFrame"].toFloat();
|
||||
lastFrame = settingsMap["lastFrame"].toFloat();
|
||||
}
|
||||
|
||||
if (settingsMap.contains("loop")) {
|
||||
|
@ -147,7 +148,7 @@ void AnimationPropertyGroup::setFromOldAnimationSettings(const QString& value) {
|
|||
|
||||
if (_animationLoop) {
|
||||
_animationLoop->setFPS(fps);
|
||||
_animationLoop->setFrameIndex(frameIndex);
|
||||
_animationLoop->setCurrentFrame(currentFrame);
|
||||
_animationLoop->setRunning(running);
|
||||
_animationLoop->setFirstFrame(firstFrame);
|
||||
_animationLoop->setLastFrame(lastFrame);
|
||||
|
@ -156,7 +157,7 @@ void AnimationPropertyGroup::setFromOldAnimationSettings(const QString& value) {
|
|||
_animationLoop->setStartAutomatically(startAutomatically);
|
||||
} else {
|
||||
setFPS(fps);
|
||||
setFrameIndex(frameIndex);
|
||||
setCurrentFrame(currentFrame);
|
||||
setRunning(running);
|
||||
setFirstFrame(firstFrame);
|
||||
setLastFrame(lastFrame);
|
||||
|
@ -171,7 +172,7 @@ void AnimationPropertyGroup::debugDump() const {
|
|||
qDebug() << " AnimationPropertyGroup: ---------------------------------------------";
|
||||
qDebug() << " url:" << getURL() << " has changed:" << urlChanged();
|
||||
qDebug() << " fps:" << getFPS() << " has changed:" << fpsChanged();
|
||||
qDebug() << "frameIndex:" << getFrameIndex() << " has changed:" << frameIndexChanged();
|
||||
qDebug() << "currentFrame:" << getCurrentFrame() << " has changed:" << currentFrameChanged();
|
||||
}
|
||||
|
||||
bool AnimationPropertyGroup::appendToEditPacket(OctreePacketData* packetData,
|
||||
|
@ -186,7 +187,7 @@ bool AnimationPropertyGroup::appendToEditPacket(OctreePacketData* packetData,
|
|||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_URL, getURL());
|
||||
if (_animationLoop) {
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FPS, _animationLoop->getFPS());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, _animationLoop->getFrameIndex());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, _animationLoop->getCurrentFrame());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, _animationLoop->getRunning());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_LOOP, _animationLoop->getLoop());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FIRST_FRAME, _animationLoop->getFirstFrame());
|
||||
|
@ -195,7 +196,7 @@ bool AnimationPropertyGroup::appendToEditPacket(OctreePacketData* packetData,
|
|||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_START_AUTOMATICALLY, _animationLoop->getStartAutomatically());
|
||||
} else {
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FPS, getFPS());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, getFrameIndex());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, getCurrentFrame());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, getRunning());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_LOOP, getLoop());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FIRST_FRAME, getFirstFrame());
|
||||
|
@ -218,7 +219,7 @@ bool AnimationPropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyF
|
|||
|
||||
if (_animationLoop) {
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FPS, float, _animationLoop->setFPS);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, float, _animationLoop->setFrameIndex);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, float, _animationLoop->setCurrentFrame);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, bool, _animationLoop->setRunning);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_LOOP, bool, _animationLoop->setLoop);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FIRST_FRAME, float, _animationLoop->setFirstFrame);
|
||||
|
@ -227,7 +228,7 @@ bool AnimationPropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyF
|
|||
READ_ENTITY_PROPERTY(PROP_ANIMATION_START_AUTOMATICALLY, bool, _animationLoop->setStartAutomatically);
|
||||
} else {
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FPS, float, setFPS);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, float, setFrameIndex);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, float, setCurrentFrame);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, bool, setRunning);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_LOOP, bool, setLoop);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FIRST_FRAME, float, setFirstFrame);
|
||||
|
@ -238,7 +239,7 @@ bool AnimationPropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyF
|
|||
|
||||
DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_ANIMATION_URL, URL);
|
||||
DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_ANIMATION_FPS, FPS);
|
||||
DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_ANIMATION_FRAME_INDEX, FrameIndex);
|
||||
DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_ANIMATION_FRAME_INDEX, CurrentFrame);
|
||||
DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_ANIMATION_PLAYING, Running);
|
||||
DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_ANIMATION_LOOP, Loop);
|
||||
DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_ANIMATION_FIRST_FRAME, FirstFrame);
|
||||
|
@ -254,7 +255,7 @@ bool AnimationPropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyF
|
|||
void AnimationPropertyGroup::markAllChanged() {
|
||||
_urlChanged = true;
|
||||
_fpsChanged = true;
|
||||
_frameIndexChanged = true;
|
||||
_currentFrameChanged = true;
|
||||
_runningChanged = true;
|
||||
}
|
||||
|
||||
|
@ -263,7 +264,7 @@ EntityPropertyFlags AnimationPropertyGroup::getChangedProperties() const {
|
|||
|
||||
CHECK_PROPERTY_CHANGE(PROP_ANIMATION_URL, url);
|
||||
CHECK_PROPERTY_CHANGE(PROP_ANIMATION_FPS, fps);
|
||||
CHECK_PROPERTY_CHANGE(PROP_ANIMATION_FRAME_INDEX, frameIndex);
|
||||
CHECK_PROPERTY_CHANGE(PROP_ANIMATION_FRAME_INDEX, currentFrame);
|
||||
CHECK_PROPERTY_CHANGE(PROP_ANIMATION_PLAYING, running);
|
||||
CHECK_PROPERTY_CHANGE(PROP_ANIMATION_LOOP, loop);
|
||||
CHECK_PROPERTY_CHANGE(PROP_ANIMATION_FIRST_FRAME, firstFrame);
|
||||
|
@ -278,7 +279,7 @@ void AnimationPropertyGroup::getProperties(EntityItemProperties& properties) con
|
|||
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Animation, URL, getURL);
|
||||
if (_animationLoop) {
|
||||
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Animation, FPS, _animationLoop->getFPS);
|
||||
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Animation, FrameIndex, _animationLoop->getFrameIndex);
|
||||
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Animation, CurrentFrame, _animationLoop->getCurrentFrame);
|
||||
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Animation, Running, _animationLoop->getRunning);
|
||||
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Animation, Loop, _animationLoop->getLoop);
|
||||
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Animation, FirstFrame, _animationLoop->getFirstFrame);
|
||||
|
@ -287,7 +288,7 @@ void AnimationPropertyGroup::getProperties(EntityItemProperties& properties) con
|
|||
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Animation, StartAutomatically, _animationLoop->getStartAutomatically);
|
||||
} else {
|
||||
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Animation, FPS, getFPS);
|
||||
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Animation, FrameIndex, getFrameIndex);
|
||||
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Animation, CurrentFrame, getCurrentFrame);
|
||||
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Animation, Running, getRunning);
|
||||
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Animation, Loop, getLoop);
|
||||
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Animation, FirstFrame, getFirstFrame);
|
||||
|
@ -303,7 +304,7 @@ bool AnimationPropertyGroup::setProperties(const EntityItemProperties& propertie
|
|||
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Animation, URL, url, setURL);
|
||||
if (_animationLoop) {
|
||||
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Animation, FPS, fps, _animationLoop->setFPS);
|
||||
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Animation, FrameIndex, frameIndex, _animationLoop->setFrameIndex);
|
||||
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Animation, CurrentFrame, currentFrame, _animationLoop->setCurrentFrame);
|
||||
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Animation, Running, running, _animationLoop->setRunning);
|
||||
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Animation, Loop, loop, _animationLoop->setLoop);
|
||||
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Animation, FirstFrame, firstFrame, _animationLoop->setFirstFrame);
|
||||
|
@ -312,7 +313,7 @@ bool AnimationPropertyGroup::setProperties(const EntityItemProperties& propertie
|
|||
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Animation, StartAutomatically, startAutomatically, _animationLoop->setStartAutomatically);
|
||||
} else {
|
||||
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Animation, FPS, fps, setFPS);
|
||||
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Animation, FrameIndex, frameIndex, setFrameIndex);
|
||||
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Animation, CurrentFrame, currentFrame, setCurrentFrame);
|
||||
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Animation, Running, running, setRunning);
|
||||
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Animation, Loop, loop, setLoop);
|
||||
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Animation, FirstFrame, firstFrame, setFirstFrame);
|
||||
|
@ -353,7 +354,7 @@ void AnimationPropertyGroup::appendSubclassData(OctreePacketData* packetData, En
|
|||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_URL, getURL());
|
||||
if (_animationLoop) {
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FPS, _animationLoop->getFPS());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, _animationLoop->getFrameIndex());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, _animationLoop->getCurrentFrame());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, _animationLoop->getRunning());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_LOOP, _animationLoop->getLoop());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FIRST_FRAME, _animationLoop->getFirstFrame());
|
||||
|
@ -362,7 +363,7 @@ void AnimationPropertyGroup::appendSubclassData(OctreePacketData* packetData, En
|
|||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_START_AUTOMATICALLY, _animationLoop->getStartAutomatically());
|
||||
} else {
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FPS, getFPS());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, getFrameIndex());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, getCurrentFrame());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, getRunning());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_LOOP, getLoop());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FIRST_FRAME, getFirstFrame());
|
||||
|
@ -385,7 +386,7 @@ int AnimationPropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char
|
|||
if (_animationLoop) {
|
||||
// apply new properties to our associated AnimationLoop
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FPS, float, _animationLoop->setFPS);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, float, _animationLoop->setFrameIndex);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, float, _animationLoop->setCurrentFrame);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, bool, _animationLoop->setRunning);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_LOOP, bool, _animationLoop->setLoop);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FIRST_FRAME, float, _animationLoop->setFirstFrame);
|
||||
|
@ -394,7 +395,7 @@ int AnimationPropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char
|
|||
READ_ENTITY_PROPERTY(PROP_ANIMATION_START_AUTOMATICALLY, bool, _animationLoop->setStartAutomatically);
|
||||
} else {
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FPS, float, setFPS);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, float, setFrameIndex);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, float, setCurrentFrame);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, bool, setRunning);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_LOOP, bool, setLoop);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FIRST_FRAME, float, setFirstFrame);
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
|
||||
DEFINE_PROPERTY_REF(PROP_ANIMATION_URL, URL, url, QString);
|
||||
DEFINE_PROPERTY(PROP_ANIMATION_FPS, FPS, fps, float);
|
||||
DEFINE_PROPERTY(PROP_ANIMATION_FRAME_INDEX, FrameIndex, frameIndex, float);
|
||||
DEFINE_PROPERTY(PROP_ANIMATION_FRAME_INDEX, CurrentFrame, currentFrame, float);
|
||||
DEFINE_PROPERTY(PROP_ANIMATION_PLAYING, Running, running, bool); // was animationIsPlaying
|
||||
DEFINE_PROPERTY(PROP_ANIMATION_LOOP, Loop, loop, bool); // was animationSettings.loop
|
||||
DEFINE_PROPERTY(PROP_ANIMATION_FIRST_FRAME, FirstFrame, firstFrame, float); // was animationSettings.firstFrame
|
||||
|
|
|
@ -823,7 +823,7 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue
|
|||
|
||||
ADD_GROUP_PROPERTY_TO_MAP(PROP_ANIMATION_URL, Animation, animation, URL, url);
|
||||
ADD_GROUP_PROPERTY_TO_MAP(PROP_ANIMATION_FPS, Animation, animation, FPS, fps);
|
||||
ADD_GROUP_PROPERTY_TO_MAP(PROP_ANIMATION_FRAME_INDEX, Animation, animation, FrameIndex, frameIndex);
|
||||
ADD_GROUP_PROPERTY_TO_MAP(PROP_ANIMATION_FRAME_INDEX, Animation, animation, CurrentFrame, currentFrame);
|
||||
ADD_GROUP_PROPERTY_TO_MAP(PROP_ANIMATION_PLAYING, Animation, animation, Running, running);
|
||||
ADD_GROUP_PROPERTY_TO_MAP(PROP_ANIMATION_LOOP, Animation, animation, Loop, loop);
|
||||
ADD_GROUP_PROPERTY_TO_MAP(PROP_ANIMATION_FIRST_FRAME, Animation, animation, FirstFrame, firstFrame);
|
||||
|
|
|
@ -36,7 +36,7 @@ ModelEntityItem::ModelEntityItem(const EntityItemID& entityItemID, const EntityI
|
|||
_type = EntityTypes::Model;
|
||||
setProperties(properties);
|
||||
_jointMappingCompleted = false;
|
||||
_lastKnownFrameIndex = -1;
|
||||
_lastKnownCurrentFrame = -1;
|
||||
_color[0] = _color[1] = _color[2] = 0;
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ int ModelEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
|
|||
if (args.bitstreamVersion < VERSION_ENTITIES_ANIMATION_PROPERTIES_GROUP) {
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_URL, QString, setAnimationURL);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FPS, float, setAnimationFPS);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, float, setAnimationFrameIndex);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, float, setAnimationCurrentFrame);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, bool, setAnimationIsPlaying);
|
||||
}
|
||||
|
||||
|
@ -226,17 +226,17 @@ void ModelEntityItem::getAnimationFrame(bool& newFrame,
|
|||
|
||||
int frameCount = frames.size();
|
||||
if (frameCount > 0) {
|
||||
int animationFrameIndex = (int)(glm::floor(getAnimationFrameIndex())) % frameCount;
|
||||
if (animationFrameIndex < 0 || animationFrameIndex > frameCount) {
|
||||
animationFrameIndex = 0;
|
||||
int animationCurrentFrame = (int)(glm::floor(getAnimationCurrentFrame())) % frameCount;
|
||||
if (animationCurrentFrame < 0 || animationCurrentFrame > frameCount) {
|
||||
animationCurrentFrame = 0;
|
||||
}
|
||||
|
||||
if (animationFrameIndex != _lastKnownFrameIndex) {
|
||||
_lastKnownFrameIndex = animationFrameIndex;
|
||||
if (animationCurrentFrame != _lastKnownCurrentFrame) {
|
||||
_lastKnownCurrentFrame = animationCurrentFrame;
|
||||
newFrame = true;
|
||||
|
||||
const QVector<glm::quat>& rotations = frames[animationFrameIndex].rotations;
|
||||
const QVector<glm::vec3>& translations = frames[animationFrameIndex].translations;
|
||||
const QVector<glm::quat>& rotations = frames[animationCurrentFrame].rotations;
|
||||
const QVector<glm::vec3>& translations = frames[animationCurrentFrame].translations;
|
||||
|
||||
_lastKnownFrameDataRotations.resize(_jointMapping.size());
|
||||
_lastKnownFrameDataTranslations.resize(_jointMapping.size());
|
||||
|
@ -327,7 +327,7 @@ void ModelEntityItem::setAnimationURL(const QString& url) {
|
|||
|
||||
void ModelEntityItem::setAnimationSettings(const QString& value) {
|
||||
// the animations setting is a JSON string that may contain various animation settings.
|
||||
// if it includes fps, frameIndex, or running, those values will be parsed out and
|
||||
// if it includes fps, currentFrame, or running, those values will be parsed out and
|
||||
// will over ride the regular animation settings
|
||||
|
||||
QJsonDocument settingsAsJson = QJsonDocument::fromJson(value.toUtf8());
|
||||
|
@ -338,8 +338,9 @@ void ModelEntityItem::setAnimationSettings(const QString& value) {
|
|||
setAnimationFPS(fps);
|
||||
}
|
||||
|
||||
// old settings used frameIndex
|
||||
if (settingsMap.contains("frameIndex")) {
|
||||
float frameIndex = settingsMap["frameIndex"].toFloat();
|
||||
float currentFrame = settingsMap["frameIndex"].toFloat();
|
||||
#ifdef WANT_DEBUG
|
||||
if (isAnimatingSomething()) {
|
||||
qCDebug(entities) << "ModelEntityItem::setAnimationSettings() calling setAnimationFrameIndex()...";
|
||||
|
@ -347,11 +348,11 @@ void ModelEntityItem::setAnimationSettings(const QString& value) {
|
|||
qCDebug(entities) << " animation URL:" << getAnimationURL();
|
||||
qCDebug(entities) << " settings:" << value;
|
||||
qCDebug(entities) << " settingsMap[frameIndex]:" << settingsMap["frameIndex"];
|
||||
qCDebug(entities" frameIndex: %20.5f", frameIndex);
|
||||
qCDebug(entities" currentFrame: %20.5f", currentFrame);
|
||||
}
|
||||
#endif
|
||||
|
||||
setAnimationFrameIndex(frameIndex);
|
||||
setAnimationCurrentFrame(currentFrame);
|
||||
}
|
||||
|
||||
if (settingsMap.contains("running")) {
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
const QString& getAnimationURL() const { return _animationProperties.getURL(); }
|
||||
void setAnimationURL(const QString& url);
|
||||
|
||||
void setAnimationFrameIndex(float value) { _animationLoop.setFrameIndex(value); }
|
||||
void setAnimationCurrentFrame(float value) { _animationLoop.setCurrentFrame(value); }
|
||||
void setAnimationIsPlaying(bool value);
|
||||
void setAnimationFPS(float value);
|
||||
|
||||
|
@ -109,7 +109,7 @@ public:
|
|||
bool jointsMapped() const { return _jointMappingCompleted; }
|
||||
|
||||
bool getAnimationIsPlaying() const { return _animationLoop.getRunning(); }
|
||||
float getAnimationFrameIndex() const { return _animationLoop.getFrameIndex(); }
|
||||
float getAnimationCurrentFrame() const { return _animationLoop.getCurrentFrame(); }
|
||||
float getAnimationFPS() const { return _animationLoop.getFPS(); }
|
||||
|
||||
static const QString DEFAULT_TEXTURES;
|
||||
|
@ -126,7 +126,7 @@ private:
|
|||
protected:
|
||||
QVector<glm::quat> _lastKnownFrameDataRotations;
|
||||
QVector<glm::vec3> _lastKnownFrameDataTranslations;
|
||||
int _lastKnownFrameIndex;
|
||||
int _lastKnownCurrentFrame;
|
||||
|
||||
|
||||
bool isAnimatingSomething() const;
|
||||
|
|
Loading…
Reference in a new issue