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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user