Skip to content

File DebugLine.h

File List > scene > DebugLine.h

Go to the documentation of this file

#pragma once
#include "Context.h"

#include "ID.h"
#include "Transform.h"

#include "VertexArray.h"
#include "buffers/IndexBuffer.h"
#include "shaders/RenderShader.h"

#include "Parameters.h"

class DebugLine : public ObjectID, public Transform3D
{
private:
    std::vector<glm::vec3> dLine_pos_list;

    float dLine_width = 2;
    float dLine_opacity = 1.0f;
public:
    bool using_stipple = false, using_smooth = true, is_multi_lines = false;
    glm::vec3 dLine_color = glm::vec3{ 1.0f,1.0f,1.0f };

    RenderShader dLine_shader;

    glm::vec3 dLine_start, dLine_end;


    DebugLine(const glm::vec3& start, const glm::vec3& end);
    DebugLine(const std::vector<glm::vec3>& vertices);
    DebugLine();

    void SetDebugLineParas(bool stipple, bool smooth, float width, float opacity);

    void PushDebugLine(const glm::vec3& point);
    void PushDebugLine(float x, float y, float z);
    void PushDebugLines(const std::vector<glm::vec3>& points);

    void RenderDdbugLine(const Context& ctx);

    void SetDLineShader();
    void* GetShader()       override { return &dLine_shader; };
    void* GetTransform()    override { return dynamic_cast<Transform*>(GetTransformPtr()); }

};