skein/src/particlevisualizer.cpp

24 lines
665 B
C++
Raw Normal View History

2024-08-18 15:12:08 +02:00
#include "particlevisualizer.hpp"
ParticleVisualizer::ParticleVisualizer(Particle& particle, GLuint sphereShaderProgram, GLuint widgetShaderProgram)
: _particle(particle), _sphere({0.07, 2, sphereShaderProgram}), _widget(widgetShaderProgram)
{
}
void ParticleVisualizer::render(float time)
{
const Orbit& orbit = _particle.getOrbit();
const float meanAnomaly = time;
glm::vec3 pos = orbit.getPosition(meanAnomaly);
// render widget
glm::mat4 widgetMatrix = orbit.getLookAlongMatrix(time);
_widget.setModelMatrix(widgetMatrix);
_widget.render(time);
// render sphere
_sphere.setPosition(pos);
_sphere.render(time);
}