Camera Working
This commit is contained in:
parent
ed82f40492
commit
00fc2aff1c
@ -46,7 +46,7 @@ namespace Deer {
|
||||
m_running = true;
|
||||
|
||||
const double targetUpdateTime = 1.0 / 60.0; // Fixed 60 FPS update
|
||||
double targetRenderTime = 1.0 / 120.0; // User-defined render FPS
|
||||
double targetRenderTime = 1.0 / 160.0; // User-defined render FPS
|
||||
|
||||
auto previousTime = std::chrono::high_resolution_clock::now();
|
||||
double accumulatedUpdateTime = 0.0;
|
||||
|
@ -45,7 +45,7 @@ namespace Deer {
|
||||
void Scene::tickExecution() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Scene::endExecution() {
|
||||
DEER_CORE_ASSERT(isExecuting, "Deer scene is not executing");
|
||||
isExecuting = false;
|
||||
|
@ -79,9 +79,7 @@ namespace Deer {
|
||||
Scene::tickExecution();
|
||||
|
||||
if (VoxelWorld::isInitialized())
|
||||
VoxelWorld::bakeNextChunk();
|
||||
|
||||
EditorEngine::tick();
|
||||
VoxelWorld::bakeNextChunk();
|
||||
}
|
||||
|
||||
void DeerStudioApplication::onEvent(Event& e) {
|
||||
|
@ -15,7 +15,6 @@ namespace Deer {
|
||||
void deinitialize();
|
||||
|
||||
void render();
|
||||
void tick();
|
||||
|
||||
extern asIScriptEngine* scriptEngine;
|
||||
extern asIScriptModule* scriptModule;
|
||||
|
@ -23,7 +23,7 @@ namespace Deer {
|
||||
bool buttonCenter(std::string&);
|
||||
// Renders a button at the end
|
||||
bool buttonEnd(std::string&);
|
||||
|
||||
|
||||
// Renders a text
|
||||
void text(std::string&);
|
||||
// Renders a text
|
||||
@ -58,6 +58,20 @@ namespace Deer {
|
||||
// Returns if the specified mouse button is double clicked
|
||||
bool isMouseDoubleClicked(int mouse);
|
||||
|
||||
bool isKeyDown(int);
|
||||
bool isKeyPressed(int);
|
||||
|
||||
bool isMouseDraggin(int);
|
||||
float getMouseDragDeltaX();
|
||||
float getMouseDragDeltaY();
|
||||
float getMouseDeltaX();
|
||||
float getMouseDeltaY();
|
||||
|
||||
void disablePannelPadding(bool);
|
||||
|
||||
int getAvailableSizeX();
|
||||
int getAvailableSizeY();
|
||||
|
||||
// Draws a button for a popup menu
|
||||
bool menuItem(std::string&);
|
||||
// Draws a button disabled
|
||||
@ -84,5 +98,6 @@ namespace Deer {
|
||||
bool isPannelActive();
|
||||
|
||||
void registerUIFunctions();
|
||||
void registerUIStructs();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +99,10 @@ namespace Deer {
|
||||
ImGui::Text("%s", msg.c_str());
|
||||
}
|
||||
|
||||
bool isPannelActive() {
|
||||
return ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows);
|
||||
}
|
||||
|
||||
void textEnd(std::string& msg) {
|
||||
float sizeX;
|
||||
if (ImGui::GetColumnsCount() > 1)
|
||||
@ -427,5 +431,56 @@ namespace Deer {
|
||||
return value;
|
||||
}
|
||||
|
||||
bool isKeyDown(int key) {
|
||||
return ImGui::IsKeyDown((ImGuiKey)key);
|
||||
}
|
||||
|
||||
bool isKeyPressed(int key) {
|
||||
return ImGui::IsKeyPressed((ImGuiKey)key, false);
|
||||
}
|
||||
|
||||
bool isMouseDraggin(int key) {
|
||||
if (key == ImGuiKey_MouseRight)
|
||||
return ImGui::IsMouseDragging(ImGuiMouseButton_Right);
|
||||
else if (key == ImGuiKey_MouseLeft)
|
||||
return ImGui::IsMouseDragging(ImGuiMouseButton_Left);
|
||||
else if (key == ImGuiKey_MouseMiddle)
|
||||
return ImGui::IsMouseDragging(ImGuiMouseButton_Middle);
|
||||
return false;
|
||||
}
|
||||
|
||||
float getMouseDeltaX() {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
return io.MouseDelta.x;
|
||||
}
|
||||
|
||||
float getMouseDeltaY() {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
return io.MouseDelta.y;
|
||||
}
|
||||
|
||||
float getMouseDragDeltaX() {
|
||||
return ImGui::GetMouseDragDelta().x;
|
||||
}
|
||||
|
||||
float getMouseDragDeltaY() {
|
||||
return ImGui::GetMouseDragDelta().y;
|
||||
}
|
||||
|
||||
int getAvailableSizeX() {
|
||||
return ImGui::GetContentRegionAvail().x;
|
||||
}
|
||||
|
||||
int getAvailableSizeY() {
|
||||
return ImGui::GetContentRegionAvail().y;
|
||||
}
|
||||
|
||||
void disablePannelPadding(bool value) {
|
||||
if (currentDockPanelExecution) {
|
||||
if (value != (currentDockPanelExecution->flags & DockPannelFlag_PannelPadding)){
|
||||
currentDockPanelExecution->flags ^= DockPannelFlag_PannelPadding;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -68,6 +68,7 @@ namespace Deer {
|
||||
REGISTER_EXT_OBJECT_METHOD("vec3", "vec3 opSub(const vec3 &in) const", vec3_sub);
|
||||
REGISTER_EXT_OBJECT_METHOD("vec3", "vec3 opNeg() const", vec3_neg);
|
||||
REGISTER_EXT_OBJECT_METHOD("vec3", "vec3 opMul(float) const", vec3_mult);
|
||||
REGISTER_EXT_OBJECT_METHOD("vec3", "vec3 opMul_r(float) const", vec3_mult);
|
||||
|
||||
REGISTER_EXT_OBJECT_CONSTRUCTOR("quat", "void f()", quat_construct);
|
||||
REGISTER_EXT_OBJECT_CONSTRUCTOR("quat", "void f(float, float, float, float)", quat_constructFromValue);
|
||||
@ -75,7 +76,7 @@ namespace Deer {
|
||||
|
||||
REGISTER_EXT_OBJECT_METHOD("quat", "quat opMul(const quat &in) const", quat_multiply);
|
||||
REGISTER_EXT_OBJECT_METHOD("quat", "vec3 getEuler() const", quat_getEuler);
|
||||
REGISTER_EXT_OBJECT_METHOD("quat", "void setEuler(vec3)", quat_multiply);
|
||||
REGISTER_EXT_OBJECT_METHOD("quat", "void setEuler(vec3)", quat_setEuler);
|
||||
|
||||
REGISTER_EXT_OBJECT_CONSTRUCTOR("Transform", "void f()", transform_construct);
|
||||
REGISTER_EXT_OBJECT_CONSTRUCTOR("Camera", "void f()", camera_construct);
|
||||
|
@ -21,6 +21,7 @@ namespace Deer {
|
||||
AS_CHECK(scriptEngine->RegisterFuncdef("void ReciverFunc(any@)"));
|
||||
AS_CHECK(scriptEngine->RegisterFuncdef("void TransferFunc(any@, any@)"));
|
||||
|
||||
registerUIStructs();
|
||||
registerResourceTypeEnum();
|
||||
registerEntityStructs();
|
||||
registerMathStructs();
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "scripthandle.h"
|
||||
#include "scriptany.h"
|
||||
#include "angelscript.h"
|
||||
#include "imgui.h"
|
||||
|
||||
namespace Deer {
|
||||
void EditorEngine::registerUIFunctions() {
|
||||
@ -40,6 +41,214 @@ namespace Deer {
|
||||
REGISTER_GLOBAL_FUNC("void titleCenter(const string&in)", titleCenter);
|
||||
REGISTER_GLOBAL_FUNC("void titleCenterY(const string&in, int)", titleCenterY);
|
||||
REGISTER_GLOBAL_FUNC("void titleEnd(const string&in)", titleEnd);
|
||||
REGISTER_GLOBAL_FUNC("bool isKeyDown(key)", isKeyDown);
|
||||
REGISTER_GLOBAL_FUNC("bool isKeyPressed(key)", isKeyPressed);
|
||||
REGISTER_GLOBAL_FUNC("bool isMouseDraggin(key)", isMouseDraggin);
|
||||
REGISTER_GLOBAL_FUNC("bool isPannelActive()", isPannelActive);
|
||||
REGISTER_GLOBAL_FUNC("float getMouseDragDeltaX()", getMouseDragDeltaX);
|
||||
REGISTER_GLOBAL_FUNC("float getMouseDragDeltaY()", getMouseDragDeltaY);
|
||||
REGISTER_GLOBAL_FUNC("float getMouseDeltaX()", getMouseDeltaX);
|
||||
REGISTER_GLOBAL_FUNC("float getMouseDeltaY()", getMouseDeltaY);
|
||||
REGISTER_GLOBAL_FUNC("int getAvailableSizeX()", getAvailableSizeX);
|
||||
REGISTER_GLOBAL_FUNC("int getAvailableSizeY()", getAvailableSizeY);
|
||||
REGISTER_GLOBAL_FUNC("void disablePannelPadding(bool)", disablePannelPadding);
|
||||
scriptEngine->SetDefaultNamespace("");
|
||||
}
|
||||
}
|
||||
|
||||
void EditorEngine::registerUIStructs() {
|
||||
AS_CHECK(scriptEngine->RegisterEnum("key"));
|
||||
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "A", ImGuiKey_A));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "B", ImGuiKey_B));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "C", ImGuiKey_C));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "D", ImGuiKey_D));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "E", ImGuiKey_E));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "F", ImGuiKey_F));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "G", ImGuiKey_G));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "H", ImGuiKey_H));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "I", ImGuiKey_I));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "J", ImGuiKey_J));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "K", ImGuiKey_K));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "L", ImGuiKey_L));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "M", ImGuiKey_M));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "N", ImGuiKey_N));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "O", ImGuiKey_O));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "P", ImGuiKey_P));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "Q", ImGuiKey_Q));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "R", ImGuiKey_R));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "S", ImGuiKey_S));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "T", ImGuiKey_T));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "U", ImGuiKey_U));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "V", ImGuiKey_V));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "W", ImGuiKey_W));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "X", ImGuiKey_X));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "Y", ImGuiKey_Y));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "Z", ImGuiKey_Z));
|
||||
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "K0", ImGuiKey_0));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "K1", ImGuiKey_1));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "K2", ImGuiKey_2));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "K3", ImGuiKey_3));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "K4", ImGuiKey_4));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "K5", ImGuiKey_5));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "K6", ImGuiKey_6));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "K7", ImGuiKey_7));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "K8", ImGuiKey_8));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "K9", ImGuiKey_9));
|
||||
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "Tab", ImGuiKey_Tab));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "Enter", ImGuiKey_Enter));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "Escape", ImGuiKey_Escape));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "Backspace", ImGuiKey_Backspace));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "Space", ImGuiKey_Space));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "Delete", ImGuiKey_Delete));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "Insert", ImGuiKey_Insert));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "Home", ImGuiKey_Home));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "End", ImGuiKey_End));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "PageUp", ImGuiKey_PageUp));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "PageDown", ImGuiKey_PageDown));
|
||||
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "Right", ImGuiKey_RightArrow));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "Up", ImGuiKey_UpArrow));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "Down", ImGuiKey_DownArrow));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "Left", ImGuiKey_LeftArrow));
|
||||
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "RightCtrl", ImGuiKey_RightCtrl));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "LeftShift", ImGuiKey_LeftShift));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "RightShift", ImGuiKey_RightShift));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "LeftAlt", ImGuiKey_LeftAlt));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "RightAlt", ImGuiKey_RightAlt));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "LeftSuper", ImGuiKey_LeftSuper));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "RightSuper", ImGuiKey_RightSuper));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "LeftCtrl", ImGuiKey_LeftCtrl));
|
||||
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "MouseLeft", ImGuiKey_MouseLeft));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "MouseRight", ImGuiKey_MouseRight));
|
||||
AS_CHECK(scriptEngine->RegisterEnumValue("key", "MouseMiddle", ImGuiKey_MouseMiddle));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
enum ImGuiKey : int
|
||||
{
|
||||
// Keyboard
|
||||
ImGuiKey_None = 0,
|
||||
ImGuiKey_Tab = 512, // == ImGuiKey_NamedKey_BEGIN
|
||||
ImGuiKey_LeftArrow,
|
||||
ImGuiKey_RightArrow,
|
||||
ImGuiKey_UpArrow,
|
||||
ImGuiKey_DownArrow,
|
||||
ImGuiKey_PageUp,
|
||||
ImGuiKey_PageDown,
|
||||
ImGuiKey_Home,
|
||||
ImGuiKey_End,
|
||||
ImGuiKey_Insert,
|
||||
ImGuiKey_Delete,
|
||||
ImGuiKey_Backspace,
|
||||
ImGuiKey_Space,
|
||||
ImGuiKey_Enter,
|
||||
ImGuiKey_Escape,
|
||||
ImGuiKey_LeftCtrl, ImGuiKey_LeftShift, ImGuiKey_LeftAlt, ImGuiKey_LeftSuper,
|
||||
ImGuiKey_RightCtrl, ImGuiKey_RightShift, ImGuiKey_RightAlt, ImGuiKey_RightSuper,
|
||||
ImGuiKey_Menu,
|
||||
ImGuiKey_0, ImGuiKey_1, ImGuiKey_2, ImGuiKey_3, ImGuiKey_4, ImGuiKey_5, ImGuiKey_6, ImGuiKey_7, ImGuiKey_8, ImGuiKey_9,
|
||||
ImGuiKey_A, ImGuiKey_B, ImGuiKey_C, ImGuiKey_D, ImGuiKey_E, ImGuiKey_F, ImGuiKey_G, ImGuiKey_H, ImGuiKey_I, ImGuiKey_J,
|
||||
ImGuiKey_K, ImGuiKey_L, ImGuiKey_M, ImGuiKey_N, ImGuiKey_O, ImGuiKey_P, ImGuiKey_Q, ImGuiKey_R, ImGuiKey_S, ImGuiKey_T,
|
||||
ImGuiKey_U, ImGuiKey_V, ImGuiKey_W, ImGuiKey_X, ImGuiKey_Y, ImGuiKey_Z,
|
||||
ImGuiKey_F1, ImGuiKey_F2, ImGuiKey_F3, ImGuiKey_F4, ImGuiKey_F5, ImGuiKey_F6,
|
||||
ImGuiKey_F7, ImGuiKey_F8, ImGuiKey_F9, ImGuiKey_F10, ImGuiKey_F11, ImGuiKey_F12,
|
||||
ImGuiKey_Apostrophe, // '
|
||||
ImGuiKey_Comma, // ,
|
||||
ImGuiKey_Minus, // -
|
||||
ImGuiKey_Period, // .
|
||||
ImGuiKey_Slash, // /
|
||||
ImGuiKey_Semicolon, // ;
|
||||
ImGuiKey_Equal, // =
|
||||
ImGuiKey_LeftBracket, // [
|
||||
ImGuiKey_Backslash, // \ (this text inhibit multiline comment caused by backslash)
|
||||
ImGuiKey_RightBracket, // ]
|
||||
ImGuiKey_GraveAccent, // `
|
||||
ImGuiKey_CapsLock,
|
||||
ImGuiKey_ScrollLock,
|
||||
ImGuiKey_NumLock,
|
||||
ImGuiKey_PrintScreen,
|
||||
ImGuiKey_Pause,
|
||||
ImGuiKey_Keypad0, ImGuiKey_Keypad1, ImGuiKey_Keypad2, ImGuiKey_Keypad3, ImGuiKey_Keypad4,
|
||||
ImGuiKey_Keypad5, ImGuiKey_Keypad6, ImGuiKey_Keypad7, ImGuiKey_Keypad8, ImGuiKey_Keypad9,
|
||||
ImGuiKey_KeypadDecimal,
|
||||
ImGuiKey_KeypadDivide,
|
||||
ImGuiKey_KeypadMultiply,
|
||||
ImGuiKey_KeypadSubtract,
|
||||
ImGuiKey_KeypadAdd,
|
||||
ImGuiKey_KeypadEnter,
|
||||
ImGuiKey_KeypadEqual,
|
||||
|
||||
// Gamepad (some of those are analog values, 0.0f to 1.0f) // NAVIGATION ACTION
|
||||
// (download controller mapping PNG/PSD at http://dearimgui.org/controls_sheets)
|
||||
ImGuiKey_GamepadStart, // Menu (Xbox) + (Switch) Start/Options (PS)
|
||||
ImGuiKey_GamepadBack, // View (Xbox) - (Switch) Share (PS)
|
||||
ImGuiKey_GamepadFaceLeft, // X (Xbox) Y (Switch) Square (PS) // Tap: Toggle Menu. Hold: Windowing mode (Focus/Move/Resize windows)
|
||||
ImGuiKey_GamepadFaceRight, // B (Xbox) A (Switch) Circle (PS) // Cancel / Close / Exit
|
||||
ImGuiKey_GamepadFaceUp, // Y (Xbox) X (Switch) Triangle (PS) // Text Input / On-screen Keyboard
|
||||
ImGuiKey_GamepadFaceDown, // A (Xbox) B (Switch) Cross (PS) // Activate / Open / Toggle / Tweak
|
||||
ImGuiKey_GamepadDpadLeft, // D-pad Left // Move / Tweak / Resize Window (in Windowing mode)
|
||||
ImGuiKey_GamepadDpadRight, // D-pad Right // Move / Tweak / Resize Window (in Windowing mode)
|
||||
ImGuiKey_GamepadDpadUp, // D-pad Up // Move / Tweak / Resize Window (in Windowing mode)
|
||||
ImGuiKey_GamepadDpadDown, // D-pad Down // Move / Tweak / Resize Window (in Windowing mode)
|
||||
ImGuiKey_GamepadL1, // L Bumper (Xbox) L (Switch) L1 (PS) // Tweak Slower / Focus Previous (in Windowing mode)
|
||||
ImGuiKey_GamepadR1, // R Bumper (Xbox) R (Switch) R1 (PS) // Tweak Faster / Focus Next (in Windowing mode)
|
||||
ImGuiKey_GamepadL2, // L Trig. (Xbox) ZL (Switch) L2 (PS) [Analog]
|
||||
ImGuiKey_GamepadR2, // R Trig. (Xbox) ZR (Switch) R2 (PS) [Analog]
|
||||
ImGuiKey_GamepadL3, // L Stick (Xbox) L3 (Switch) L3 (PS)
|
||||
ImGuiKey_GamepadR3, // R Stick (Xbox) R3 (Switch) R3 (PS)
|
||||
ImGuiKey_GamepadLStickLeft, // [Analog] // Move Window (in Windowing mode)
|
||||
ImGuiKey_GamepadLStickRight, // [Analog] // Move Window (in Windowing mode)
|
||||
ImGuiKey_GamepadLStickUp, // [Analog] // Move Window (in Windowing mode)
|
||||
ImGuiKey_GamepadLStickDown, // [Analog] // Move Window (in Windowing mode)
|
||||
ImGuiKey_GamepadRStickLeft, // [Analog]
|
||||
ImGuiKey_GamepadRStickRight, // [Analog]
|
||||
ImGuiKey_GamepadRStickUp, // [Analog]
|
||||
ImGuiKey_GamepadRStickDown, // [Analog]
|
||||
|
||||
// Aliases: Mouse Buttons (auto-submitted from AddMouseButtonEvent() calls)
|
||||
// - This is mirroring the data also written to io.MouseDown[], io.MouseWheel, in a format allowing them to be accessed via standard key API.
|
||||
ImGuiKey_MouseLeft, ImGuiKey_MouseRight, ImGuiKey_MouseMiddle, ImGuiKey_MouseX1, ImGuiKey_MouseX2, ImGuiKey_MouseWheelX, ImGuiKey_MouseWheelY,
|
||||
|
||||
// [Internal] Reserved for mod storage
|
||||
ImGuiKey_ReservedForModCtrl, ImGuiKey_ReservedForModShift, ImGuiKey_ReservedForModAlt, ImGuiKey_ReservedForModSuper,
|
||||
ImGuiKey_COUNT,
|
||||
|
||||
// Keyboard Modifiers (explicitly submitted by backend via AddKeyEvent() calls)
|
||||
// - This is mirroring the data also written to io.KeyCtrl, io.KeyShift, io.KeyAlt, io.KeySuper, in a format allowing
|
||||
// them to be accessed via standard key API, allowing calls such as IsKeyPressed(), IsKeyReleased(), querying duration etc.
|
||||
// - Code polling every key (e.g. an interface to detect a key press for input mapping) might want to ignore those
|
||||
// and prefer using the real keys (e.g. ImGuiKey_LeftCtrl, ImGuiKey_RightCtrl instead of ImGuiMod_Ctrl).
|
||||
// - In theory the value of keyboard modifiers should be roughly equivalent to a logical or of the equivalent left/right keys.
|
||||
// In practice: it's complicated; mods are often provided from different sources. Keyboard layout, IME, sticky keys and
|
||||
// backends tend to interfere and break that equivalence. The safer decision is to relay that ambiguity down to the end-user...
|
||||
ImGuiMod_None = 0,
|
||||
ImGuiMod_Ctrl = 1 << 12, // Ctrl
|
||||
ImGuiMod_Shift = 1 << 13, // Shift
|
||||
ImGuiMod_Alt = 1 << 14, // Option/Menu
|
||||
ImGuiMod_Super = 1 << 15, // Cmd/Super/Windows
|
||||
ImGuiMod_Shortcut = 1 << 11, // Alias for Ctrl (non-macOS) _or_ Super (macOS).
|
||||
ImGuiMod_Mask_ = 0xF800, // 5-bits
|
||||
|
||||
// [Internal] Prior to 1.87 we required user to fill io.KeysDown[512] using their own native index + the io.KeyMap[] array.
|
||||
// We are ditching this method but keeping a legacy path for user code doing e.g. IsKeyPressed(MY_NATIVE_KEY_CODE)
|
||||
ImGuiKey_NamedKey_BEGIN = 512,
|
||||
ImGuiKey_NamedKey_END = ImGuiKey_COUNT,
|
||||
ImGuiKey_NamedKey_COUNT = ImGuiKey_NamedKey_END - ImGuiKey_NamedKey_BEGIN,
|
||||
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||
ImGuiKey_KeysData_SIZE = ImGuiKey_NamedKey_COUNT, // Size of KeysData[]: only hold named keys
|
||||
ImGuiKey_KeysData_OFFSET = ImGuiKey_NamedKey_BEGIN, // First key stored in io.KeysData[0]. Accesses to io.KeysData[] must use (key - ImGuiKey_KeysData_OFFSET).
|
||||
#else
|
||||
ImGuiKey_KeysData_SIZE = ImGuiKey_COUNT, // Size of KeysData[]: hold legacy 0..512 keycodes + named keys
|
||||
ImGuiKey_KeysData_OFFSET = 0, // First key stored in io.KeysData[0]. Accesses to io.KeysData[] must use (key - ImGuiKey_KeysData_OFFSET).
|
||||
#endif
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
ImGuiKey_ModCtrl = ImGuiMod_Ctrl, ImGuiKey_ModShift = ImGuiMod_Shift, ImGuiKey_ModAlt = ImGuiMod_Alt, ImGuiKey_ModSuper = ImGuiMod_Super, // Renamed in 1.89
|
||||
ImGuiKey_KeyPadEnter = ImGuiKey_KeypadEnter, // Renamed in 1.87
|
||||
#endif
|
||||
}*/
|
@ -46,7 +46,6 @@ namespace Deer {
|
||||
return;
|
||||
}
|
||||
|
||||
tickFunction = type->GetMethodByDecl("void onTick()");
|
||||
menuBarFunction = type->GetMethodByDecl("void onMenuBar()");
|
||||
initFunction = type->GetMethodByDecl("void onInit()");
|
||||
|
||||
@ -84,6 +83,11 @@ namespace Deer {
|
||||
}
|
||||
|
||||
void EditorEngine::DockPanelObject::executeRender() {
|
||||
// We cache the result because the user can remove the flag while executing
|
||||
bool hasPadding = flags & DockPannelFlag_PannelPadding;
|
||||
if (hasPadding)
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||
|
||||
if (menuBarFunction) {
|
||||
ImGui::Begin(type->GetName(), (bool*)0, ImGuiWindowFlags_MenuBar);
|
||||
|
||||
@ -109,6 +113,11 @@ namespace Deer {
|
||||
ImGui::Begin(type->GetName());
|
||||
}
|
||||
|
||||
// This is to make sure that right click activates the window
|
||||
if (ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) &&
|
||||
(ImGui::IsMouseClicked(ImGuiMouseButton_Right) || ImGui::IsMouseClicked(ImGuiMouseButton_Middle))) {
|
||||
ImGui::SetWindowFocus();
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
ImGui::TextColored(ImVec4(1, 0.3f, 0.3f, 1), "There was a runtime error");
|
||||
@ -134,34 +143,13 @@ namespace Deer {
|
||||
);
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void EditorEngine::DockPanelObject::tickExecution() {
|
||||
if (!isValid)
|
||||
return;
|
||||
|
||||
if (!tickFunction)
|
||||
return;
|
||||
|
||||
AS_CHECK_ADDITIONAL_INFO(
|
||||
scriptContext->Prepare(tickFunction),
|
||||
type->GetName()
|
||||
);
|
||||
|
||||
AS_CHECK_ADDITIONAL_INFO(
|
||||
scriptContext->SetObject(object),
|
||||
type->GetName()
|
||||
);
|
||||
|
||||
AS_CHECK_ADDITIONAL_INFO(
|
||||
scriptContext->Execute(),
|
||||
type->GetName()
|
||||
);
|
||||
|
||||
if (hasPadding)
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
EditorEngine::DockPanelObject::DockPanelObject(DockPanelObject&& other) noexcept
|
||||
: isValid(other.isValid), renderFunction(other.renderFunction), type(other.type), object(other.object), menuBarFunction(other.menuBarFunction), initFunction(other.initFunction), tickFunction(other.tickFunction) {
|
||||
: isValid(other.isValid), renderFunction(other.renderFunction), type(other.type), object(other.object), menuBarFunction(other.menuBarFunction), initFunction(other.initFunction) {
|
||||
|
||||
other.isValid = false;
|
||||
other.renderFunction = nullptr;
|
||||
@ -169,7 +157,6 @@ namespace Deer {
|
||||
other.object = nullptr;
|
||||
other.menuBarFunction = nullptr;
|
||||
other.initFunction = nullptr;
|
||||
other.tickFunction = nullptr;
|
||||
}
|
||||
|
||||
EditorEngine::DockPanelObject& EditorEngine::DockPanelObject::operator=(EditorEngine::DockPanelObject&& other) noexcept {
|
||||
@ -180,7 +167,6 @@ namespace Deer {
|
||||
object = other.object;
|
||||
menuBarFunction = other.menuBarFunction;
|
||||
initFunction = other.initFunction;
|
||||
tickFunction = other.tickFunction;
|
||||
|
||||
other.isValid = false;
|
||||
other.renderFunction = nullptr;
|
||||
@ -188,7 +174,6 @@ namespace Deer {
|
||||
other.object = nullptr;
|
||||
other.menuBarFunction = nullptr;
|
||||
other.initFunction = nullptr;
|
||||
other.tickFunction = nullptr;
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
@ -1,4 +1,6 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
class asITypeInfo;
|
||||
class asIScriptObject;
|
||||
class asIScriptFunction;
|
||||
@ -10,7 +12,6 @@ namespace Deer {
|
||||
asITypeInfo* type = nullptr;
|
||||
asIScriptObject* object = nullptr;
|
||||
asIScriptFunction* renderFunction = nullptr;
|
||||
asIScriptFunction* tickFunction = nullptr;
|
||||
asIScriptFunction* menuBarFunction = nullptr;
|
||||
asIScriptFunction* initFunction = nullptr;
|
||||
bool isValid = false;
|
||||
@ -24,11 +25,16 @@ namespace Deer {
|
||||
|
||||
DockPanelObject(DockPanelObject&& other) noexcept;
|
||||
DockPanelObject& operator=(DockPanelObject&& other) noexcept;
|
||||
|
||||
uint32_t flags = 0;
|
||||
|
||||
void executeRender();
|
||||
void tickExecution();
|
||||
void invalidate();
|
||||
void init();
|
||||
};
|
||||
}
|
||||
|
||||
enum DockPannelFlags {
|
||||
DockPannelFlag_PannelPadding = 1 << 0
|
||||
};
|
||||
}
|
@ -54,8 +54,10 @@ namespace Deer {
|
||||
active = true;
|
||||
|
||||
for (auto& pannel : dockPanels) {
|
||||
currentDockPanelExecution = &pannel;
|
||||
pannel.init();
|
||||
}
|
||||
currentDockPanelExecution = nullptr;
|
||||
}
|
||||
|
||||
void EditorEngine::deinitialize() {
|
||||
@ -83,15 +85,4 @@ namespace Deer {
|
||||
}
|
||||
currentDockPanelExecution = nullptr;
|
||||
}
|
||||
|
||||
void EditorEngine::tick() {
|
||||
if (!active)
|
||||
return;
|
||||
|
||||
for (auto& panel : dockPanels) {
|
||||
currentDockPanelExecution = &panel;
|
||||
panel.tickExecution();
|
||||
}
|
||||
currentDockPanelExecution = nullptr;
|
||||
}
|
||||
}
|
84
roe/Editor/Viewport.as
Normal file
84
roe/Editor/Viewport.as
Normal file
@ -0,0 +1,84 @@
|
||||
class ViewportPannel : DockPanel {
|
||||
FrameBuffer frameBuffer;
|
||||
SceneCamera sceneCamera;
|
||||
Environment mainEnv;
|
||||
|
||||
float pitch = 0;
|
||||
float yaw = 0;
|
||||
float vel = 0.02f;
|
||||
|
||||
void onRender() {
|
||||
if (!frameBuffer.isValid())
|
||||
return;
|
||||
|
||||
int x = UI::getAvailableSizeX();
|
||||
int y = UI::getAvailableSizeY();
|
||||
frameBuffer.resize(x, y);
|
||||
frameBuffer.clearRGBA(0, 0, 0, 255);
|
||||
|
||||
sceneCamera.camera.aspect = float(x) / y;
|
||||
mainEnv.render(frameBuffer, sceneCamera);
|
||||
|
||||
UI::drawFrameBufferCentered(frameBuffer, x, y);
|
||||
|
||||
if (!UI::isPannelActive())
|
||||
return;
|
||||
|
||||
if (UI::isMouseDraggin(key::MouseRight) && !UI::isKeyDown(key::MouseMiddle)) {
|
||||
pitch += UI::getMouseDeltaY() * 0.1f;
|
||||
yaw += UI::getMouseDeltaX() * 0.1f;
|
||||
|
||||
sceneCamera.transform.rotation.setEuler(vec3(pitch, yaw, 0));
|
||||
}
|
||||
|
||||
if (UI::isMouseDraggin(key::MouseMiddle) && !UI::isKeyDown(key::MouseRight)) {
|
||||
vec3 panDir = vec3();
|
||||
|
||||
panDir.x -= UI::getMouseDeltaX();
|
||||
panDir.y += UI::getMouseDeltaY();
|
||||
|
||||
panDir = panDir * vel * 0.4f;
|
||||
sceneCamera.transform.position = sceneCamera.transform.relative(panDir);
|
||||
}
|
||||
|
||||
|
||||
vec3 relDir = vec3();
|
||||
|
||||
if (UI::isKeyDown(key::W))
|
||||
relDir.z++;
|
||||
if (UI::isKeyDown(key::S))
|
||||
relDir.z--;
|
||||
|
||||
if (UI::isKeyDown(key::D))
|
||||
relDir.x++;
|
||||
if (UI::isKeyDown(key::A))
|
||||
relDir.x--;
|
||||
|
||||
relDir = relDir * vel;
|
||||
sceneCamera.transform.position = sceneCamera.transform.relative(relDir);
|
||||
|
||||
float vertically = 0;
|
||||
if (UI::isKeyDown(key::Space))
|
||||
vertically++;
|
||||
if (UI::isKeyDown(key::LeftCtrl))
|
||||
vertically--;
|
||||
|
||||
sceneCamera.transform.position = sceneCamera.transform.position + vec3(0, vertically * vel, 0);
|
||||
}
|
||||
|
||||
void onInit() {
|
||||
frameBuffer = Engine::createRGBA8FrameBuffer("MainFrameBuffer", 400, 400);
|
||||
mainEnv = Engine::getMainEnvironment();
|
||||
|
||||
sceneCamera.transform.position = vec3(0, 1, -2);
|
||||
UI::disablePannelPadding(true);
|
||||
}
|
||||
|
||||
void onMenuBar() {
|
||||
if (UI::menuItem("Start")) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,20 @@ funcdef void ReciverFunc(any@ value);
|
||||
funcdef void TransferFunc(any@ from, any@ data);
|
||||
|
||||
|
||||
enum key
|
||||
{
|
||||
None = 0,
|
||||
A, B, C, D, E, F, G, H, I, J, K, L, M,
|
||||
N, O, P, Q, R, S, T, U, V, W, X, Y, Z,
|
||||
K0, K1, K2, K3, K4, K5, K6, K7, K8, K9,
|
||||
Tab, Enter, Escape, Backspace, Space, Delete, Insert, Home, End, PageUp, PageDown,
|
||||
Right, Up, Down, Left,
|
||||
RightCtrl, LeftShift, RightShift,
|
||||
LeftAlt, RightAlt, LeftSuper,
|
||||
RightSuper, LeftCtrl,
|
||||
MouseLeft,MouseRight,MouseMiddle
|
||||
};
|
||||
|
||||
//This file was generated automatically
|
||||
enum ResourceType {
|
||||
Mesh = 1,
|
||||
@ -214,6 +228,7 @@ class vec3 {
|
||||
vec3 opNeg() const;
|
||||
// Multiply by scalar
|
||||
vec3 opMul(float) const;
|
||||
vec3 opMul_r(float) const;
|
||||
|
||||
float x;
|
||||
float y;
|
||||
@ -292,6 +307,8 @@ class Environment {
|
||||
class DockPanel {
|
||||
// Called to render the dock panel UI
|
||||
void onRender();
|
||||
void onInit();
|
||||
void onMenuBar();
|
||||
}
|
||||
|
||||
|
||||
@ -474,4 +491,15 @@ namespace UI {
|
||||
|
||||
bool isPannelActive();
|
||||
|
||||
bool isKeyDown(key);
|
||||
bool isKeyPressed(key);
|
||||
|
||||
bool isMouseDraggin(key);
|
||||
float getMouseDragDeltaX();
|
||||
float getMouseDragDeltaY();
|
||||
float getMouseDeltaX();
|
||||
float getMouseDeltaY();
|
||||
int getAvailableSizeX();
|
||||
int getAvailableSizeY();
|
||||
void disablePannelPadding(bool)
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
class Test : DockPanel {
|
||||
FrameBuffer frameBuffer;
|
||||
SceneCamera sceneCamera;
|
||||
Environment mainEnv;
|
||||
|
||||
void onRender() {
|
||||
if (!frameBuffer.isValid())
|
||||
return;
|
||||
|
||||
UI::text("Works");
|
||||
|
||||
frameBuffer.clearRGBA(0, 0, 0, 255);
|
||||
|
||||
mainEnv.render(frameBuffer, sceneCamera);
|
||||
UI::drawFrameBufferCentered(frameBuffer, 400, 400);
|
||||
}
|
||||
|
||||
void onTick() {
|
||||
vec3 newPos = sceneCamera.transform.relative(vec3(0, 0, 0.01f));
|
||||
sceneCamera.transform.position = newPos;
|
||||
}
|
||||
|
||||
void onInit() {
|
||||
frameBuffer = Engine::createRGBA8FrameBuffer("MainFrameBuffer", 400, 400);
|
||||
mainEnv = Engine::getMainEnvironment();
|
||||
|
||||
sceneCamera.transform.position = vec3(0, 1, -2);
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,8 @@ Collapsed=0
|
||||
DockId=0x00000004,1
|
||||
|
||||
[Window][Game Window]
|
||||
Pos=365,24
|
||||
Size=521,504
|
||||
Pos=318,24
|
||||
Size=600,472
|
||||
Collapsed=0
|
||||
DockId=0x00000006,0
|
||||
|
||||
@ -27,14 +27,14 @@ Collapsed=0
|
||||
DockId=0x00000001,0
|
||||
|
||||
[Window][Terrain Editor]
|
||||
Pos=888,24
|
||||
Size=392,504
|
||||
Pos=920,24
|
||||
Size=360,472
|
||||
Collapsed=0
|
||||
DockId=0x00000004,0
|
||||
|
||||
[Window][Viewport]
|
||||
Pos=365,24
|
||||
Size=521,504
|
||||
Pos=318,24
|
||||
Size=600,472
|
||||
Collapsed=0
|
||||
DockId=0x00000006,1
|
||||
|
||||
@ -57,14 +57,14 @@ Collapsed=0
|
||||
DockId=0x00000008,1
|
||||
|
||||
[Window][MeshExplorer]
|
||||
Pos=0,530
|
||||
Size=1280,190
|
||||
Pos=0,498
|
||||
Size=1280,222
|
||||
Collapsed=0
|
||||
DockId=0x00000008,0
|
||||
|
||||
[Window][TreePannel]
|
||||
Pos=0,24
|
||||
Size=363,504
|
||||
Size=316,472
|
||||
Collapsed=0
|
||||
DockId=0x00000005,0
|
||||
|
||||
@ -79,8 +79,8 @@ Size=351,75
|
||||
Collapsed=0
|
||||
|
||||
[Window][PropertiesPannel]
|
||||
Pos=888,24
|
||||
Size=392,504
|
||||
Pos=920,24
|
||||
Size=360,472
|
||||
Collapsed=0
|
||||
DockId=0x00000004,1
|
||||
|
||||
@ -91,25 +91,31 @@ Collapsed=0
|
||||
DockId=0x00000004,1
|
||||
|
||||
[Window][ShaderExplorer]
|
||||
Pos=0,530
|
||||
Size=1280,190
|
||||
Pos=0,498
|
||||
Size=1280,222
|
||||
Collapsed=0
|
||||
DockId=0x00000008,1
|
||||
|
||||
[Window][Test]
|
||||
Pos=365,24
|
||||
Size=521,504
|
||||
Pos=398,24
|
||||
Size=612,549
|
||||
Collapsed=0
|
||||
DockId=0x00000006,2
|
||||
|
||||
[Window][ViewportPannel]
|
||||
Pos=318,24
|
||||
Size=600,472
|
||||
Collapsed=0
|
||||
DockId=0x00000006,2
|
||||
|
||||
[Docking][Data]
|
||||
DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=1280,696 Split=Y
|
||||
DockNode ID=0x00000007 Parent=0xA1672E74 SizeRef=1280,504 Split=Y
|
||||
DockNode ID=0x00000007 Parent=0xA1672E74 SizeRef=1280,472 Split=Y
|
||||
DockNode ID=0x00000001 Parent=0x00000007 SizeRef=2560,363 Split=X Selected=0x13926F0B
|
||||
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=886,338 Split=X Selected=0x13926F0B
|
||||
DockNode ID=0x00000005 Parent=0x00000003 SizeRef=363,446 Selected=0xE45B9F93
|
||||
DockNode ID=0x00000006 Parent=0x00000003 SizeRef=521,446 CentralNode=1 Selected=0x44A6A033
|
||||
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=392,338 Selected=0xA35A27E3
|
||||
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=918,338 Split=X Selected=0x13926F0B
|
||||
DockNode ID=0x00000005 Parent=0x00000003 SizeRef=316,446 Selected=0xE45B9F93
|
||||
DockNode ID=0x00000006 Parent=0x00000003 SizeRef=600,446 CentralNode=1 Selected=0x34A4C10F
|
||||
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=360,338 Selected=0xA35A27E3
|
||||
DockNode ID=0x00000002 Parent=0x00000007 SizeRef=2560,331 Selected=0xCF339702
|
||||
DockNode ID=0x00000008 Parent=0xA1672E74 SizeRef=1280,190 Selected=0xD962995A
|
||||
DockNode ID=0x00000008 Parent=0xA1672E74 SizeRef=1280,222 Selected=0xD962995A
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user