Visualizer/src/Topology.hpp

39 lines
1 KiB
C++
Raw Normal View History

2021-12-25 02:15:50 +00:00
#pragma once
#include <lol/lol.hpp>
2021-12-26 06:00:15 +00:00
#include "Colormaps.hpp"
2021-12-25 02:15:50 +00:00
inline float Map(const glm::vec2& from, const glm::vec2& to, float val)
{
return (val - from.x) * (to.y - to.x) / (from.y - from.x) + to.x;
}
class Topology : public lol::Drawable
{
public:
Topology(const glm::vec2& size, const glm::uvec2& subdivision);
~Topology();
2021-12-25 14:01:15 +00:00
void PreRender(const lol::CameraBase& camera) override;
2021-12-25 02:15:50 +00:00
2021-12-26 02:58:14 +00:00
inline void SetHeightMapping(bool enable) { heightFactor = enable ? 2.0f : 0.0f; }
2021-12-26 05:14:13 +00:00
inline void SetColorMapping(bool enable) { renderColor = enable; }
inline void Scroll(bool enable) { scroll = enable; }
2021-12-26 02:58:14 +00:00
2021-12-25 02:15:50 +00:00
inline float* GetTopology() const { return (float*)image.GetPixels(); };
inline const glm::uvec2& GetSize() const { return image.GetDimensions(); };
2021-12-26 06:00:15 +00:00
void SetColormap(const Colormap& cm);
2021-12-25 02:15:50 +00:00
void MakeTexture();
private:
lol::Image image;
2021-12-26 05:14:13 +00:00
lol::Texture2D* texture;
std::shared_ptr<lol::Texture1D> colormap;
2021-12-25 14:01:15 +00:00
float offset = 0.0f;
2021-12-26 02:58:14 +00:00
float heightFactor = 2.0f;
2021-12-26 05:14:13 +00:00
bool renderColor = true;
bool scroll = false;
glm::vec2 range;
2021-12-25 02:15:50 +00:00
};