2023-05-08 20:07:29 +00:00
|
|
|
#pragma once
|
|
|
|
#include <iostream>
|
|
|
|
#include <mini/ini.h>
|
|
|
|
#include <glm/glm.hpp>
|
|
|
|
#include <glm/gtc/type_ptr.hpp>
|
|
|
|
#include <glm/gtc/matrix_transform.hpp>
|
2023-05-11 18:27:07 +00:00
|
|
|
#include <nfd.h>
|
|
|
|
|
2023-05-08 20:07:29 +00:00
|
|
|
#include "AssetManagement/SceneSerializer.h"
|
|
|
|
#include "AssetManagement/AssetRegistry.h"
|
|
|
|
#include "AssetManagement/AssetFinder.h"
|
|
|
|
#include "PropertyPanels/Inspector.h"
|
|
|
|
#include "AssetManagement/uuid.h"
|
|
|
|
#include "Project/Settings.h"
|
|
|
|
#include "Console.h"
|
|
|
|
#include "AssetManagement/AssetLoaders/ModelLoader.h"
|
2023-05-11 18:27:07 +00:00
|
|
|
#include "IconsMaterialDesign.h"
|
|
|
|
#include "Project/Project.h"
|
|
|
|
#include <ImGuizmo.h>
|
2023-05-12 20:38:10 +00:00
|
|
|
#include "EditorCamera.h"
|
|
|
|
#include "../../YoggieEngine/src/Graphics/Memory/VertexArray.h"
|
|
|
|
#include "../../YoggieEngine/src/Graphics/Memory/Buffer.h"
|
2023-05-08 20:07:29 +00:00
|
|
|
|
|
|
|
using namespace YoggieEngine;
|
|
|
|
class EditorLayer : public Layer {
|
|
|
|
|
|
|
|
public:
|
2023-05-12 20:38:10 +00:00
|
|
|
EditorLayer() :
|
2023-05-08 20:07:29 +00:00
|
|
|
Layer(),
|
2023-05-12 20:38:10 +00:00
|
|
|
Logo("rsc/Yoggie.png"),
|
|
|
|
inspector(Selected),
|
|
|
|
scene(),
|
|
|
|
renderer()
|
2023-05-08 20:07:29 +00:00
|
|
|
{
|
2023-05-12 20:38:10 +00:00
|
|
|
|
|
|
|
spdlog::info("Colour attachment id: {0}", renderer.getCurrentFrameBuffer().GetColourAttachment());
|
|
|
|
|
|
|
|
Selected = YoggieEngine::Entity((entt::entity)-1, &scene);
|
|
|
|
|
|
|
|
AssetRegistry assetManager = AssetRegistry();
|
|
|
|
// ModelLoader modelLoader = ModelLoader();
|
|
|
|
|
|
|
|
spdlog::info("{0}", project.GetProjectDirectory().string());
|
|
|
|
|
|
|
|
//auto latern = modelLoader.LoadAsset(std::filesystem::path("build/debug/Models/Latern.gltf"));
|
|
|
|
//spdlog::info("Loaded mesh: {0}", latern.GetName());
|
|
|
|
|
2023-05-08 20:07:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OnStartup() override {
|
|
|
|
std::string path = (std::filesystem::current_path()).string();
|
|
|
|
project.setProjectDirectory(path);
|
|
|
|
assetsView = AssetFinder(project.GetProjectDirectory());
|
|
|
|
LoadLastOrEmptyProject();
|
2023-05-12 20:38:10 +00:00
|
|
|
cube = (ModelLoader()).LoadAsset(std::filesystem::path("build/debug/Models/cube.obj"));
|
2023-05-08 20:07:29 +00:00
|
|
|
//Settings settings = Settings();
|
|
|
|
//Console console = Console();
|
2023-05-11 18:27:07 +00:00
|
|
|
|
2023-05-08 20:07:29 +00:00
|
|
|
}
|
2023-05-12 20:38:10 +00:00
|
|
|
glm::vec3 cameraPosition = glm::vec3(0.0f, 0.0f, -5.0f);
|
|
|
|
glm::vec3 cameraRotation = glm::vec3(0.0f);
|
2023-05-08 20:07:29 +00:00
|
|
|
void OnUpdate() override {
|
|
|
|
scene.Update();
|
2023-05-11 18:27:07 +00:00
|
|
|
/*
|
|
|
|
* if (Sceneview.isFocused) {
|
2023-05-08 20:07:29 +00:00
|
|
|
UpdateSceneCamera(sceneview);
|
|
|
|
}
|
2023-05-11 18:27:07 +00:00
|
|
|
*/
|
2023-05-12 20:38:10 +00:00
|
|
|
|
|
|
|
auto components = scene.getReg().view<Render3DComponent>();
|
|
|
|
for(auto component : components){
|
|
|
|
auto& renderComponent = YoggieEngine::Entity(component, &scene).GetComponent<Render3DComponent>();
|
|
|
|
|
|
|
|
renderComponent.mesh = cube;
|
|
|
|
|
|
|
|
if (renderComponent.VAO == 0 || renderComponent.IBO == 0) {
|
|
|
|
VertexArray va = VertexArray();
|
|
|
|
Buffer vertexBuffer = Buffer();
|
|
|
|
Buffer elementBuffer = Buffer();
|
|
|
|
|
|
|
|
va.Create();
|
|
|
|
va.Bind();
|
|
|
|
|
|
|
|
vertexBuffer.createBuffer();
|
|
|
|
vertexBuffer.Bind(false);
|
|
|
|
vertexBuffer.setBufferData((void*)&renderComponent.mesh.vertices[0], renderComponent.mesh.vertices.size() * sizeof(Vertex), false);
|
|
|
|
|
|
|
|
elementBuffer.createBuffer();
|
|
|
|
elementBuffer.Bind(true);
|
|
|
|
elementBuffer.setBufferData((void*)&renderComponent.mesh.elements[0], renderComponent.mesh.elements.size() * sizeof(unsigned int), true);
|
|
|
|
|
|
|
|
va.AttachAttribute(0, 3, sizeof(Vertex));
|
|
|
|
|
|
|
|
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)0);
|
|
|
|
glEnableVertexAttribArray(0);
|
|
|
|
glEnableVertexAttribArray(1);
|
|
|
|
|
|
|
|
va.Unbind();
|
|
|
|
vertexBuffer.Unbind(false);
|
|
|
|
elementBuffer.Unbind(true);
|
|
|
|
|
|
|
|
renderComponent.VAO = va.getID();
|
|
|
|
renderComponent.IBO = elementBuffer.getBufferID();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
camera->view = glm::translate(glm::mat4(1.0f), cameraPosition) * glm::toMat4(glm::quat(cameraRotation));
|
|
|
|
|
|
|
|
renderer.Render(scene, *camera);
|
|
|
|
|
2023-05-08 20:07:29 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OnUI() override {
|
2023-05-11 18:27:07 +00:00
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, { ImGui::GetWindowWidth(), 7 });
|
|
|
|
ImGui::BeginMainMenuBar();
|
|
|
|
int scaleFactor = 30;
|
|
|
|
ImGui::Image((ImTextureID)Logo.GetID(), { Logo.getSize().x / scaleFactor , Logo.getSize().y / scaleFactor });
|
|
|
|
ImGui::PopStyleVar();
|
|
|
|
|
|
|
|
if (ImGui::BeginMenu("App")) {
|
|
|
|
|
|
|
|
if (ImGui::MenuItem("Load Project"))
|
|
|
|
{
|
|
|
|
nfdresult_t result = NFD_OpenDialog({ "yproj" }, NULL, &path);
|
|
|
|
switch (result) {
|
|
|
|
case(NFD_OKAY):
|
|
|
|
//Project::LoadProject(path, project);
|
|
|
|
//AssetRegistry::setAssetPath(project.GetProjectDirectory());
|
|
|
|
//AssetRegistry::BuildAssetView();
|
|
|
|
break;
|
|
|
|
case(NFD_CANCEL):
|
|
|
|
break;
|
|
|
|
case(NFD_ERROR):
|
|
|
|
spdlog::error("NFD_Error: {0}", NFD_GetError());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ImGui::MenuItem("Save project as...")) {
|
|
|
|
nfdresult_t result = NFD_SaveDialog({ "yproj" }, NULL, &path);
|
|
|
|
switch (result) {
|
|
|
|
case(NFD_OKAY):
|
|
|
|
spdlog::info("Save as: {0}", path);
|
|
|
|
//Project::SaveProject(path, project);
|
|
|
|
break;
|
|
|
|
case(NFD_CANCEL):
|
|
|
|
break;
|
|
|
|
case(NFD_ERROR):
|
|
|
|
spdlog::error("NFD_Error: {0}", NFD_GetError());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndMenu();
|
2023-05-08 20:07:29 +00:00
|
|
|
}
|
2023-05-11 18:27:07 +00:00
|
|
|
if (ImGui::BeginMenu("Scene")) {
|
|
|
|
|
|
|
|
if (ImGui::MenuItem("Save scene"))
|
|
|
|
{
|
|
|
|
nfdresult_t result = NFD_SaveDialog({ "yscene" }, NULL, &path);
|
|
|
|
switch (result) {
|
|
|
|
case(NFD_OKAY):
|
|
|
|
//SaveScene(path, scene);
|
|
|
|
|
|
|
|
//project.AddScene(scene);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case(NFD_CANCEL):
|
|
|
|
break;
|
|
|
|
case(NFD_ERROR):
|
|
|
|
std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ImGui::MenuItem("Load scene"))
|
|
|
|
{
|
|
|
|
auto result = NFD_OpenDialog({ "yscene" }, NULL, &path);
|
|
|
|
switch (result) {
|
|
|
|
case (NFD_OKAY):
|
|
|
|
//LoadScene(path, scene);
|
|
|
|
break;
|
|
|
|
case(NFD_CANCEL):
|
|
|
|
break;
|
|
|
|
case(NFD_ERROR):
|
|
|
|
std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ImGui::MenuItem("Add Entity"))
|
|
|
|
{
|
|
|
|
//scene.AddEntity("New Entity");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ImGui::MenuItem("Import Model"))
|
|
|
|
{
|
|
|
|
auto result = NFD_OpenDialog("obj,fbx,gltf", NULL, &path);
|
|
|
|
switch (result) {
|
|
|
|
case(NFD_OKAY):
|
|
|
|
// Import Model
|
|
|
|
|
|
|
|
AssetRegistry::LoadFromSource(
|
|
|
|
path,
|
|
|
|
"build/Debug/Assets"//project.get()->GetProjectDirectory() / "Assets"
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case(NFD_CANCEL):
|
|
|
|
break;
|
|
|
|
case(NFD_ERROR):
|
|
|
|
std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ImGui::MenuItem("Import MeshAsset (temp)"))
|
|
|
|
{
|
|
|
|
auto result = NFD_OpenDialog("mesh", NULL, &path);
|
|
|
|
|
|
|
|
switch (result) {
|
|
|
|
case(NFD_OKAY):
|
|
|
|
{
|
|
|
|
YoggieEngine::Mesh* importedMesh = AssetRegistry::LoadFromAssetFile(path);
|
|
|
|
if (importedMesh != nullptr)
|
|
|
|
{
|
|
|
|
auto full_name = std::filesystem::path(path);
|
|
|
|
// auto importedModel = scene.AddEntity(full_name.filename().u8string());
|
|
|
|
// auto& rendererComponent = importedModel.AddComponent<YoggieEngine::Render3DComponent>();
|
|
|
|
// rendererComponent.mesh = *importedMesh;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case(NFD_CANCEL):
|
|
|
|
spdlog::debug("User cancelled action");
|
|
|
|
break;
|
|
|
|
case(NFD_ERROR):
|
|
|
|
spdlog::warn("Something went wrong!");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::SameLine(ImGui::GetWindowWidth() / 4 * 3);
|
|
|
|
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.3f, 0.3f, 0.3f, 1.0f));
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
|
|
|
ImGui::Button(ICON_MD_ROCKET_LAUNCH "Project");
|
|
|
|
|
|
|
|
ImGui::SameLine(ImGui::GetWindowWidth() - 120);
|
|
|
|
|
|
|
|
/*
|
|
|
|
ImGui::PopStyleColor();
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.1f, 0.1f, 0.1f, 0.01f));
|
|
|
|
if (ImGui::Button(ICON_MD_MINIMIZE)) { spdlog::info("Minimize"); }
|
|
|
|
if (ImGui::Button(ICON_MD_MAXIMIZE)) { spdlog::info("Maximize"); }
|
|
|
|
if (ImGui::Button(ICON_MD_CLOSE)) { spdlog::info("Quit"); }
|
|
|
|
*/
|
|
|
|
ImGui::PopStyleColor(1);
|
|
|
|
ImGui::PopStyleVar();
|
|
|
|
|
|
|
|
ImGui::EndMainMenuBar();
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::Begin("RuntimeControls");
|
|
|
|
ImGui::SameLine((ImGui::GetWindowContentRegionMax().x / 2) - (90));
|
|
|
|
auto color = ImVec4{ 0.001 * 12 , 0.001 * 201 , 0.001 * 69, 1.0f };
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Button, color);
|
|
|
|
const float strengthIncrease = 1.5f;
|
|
|
|
ImGui::PushStyleColor(
|
|
|
|
ImGuiCol_ButtonHovered,
|
|
|
|
ImVec4{
|
|
|
|
color.x * strengthIncrease,
|
|
|
|
color.y * strengthIncrease,
|
|
|
|
color.z * strengthIncrease,
|
|
|
|
color.w
|
|
|
|
}
|
|
|
|
);
|
|
|
|
if (ImGui::Button(ICON_MD_PLAY_ARROW, { 90,25 })) {
|
|
|
|
// Play game
|
|
|
|
}
|
|
|
|
ImGui::PopStyleColor(2);
|
|
|
|
ImGui::SameLine();
|
|
|
|
color = ImVec4{ 0.001 * 14, 0.001 * 157, 0.001 * 201, 1.0f };
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Button, color);
|
|
|
|
|
|
|
|
ImGui::PushStyleColor(
|
|
|
|
ImGuiCol_ButtonHovered,
|
|
|
|
ImVec4{
|
|
|
|
color.x * strengthIncrease,
|
|
|
|
color.y * strengthIncrease,
|
|
|
|
color.z * strengthIncrease,
|
|
|
|
color.w
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ImGui::Button(ICON_MD_ELECTRIC_BOLT, { 90,25 })) {
|
|
|
|
// Simulate physics
|
|
|
|
}
|
|
|
|
ImGui::PopStyleColor(2);
|
|
|
|
ImGui::End();
|
|
|
|
|
|
|
|
|
2023-05-12 20:38:10 +00:00
|
|
|
unsigned int viewportWindowFlags = ImGuiWindowFlags_NoTitleBar
|
|
|
|
| ImGuiWindowFlags_NoDecoration
|
|
|
|
| ImGuiWindowFlags_NoScrollbar
|
|
|
|
| ImGuiWindowFlags_NoMove
|
|
|
|
| ImGuiWindowFlags_NoCollapse;
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{ 0,0 });
|
|
|
|
ImGui::Begin("SceneView",nullptr,viewportWindowFlags);
|
|
|
|
spdlog::info( "Editor Resolution {0}x{1}", (float)ImGui::GetWindowWidth(),(float)ImGui::GetWindowHeight());
|
2023-05-11 18:27:07 +00:00
|
|
|
|
2023-05-12 20:38:10 +00:00
|
|
|
ImGui::Image((ImTextureID)(intptr_t)renderer.getCurrentFrameBuffer().GetColourAttachment(),
|
|
|
|
ImVec2{(float)ImGui::GetWindowWidth(),(float)ImGui::GetWindowHeight()});
|
2023-05-11 18:27:07 +00:00
|
|
|
|
|
|
|
ImGuizmo::Enable(true);
|
|
|
|
ImGuizmo::SetOrthographic(false);
|
|
|
|
ImGuizmo::SetDrawlist();
|
|
|
|
|
|
|
|
ImGuizmo::SetRect(ImGui::GetWindowPos().x, ImGui::GetWindowPos().y, ImGui::GetContentRegionMax().x, ImGui::GetContentRegionMax().y);
|
|
|
|
/*
|
|
|
|
const auto& projection = camera.projection;
|
|
|
|
glm::mat4& view = glm::mat4(1.0f);
|
|
|
|
ImGuizmo::DrawGrid();
|
|
|
|
ImGuizmo::ViewManipulate();
|
|
|
|
|
|
|
|
|
|
|
|
if(selected != nullptr && selected->isValid()){
|
|
|
|
auto& tc = selected->GetComponent<YoggieEngine::TransformComponent>();
|
|
|
|
glm::mat4 transform = tc.GetTransform();
|
|
|
|
|
|
|
|
ImGuizmo::Manipulate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
ImGui::End();
|
2023-05-12 20:38:10 +00:00
|
|
|
ImGui::PopStyleVar();
|
|
|
|
|
|
|
|
ImGui::Begin("EditorCamera");
|
|
|
|
|
|
|
|
ImGui::SliderFloat3("position", glm::value_ptr(cameraPosition), -50, 50);
|
|
|
|
ImGui::End();
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-05-11 18:27:07 +00:00
|
|
|
|
|
|
|
ImGui::Begin(ICON_MD_MENU "SceneExplorer",nullptr);
|
|
|
|
scene.getReg().each([&](entt::entity enttNumber) {
|
|
|
|
YoggieEngine::Entity entity = YoggieEngine::Entity(enttNumber, &scene);
|
|
|
|
auto id = entity.GetComponent<YoggieEngine::IdentifierComponent>();
|
|
|
|
if (ImGui::Selectable(id.name.c_str(), entity == Selected)) {
|
|
|
|
Selected = YoggieEngine::Entity(enttNumber, &scene);
|
2023-05-12 20:38:10 +00:00
|
|
|
|
2023-05-11 18:27:07 +00:00
|
|
|
}
|
|
|
|
});
|
2023-05-12 20:38:10 +00:00
|
|
|
|
|
|
|
|
2023-05-11 18:27:07 +00:00
|
|
|
ImGui::End();
|
2023-05-08 20:07:29 +00:00
|
|
|
|
|
|
|
inspector.Update();
|
2023-05-11 18:27:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
//settings.Update();
|
2023-05-08 20:07:29 +00:00
|
|
|
//console.Update();
|
|
|
|
|
|
|
|
assetsView.Update();
|
|
|
|
|
|
|
|
ImGui::ShowDemoWindow();
|
|
|
|
//ImGui::ShowMetricsWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OnCreate() override {
|
2023-05-09 17:36:34 +00:00
|
|
|
spdlog::info(" Layer Create!" );
|
2023-05-08 20:07:29 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnDestroy() override {
|
2023-05-09 17:36:34 +00:00
|
|
|
spdlog::info( " Layer Destroy!" );
|
2023-05-11 18:27:07 +00:00
|
|
|
|
2023-05-08 20:07:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
Inspector inspector;
|
|
|
|
AssetFinder assetsView;
|
|
|
|
|
|
|
|
bool SimulatePhysics = true;
|
|
|
|
YoggieEngine::Entity Selected;
|
|
|
|
Project project;
|
|
|
|
Scene scene;
|
2023-05-11 18:27:07 +00:00
|
|
|
char* path = nullptr;
|
|
|
|
Texture Logo;
|
2023-05-12 20:38:10 +00:00
|
|
|
Renderer renderer;
|
|
|
|
Camera* camera = new EditorCamera();
|
|
|
|
Mesh cube ;
|
2023-05-08 20:07:29 +00:00
|
|
|
|
|
|
|
void LoadLastOrEmptyProject() {
|
|
|
|
// Check if there is a last known loaded project and
|
|
|
|
// load that one .
|
|
|
|
|
|
|
|
// Otherwise load no project..
|
|
|
|
// OR
|
|
|
|
// Load an empty project.
|
|
|
|
mINI::INIStructure ini;
|
|
|
|
|
|
|
|
if (std::filesystem::exists("build\\Debug\\Editor.ini"))
|
|
|
|
{
|
|
|
|
mINI::INIFile file("build\\Debug\\Editor.ini");
|
|
|
|
file.read(ini);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spdlog::debug("Could not find an `Editor.ini` file.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ini["editor"]["openlastproject"] == "TRUE")
|
|
|
|
{
|
|
|
|
|
|
|
|
Project::LoadProject(ini["cache"]["project"], project);
|
|
|
|
LoadScene(ini["cache"]["scene"], scene);
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spdlog::debug("Starting without a project. Please create one.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-05-11 18:27:07 +00:00
|
|
|
void UpdateSceneCamera() {
|
2023-05-08 20:07:29 +00:00
|
|
|
const float movement_speed = 0.01f;
|
|
|
|
static float lastX = 400, lastY = 300;
|
|
|
|
const float sensitivity = 0.1;
|
|
|
|
static bool firstMouse = true;
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
if (MouseButtonPressed(YOGGIE_MOUSE_BUTTON_RIGHT)) {
|
|
|
|
|
|
|
|
glfwSetInputMode((GLFWwindow*)appWindow->GetHandle(), GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
|
|
|
auto newX = getCursorPosX(appWindow);
|
|
|
|
auto newY = getCursorPosY(appWindow);
|
|
|
|
|
|
|
|
if (firstMouse)
|
|
|
|
{
|
|
|
|
lastX = newX;
|
|
|
|
lastY = newY;
|
|
|
|
firstMouse = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float xoffset = newX - lastX;
|
|
|
|
float yoffset = newY - lastY;
|
|
|
|
|
|
|
|
lastX = newX;
|
|
|
|
lastY = newY;
|
|
|
|
|
|
|
|
xoffset *= sensitivity;
|
|
|
|
yoffset *= sensitivity;
|
|
|
|
|
|
|
|
sceneview.cam.Rotation.x += (xoffset / 2);
|
|
|
|
sceneview.cam.Rotation.y += (xoffset /2);
|
|
|
|
sceneview.cam.Rotation.z += yoffset;
|
|
|
|
|
|
|
|
|
|
|
|
if (sceneview.cam.pitch > 89.0f)
|
|
|
|
sceneview.cam.pitch = 89.0f;
|
|
|
|
if (sceneview.cam.pitch < -89.0f)
|
|
|
|
sceneview.cam.pitch = -89.0f;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (firstMouse == false)
|
|
|
|
{
|
|
|
|
glfwSetInputMode((GLFWwindow*)appWindow->GetHandle(), GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
|
|
|
firstMouse = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2023-05-11 18:27:07 +00:00
|
|
|
/*
|
|
|
|
EditorCamera& cam = sceneview.GetCamera();
|
2023-05-08 20:07:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (keyIsPressed(YOGGIE_KEY_UP))
|
|
|
|
cam.Rotation.x += movement_speed;
|
|
|
|
|
|
|
|
if (keyIsPressed(YOGGIE_KEY_DOWN))
|
|
|
|
cam.Rotation.x -= movement_speed;
|
|
|
|
|
|
|
|
if (keyIsPressed(YOGGIE_KEY_LEFT))
|
|
|
|
cam.Rotation.y += movement_speed;
|
|
|
|
|
|
|
|
if (keyIsPressed(YOGGIE_KEY_RIGHT))
|
|
|
|
cam.Rotation.y -= movement_speed;
|
|
|
|
|
|
|
|
|
|
|
|
cam.Update();
|
|
|
|
|
2023-05-11 18:27:07 +00:00
|
|
|
*/
|
|
|
|
|
2023-05-08 20:07:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
// Check for Camara movement input here!
|
|
|
|
if (keyIsPressed(YOGGIE_KEY_W))
|
|
|
|
sceneview.cam.Position -= sceneview.cam.Front * movement_speed;
|
|
|
|
|
|
|
|
if (keyIsPressed(YOGGIE_KEY_A))
|
|
|
|
sceneview.cam.Position += sceneview.cam.Right * movement_speed;
|
|
|
|
|
|
|
|
if (keyIsPressed(YOGGIE_KEY_S))
|
|
|
|
sceneview.cam.Position += sceneview.cam.Front * movement_speed;
|
|
|
|
|
|
|
|
if (keyIsPressed(YOGGIE_KEY_D))
|
|
|
|
sceneview.cam.Position -= sceneview.cam.Right * movement_speed;
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|