Extract animation base class.
Skips some complicated computations, so yay.
This commit is contained in:
@@ -33,7 +33,7 @@ ActivityAnimation::ActivityAnimation(std::size_t count, const float *aPos, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivityAnimation::draw(float timeScale) const
|
void ActivityAnimation::draw(float timeScale)
|
||||||
{
|
{
|
||||||
std::unique_ptr<float[]> vertexBuffer(new float[bufferLength]);
|
std::unique_ptr<float[]> vertexBuffer(new float[bufferLength]);
|
||||||
|
|
||||||
|
|||||||
@@ -3,14 +3,16 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "Animation.hpp"
|
||||||
|
|
||||||
namespace fmri
|
namespace fmri
|
||||||
{
|
{
|
||||||
class ActivityAnimation
|
class ActivityAnimation
|
||||||
|
: public Animation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ActivityAnimation(std::size_t count, const float* aPos, const float* bPos, const float xDist);
|
ActivityAnimation(std::size_t count, const float* aPos, const float* bPos, const float xDist);
|
||||||
void draw(float timeScale) const;
|
void draw(float timeScale) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::size_t bufferLength;
|
std::size_t bufferLength;
|
||||||
|
|||||||
5
src/Animation.cpp
Normal file
5
src/Animation.cpp
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
//
|
||||||
|
// Created by bert on 13/02/18.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "Animation.hpp"
|
||||||
14
src/Animation.hpp
Normal file
14
src/Animation.hpp
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
namespace fmri
|
||||||
|
{
|
||||||
|
class Animation
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~Animation() = default;
|
||||||
|
|
||||||
|
virtual void draw(float step) = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -12,7 +12,6 @@
|
|||||||
#include "camera.hpp"
|
#include "camera.hpp"
|
||||||
#include "LayerVisualisation.hpp"
|
#include "LayerVisualisation.hpp"
|
||||||
#include "Range.hpp"
|
#include "Range.hpp"
|
||||||
#include "ActivityAnimation.hpp"
|
|
||||||
#include "visualisations.hpp"
|
#include "visualisations.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@@ -25,7 +24,7 @@ struct
|
|||||||
vector<vector<LayerData>> data;
|
vector<vector<LayerData>> data;
|
||||||
vector<vector<LayerData>>::iterator currentData;
|
vector<vector<LayerData>>::iterator currentData;
|
||||||
vector<unique_ptr<LayerVisualisation>> layerVisualisations;
|
vector<unique_ptr<LayerVisualisation>> layerVisualisations;
|
||||||
vector<unique_ptr<ActivityAnimation>> animations;
|
vector<unique_ptr<Animation>> animations;
|
||||||
float animationStep = 0;
|
float animationStep = 0;
|
||||||
} rendererData;
|
} rendererData;
|
||||||
|
|
||||||
|
|||||||
@@ -158,9 +158,10 @@ namespace fmri
|
|||||||
std::default_random_engine& rng();
|
std::default_random_engine& rng();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get the current animation offset for a particular animation.
|
||||||
*
|
*
|
||||||
* @tparam Duration Duration type of length
|
* @tparam Duration Duration type of length. Should be a specialisation of std::chrono::duration
|
||||||
* @param length
|
* @param length The length of the animation.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
template<class Duration>
|
template<class Duration>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "MultiImageVisualisation.hpp"
|
#include "MultiImageVisualisation.hpp"
|
||||||
#include "FlatLayerVisualisation.hpp"
|
#include "FlatLayerVisualisation.hpp"
|
||||||
#include "Range.hpp"
|
#include "Range.hpp"
|
||||||
|
#include "ActivityAnimation.hpp"
|
||||||
|
|
||||||
using namespace fmri;
|
using namespace fmri;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@@ -56,9 +57,9 @@ computeActivityStrengths(const LayerData &prevState, const LayerInfo &layer)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
fmri::ActivityAnimation *fmri::getActivityAnimation(const fmri::LayerData &prevState, const fmri::LayerData &curState,
|
Animation * fmri::getActivityAnimation(const fmri::LayerData &prevState, const fmri::LayerData &curState,
|
||||||
const fmri::LayerInfo &layer, const vector<float> &prevPositions,
|
const fmri::LayerInfo &layer, const vector<float> &prevPositions,
|
||||||
const vector<float> &curPositions)
|
const vector<float> &curPositions)
|
||||||
{
|
{
|
||||||
if (layer.type() != LayerInfo::Type::InnerProduct) {
|
if (layer.type() != LayerInfo::Type::InnerProduct) {
|
||||||
// Only supported type at this time
|
// Only supported type at this time
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "LayerVisualisation.hpp"
|
#include "LayerVisualisation.hpp"
|
||||||
#include "LayerData.hpp"
|
#include "LayerData.hpp"
|
||||||
#include "ActivityAnimation.hpp"
|
#include "Animation.hpp"
|
||||||
#include "LayerInfo.hpp"
|
#include "LayerInfo.hpp"
|
||||||
|
|
||||||
namespace fmri {
|
namespace fmri {
|
||||||
@@ -14,7 +14,7 @@ namespace fmri {
|
|||||||
*/
|
*/
|
||||||
LayerVisualisation* getVisualisationForLayer(const LayerData& layer);
|
LayerVisualisation* getVisualisationForLayer(const LayerData& layer);
|
||||||
|
|
||||||
ActivityAnimation *getActivityAnimation(const fmri::LayerData &prevState, const fmri::LayerData &curState,
|
Animation * getActivityAnimation(const fmri::LayerData &prevState, const fmri::LayerData &curState,
|
||||||
const fmri::LayerInfo &layer, const vector<float> &prevPositions,
|
const fmri::LayerInfo &layer, const vector<float> &prevPositions,
|
||||||
const vector<float> &curPositions);
|
const vector<float> &curPositions);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user