Add Origin Indicator drawable
This commit is contained in:
46
openVulkanoCpp/Scene/Prefabs/OriginIndicatorDrawable.hpp
Normal file
46
openVulkanoCpp/Scene/Prefabs/OriginIndicatorDrawable.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Scene/Drawable.hpp"
|
||||
#include "Scene/Shader/Shader.hpp"
|
||||
#include "Scene/Node.hpp"
|
||||
|
||||
namespace OpenVulkano::Scene
|
||||
{
|
||||
class OriginIndicatorDrawable final : public Drawable
|
||||
{
|
||||
Shader m_shader;
|
||||
|
||||
public:
|
||||
OriginIndicatorDrawable()
|
||||
: Drawable(DrawEncoder::GetDrawEncoder<OriginIndicatorDrawable>(), DrawPhase::MAIN)
|
||||
{
|
||||
m_shader.cullMode = CullMode::NONE;
|
||||
m_shader.topology = Topology::LINE_LIST;
|
||||
m_shader.AddShaderProgram(ShaderProgramType::VERTEX, "Shader/originIndicator");
|
||||
m_shader.AddShaderProgram(ShaderProgramType::FRAGMENT, "Shader/basic");
|
||||
SetShader(&m_shader);
|
||||
}
|
||||
};
|
||||
|
||||
class OriginIndicatorNode final : public Node
|
||||
{
|
||||
OriginIndicatorDrawable drawable;
|
||||
|
||||
public:
|
||||
OriginIndicatorNode(float size = 0.25f) : Node(Math::Utils::scale(Math::Vector3f(size, size, size)))
|
||||
{
|
||||
AddChild(&drawable);
|
||||
}
|
||||
|
||||
void SetSize(float size = 0.25f)
|
||||
{
|
||||
SetMatrix(Math::Utils::scale(Math::Vector3f(size, size, size)));
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user