Compare commits
4 Commits
473ff0840d
...
236da3059f
| Author | SHA256 | Date | |
|---|---|---|---|
| 236da3059f | |||
| bf4189bba0 | |||
| 11e8d343af | |||
| 37958449a2 |
@@ -5,7 +5,7 @@ namespace TSE
|
|||||||
{
|
{
|
||||||
#define TSE_VERSION_MAJOR 0
|
#define TSE_VERSION_MAJOR 0
|
||||||
#define TSE_VERSION_MINOR 1
|
#define TSE_VERSION_MINOR 1
|
||||||
#define TSE_VERSION_BUILD 2
|
#define TSE_VERSION_BUILD 3
|
||||||
|
|
||||||
#define TSE_VERSION_STRING std::to_string(TSE_VERSION_MAJOR) + "." + std::to_string(TSE_VERSION_MINOR) + "." + std::to_string(TSE_VERSION_BUILD)
|
#define TSE_VERSION_STRING std::to_string(TSE_VERSION_MAJOR) + "." + std::to_string(TSE_VERSION_MINOR) + "." + std::to_string(TSE_VERSION_BUILD)
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "interfaces/IRenderer.hpp"
|
#include "interfaces/IRenderer.hpp"
|
||||||
|
|
||||||
TSE::Camera* TSE::Camera::mainCamera = nullptr;
|
TSE::Camera* TSE::Camera::mainCamera = nullptr;
|
||||||
|
TSE::ICameraHelper* TSE::Camera::helper = nullptr;
|
||||||
|
|
||||||
float TSE::Camera::GetRenderScale() const
|
float TSE::Camera::GetRenderScale() const
|
||||||
{
|
{
|
||||||
@@ -182,6 +183,7 @@ void TSE::Camera::PreDraw(IShader *shader)
|
|||||||
viewMatrix = BuildView_Zplus_RH(worlmatrix);
|
viewMatrix = BuildView_Zplus_RH(worlmatrix);
|
||||||
|
|
||||||
shader->SetUniform("camMatrix", &viewMatrix);
|
shader->SetUniform("camMatrix", &viewMatrix);
|
||||||
|
helper->OnRenderTargetChanged(lastRtSize.x, lastRtSize.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TSE::Camera::PostDraw()
|
void TSE::Camera::PostDraw()
|
||||||
|
|||||||
@@ -17,6 +17,12 @@ namespace TSE
|
|||||||
Perspective = 2,
|
Perspective = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ICameraHelper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline virtual void OnRenderTargetChanged(float width, float height) {};
|
||||||
|
};
|
||||||
|
|
||||||
class Camera : public IResizeNotifiable, public BehaviourScript
|
class Camera : public IResizeNotifiable, public BehaviourScript
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -35,6 +41,7 @@ namespace TSE
|
|||||||
Vector2 lastRtSize = {0, 0};
|
Vector2 lastRtSize = {0, 0};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static ICameraHelper* helper;
|
||||||
static Camera* mainCamera;
|
static Camera* mainCamera;
|
||||||
|
|
||||||
// Getter
|
// Getter
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ namespace TSE
|
|||||||
objectEntries[id] = this;
|
objectEntries[id] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transformable::Transformable(uuids::uuid id)
|
Transformable::Transformable(uuids::uuid _id)
|
||||||
: id(id), position(0, 0, 0), scale(1, 1, 1), rotation(), name("")
|
: id(_id), position(0, 0, 0), scale(1, 1, 1), rotation(), name("")
|
||||||
{
|
{
|
||||||
objectEntries[id] = this;
|
objectEntries[_id] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transformable::Transformable(const string &name)
|
Transformable::Transformable(const string &name)
|
||||||
@@ -28,10 +28,14 @@ namespace TSE
|
|||||||
objectEntries[id] = this;
|
objectEntries[id] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transformable::Transformable(const string &name, uuids::uuid id)
|
Transformable::Transformable(const string &name, uuids::uuid _id)
|
||||||
: id(id), position(0, 0, 0), scale(1, 1, 1), rotation(), name(name)
|
: id(_id), position(0, 0, 0), scale(1, 1, 1), rotation(), name(name)
|
||||||
|
{
|
||||||
|
objectEntries[_id] = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Transformable::~Transformable()
|
||||||
{
|
{
|
||||||
objectEntries[id] = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Transformable::forward() const
|
Vector3 Transformable::forward() const
|
||||||
@@ -366,14 +370,20 @@ namespace TSE
|
|||||||
{
|
{
|
||||||
//deleting children
|
//deleting children
|
||||||
if(!onlyThis)
|
if(!onlyThis)
|
||||||
|
{
|
||||||
for(auto child : t->children)
|
for(auto child : t->children)
|
||||||
{
|
{
|
||||||
HardDelete(child);
|
HardDelete(child, onlyThis);
|
||||||
}
|
}
|
||||||
|
t->children.clear();
|
||||||
|
}
|
||||||
|
|
||||||
//deleting atteched scripts
|
//deleting atteched scripts
|
||||||
for (auto& [_, script] : t->components)
|
for (auto& [_, script] : t->components)
|
||||||
|
{
|
||||||
delete script;
|
delete script;
|
||||||
|
}
|
||||||
|
t->components.clear();
|
||||||
|
|
||||||
//deleting self
|
//deleting self
|
||||||
Delete(t);
|
Delete(t);
|
||||||
@@ -442,6 +452,19 @@ namespace TSE
|
|||||||
return objectEntries.size();
|
return objectEntries.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Transformable *Transformable::GetTansformableAt(int i)
|
||||||
|
{
|
||||||
|
int x = 0;
|
||||||
|
for(auto obj : objectEntries)
|
||||||
|
{
|
||||||
|
if(i == x++)
|
||||||
|
{
|
||||||
|
return obj.second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
Transformable *Transformable::Find(string name)
|
Transformable *Transformable::Find(string name)
|
||||||
{
|
{
|
||||||
for(auto obj : objectEntries)
|
for(auto obj : objectEntries)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace TSE
|
|||||||
Transformable(uuids::uuid id);
|
Transformable(uuids::uuid id);
|
||||||
Transformable(const string& name);
|
Transformable(const string& name);
|
||||||
Transformable(const string& name, uuids::uuid id);
|
Transformable(const string& name, uuids::uuid id);
|
||||||
~Transformable() = default;
|
~Transformable();
|
||||||
|
|
||||||
Vector3 forward() const;
|
Vector3 forward() const;
|
||||||
Vector3 right() const;
|
Vector3 right() const;
|
||||||
@@ -100,6 +100,7 @@ namespace TSE
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
static int GetTansformableCount();
|
static int GetTansformableCount();
|
||||||
|
static Transformable* GetTansformableAt(int i);
|
||||||
static Transformable* Find(string name);
|
static Transformable* Find(string name);
|
||||||
static Transformable* Find(uuids::uuid id);
|
static Transformable* Find(uuids::uuid id);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ void TSE::ICursorHandler::Enable()
|
|||||||
if(!enabled())
|
if(!enabled())
|
||||||
{
|
{
|
||||||
IInputManager::instance()->RegisterCursorHandler(this);
|
IInputManager::instance()->RegisterCursorHandler(this);
|
||||||
|
Enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,6 +26,7 @@ void TSE::ICursorHandler::Disable()
|
|||||||
if(enabled())
|
if(enabled())
|
||||||
{
|
{
|
||||||
IInputManager::instance()->UnregisterCursorHandler(this);
|
IInputManager::instance()->UnregisterCursorHandler(this);
|
||||||
|
Enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ void TSE::IKeyInputHandler::Enable()
|
|||||||
if(!enabled())
|
if(!enabled())
|
||||||
{
|
{
|
||||||
IInputManager::instance()->RegisterKeyHandler(this);
|
IInputManager::instance()->RegisterKeyHandler(this);
|
||||||
|
Enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,6 +26,7 @@ void TSE::IKeyInputHandler::Disable()
|
|||||||
if(enabled())
|
if(enabled())
|
||||||
{
|
{
|
||||||
IInputManager::instance()->UnregisterKeyHandler(this);
|
IInputManager::instance()->UnregisterKeyHandler(this);
|
||||||
|
Enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ void TSE::IWindow::BaseUpdate() const
|
|||||||
Time::Update();
|
Time::Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TSE::Vector2 TSE::IWindow::GetSize() const
|
||||||
|
{
|
||||||
|
return Vector2({width, height});
|
||||||
|
}
|
||||||
|
|
||||||
TSE::IWindow::~IWindow()
|
TSE::IWindow::~IWindow()
|
||||||
{
|
{
|
||||||
AudioEngine::Destroy();
|
AudioEngine::Destroy();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "IRenderTarget.hpp"
|
#include "IRenderTarget.hpp"
|
||||||
#include "Types.hpp"
|
#include "Types.hpp"
|
||||||
|
#include "Vector2.hpp"
|
||||||
|
|
||||||
namespace TSE
|
namespace TSE
|
||||||
{
|
{
|
||||||
@@ -20,6 +21,7 @@ namespace TSE
|
|||||||
|
|
||||||
bool BaseInit() const;
|
bool BaseInit() const;
|
||||||
void BaseUpdate() const;
|
void BaseUpdate() const;
|
||||||
|
Vector2 GetSize() const;
|
||||||
~IWindow();
|
~IWindow();
|
||||||
};
|
};
|
||||||
} // namespace TSE
|
} // namespace TSE
|
||||||
|
|||||||
172
TSE_Editor/src/BehaviourScripts/basicEditorCamera.cpp
Normal file
172
TSE_Editor/src/BehaviourScripts/basicEditorCamera.cpp
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
#include "basicEditorCamera.hpp"
|
||||||
|
#include "elements/Transformable.hpp"
|
||||||
|
#include "utils/Time.hpp"
|
||||||
|
#include "BehaviourScripts/Camera.hpp"
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
void TSE::EDITOR::basicEditorCamera::OnUpdate()
|
||||||
|
{
|
||||||
|
auto euler = baseObject->GetEuler();
|
||||||
|
auto finalrot = rotDelta * rotationMultiplier * Time::deltaTime();
|
||||||
|
rotDelta = Vector2::zero;
|
||||||
|
if(mouseInputEnabled)
|
||||||
|
{
|
||||||
|
euler.y += finalrot.x;
|
||||||
|
euler.x += finalrot.y;
|
||||||
|
}
|
||||||
|
baseObject->SetEuler(euler);
|
||||||
|
|
||||||
|
Vector3 move;
|
||||||
|
|
||||||
|
if(keyInputEnabled && SceneView::IsHovered)
|
||||||
|
delta = delta + keydelta * keyMultiplier;
|
||||||
|
|
||||||
|
move = baseObject->right() * delta.x;
|
||||||
|
move = move + baseObject->up() * delta.y;
|
||||||
|
move = move + baseObject->forward() * delta.z;
|
||||||
|
|
||||||
|
delta = Vector3::zero;
|
||||||
|
|
||||||
|
|
||||||
|
move = move * movementMultiplier * Time::deltaTime();
|
||||||
|
|
||||||
|
baseObject->position = baseObject->position + move;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TSE::EDITOR::basicEditorCamera::Start()
|
||||||
|
{
|
||||||
|
ICursorHandler::Enable();
|
||||||
|
IKeyInputHandler::Enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TSE::EDITOR::basicEditorCamera::OnKeyDown(const Key &key, const Modifier &mods)
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case Key::LeftShift:
|
||||||
|
isShiftPressed = true;
|
||||||
|
break;
|
||||||
|
case Key::W:
|
||||||
|
keydelta = keydelta + Vector3::forward * keyMultiplier;
|
||||||
|
break;
|
||||||
|
case Key::A:
|
||||||
|
keydelta = keydelta + Vector3::left * keyMultiplier;
|
||||||
|
break;
|
||||||
|
case Key::S:
|
||||||
|
keydelta = keydelta + Vector3::back * keyMultiplier;
|
||||||
|
break;
|
||||||
|
case Key::D:
|
||||||
|
keydelta = keydelta + Vector3::right * keyMultiplier;
|
||||||
|
break;
|
||||||
|
case Key::E:
|
||||||
|
keydelta = keydelta + Vector3::up * keyMultiplier;
|
||||||
|
break;
|
||||||
|
case Key::Q:
|
||||||
|
keydelta = keydelta + Vector3::down * keyMultiplier;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TSE::EDITOR::basicEditorCamera::OnKeyUp(const Key &key, const Modifier &mods)
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case Key::LeftShift:
|
||||||
|
isShiftPressed = false;
|
||||||
|
break;
|
||||||
|
case Key::W:
|
||||||
|
keydelta = keydelta - Vector3::forward * keyMultiplier;
|
||||||
|
break;
|
||||||
|
case Key::A:
|
||||||
|
keydelta = keydelta - Vector3::left * keyMultiplier;
|
||||||
|
break;
|
||||||
|
case Key::S:
|
||||||
|
keydelta = keydelta - Vector3::back * keyMultiplier;
|
||||||
|
break;
|
||||||
|
case Key::D:
|
||||||
|
keydelta = keydelta - Vector3::right * keyMultiplier;
|
||||||
|
break;
|
||||||
|
case Key::E:
|
||||||
|
keydelta = keydelta - Vector3::up * keyMultiplier;
|
||||||
|
break;
|
||||||
|
case Key::Q:
|
||||||
|
keydelta = keydelta - Vector3::down * keyMultiplier;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TSE::EDITOR::basicEditorCamera::OnMouseButtonDown(const MouseBtn &btn, const Modifier &mods)
|
||||||
|
{
|
||||||
|
if(!mouseInputEnabled) return;
|
||||||
|
switch (btn)
|
||||||
|
{
|
||||||
|
case MouseBtn::RightMouse:
|
||||||
|
holdingRightClick = true;
|
||||||
|
break;
|
||||||
|
case MouseBtn::LeftMouse:
|
||||||
|
holdingLeftClick = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TSE::EDITOR::basicEditorCamera::OnMouseButtonUp(const MouseBtn &btn, const Modifier &mods)
|
||||||
|
{
|
||||||
|
if(!mouseInputEnabled) return;
|
||||||
|
switch (btn)
|
||||||
|
{
|
||||||
|
case MouseBtn::RightMouse:
|
||||||
|
holdingRightClick = false;
|
||||||
|
break;
|
||||||
|
case MouseBtn::LeftMouse:
|
||||||
|
holdingLeftClick = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TSE::EDITOR::basicEditorCamera::OnMousePosition(const Vector2 &pos)
|
||||||
|
{
|
||||||
|
if(!mouseInputEnabled || !SceneView::IsHovered) return;
|
||||||
|
if(isShiftPressed && holdingLeftClick)
|
||||||
|
{
|
||||||
|
auto tmp = pos - lastMousepos;
|
||||||
|
tmp.x *= -1;
|
||||||
|
delta = delta + tmp;
|
||||||
|
}
|
||||||
|
else if(holdingRightClick)
|
||||||
|
{
|
||||||
|
rotDelta = rotDelta + (pos - lastMousepos);
|
||||||
|
}
|
||||||
|
lastMousepos = pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TSE::EDITOR::basicEditorCamera::OnMouseScroll(const Vector2 &mdelta)
|
||||||
|
{
|
||||||
|
if(!mouseInputEnabled || !SceneView::IsHovered) return;
|
||||||
|
Camera* editorCam = (Camera*)Transformable::Find(".EditorCamera")->GetBehaviourScript(CAMERA);
|
||||||
|
float scale = editorCam->GetRenderScale();
|
||||||
|
|
||||||
|
scale += mdelta.y * zoomMultiplier;
|
||||||
|
scale = std::clamp(scale, zoomMin, zoomMax);
|
||||||
|
|
||||||
|
editorCam->SetRenderScale(scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TSE::EDITOR::basicEditorCamera::CustomDraw(const bool &debug)
|
||||||
|
{
|
||||||
|
ImGui::DragFloat("Rotation Speed", &rotationMultiplier, 0.1f);
|
||||||
|
ImGui::DragFloat("Movement Speed", &movementMultiplier, 0.1f);
|
||||||
|
ImGui::DragFloat("Zoom Speed", &zoomMultiplier, 0.1f);
|
||||||
|
ImGui::DragFloat("key Speed", &keyMultiplier, 0.1f);
|
||||||
|
|
||||||
|
ImGui::Checkbox("Keybord Input", &keyInputEnabled);
|
||||||
|
ImGui::Checkbox("Mouse Input", &mouseInputEnabled);
|
||||||
|
}
|
||||||
60
TSE_Editor/src/BehaviourScripts/basicEditorCamera.hpp
Normal file
60
TSE_Editor/src/BehaviourScripts/basicEditorCamera.hpp
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define BASIC_EDITOR_CAMERA typeid(basicEditorCamera).name()
|
||||||
|
|
||||||
|
#include "elements/BehaviourScript.hpp"
|
||||||
|
#include "interfaces/ICursorHandler.hpp"
|
||||||
|
#include "interfaces/IKeyInputHandler.hpp"
|
||||||
|
#include "Vector2.hpp"
|
||||||
|
#include "Vector3.hpp"
|
||||||
|
#include "imgui/imgui.h"
|
||||||
|
#include "UI/windows/SceneView.hpp"
|
||||||
|
|
||||||
|
namespace TSE::EDITOR
|
||||||
|
{
|
||||||
|
class basicEditorCamera : public BehaviourScript, public ICursorHandler, public IKeyInputHandler
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
bool keyInputEnabled = true;
|
||||||
|
bool mouseInputEnabled = true;
|
||||||
|
|
||||||
|
bool isShiftPressed = false;
|
||||||
|
bool holdingRightClick = false;
|
||||||
|
bool holdingLeftClick = false;
|
||||||
|
Vector3 delta = Vector3::zero;
|
||||||
|
Vector3 keydelta = Vector3::zero;
|
||||||
|
Vector2 rotDelta = Vector2::zero;
|
||||||
|
Vector2 lastMousepos;
|
||||||
|
float keyMultiplier = 0.5f;
|
||||||
|
|
||||||
|
float rotationMultiplier = 150;
|
||||||
|
float movementMultiplier = 64;
|
||||||
|
float zoomMultiplier = 2;
|
||||||
|
|
||||||
|
const float zoomMin = 6;
|
||||||
|
const float zoomMax = 500;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void OnUpdate() override;
|
||||||
|
void Start() override;
|
||||||
|
inline const char* GetName() override
|
||||||
|
{
|
||||||
|
return "basicEditorCamera";
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnKeyDown(const Key& key, const Modifier& mods) override;
|
||||||
|
|
||||||
|
void OnKeyUp(const Key& key, const Modifier& mods) override;
|
||||||
|
|
||||||
|
void OnMouseButtonDown(const MouseBtn& btn, const Modifier& mods) override;
|
||||||
|
|
||||||
|
void OnMouseButtonUp(const MouseBtn& btn, const Modifier& mods) override;
|
||||||
|
|
||||||
|
void OnMousePosition(const Vector2& pos) override;
|
||||||
|
|
||||||
|
void OnMouseScroll(const Vector2& delta) override;
|
||||||
|
|
||||||
|
void CustomDraw(const bool& debug) override;
|
||||||
|
|
||||||
|
};
|
||||||
|
} // namespace TSE::EDITOR
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "BehaviourScriptRegistry.hpp"
|
#include "BehaviourScriptRegistry.hpp"
|
||||||
#include "BehaviourScripts/AudioListener.hpp"
|
#include "BehaviourScripts/AudioListener.hpp"
|
||||||
#include "BehaviourScripts/AudioSource.hpp"
|
#include "BehaviourScripts/AudioSource.hpp"
|
||||||
|
#include "BehaviourScripts/basicEditorCamera.hpp"
|
||||||
|
|
||||||
TSE::EDITOR::EditorSubsystem::EditorSubsystem() : sv(nullptr), editorLayer("")
|
TSE::EDITOR::EditorSubsystem::EditorSubsystem() : sv(nullptr), editorLayer("")
|
||||||
{
|
{
|
||||||
@@ -34,8 +35,8 @@ TSE::EDITOR::EditorSubsystem::EditorSubsystem() : sv(nullptr), editorLayer("")
|
|||||||
editorCam->SetRenderTarget(rt);
|
editorCam->SetRenderTarget(rt);
|
||||||
editorCamera->AddBehaviourScript(editorCam);
|
editorCamera->AddBehaviourScript(editorCam);
|
||||||
|
|
||||||
// basicCameraControls controls = basicCameraControls();
|
basicEditorCamera* controls = new basicEditorCamera();
|
||||||
// editorCamera->AddBehaviourScript(&controls);
|
editorCamera->AddBehaviourScript(controls);
|
||||||
|
|
||||||
editorLayer = Layer(".editor");
|
editorLayer = Layer(".editor");
|
||||||
editorLayer.AddTransformable(editorCamera);
|
editorLayer.AddTransformable(editorCamera);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ void TSE::EDITOR::CameraView::Define()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImGuiWindowFlags flags2 = ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar;
|
ImGuiWindowFlags flags2 = ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar;
|
||||||
if(ImGui::BeginChild("##SceneChild", {0,0}, ImGuiChildFlags_None, flags2))
|
if(ImGui::BeginChild("##CameraChild", {0,0}, ImGuiChildFlags_None, flags2))
|
||||||
{
|
{
|
||||||
ImGui::Image(fb->GetTextureId(), {fb->Width(), fb->Height()},{0,1}, {1,0});
|
ImGui::Image(fb->GetTextureId(), {fb->Width(), fb->Height()},{0,1}, {1,0});
|
||||||
auto vec2 = ImGui::GetWindowSize();
|
auto vec2 = ImGui::GetWindowSize();
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ void TSE::EDITOR::HirearchieView::SetScene(Scene *s)
|
|||||||
currentScene = s;
|
currentScene = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool selectedFound = false;
|
||||||
|
|
||||||
void TSE::EDITOR::HirearchieView::Define()
|
void TSE::EDITOR::HirearchieView::Define()
|
||||||
{
|
{
|
||||||
if(currentScene == nullptr) return;
|
if(currentScene == nullptr) return;
|
||||||
@@ -32,6 +34,7 @@ void TSE::EDITOR::HirearchieView::Define()
|
|||||||
if(collapseOpen)
|
if(collapseOpen)
|
||||||
{
|
{
|
||||||
int layerCount = currentScene->GetLayerCount();
|
int layerCount = currentScene->GetLayerCount();
|
||||||
|
selectedFound = false;
|
||||||
for (int i = 0; i < layerCount; i++)
|
for (int i = 0; i < layerCount; i++)
|
||||||
{
|
{
|
||||||
auto layer = currentScene->GetLayerAt(i);
|
auto layer = currentScene->GetLayerAt(i);
|
||||||
@@ -39,6 +42,11 @@ void TSE::EDITOR::HirearchieView::Define()
|
|||||||
DisplayLayer(layer);
|
DisplayLayer(layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!selectedFound && PropertiesView::GetCurrentInspectableType() == InspectableType::Transformable)
|
||||||
|
{
|
||||||
|
PropertiesView::ForceClearInspectorElement();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(activatePopUpNamingLayer)
|
if(activatePopUpNamingLayer)
|
||||||
@@ -123,6 +131,7 @@ void TSE::EDITOR::HirearchieView::MenuBar()
|
|||||||
ImGui::EndMenuBar();
|
ImGui::EndMenuBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TSE::EDITOR::HirearchieView::DisplayLayer(Layer *l)
|
void TSE::EDITOR::HirearchieView::DisplayLayer(Layer *l)
|
||||||
{
|
{
|
||||||
ImGui::Indent(20.0f);
|
ImGui::Indent(20.0f);
|
||||||
@@ -198,8 +207,10 @@ void TSE::EDITOR::HirearchieView::DisplayObj(Transformable *t, Layer *l)
|
|||||||
if(selected == t->id)
|
if(selected == t->id)
|
||||||
{
|
{
|
||||||
flags |= ImGuiTreeNodeFlags_Selected;
|
flags |= ImGuiTreeNodeFlags_Selected;
|
||||||
|
selectedFound = true;
|
||||||
}
|
}
|
||||||
bool open = ImGui::TreeNodeEx((t->GetName() + "##" + to_string(t->id)).c_str(), flags);
|
string name = t->GetName() + "##" + to_string(t->id);
|
||||||
|
bool open = ImGui::TreeNodeEx((name).c_str(), flags);
|
||||||
if(ImGui::BeginPopupContextItem())
|
if(ImGui::BeginPopupContextItem())
|
||||||
{
|
{
|
||||||
bool disabled = false;
|
bool disabled = false;
|
||||||
@@ -281,6 +292,7 @@ void TSE::EDITOR::HirearchieView::DisplayObj(Transformable *t, Layer *l)
|
|||||||
{
|
{
|
||||||
selected = t->id;
|
selected = t->id;
|
||||||
PropertiesView::SetInspectorElement(InspectableType::Transformable, t);
|
PropertiesView::SetInspectorElement(InspectableType::Transformable, t);
|
||||||
|
selectedFound = true;
|
||||||
}
|
}
|
||||||
if(open)
|
if(open)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,6 +30,11 @@ void TSE::EDITOR::PropertiesView::MenuBar()
|
|||||||
ImGui::EndMenuBar();
|
ImGui::EndMenuBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TSE::EDITOR::InspectableType TSE::EDITOR::PropertiesView::GetCurrentInspectableType()
|
||||||
|
{
|
||||||
|
return currentlyInspecting.type;
|
||||||
|
}
|
||||||
|
|
||||||
void TSE::EDITOR::PropertiesView::SetInspectorElement(InspectableType type, void *element)
|
void TSE::EDITOR::PropertiesView::SetInspectorElement(InspectableType type, void *element)
|
||||||
{
|
{
|
||||||
if(!locked)
|
if(!locked)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ namespace TSE::EDITOR
|
|||||||
|
|
||||||
void Define() override;
|
void Define() override;
|
||||||
void MenuBar();
|
void MenuBar();
|
||||||
|
static InspectableType GetCurrentInspectableType();
|
||||||
static void SetInspectorElement(InspectableType type, void* element);
|
static void SetInspectorElement(InspectableType type, void* element);
|
||||||
static void ClearInspectorElement();
|
static void ClearInspectorElement();
|
||||||
static void ForceClearInspectorElement();
|
static void ForceClearInspectorElement();
|
||||||
|
|||||||
@@ -16,6 +16,14 @@ void TSE::EDITOR::SceneView::Define()
|
|||||||
{
|
{
|
||||||
fb->SetSize({vec2.x, vec2.y});
|
fb->SetSize({vec2.x, vec2.y});
|
||||||
}
|
}
|
||||||
|
if(ImGui::IsWindowFocused())
|
||||||
|
{
|
||||||
|
IsHovered = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IsHovered = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ namespace TSE::EDITOR
|
|||||||
private:
|
private:
|
||||||
TSE::IRenderTexture* fb;
|
TSE::IRenderTexture* fb;
|
||||||
public:
|
public:
|
||||||
|
inline static bool IsHovered = false;
|
||||||
SceneView(TSE::IRenderTexture* frameBuffer);
|
SceneView(TSE::IRenderTexture* frameBuffer);
|
||||||
void Define() override;
|
void Define() override;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,19 +17,22 @@ void TSE::GLFW::InputGlfw::KeyCallback(GLFWwindow *window, int key, int scancode
|
|||||||
case 1: //down
|
case 1: //down
|
||||||
for(auto handler : ((InputGlfw*)instance())->keyHandler)
|
for(auto handler : ((InputGlfw*)instance())->keyHandler)
|
||||||
{
|
{
|
||||||
handler->OnKeyDown((Key)key, (Modifier)mods);
|
if(handler->enabled())
|
||||||
|
handler->OnKeyDown((Key)key, (Modifier)mods);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0: //up
|
case 0: //up
|
||||||
for(auto handler : ((InputGlfw*)instance())->keyHandler)
|
for(auto handler : ((InputGlfw*)instance())->keyHandler)
|
||||||
{
|
{
|
||||||
handler->OnKeyUp((Key)key, (Modifier)mods);
|
if(handler->enabled())
|
||||||
|
handler->OnKeyUp((Key)key, (Modifier)mods);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2: //hold
|
case 2: //hold
|
||||||
for(auto handler : ((InputGlfw*)instance())->keyHandler)
|
for(auto handler : ((InputGlfw*)instance())->keyHandler)
|
||||||
{
|
{
|
||||||
handler->OnKeyHold((Key)key, (Modifier)mods);
|
if(handler->enabled())
|
||||||
|
handler->OnKeyHold((Key)key, (Modifier)mods);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -42,19 +45,22 @@ void TSE::GLFW::InputGlfw::MouseButtonCallback(GLFWwindow *window, int button, i
|
|||||||
case 1: //down
|
case 1: //down
|
||||||
for(auto handler : ((InputGlfw*)instance())->cursorHandler)
|
for(auto handler : ((InputGlfw*)instance())->cursorHandler)
|
||||||
{
|
{
|
||||||
handler->OnMouseButtonDown((MouseBtn)button, (Modifier)mods);
|
if(handler->enabled())
|
||||||
|
handler->OnMouseButtonDown((MouseBtn)button, (Modifier)mods);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0: //up
|
case 0: //up
|
||||||
for(auto handler : ((InputGlfw*)instance())->cursorHandler)
|
for(auto handler : ((InputGlfw*)instance())->cursorHandler)
|
||||||
{
|
{
|
||||||
handler->OnMouseButtonUp((MouseBtn)button, (Modifier)mods);
|
if(handler->enabled())
|
||||||
|
handler->OnMouseButtonUp((MouseBtn)button, (Modifier)mods);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2: //hold
|
case 2: //hold
|
||||||
for(auto handler : ((InputGlfw*)instance())->cursorHandler)
|
for(auto handler : ((InputGlfw*)instance())->cursorHandler)
|
||||||
{
|
{
|
||||||
handler->OnMouseButtonHold((MouseBtn)button, (Modifier)mods);
|
if(handler->enabled())
|
||||||
|
handler->OnMouseButtonHold((MouseBtn)button, (Modifier)mods);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -64,7 +70,8 @@ void TSE::GLFW::InputGlfw::CursorPosCallback(GLFWwindow *window, double xpos, do
|
|||||||
{
|
{
|
||||||
for(auto handler : ((InputGlfw*)instance())->cursorHandler)
|
for(auto handler : ((InputGlfw*)instance())->cursorHandler)
|
||||||
{
|
{
|
||||||
handler->OnMousePosition(Vector2(xpos, ypos));
|
if(handler->enabled())
|
||||||
|
handler->OnMousePosition(Vector2(xpos, ypos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +79,8 @@ void TSE::GLFW::InputGlfw::ScrollCallback(GLFWwindow *window, double xoffset, do
|
|||||||
{
|
{
|
||||||
for(auto handler : ((InputGlfw*)instance())->cursorHandler)
|
for(auto handler : ((InputGlfw*)instance())->cursorHandler)
|
||||||
{
|
{
|
||||||
handler->OnMouseScroll(Vector2(xoffset, yoffset));
|
if(handler->enabled())
|
||||||
|
handler->OnMouseScroll(Vector2(xoffset, yoffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,6 +114,7 @@ void TSE::GLFW::InputGlfw::CharCallback(GLFWwindow *window, unsigned int codepoi
|
|||||||
|
|
||||||
for(auto handler : ((InputGlfw*)instance())->keyHandler)
|
for(auto handler : ((InputGlfw*)instance())->keyHandler)
|
||||||
{
|
{
|
||||||
handler->OnChar(msg);
|
if(handler->enabled())
|
||||||
|
handler->OnChar(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
TSE_GlfwOpenGlImpl/src/CameraHelperOpenGL.hpp
Normal file
17
TSE_GlfwOpenGlImpl/src/CameraHelperOpenGL.hpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "BehaviourScripts/Camera.hpp"
|
||||||
|
#include "GL/gl3w.h"
|
||||||
|
#include "GL/gl.h"
|
||||||
|
|
||||||
|
namespace TSE::GLFW
|
||||||
|
{
|
||||||
|
class CameraHelperOpenGL : public ICameraHelper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline void OnRenderTargetChanged(float width, float height) override
|
||||||
|
{
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} // namespace TSE::GLFW
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "interfaces/IRenderer.hpp"
|
#include "interfaces/IRenderer.hpp"
|
||||||
#include "BehaviourScripts/Camera.hpp"
|
#include "BehaviourScripts/Camera.hpp"
|
||||||
#include "RenderTextureCreatorOpenGL.hpp"
|
#include "RenderTextureCreatorOpenGL.hpp"
|
||||||
|
#include "CameraHelperOpenGL.hpp"
|
||||||
|
|
||||||
TSE::GLFW::OpenGLRenderingBackend::OpenGLRenderingBackend(Color _backgroundColor, bool _vsync)
|
TSE::GLFW::OpenGLRenderingBackend::OpenGLRenderingBackend(Color _backgroundColor, bool _vsync)
|
||||||
: OpenGLRenderingBackend(_backgroundColor, _vsync, 0, false){ }
|
: OpenGLRenderingBackend(_backgroundColor, _vsync, 0, false){ }
|
||||||
@@ -39,6 +40,7 @@ void TSE::GLFW::OpenGLRenderingBackend::InitPreWindow()
|
|||||||
{
|
{
|
||||||
IRenderTexture::factory = new RenderTextureCreatorOpenGL();
|
IRenderTexture::factory = new RenderTextureCreatorOpenGL();
|
||||||
Texture::helper = new TextureHelperOpenGL();
|
Texture::helper = new TextureHelperOpenGL();
|
||||||
|
Camera::helper = new CameraHelperOpenGL();
|
||||||
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, TSE_OPENGL_VERSION_MAJOR);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, TSE_OPENGL_VERSION_MAJOR);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, TSE_OPENGL_VERSION_MINOR);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, TSE_OPENGL_VERSION_MINOR);
|
||||||
|
|||||||
Reference in New Issue
Block a user