added window containing basic node info (accessible from window or picker)
This commit is contained in:
parent
445f39825e
commit
afbab7711d
@ -26,6 +26,7 @@ Editor::Editor() :
|
||||
m_materialEditorEnabled(false),
|
||||
m_editorEnabled(false)
|
||||
{
|
||||
setID("editor");
|
||||
m_objectEditor = new ObjectEditor();
|
||||
addChild(m_pickerNode);
|
||||
m_pickerNode->setEnabled(false);
|
||||
@ -79,6 +80,12 @@ void Editor::gui()
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if(ImGui::BeginMenu("Scene"))
|
||||
{
|
||||
if(ImGui::MenuItem("Show Root Info"))
|
||||
getEngine().getScene()->getRootObject()->openInfoWindow();
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
}
|
||||
|
@ -118,6 +118,38 @@ void Engine::update()
|
||||
ImGui::ProgressBar(m_loadingThread->getTotalProgress());
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
/* Example overlay from demo
|
||||
|
||||
// Demonstrate creating a simple static window with no decoration + a context-menu to choose which corner of the screen to use.
|
||||
static void ShowExampleAppFixedOverlay(bool* p_open)
|
||||
{
|
||||
const float DISTANCE = 10.0f;
|
||||
static int corner = 0;
|
||||
ImVec2 window_pos = ImVec2((corner & 1) ? ImGui::GetIO().DisplaySize.x - DISTANCE : DISTANCE, (corner & 2) ? ImGui::GetIO().DisplaySize.y - DISTANCE : DISTANCE);
|
||||
ImVec2 window_pos_pivot = ImVec2((corner & 1) ? 1.0f : 0.0f, (corner & 2) ? 1.0f : 0.0f);
|
||||
ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.0f, 0.0f, 0.0f, 0.3f)); // Transparent background
|
||||
if (ImGui::Begin("Example: Fixed Overlay", p_open, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoSavedSettings))
|
||||
{
|
||||
ImGui::Text("Simple overlay\nin the corner of the screen.\n(right-click to change position)");
|
||||
ImGui::Separator();
|
||||
ImGui::Text("Mouse Position: (%.1f,%.1f)", ImGui::GetIO().MousePos.x, ImGui::GetIO().MousePos.y);
|
||||
if (ImGui::BeginPopupContextWindow())
|
||||
{
|
||||
if (ImGui::MenuItem("Top-left", NULL, corner == 0)) corner = 0;
|
||||
if (ImGui::MenuItem("Top-right", NULL, corner == 1)) corner = 1;
|
||||
if (ImGui::MenuItem("Bottom-left", NULL, corner == 2)) corner = 2;
|
||||
if (ImGui::MenuItem("Bottom-right", NULL, corner == 3)) corner = 3;
|
||||
if (p_open && ImGui::MenuItem("Close")) *p_open = false;
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
*
|
||||
* */
|
||||
}
|
||||
|
||||
// update Physics
|
||||
|
@ -103,6 +103,8 @@ KeyMapper::KeyMapper() :
|
||||
|
||||
void KeyMapper::update()
|
||||
{
|
||||
SceneNode::update();
|
||||
|
||||
if(m_enabled)
|
||||
gui();
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ PlayerCharacterNode::PlayerCharacterNode(bool noClip) :
|
||||
// m_playerLightNode = new LightNode(m_playerLight);
|
||||
// m_playerLightNode->setParent(this);
|
||||
|
||||
setID("player");
|
||||
// Create the shape
|
||||
btCollisionShape *shape = new btCapsuleShape(TORSO_RADIUS, TORSO_HEIGHT);
|
||||
|
||||
|
@ -35,7 +35,8 @@ SceneNode::SceneNode(std::string node_id,Script* script) :
|
||||
m_transform(glm::mat4()),
|
||||
m_script(script),
|
||||
m_rigidBody(nullptr),
|
||||
m_motionState(this)
|
||||
m_motionState(this),
|
||||
m_showInfo(false)
|
||||
{
|
||||
if(m_script != nullptr)
|
||||
m_script->begin(this);
|
||||
@ -131,6 +132,7 @@ void SceneNode::update()
|
||||
child->update();
|
||||
}
|
||||
}
|
||||
gui();
|
||||
}
|
||||
|
||||
void SceneNode::setSceneTree(SceneTree *tree)
|
||||
@ -294,3 +296,34 @@ SceneNode* SceneNode::clone()
|
||||
node->addChild(child->clone());
|
||||
return node;
|
||||
}
|
||||
|
||||
void SceneNode::openInfoWindow()
|
||||
{
|
||||
m_showInfo = true;
|
||||
}
|
||||
|
||||
void SceneNode::gui()
|
||||
{
|
||||
if(m_showInfo & m_id != "undefined id")
|
||||
{
|
||||
bool enabled = true;
|
||||
std::string window_name("Node info##"+m_id);
|
||||
ImGui::Begin(window_name.data(),&enabled);
|
||||
ImGui::Text("Id: %s",m_id.data());
|
||||
if(m_parent != nullptr)
|
||||
{
|
||||
ImGui::Text("Parent Id: %s",m_parent->getID().data());
|
||||
if(ImGui::Button("Show Parent Info"))
|
||||
m_parent->openInfoWindow();
|
||||
}
|
||||
for(SceneNode* child : m_children){
|
||||
if(ImGui::Button(child->getID().data()))
|
||||
child->openInfoWindow();
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
if(!enabled)
|
||||
m_showInfo = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,8 @@ private:
|
||||
void setParent(SceneNode* parent);
|
||||
void updateLightSource();
|
||||
|
||||
bool m_showInfo;
|
||||
|
||||
public:
|
||||
// constructor/destructor
|
||||
SceneNode(std::string node_id = "undefined id",Script *script = nullptr);
|
||||
@ -172,6 +174,9 @@ public:
|
||||
archive(m_transform);
|
||||
}
|
||||
|
||||
void openInfoWindow();
|
||||
void gui();
|
||||
|
||||
// global engine methods
|
||||
Engine& getEngine();
|
||||
};
|
||||
|
@ -17,6 +17,7 @@ SceneTree::SceneTree(Engine &engine) :
|
||||
m_shaderRefreshRequired(false),
|
||||
m_camera(nullptr)
|
||||
{
|
||||
m_root.setID("root");
|
||||
DeferredPipeline *pipeline = new DeferredPipeline();
|
||||
m_pipeline = pipeline;
|
||||
pipeline->setRenderTarget(FrameBuffer::screen);
|
||||
|
@ -29,6 +29,7 @@ SparrowShell::SparrowShell(sf::Window* window):
|
||||
m_animationProgress(0.f),
|
||||
m_isMoving(false)
|
||||
{
|
||||
setID("sparrowshell");
|
||||
sf::Vector2u size = window->getSize();
|
||||
m_dimension = glm::ivec2(size.x,DEFAULT_FONT_SIZE*(BUFFER_DISPLAYED_LINES+1));
|
||||
m_buffer->setFontSize(DEFAULT_FONT_SIZE);
|
||||
|
@ -296,6 +296,8 @@ public:
|
||||
SceneNode* tree = Loader::loadMesh("Tree01.obj");
|
||||
for(int i=0; i<8; ++i)
|
||||
{
|
||||
std::string id = "tree#"+ std::to_string(i);
|
||||
tree->setID(id);
|
||||
tree->moveTo(glm::vec3(-(10 + rand()%20), 0, rand()%40 - 5));
|
||||
sandbox->addChild(tree->clone());
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ Mesh* ScenePicker::generateMesh()
|
||||
ScenePicker::ScenePicker() :
|
||||
m_pickSucceeded(false)
|
||||
{
|
||||
setID("picker");
|
||||
setMesh(generateMesh());
|
||||
}
|
||||
|
||||
@ -43,14 +44,7 @@ ScenePicker::~ScenePicker()
|
||||
delete getMesh();
|
||||
}
|
||||
|
||||
void ScenePicker::update()
|
||||
{
|
||||
SceneNode::update();
|
||||
|
||||
if(isEnabled())
|
||||
{
|
||||
pick();
|
||||
|
||||
void ScenePicker::gui(){
|
||||
bool isEnabled = true;
|
||||
ImGui::Begin("Picker", &isEnabled);
|
||||
if(m_pickSucceeded)
|
||||
@ -58,6 +52,8 @@ void ScenePicker::update()
|
||||
ImGui::Text("Intersection : ( %.3f, %.3f, %.3f )", m_pickedPos.x, m_pickedPos.y, m_pickedPos.z);
|
||||
if(!isVisible()) setVisible(m_pickSucceeded);
|
||||
ImGui::Text("Node : %s",m_pickedNode->getID().data());
|
||||
if(ImGui::Button("Show Node Info"))
|
||||
m_pickedNode->openInfoWindow();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -70,6 +66,16 @@ void ScenePicker::update()
|
||||
|
||||
if(!isEnabled)
|
||||
getEngine().getEditor()->togglePicker();
|
||||
}
|
||||
|
||||
void ScenePicker::update()
|
||||
{
|
||||
SceneNode::update();
|
||||
|
||||
if(isEnabled())
|
||||
{
|
||||
pick();
|
||||
gui();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
virtual void update();
|
||||
|
||||
void pick();
|
||||
|
||||
void gui();
|
||||
glm::vec3 getIntersection() { return m_pickedPos; }
|
||||
bool getTraceSucceeded() { m_pickSucceeded; }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user