Added gizmo for audio emitter
This commit is contained in:
@@ -33,11 +33,12 @@
|
||||
#include <src/Rendering/SceneRenderer.h>
|
||||
|
||||
|
||||
const std::string WindowTitle = "Nuake Editor";
|
||||
std::string WindowTitle = "Nuake Editor ";
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
bool playMode = false;
|
||||
using namespace Nuake;
|
||||
|
||||
std::string projectPath = "";
|
||||
|
||||
Vector2 editorResolution = Vector2(1280, 720);
|
||||
@@ -47,15 +48,6 @@ int main(int argc, char* argv[])
|
||||
char* arg = argv[i];
|
||||
std::string args = std::string(arg);
|
||||
|
||||
if (args == "--play")
|
||||
{
|
||||
if (argc > 2)
|
||||
{
|
||||
projectPath = std::string(argv[i + 1]);
|
||||
}
|
||||
playMode = true;
|
||||
}
|
||||
|
||||
if (args == "--resolution")
|
||||
{
|
||||
if (argc >= i + 1)
|
||||
@@ -83,134 +75,101 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
bool shouldLoadProject = false;
|
||||
if (!playMode && argc > 1)
|
||||
if (argc > 1)
|
||||
{
|
||||
shouldLoadProject = true;
|
||||
projectPath = std::string(argv[1]);
|
||||
}
|
||||
|
||||
if (playMode)
|
||||
Nuake::Engine::Init();
|
||||
Engine::GetCurrentWindow()->SetSize(editorResolution);
|
||||
|
||||
Nuake::EditorInterface editor;
|
||||
editor.BuildFonts();
|
||||
|
||||
#ifdef NK_DEBUG
|
||||
WindowTitle += "(DEBUG)";
|
||||
#endif
|
||||
#ifdef NK_RELEASE
|
||||
WindowTitle += "(RELEASE)";
|
||||
#endif
|
||||
|
||||
Ref<Nuake::Window> window = Nuake::Engine::GetCurrentWindow();
|
||||
window->SetTitle(WindowTitle);
|
||||
|
||||
if (monitorIdx != -1)
|
||||
{
|
||||
Nuake::Engine::Init();
|
||||
Nuake::EditorInterface editor;
|
||||
editor.BuildFonts();
|
||||
|
||||
Ref<Nuake::Project> project = Nuake::Project::New();
|
||||
FileSystem::SetRootDirectory(FileSystem::GetParentPath(projectPath));
|
||||
|
||||
project->FullPath = projectPath;
|
||||
project->Deserialize(FileSystem::ReadFile(projectPath, true));
|
||||
|
||||
Ref<Nuake::Window> window = Nuake::Engine::GetCurrentWindow();
|
||||
window->SetTitle(project->Name);
|
||||
|
||||
Nuake::Engine::LoadProject(project);
|
||||
|
||||
Nuake::Engine::EnterPlayMode();
|
||||
auto shader = Nuake::ShaderManager::GetShader("resources/Shaders/copy.shader");
|
||||
while (!window->ShouldClose())
|
||||
{
|
||||
Nuake::Vector2 WindowSize = window->GetSize();
|
||||
glViewport(0, 0, WindowSize.x, WindowSize.y);
|
||||
Nuake::Renderer2D::BeginDraw(WindowSize);
|
||||
Nuake::Engine::Tick();
|
||||
Nuake::Engine::Draw();
|
||||
|
||||
shader->Bind();
|
||||
|
||||
window->GetFrameBuffer()->GetTexture()->Bind(0);
|
||||
shader->SetUniform1i("u_Source", 0);
|
||||
Nuake::Renderer::DrawQuad(Nuake::Matrix4(1));
|
||||
|
||||
Nuake::Engine::EndDraw();
|
||||
}
|
||||
window->SetMonitor(monitorIdx);
|
||||
}
|
||||
else
|
||||
|
||||
GizmoDrawer gizmoDrawer = GizmoDrawer();
|
||||
|
||||
if (shouldLoadProject)
|
||||
{
|
||||
Nuake::Engine::Init();
|
||||
Engine::GetCurrentWindow()->SetSize(editorResolution);
|
||||
FileSystem::SetRootDirectory(FileSystem::GetParentPath(projectPath));
|
||||
|
||||
Nuake::EditorInterface editor;
|
||||
editor.BuildFonts();
|
||||
auto project = Project::New();
|
||||
auto projectFileData = FileSystem::ReadFile(projectPath, true);
|
||||
try
|
||||
{
|
||||
project->Deserialize(json::parse(projectFileData));
|
||||
project->FullPath = projectPath;
|
||||
|
||||
Ref<Nuake::Window> window = Nuake::Engine::GetCurrentWindow();
|
||||
window->SetTitle(WindowTitle);
|
||||
Engine::LoadProject(project);
|
||||
|
||||
if (monitorIdx != -1)
|
||||
{
|
||||
window->SetMonitor(monitorIdx);
|
||||
}
|
||||
|
||||
using namespace Nuake;
|
||||
|
||||
GizmoDrawer gizmoDrawer = GizmoDrawer();
|
||||
|
||||
if (shouldLoadProject)
|
||||
{
|
||||
FileSystem::SetRootDirectory(FileSystem::GetParentPath(projectPath));
|
||||
|
||||
auto project = Project::New();
|
||||
auto projectFileData = FileSystem::ReadFile(projectPath, true);
|
||||
try
|
||||
{
|
||||
project->Deserialize(json::parse(projectFileData));
|
||||
project->FullPath = projectPath;
|
||||
|
||||
Engine::LoadProject(project);
|
||||
|
||||
editor.filesystem->m_CurrentDirectory = Nuake::FileSystem::RootDirectory;
|
||||
}
|
||||
catch (std::exception exception)
|
||||
{
|
||||
Logger::Log("Error loading project: " + projectPath, "editor", CRITICAL);
|
||||
Logger::Log(exception.what());
|
||||
}
|
||||
}
|
||||
editor.filesystem->m_CurrentDirectory = Nuake::FileSystem::RootDirectory;
|
||||
}
|
||||
catch (std::exception exception)
|
||||
{
|
||||
Logger::Log("Error loading project: " + projectPath, "editor", CRITICAL);
|
||||
Logger::Log(exception.what());
|
||||
}
|
||||
}
|
||||
|
||||
while (!window->ShouldClose())
|
||||
while (!window->ShouldClose())
|
||||
{
|
||||
Nuake::Engine::Tick();
|
||||
Nuake::Engine::Draw();
|
||||
|
||||
Timestep ts = Nuake::Engine::GetTimestep();
|
||||
|
||||
Nuake::Vector2 WindowSize = window->GetSize();
|
||||
glViewport(0, 0, WindowSize.x, WindowSize.y);
|
||||
Nuake::Renderer2D::BeginDraw(WindowSize);
|
||||
|
||||
auto sceneFramebuffer = window->GetFrameBuffer();
|
||||
sceneFramebuffer->Bind();
|
||||
{
|
||||
Nuake::Engine::Tick();
|
||||
Nuake::Engine::Draw();
|
||||
|
||||
Timestep ts = Nuake::Engine::GetTimestep();
|
||||
|
||||
Nuake::Vector2 WindowSize = window->GetSize();
|
||||
glViewport(0, 0, WindowSize.x, WindowSize.y);
|
||||
Nuake::Renderer2D::BeginDraw(WindowSize);
|
||||
|
||||
auto sceneFramebuffer = window->GetFrameBuffer();
|
||||
sceneFramebuffer->Bind();
|
||||
Ref<Nuake::Scene> currentScene = Nuake::Engine::GetCurrentScene();
|
||||
Ref<EditorCamera> camera;
|
||||
if (currentScene)
|
||||
{
|
||||
Ref<Nuake::Scene> currentScene = Nuake::Engine::GetCurrentScene();
|
||||
Ref<EditorCamera> camera;
|
||||
if (currentScene)
|
||||
camera = currentScene->m_EditorCamera;
|
||||
}
|
||||
|
||||
if (currentScene && !Nuake::Engine::IsPlayMode())
|
||||
{
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
if (editor.ShouldDrawAxis())
|
||||
{
|
||||
camera = currentScene->m_EditorCamera;
|
||||
//gizmoDrawer.DrawAxis(currentScene);
|
||||
}
|
||||
|
||||
if (currentScene && !Nuake::Engine::IsPlayMode())
|
||||
if (editor.ShouldDrawCollision())
|
||||
{
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
if (editor.ShouldDrawAxis())
|
||||
{
|
||||
//gizmoDrawer.DrawAxis(currentScene);
|
||||
}
|
||||
|
||||
if (editor.ShouldDrawCollision())
|
||||
{
|
||||
gizmoDrawer.DrawGizmos(currentScene);
|
||||
}
|
||||
gizmoDrawer.DrawGizmos(currentScene);
|
||||
}
|
||||
}
|
||||
sceneFramebuffer->Unbind();
|
||||
|
||||
editor.Update(ts);
|
||||
editor.Draw();
|
||||
|
||||
Nuake::Engine::EndDraw();
|
||||
}
|
||||
sceneFramebuffer->Unbind();
|
||||
|
||||
editor.Update(ts);
|
||||
editor.Draw();
|
||||
|
||||
Nuake::Engine::EndDraw();
|
||||
}
|
||||
|
||||
|
||||
Nuake::Engine::Close();
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <src/Scene/Components/ModelComponent.h>
|
||||
#include <src/Scene/Components/ParticleEmitterComponent.h>
|
||||
#include <src/Scene/Components/BoneComponent.h>
|
||||
#include <src/Scene/Components/AudioEmitterComponent.h>
|
||||
|
||||
GizmoDrawer::GizmoDrawer()
|
||||
{
|
||||
@@ -367,6 +368,26 @@ void GizmoDrawer::DrawGizmos(Ref<Scene> scene)
|
||||
renderList.AddToRenderList(Renderer::QuadMesh, particleTransform);
|
||||
}
|
||||
|
||||
renderList.Flush(gizmoShader, true);
|
||||
|
||||
auto audioView = scene->m_Registry.view<TransformComponent, AudioEmitterComponent>();
|
||||
for (auto e : audioView)
|
||||
{
|
||||
gizmoShader->SetUniformTex("gizmo_texture", TextureManager::Get()->GetTexture("resources/Gizmos/speaker.png").get());
|
||||
auto [transformComponent, audioEmitterComponent] = scene->m_Registry.get<TransformComponent, AudioEmitterComponent>(e);
|
||||
|
||||
auto initialTransform = transformComponent.GetGlobalTransform();
|
||||
Matrix4 transform = initialTransform;
|
||||
transform = glm::inverse(scene->m_EditorCamera->GetTransform());
|
||||
|
||||
// Translation
|
||||
const Vector3& globalPosition = transformComponent.GetGlobalPosition();
|
||||
transform[3] = initialTransform[3];
|
||||
transform = glm::scale(transform, Vector3(0.5f, 0.5f, 0.5f));
|
||||
|
||||
renderList.AddToRenderList(Renderer::QuadMesh, transform);
|
||||
}
|
||||
|
||||
renderList.Flush(gizmoShader, true);
|
||||
|
||||
RenderCommand::Enable(RendererEnum::DEPTH_TEST);
|
||||
|
||||
@@ -8,12 +8,9 @@
|
||||
#include <src/Resource/ResourceLoader.h>
|
||||
#include <src/Resource/FontAwesome5.h>
|
||||
#include <src/Scripting/WrenScript.h>
|
||||
|
||||
#include <Engine.h>
|
||||
|
||||
#include "src/Scene/Components/WrenScriptComponent.h"
|
||||
#include "src/Scene/Components/ParticleEmitterComponent.h"
|
||||
|
||||
|
||||
EditorSelectionPanel::EditorSelectionPanel()
|
||||
{
|
||||
}
|
||||
@@ -150,7 +147,9 @@ void EditorSelectionPanel::DrawAddComponentMenu(Nuake::Entity entity)
|
||||
MenuItemComponent("Sphere collider", SphereColliderComponent)
|
||||
MenuItemComponent("Mesh collider", MeshColliderComponent)
|
||||
ImGui::Separator();
|
||||
MenuItemComponent("Quake map", QuakeMapComponent)
|
||||
MenuItemComponent("Quake map", QuakeMapComponent);
|
||||
ImGui::Separator();
|
||||
MenuItemComponent("Audio Emitter", AudioEmitterComponent);
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
ImGui::Separator();
|
||||
|
||||
@@ -5,6 +5,8 @@ namespace Nuake
|
||||
class AudioSource
|
||||
{
|
||||
private:
|
||||
bool m_Loop = false;
|
||||
bool m_Is3D = false;
|
||||
|
||||
public:
|
||||
AudioSource() = default;
|
||||
|
||||
17
Nuake/src/Scene/Components/AudioEmitterComponent.h
Normal file
17
Nuake/src/Scene/Components/AudioEmitterComponent.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include "src/Core/Core.h"
|
||||
#include "src/Resource/Serializable.h"
|
||||
|
||||
namespace Nuake {
|
||||
|
||||
class AudioEmitterComponent
|
||||
{
|
||||
public:
|
||||
float Volume = 1.0f;
|
||||
float Pan = 0.0f;
|
||||
float PlaybackSpeed = 1.0f;
|
||||
|
||||
json Serialize();
|
||||
bool Deserialize(const json& j);
|
||||
};
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "src/Core/Core.h"
|
||||
|
||||
namespace Nuake {
|
||||
|
||||
class BoxColliderComponent
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -17,7 +17,11 @@
|
||||
#include "CylinderColliderComponent.h"
|
||||
#include "NativeScriptComponent.h"
|
||||
|
||||
#include "ParticleEmitterComponent.h"
|
||||
|
||||
#include "ParentComponent.h"
|
||||
#include "NameComponent.h"
|
||||
#include "BoxCollider.h"
|
||||
#include "AudioEmitterComponent.h"
|
||||
#include "WrenScriptComponent.h"
|
||||
#include "../Entities/Entity.h"
|
||||
|
||||
Reference in New Issue
Block a user