2024-08-18 15:12:08 +02:00
|
|
|
#include "particlevisualizer.hpp"
|
|
|
|
|
2024-08-20 01:35:43 +02:00
|
|
|
ParticleVisualizer::ParticleVisualizer(const ParticleMap& map, const std::string& particleId, float radius,
|
2024-08-21 15:56:56 +02:00
|
|
|
GLuint sphereShaderProgram, GLuint widgetShaderProgram, float scale)
|
|
|
|
: _map(map), _particleId(particleId), _sphere({radius, 2, sphereShaderProgram}),
|
|
|
|
_widget(widgetShaderProgram), _scale(scale)
|
2024-08-18 15:12:08 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ParticleVisualizer::render(float time)
|
|
|
|
{
|
2024-08-20 01:35:43 +02:00
|
|
|
// TODO: get mean anomly from particle which has the mass!!
|
2024-08-18 15:12:08 +02:00
|
|
|
const float meanAnomaly = time;
|
2024-08-20 01:35:43 +02:00
|
|
|
glm::vec3 pos = _map.getParticlePosition(_particleId, meanAnomaly);
|
2024-08-21 14:30:21 +02:00
|
|
|
float y = pos.z;
|
|
|
|
pos.z = pos.y;
|
|
|
|
pos.y = y;
|
|
|
|
pos.z *= -1;
|
2024-08-18 15:12:08 +02:00
|
|
|
|
2024-08-21 15:56:56 +02:00
|
|
|
pos /= _scale;
|
|
|
|
|
2024-08-20 01:35:43 +02:00
|
|
|
// TODO: extract widget to its own visualizer since we know it wants an orbit but we
|
|
|
|
// might not have one here
|
|
|
|
//// render widget
|
|
|
|
//const Orbit& orbit = _map.getOrbit(_particleId);
|
|
|
|
//glm::mat4 widgetMatrix = orbit.getLookAlongMatrix(time);
|
|
|
|
//_widget.setModelMatrix(widgetMatrix);
|
|
|
|
//_widget.render(time);
|
2024-08-18 15:12:08 +02:00
|
|
|
|
|
|
|
// render sphere
|
|
|
|
_sphere.setPosition(pos);
|
|
|
|
_sphere.render(time);
|
|
|
|
}
|