Program Listing for File AgentVis.h

Return to documentation for file (include/flamegpu/visualiser/AgentVis.h)

#ifndef INCLUDE_FLAMEGPU_VISUALISER_AGENTVIS_H_
#define INCLUDE_FLAMEGPU_VISUALISER_AGENTVIS_H_
#ifdef FLAMEGPU_VISUALISATION

// #include <glm/mat4x4.hpp>
#include <unordered_map>
#include <memory>
#include <string>
#include <map>

// @todo - All vis headers should live in the vis repo.
#include "flamegpu/visualiser/AgentStateVis.h"
#include "flamegpu/visualiser/config/AgentStateConfig.h"
#include "flamegpu/visualiser/config/Stock.h"
#include "flamegpu/visualiser/config/TexBufferConfig.h"

namespace flamegpu {
struct AgentData;
namespace detail {
class CUDAAgent;
}  // namespace detail

namespace visualiser {
struct Palette;
class FLAMEGPU_Visualisation;
class ColorFunction;
struct Color;
class AutoPalette;

struct AgentVisData {
    explicit AgentVisData(detail::CUDAAgent& agent, const std::shared_ptr<AutoPalette>& autopalette = nullptr);
    std::weak_ptr<AutoPalette> auto_palette;
    std::shared_ptr<AutoPalette> owned_auto_palette;
    AgentStateConfig defaultConfig;
    std::unordered_map<std::string, std::shared_ptr<AgentStateVisData>> states;
    detail::CUDAAgent& agent;
    std::shared_ptr<const AgentData> agentData;
    std::map<TexBufferConfig::Function, TexBufferConfig> core_tex_buffers;

    void initBindings(std::unique_ptr<FLAMEGPU_Visualisation>& vis);
    bool requestBufferResizes(std::unique_ptr<FLAMEGPU_Visualisation>& vis, bool force);
    void updateBuffers(std::unique_ptr<FLAMEGPU_Visualisation>& vis);
};

class AgentVis {
    friend class AgentStateVis;

 public:
    explicit AgentVis(std::shared_ptr<AgentVisData> data);
    AgentStateVis State(const std::string &state_name);

    void setXVariable(const std::string &var_name);
    void setYVariable(const std::string &var_name);
    void setZVariable(const std::string &var_name);
    void setXYVariable(const std::string &var_name);
    void setXYZVariable(const std::string &var_name);
    void setForwardXVariable(const std::string& var_name);
    void setForwardYVariable(const std::string& var_name);
    void setForwardZVariable(const std::string& var_name);
    void setForwardXZVariable(const std::string& var_name);
    void setForwardXYZVariable(const std::string& var_name);
    void setUpXVariable(const std::string& var_name);
    void setUpYVariable(const std::string& var_name);
    void setUpZVariable(const std::string& var_name);
    void setUpXYZVariable(const std::string& var_name);
    void setYawVariable(const std::string& var_name);
    void setPitchVariable(const std::string& var_name);
    void setRollVariable(const std::string& var_name);
    void setDirectionYPVariable(const std::string& var_name);
    void setDirectionYPRVariable(const std::string& var_name);
    void setUniformScaleVariable(const std::string& var_name);
    void setScaleXVariable(const std::string& var_name);
    void setScaleYVariable(const std::string& var_name);
    void setScaleZVariable(const std::string& var_name);
    void setScaleXYVariable(const std::string& var_name);
    void setScaleXYZVariable(const std::string& var_name);
    void clearXVariable();
    void clearYVariable();
    void clearZVariable();
    void clearXYVariable();
    void clearXYZVariable();
    void clearForwardXVariable();
    void clearForwardYVariable();
    void clearForwardZVariable();
    void clearForwardXZVariable();
    void clearForwardXYZVariable();
    void clearUpXVariable();
    void clearUpYVariable();
    void clearUpZVariable();
    void clearUpXYZVariable();
    void clearYawVariable();
    void clearPitchVariable();
    void clearRollVariable();
    void clearDirectionYPVariable();
    void clearDirectionYPRVariable();
    void clearUniformScaleVariable();
    void clearScaleXVariable();
    void clearScaleYVariable();
    void clearScaleZVariable();
    void clearScaleXYVariable();
    void clearScaleXYZVariable();
    std::string getXVariable() const;
    std::string getYVariable() const;
    std::string getZVariable() const;
    std::string getXYVariable() const;
    std::string getXYZVariable() const;
    std::string getForwardXVariable() const;
    std::string getForwardYVariable() const;
    std::string getForwardZVariable() const;
    std::string getForwardXZVariable() const;
    std::string getForwardXYZVariable() const;
    std::string getUpXVariable() const;
    std::string getUpYVariable() const;
    std::string getUpZVariable() const;
    std::string getUpXYZVariable() const;
    std::string getYawVariable() const;
    std::string getPitchVariable() const;
    std::string getRollVariable() const;
    std::string getDirectionYPVariable() const;
    std::string getDirectionYPRVariable() const;
    std::string getUniformScaleVariable() const;
    std::string getScaleXVariable() const;
    std::string getScaleYVariable() const;
    std::string getScaleZVariable() const;
    std::string getScaleXYVariable() const;
    std::string getScaleXYZVariable() const;

    void setModel(const std::string &modelPath, const std::string &texturePath = "");
    void setModel(const Stock::Models::Model &model);
    void setKeyFrameModel(const std::string& modelPathA, const std::string& modelPathB, const std::string& lerpVariableName, const std::string& texturePath = "");
    void setKeyFrameModel(const Stock::Models::KeyFrameModel& model, const std::string& lerpVariableName);
    void setModelScale(float xLen, float yLen, float zLen);
    void setModelScale(float maxLen);
    void setAutoPalette(const Palette& ap);
    void setColor(const ColorFunction &cf);
    void clearColor();

 private:
    std::shared_ptr<AgentVisData> data;
};

}  // namespace visualiser
}  // namespace flamegpu

#endif  // FLAMEGPU_VISUALISATION
#endif  // INCLUDE_FLAMEGPU_VISUALISER_AGENTVIS_H_