Skip to content

Commit

Permalink
#123 Handles cancel (Key ESC), begin code for handle rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
ducphamhong committed May 23, 2021
1 parent 8530117 commit c1be61c
Show file tree
Hide file tree
Showing 7 changed files with 229 additions and 112 deletions.
47 changes: 43 additions & 4 deletions Projects/Editor/Source/Editor/Space/Scene/CSpaceScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,17 @@ namespace Skylicht
initDefaultScene();

GUI::CBase* panel = m_window->getInnerPanel();

panel->OnRender = BIND_LISTENER(&CSpaceScene::onRender, this);
panel->OnMouseMoved = std::bind(&CSpaceScene::onMouseMoved, this, _1, _2, _3, _4, _5);
panel->OnLeftMouseClick = std::bind(&CSpaceScene::onLeftMouseClick, this, _1, _2, _3, _4);
panel->OnRightMouseClick = std::bind(&CSpaceScene::onRightMouseClick, this, _1, _2, _3, _4);
panel->OnMiddleMouseClick = std::bind(&CSpaceScene::onMiddleMouseClick, this, _1, _2, _3, _4);
panel->OnMouseWheeled = std::bind(&CSpaceScene::onMouseWheeled, this, _1, _2);

panel->setKeyboardInputEnabled(true);
panel->OnKeyPress = std::bind(&CSpaceScene::onKeyPressed, this, _1, _2, _3);
panel->OnChar = std::bind(&CSpaceScene::onChar, this, _1, _2);

m_3dPanel = panel;

GUI::SDimension size = window->getSize();
Expand Down Expand Up @@ -205,10 +208,25 @@ namespace Skylicht
void CSpaceScene::update()
{
// test handles
static core::vector3df drag;
static core::vector3df pos;
static core::quaternion rot;

CHandles* handle = CHandles::getInstance();
drag = handle->positionHandle(drag);

// test handle position
pos = handle->positionHandle(pos);
if (handle->endCheck())
{
os::Printer::log("Handles changed!");
}

/*
rot = handle->rotateHandle(rot, pos);
if (handle->endCheck())
{
os::Printer::log("Handles changed!");
}
*/

m_viewpointController->update();
m_scene->update();
Expand All @@ -234,7 +252,7 @@ namespace Skylicht
// draw scene
m_scene->setVisibleAllZone(true);
m_viewpointZone->setVisible(false);

m_handlesRenderer->setEnable(true);
m_handlesRenderer->setCameraAndViewport(m_editorCamera, viewport);

Expand Down Expand Up @@ -418,6 +436,27 @@ namespace Skylicht
m_scene->OnEvent(event);
}

void CSpaceScene::onChar(GUI::CBase* base, u32 c)
{

}

void CSpaceScene::onKeyPressed(GUI::CBase* base, int key, bool down)
{
GUI::CInput* input = GUI::CInput::getInput();

SEvent event;
event.EventType = EET_KEY_INPUT_EVENT;
event.KeyInput.Key = (irr::EKEY_CODE)key;
event.KeyInput.PressedDown = down;
event.KeyInput.Control = input->IsControlDown();
event.KeyInput.Shift = input->IsShiftDown();

event.GameEvent.Sender = m_scene;

m_scene->OnEvent(event);
}

bool CSpaceScene::isEditorObject(CGameObject* object)
{
if (m_editorCamera->getGameObject() == object ||
Expand Down
4 changes: 4 additions & 0 deletions Projects/Editor/Source/Editor/Space/Scene/CSpaceScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ namespace Skylicht

virtual void onMouseWheeled(GUI::CBase* base, int wheel);

virtual void onChar(GUI::CBase* base, u32 c);

virtual void onKeyPressed(GUI::CBase* base, int key, bool down);

virtual void update();

bool isEditorObject(CGameObject* object);
Expand Down
Loading

0 comments on commit c1be61c

Please sign in to comment.