24 lines
665 B
C++
24 lines
665 B
C++
|
#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);
|
||
|
}
|