Implement some kind of animation.
The animation is still all wrong, but it is there at least.
This commit is contained in:
@@ -16,11 +16,11 @@ static inline float correct_timescale(float original)
|
||||
|
||||
ActivityAnimation::ActivityAnimation(std::size_t count, const float *aPos, const float *bPos, const float xDist) :
|
||||
bufferLength(3 * count),
|
||||
startingPos(new float[bufferLength]),
|
||||
delta(new float[bufferLength]),
|
||||
offset(new float[count])
|
||||
startingPos(bufferLength),
|
||||
delta(bufferLength),
|
||||
offset(bufferLength)
|
||||
{
|
||||
memcpy(startingPos.get(), aPos, sizeof(aPos[0]) * bufferLength);
|
||||
memcpy(startingPos.data(), aPos, sizeof(aPos[0]) * bufferLength);
|
||||
for (auto i : Range(bufferLength)) {
|
||||
delta[i] = bPos[i] - aPos[i];
|
||||
}
|
||||
@@ -38,12 +38,12 @@ void ActivityAnimation::draw(float timeScale) const
|
||||
std::unique_ptr<float[]> vertexBuffer(new float[bufferLength]);
|
||||
|
||||
for (auto i : Range(bufferLength)) {
|
||||
vertexBuffer[i] = startingPos[i] + correct_timescale(offset[i/3] + timeScale) * delta[i];
|
||||
vertexBuffer[i] = startingPos[i] + timeScale * delta[i];
|
||||
}
|
||||
|
||||
glColor3f(1, 1, 1);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, 0, vertexBuffer.get());
|
||||
glDrawArrays(GL_POINTS, bufferLength / 3, bufferLength);
|
||||
glDrawArrays(GL_POINTS, 0, bufferLength / 3);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace fmri
|
||||
{
|
||||
@@ -13,8 +14,8 @@ namespace fmri
|
||||
|
||||
private:
|
||||
std::size_t bufferLength;
|
||||
std::unique_ptr<float[]> startingPos;
|
||||
std::unique_ptr<float[]> delta;
|
||||
std::unique_ptr<float[]> offset;
|
||||
std::vector<float> startingPos;
|
||||
std::vector<float> delta;
|
||||
std::vector<float> offset;
|
||||
};
|
||||
}
|
||||
@@ -82,6 +82,9 @@ static void render()
|
||||
glPushMatrix();
|
||||
renderLayerName(dataSet[i]);
|
||||
rendererData.layerVisualisations[i]->render();
|
||||
if (i < rendererData.animations.size() && rendererData.animations[i]) {
|
||||
rendererData.animations[i]->draw(rendererData.animationStep);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
glTranslatef(-10, 0, 0);
|
||||
|
||||
@@ -39,8 +39,10 @@ computeActivityStrengths(const LayerData &prevState, const LayerInfo &layer)
|
||||
|
||||
const auto shape = layer.parameters()[0]->shape();
|
||||
auto weights = layer.parameters()[0]->cpu_data();
|
||||
const auto numEntries = accumulate(shape.begin(), shape.end(), 1u, multiplies<void>());
|
||||
result.reserve(numEntries);
|
||||
|
||||
for (auto i : Range(accumulate(shape.begin(), shape.end(), 1, multiplies<void>()))) {
|
||||
for (auto i : Range(numEntries)) {
|
||||
result.emplace_back(weights[i] * data[i % shape[0]], make_pair(i % shape[0], i / shape[0]));
|
||||
}
|
||||
|
||||
@@ -80,6 +82,5 @@ fmri::ActivityAnimation *fmri::getActivityAnimation(const fmri::LayerData &prevS
|
||||
memcpy(endingPositions.get() + 3 * i, curPositions.data() + 3 * entries[i].second.second, 3 * sizeof(float));
|
||||
}
|
||||
|
||||
// TODO: actually do something
|
||||
return new ActivityAnimation(entries.size(), startingPositions.get(), endingPositions.get(), 2.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user