Camera working
This commit is contained in:
parent
fc169a2c91
commit
ed82f40492
@ -80,6 +80,8 @@ namespace Deer {
|
|||||||
|
|
||||||
if (VoxelWorld::isInitialized())
|
if (VoxelWorld::isInitialized())
|
||||||
VoxelWorld::bakeNextChunk();
|
VoxelWorld::bakeNextChunk();
|
||||||
|
|
||||||
|
EditorEngine::tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeerStudioApplication::onEvent(Event& e) {
|
void DeerStudioApplication::onEvent(Event& e) {
|
||||||
@ -132,7 +134,7 @@ namespace Deer {
|
|||||||
// ---- PanelS -----
|
// ---- PanelS -----
|
||||||
TerrainEditor::onImGui();
|
TerrainEditor::onImGui();
|
||||||
viewport_onImGui();
|
viewport_onImGui();
|
||||||
EditorEngine::execute();
|
EditorEngine::render();
|
||||||
// ---- PanelS -----
|
// ---- PanelS -----
|
||||||
Scene::gizmoRenderer.refresh();
|
Scene::gizmoRenderer.refresh();
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
@ -14,7 +14,8 @@ namespace Deer {
|
|||||||
void initialize();
|
void initialize();
|
||||||
void deinitialize();
|
void deinitialize();
|
||||||
|
|
||||||
void execute();
|
void render();
|
||||||
|
void tick();
|
||||||
|
|
||||||
extern asIScriptEngine* scriptEngine;
|
extern asIScriptEngine* scriptEngine;
|
||||||
extern asIScriptModule* scriptModule;
|
extern asIScriptModule* scriptModule;
|
||||||
|
@ -29,6 +29,8 @@ namespace Deer {
|
|||||||
void camera_construct(CameraComponent*);
|
void camera_construct(CameraComponent*);
|
||||||
void sceneCamera_Construct(SceneCamera*);
|
void sceneCamera_Construct(SceneCamera*);
|
||||||
|
|
||||||
|
glm::vec3 transform_relative(glm::vec3, TransformComponent*);
|
||||||
|
|
||||||
void emptyDestructor();
|
void emptyDestructor();
|
||||||
|
|
||||||
void registerMathStructs();
|
void registerMathStructs();
|
||||||
|
@ -80,6 +80,8 @@ namespace Deer {
|
|||||||
float magicSlider(std::string&, float, float);
|
float magicSlider(std::string&, float, float);
|
||||||
// Draws a complex slider that with double click you can set a specific value in vec3
|
// Draws a complex slider that with double click you can set a specific value in vec3
|
||||||
glm::vec3 magicSlider3(std::string&, glm::vec3, float);
|
glm::vec3 magicSlider3(std::string&, glm::vec3, float);
|
||||||
|
// Returns if the current executing pannel is active
|
||||||
|
bool isPannelActive();
|
||||||
|
|
||||||
void registerUIFunctions();
|
void registerUIFunctions();
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,10 @@ namespace Deer {
|
|||||||
return *mem * *data;
|
return *mem * *data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::vec3 transform_relative(glm::vec3 pos, TransformComponent* transform) {
|
||||||
|
return transform->getMatrix() * glm::vec4(pos, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
void transform_construct(TransformComponent* mem) {
|
void transform_construct(TransformComponent* mem) {
|
||||||
new (mem) TransformComponent();
|
new (mem) TransformComponent();
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ namespace Deer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void registerMathFunctions() {
|
void registerMathFunctions() {
|
||||||
REGISTER_EXT_OBJECT_METHOD("vec3", "vec3 opAdds(const vec3 &in)", vec3_add);
|
REGISTER_EXT_OBJECT_METHOD("vec3", "vec3 opAdd(const vec3 &in)", vec3_add);
|
||||||
REGISTER_EXT_OBJECT_METHOD("vec3", "vec3 opSub(const vec3 &in) const", vec3_sub);
|
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 opNeg() const", vec3_neg);
|
||||||
REGISTER_EXT_OBJECT_METHOD("vec3", "vec3 opMul(float) const", vec3_mult);
|
REGISTER_EXT_OBJECT_METHOD("vec3", "vec3 opMul(float) const", vec3_mult);
|
||||||
@ -80,6 +80,8 @@ namespace Deer {
|
|||||||
REGISTER_EXT_OBJECT_CONSTRUCTOR("Transform", "void f()", transform_construct);
|
REGISTER_EXT_OBJECT_CONSTRUCTOR("Transform", "void f()", transform_construct);
|
||||||
REGISTER_EXT_OBJECT_CONSTRUCTOR("Camera", "void f()", camera_construct);
|
REGISTER_EXT_OBJECT_CONSTRUCTOR("Camera", "void f()", camera_construct);
|
||||||
REGISTER_EXT_OBJECT_CONSTRUCTOR("SceneCamera", "void f()", sceneCamera_Construct);
|
REGISTER_EXT_OBJECT_CONSTRUCTOR("SceneCamera", "void f()", sceneCamera_Construct);
|
||||||
|
|
||||||
|
REGISTER_EXT_OBJECT_METHOD("Transform", "vec3 relative(vec3)", transform_relative);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -46,6 +46,7 @@ namespace Deer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tickFunction = type->GetMethodByDecl("void onTick()");
|
||||||
menuBarFunction = type->GetMethodByDecl("void onMenuBar()");
|
menuBarFunction = type->GetMethodByDecl("void onMenuBar()");
|
||||||
initFunction = type->GetMethodByDecl("void onInit()");
|
initFunction = type->GetMethodByDecl("void onInit()");
|
||||||
|
|
||||||
@ -135,8 +136,32 @@ namespace Deer {
|
|||||||
ImGui::End();
|
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()
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
EditorEngine::DockPanelObject::DockPanelObject(DockPanelObject&& other) noexcept
|
EditorEngine::DockPanelObject::DockPanelObject(DockPanelObject&& other) noexcept
|
||||||
: isValid(other.isValid), renderFunction(other.renderFunction), type(other.type), object(other.object), menuBarFunction(other.menuBarFunction), initFunction(other.initFunction) {
|
: isValid(other.isValid), renderFunction(other.renderFunction), type(other.type), object(other.object), menuBarFunction(other.menuBarFunction), initFunction(other.initFunction), tickFunction(other.tickFunction) {
|
||||||
|
|
||||||
other.isValid = false;
|
other.isValid = false;
|
||||||
other.renderFunction = nullptr;
|
other.renderFunction = nullptr;
|
||||||
@ -144,6 +169,7 @@ namespace Deer {
|
|||||||
other.object = nullptr;
|
other.object = nullptr;
|
||||||
other.menuBarFunction = nullptr;
|
other.menuBarFunction = nullptr;
|
||||||
other.initFunction = nullptr;
|
other.initFunction = nullptr;
|
||||||
|
other.tickFunction = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorEngine::DockPanelObject& EditorEngine::DockPanelObject::operator=(EditorEngine::DockPanelObject&& other) noexcept {
|
EditorEngine::DockPanelObject& EditorEngine::DockPanelObject::operator=(EditorEngine::DockPanelObject&& other) noexcept {
|
||||||
@ -154,6 +180,7 @@ namespace Deer {
|
|||||||
object = other.object;
|
object = other.object;
|
||||||
menuBarFunction = other.menuBarFunction;
|
menuBarFunction = other.menuBarFunction;
|
||||||
initFunction = other.initFunction;
|
initFunction = other.initFunction;
|
||||||
|
tickFunction = other.tickFunction;
|
||||||
|
|
||||||
other.isValid = false;
|
other.isValid = false;
|
||||||
other.renderFunction = nullptr;
|
other.renderFunction = nullptr;
|
||||||
@ -161,6 +188,7 @@ namespace Deer {
|
|||||||
other.object = nullptr;
|
other.object = nullptr;
|
||||||
other.menuBarFunction = nullptr;
|
other.menuBarFunction = nullptr;
|
||||||
other.initFunction = nullptr;
|
other.initFunction = nullptr;
|
||||||
|
other.tickFunction = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -10,6 +10,7 @@ namespace Deer {
|
|||||||
asITypeInfo* type = nullptr;
|
asITypeInfo* type = nullptr;
|
||||||
asIScriptObject* object = nullptr;
|
asIScriptObject* object = nullptr;
|
||||||
asIScriptFunction* renderFunction = nullptr;
|
asIScriptFunction* renderFunction = nullptr;
|
||||||
|
asIScriptFunction* tickFunction = nullptr;
|
||||||
asIScriptFunction* menuBarFunction = nullptr;
|
asIScriptFunction* menuBarFunction = nullptr;
|
||||||
asIScriptFunction* initFunction = nullptr;
|
asIScriptFunction* initFunction = nullptr;
|
||||||
bool isValid = false;
|
bool isValid = false;
|
||||||
@ -25,6 +26,7 @@ namespace Deer {
|
|||||||
DockPanelObject& operator=(DockPanelObject&& other) noexcept;
|
DockPanelObject& operator=(DockPanelObject&& other) noexcept;
|
||||||
|
|
||||||
void executeRender();
|
void executeRender();
|
||||||
|
void tickExecution();
|
||||||
void invalidate();
|
void invalidate();
|
||||||
void init();
|
void init();
|
||||||
};
|
};
|
||||||
|
@ -73,7 +73,7 @@ namespace Deer {
|
|||||||
active = false;
|
active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorEngine::execute() {
|
void EditorEngine::render() {
|
||||||
if (!active)
|
if (!active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -83,4 +83,15 @@ namespace Deer {
|
|||||||
}
|
}
|
||||||
currentDockPanelExecution = nullptr;
|
currentDockPanelExecution = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorEngine::tick() {
|
||||||
|
if (!active)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (auto& panel : dockPanels) {
|
||||||
|
currentDockPanelExecution = &panel;
|
||||||
|
panel.tickExecution();
|
||||||
|
}
|
||||||
|
currentDockPanelExecution = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
@ -151,6 +151,7 @@ class TransformComponent {
|
|||||||
// Gets/sets rotation vector (Euler angles)
|
// Gets/sets rotation vector (Euler angles)
|
||||||
vec3 get_rotation() const property;
|
vec3 get_rotation() const property;
|
||||||
void set_rotation(const vec3) property;
|
void set_rotation(const vec3) property;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MeshComponent {
|
class MeshComponent {
|
||||||
@ -206,7 +207,7 @@ class vec3 {
|
|||||||
vec3(float, float = 0, float = 0);
|
vec3(float, float = 0, float = 0);
|
||||||
|
|
||||||
// Vector addition
|
// Vector addition
|
||||||
vec3 opAdds(const vec3&in);
|
vec3 opAdd(const vec3&in);
|
||||||
// Vector subtraction
|
// Vector subtraction
|
||||||
vec3 opSub(const vec3&in) const;
|
vec3 opSub(const vec3&in) const;
|
||||||
// Negation
|
// Negation
|
||||||
@ -244,6 +245,9 @@ class Transform {
|
|||||||
vec3 position;
|
vec3 position;
|
||||||
vec3 scale;
|
vec3 scale;
|
||||||
quat rotation;
|
quat rotation;
|
||||||
|
|
||||||
|
// Returns a vec3 relative to the transform
|
||||||
|
vec3 relative(vec3);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Camera {
|
class Camera {
|
||||||
@ -468,4 +472,6 @@ namespace UI {
|
|||||||
// Draw a title aligned to the end
|
// Draw a title aligned to the end
|
||||||
void titleEnd(const string& in txt);
|
void titleEnd(const string& in txt);
|
||||||
|
|
||||||
|
bool isPannelActive();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,12 @@ class Test : DockPanel {
|
|||||||
UI::drawFrameBufferCentered(frameBuffer, 400, 400);
|
UI::drawFrameBufferCentered(frameBuffer, 400, 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onTick() {
|
||||||
|
vec3 newPos = sceneCamera.transform.relative(vec3(0, 0, 0.01f));
|
||||||
|
sceneCamera.transform.position = newPos;
|
||||||
|
}
|
||||||
|
|
||||||
void onInit() {
|
void onInit() {
|
||||||
|
|
||||||
Engine::print("hi!!");
|
|
||||||
|
|
||||||
frameBuffer = Engine::createRGBA8FrameBuffer("MainFrameBuffer", 400, 400);
|
frameBuffer = Engine::createRGBA8FrameBuffer("MainFrameBuffer", 400, 400);
|
||||||
mainEnv = Engine::getMainEnvironment();
|
mainEnv = Engine::getMainEnvironment();
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ DockId=0x00000004,1
|
|||||||
|
|
||||||
[Window][Game Window]
|
[Window][Game Window]
|
||||||
Pos=365,24
|
Pos=365,24
|
||||||
Size=741,395
|
Size=521,504
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000006,0
|
DockId=0x00000006,0
|
||||||
|
|
||||||
@ -27,14 +27,14 @@ Collapsed=0
|
|||||||
DockId=0x00000001,0
|
DockId=0x00000001,0
|
||||||
|
|
||||||
[Window][Terrain Editor]
|
[Window][Terrain Editor]
|
||||||
Pos=1108,24
|
Pos=888,24
|
||||||
Size=172,395
|
Size=392,504
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000004,0
|
DockId=0x00000004,0
|
||||||
|
|
||||||
[Window][Viewport]
|
[Window][Viewport]
|
||||||
Pos=365,24
|
Pos=365,24
|
||||||
Size=741,395
|
Size=521,504
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000006,1
|
DockId=0x00000006,1
|
||||||
|
|
||||||
@ -57,14 +57,14 @@ Collapsed=0
|
|||||||
DockId=0x00000008,1
|
DockId=0x00000008,1
|
||||||
|
|
||||||
[Window][MeshExplorer]
|
[Window][MeshExplorer]
|
||||||
Pos=0,421
|
Pos=0,530
|
||||||
Size=1280,299
|
Size=1280,190
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000008,0
|
DockId=0x00000008,0
|
||||||
|
|
||||||
[Window][TreePannel]
|
[Window][TreePannel]
|
||||||
Pos=0,24
|
Pos=0,24
|
||||||
Size=363,395
|
Size=363,504
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000005,0
|
DockId=0x00000005,0
|
||||||
|
|
||||||
@ -79,8 +79,8 @@ Size=351,75
|
|||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][PropertiesPannel]
|
[Window][PropertiesPannel]
|
||||||
Pos=1108,24
|
Pos=888,24
|
||||||
Size=172,395
|
Size=392,504
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000004,1
|
DockId=0x00000004,1
|
||||||
|
|
||||||
@ -91,25 +91,25 @@ Collapsed=0
|
|||||||
DockId=0x00000004,1
|
DockId=0x00000004,1
|
||||||
|
|
||||||
[Window][ShaderExplorer]
|
[Window][ShaderExplorer]
|
||||||
Pos=0,421
|
Pos=0,530
|
||||||
Size=1280,299
|
Size=1280,190
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000008,1
|
DockId=0x00000008,1
|
||||||
|
|
||||||
[Window][Test]
|
[Window][Test]
|
||||||
Pos=365,24
|
Pos=365,24
|
||||||
Size=741,395
|
Size=521,504
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000006,2
|
DockId=0x00000006,2
|
||||||
|
|
||||||
[Docking][Data]
|
[Docking][Data]
|
||||||
DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=1280,696 Split=Y
|
DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=1280,696 Split=Y
|
||||||
DockNode ID=0x00000007 Parent=0xA1672E74 SizeRef=1280,395 Split=Y
|
DockNode ID=0x00000007 Parent=0xA1672E74 SizeRef=1280,504 Split=Y
|
||||||
DockNode ID=0x00000001 Parent=0x00000007 SizeRef=2560,363 Split=X Selected=0x13926F0B
|
DockNode ID=0x00000001 Parent=0x00000007 SizeRef=2560,363 Split=X Selected=0x13926F0B
|
||||||
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=1106,338 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=0x00000005 Parent=0x00000003 SizeRef=363,446 Selected=0xE45B9F93
|
||||||
DockNode ID=0x00000006 Parent=0x00000003 SizeRef=741,446 CentralNode=1 Selected=0x44A6A033
|
DockNode ID=0x00000006 Parent=0x00000003 SizeRef=521,446 CentralNode=1 Selected=0x44A6A033
|
||||||
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=172,338 Selected=0xA35A27E3
|
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=392,338 Selected=0xA35A27E3
|
||||||
DockNode ID=0x00000002 Parent=0x00000007 SizeRef=2560,331 Selected=0xCF339702
|
DockNode ID=0x00000002 Parent=0x00000007 SizeRef=2560,331 Selected=0xCF339702
|
||||||
DockNode ID=0x00000008 Parent=0xA1672E74 SizeRef=1280,299 Selected=0xD962995A
|
DockNode ID=0x00000008 Parent=0xA1672E74 SizeRef=1280,190 Selected=0xD962995A
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user