skein/src/particlevisualizer.cpp

31 lines
1.0 KiB
C++
Raw Normal View History

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,
GLuint sphereShaderProgram, GLuint widgetShaderProgram)
: _map(map), _particleId(particleId), _sphere({radius, 2, sphereShaderProgram}), _widget(widgetShaderProgram)
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-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);
}