Fixed translation issue with Imguizmo
This commit is contained in:
@ -84,11 +84,12 @@ YoggieEngine::Mesh* AssetRegistry::LoadFromAssetFile(const std::filesystem::path
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
|
||||
|
||||
YoggieEngine::Renderable* AssetRegistry::LoadFromSource(const std::filesystem::path srcPath, const std::filesystem::path assetFolder)
|
||||
{
|
||||
|
||||
/*
|
||||
* auto model = (YoggieEngine::ModelImporter()).Import(srcPath.string());
|
||||
YoggieEngine::Mesh* exportMesh = model->renderable->mesh;
|
||||
std::filesystem::path MeshFileName = assetFolder / srcPath.filename().replace_extension(".mesh");
|
||||
@ -134,6 +135,6 @@ YoggieEngine::Renderable* AssetRegistry::LoadFromSource(const std::filesystem::p
|
||||
|
||||
return model->renderable;
|
||||
|
||||
*/
|
||||
return nullptr;
|
||||
}
|
||||
*/
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
|
||||
|
||||
static YoggieEngine::Mesh* LoadFromAssetFile(const std::filesystem::path assetPath);
|
||||
static YoggieEngine::Renderable* LoadFromSource(const std::filesystem::path srcPath, const std::filesystem::path assetFolder);
|
||||
// static YoggieEngine::Renderable* LoadFromSource(const std::filesystem::path srcPath, const std::filesystem::path assetFolder);
|
||||
|
||||
private:
|
||||
int unique_number = 0;
|
||||
|
@ -8,22 +8,11 @@ public:
|
||||
Right = glm::vec3(-1.0f, 0.0f, 0.0f);
|
||||
Up = glm::vec3(0.0f, 1.0f, 0.0f);
|
||||
|
||||
|
||||
view = glm::translate(glm::mat4(1.0f), Position) * glm::toMat4(glm::quat(Rotation));
|
||||
}
|
||||
|
||||
void Update() {
|
||||
|
||||
view = glm::translate(glm::mat4(1.0f), Position) * glm::toMat4(glm::quat(Rotation));
|
||||
}
|
||||
|
||||
glm::vec3 Position = glm::vec3(0.0f);
|
||||
glm::vec3 Rotation = glm::vec3(0.0f);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
glm::vec3 Front;
|
||||
glm::vec3 Right;
|
||||
glm::vec3 Up;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "../../YoggieEngine/src/Graphics/Memory/Buffer.h"
|
||||
|
||||
using namespace YoggieEngine;
|
||||
|
||||
class EditorLayer : public Layer {
|
||||
|
||||
public:
|
||||
@ -60,8 +61,7 @@ public:
|
||||
//Console console = Console();
|
||||
|
||||
}
|
||||
glm::vec3 cameraPosition = glm::vec3(0.0f, 0.0f, -5.0f);
|
||||
glm::vec3 cameraRotation = glm::vec3(0.0f);
|
||||
|
||||
void OnUpdate() override {
|
||||
scene.Update();
|
||||
/*
|
||||
@ -113,8 +113,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
camera->view = glm::translate(glm::mat4(1.0f), cameraPosition) * glm::toMat4(glm::quat(cameraRotation));
|
||||
|
||||
|
||||
renderer.Render(scene, *camera);
|
||||
|
||||
|
||||
@ -215,11 +214,13 @@ public:
|
||||
switch (result) {
|
||||
case(NFD_OKAY):
|
||||
// Import Model
|
||||
|
||||
/*
|
||||
AssetRegistry::LoadFromSource(
|
||||
path,
|
||||
"build/Debug/Assets"//project.get()->GetProjectDirectory() / "Assets"
|
||||
);
|
||||
*/
|
||||
|
||||
break;
|
||||
case(NFD_CANCEL):
|
||||
break;
|
||||
@ -373,7 +374,7 @@ public:
|
||||
| ImGuiWindowFlags_NoCollapse;
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{ 0,0 });
|
||||
ImGui::Begin("SceneView",nullptr,viewportWindowFlags);
|
||||
|
||||
// spdlog::info("{0}x{1}", ImGui::GetWindowWidth(), ImGui::GetWindowHeight());
|
||||
|
||||
ImGui::Image((ImTextureID)(intptr_t)renderer.getCurrentFrameBuffer().GetColourAttachment(),
|
||||
ImVec2{(float)ImGui::GetWindowWidth(),(float)ImGui::GetWindowHeight()});
|
||||
@ -391,21 +392,23 @@ public:
|
||||
|
||||
ImGuizmo::SetRect(ImGui::GetWindowPos().x, ImGui::GetWindowPos().y, ImGui::GetWindowWidth(), ImGui::GetWindowHeight());
|
||||
|
||||
const auto& ProjMatrix = camera->projection;
|
||||
|
||||
const glm::mat4& viewMatrix = ((EditorCamera*)camera)->view;
|
||||
glm::mat4 cameraView = glm::inverse(viewMatrix);
|
||||
glm::mat4 cameraDelta = glm::mat4(1.0f);
|
||||
|
||||
|
||||
const auto& ProjMatrix = camera->getProjection(ImGui::GetWindowWidth(), ImGui::GetWindowHeight());
|
||||
const glm::mat4& viewMatrix = glm::inverse(camera->getTransform());
|
||||
|
||||
|
||||
auto& tc = Selected.GetComponent<YoggieEngine::TransformComponent>();
|
||||
auto transform = tc.GetTransform();
|
||||
ImGuizmo::Manipulate(glm::value_ptr(cameraView), glm::value_ptr(ProjMatrix), activeOperation, ImGuizmo::WORLD, glm::value_ptr(transform), nullptr, nullptr);
|
||||
if(ImGuizmo::IsUsing())
|
||||
ImGuizmo::Manipulate(
|
||||
glm::value_ptr(viewMatrix),
|
||||
glm::value_ptr(ProjMatrix),
|
||||
activeOperation, ImGuizmo::LOCAL, glm::value_ptr(transform));
|
||||
if (ImGuizmo::IsUsing())
|
||||
{
|
||||
tc.Decompose(transform);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -415,7 +418,7 @@ public:
|
||||
|
||||
ImGui::Begin("EditorCamera");
|
||||
|
||||
ImGui::SliderFloat3("position", glm::value_ptr(cameraPosition), -50, 50);
|
||||
ImGui::SliderFloat3("position", glm::value_ptr(camera->Position), -50, 50);
|
||||
ImGui::End();
|
||||
|
||||
|
||||
@ -469,7 +472,7 @@ private:
|
||||
char* path = nullptr;
|
||||
Texture Logo;
|
||||
Renderer renderer;
|
||||
Camera* camera = new EditorCamera();
|
||||
EditorCamera* camera = new EditorCamera();
|
||||
Mesh cube ;
|
||||
|
||||
void LoadLastOrEmptyProject() {
|
||||
|
Reference in New Issue
Block a user