tree explorer
This commit is contained in:
parent
2f6929cc70
commit
dccd2020fd
|
|
@ -0,0 +1,27 @@
|
|||
02:47:25: Creating resource group General
|
||||
02:47:25: Creating resource group OgreInternal
|
||||
02:47:25: Creating resource group OgreAutodetect
|
||||
02:47:25: SceneManagerFactory for type 'DefaultSceneManager' registered.
|
||||
02:47:25: Registering ResourceManager for type Material
|
||||
02:47:25: Registering ResourceManager for type Mesh
|
||||
02:47:25: Registering ResourceManager for type Skeleton
|
||||
02:47:25: MovableObjectFactory for type 'ParticleSystem' registered.
|
||||
02:47:25: ArchiveFactory for type 'FileSystem' registered
|
||||
02:47:25: ArchiveFactory for type 'Zip' registered
|
||||
02:47:25: ArchiveFactory for type 'EmbeddedZip' registered
|
||||
02:47:25: DDS codec registering
|
||||
02:47:25: ETC codec registering
|
||||
02:47:25: ASTC codec registering
|
||||
02:47:25: Registering ResourceManager for type GpuProgram
|
||||
02:47:25: Registering ResourceManager for type Compositor
|
||||
02:47:25: MovableObjectFactory for type 'Entity' registered.
|
||||
02:47:25: MovableObjectFactory for type 'Light' registered.
|
||||
02:47:25: MovableObjectFactory for type 'BillboardSet' registered.
|
||||
02:47:25: MovableObjectFactory for type 'ManualObject' registered.
|
||||
02:47:25: MovableObjectFactory for type 'BillboardChain' registered.
|
||||
02:47:25: MovableObjectFactory for type 'RibbonTrail' registered.
|
||||
02:47:25: MovableObjectFactory for type 'StaticGeometry' registered.
|
||||
02:47:25: MovableObjectFactory for type 'Rectangle2D' registered.
|
||||
02:47:25: Error: Cannot open file: plugins.cfg - skipping automatic plugin loading
|
||||
02:47:25: *-*-* OGRE Initialising
|
||||
02:47:25: *-*-* Version 13.6.4 (Tsathoggua)
|
||||
|
|
@ -40,6 +40,7 @@ namespace GL
|
|||
virtual void paintEvent(QPaintEvent* pEvent);
|
||||
virtual void resizeEvent(QResizeEvent* rEvent);
|
||||
virtual void mouseMoveEvent(QMouseEvent *event);
|
||||
virtual void closeEvent(QCloseEvent* event);
|
||||
virtual QPaintEngine* paintEngine() const;
|
||||
private:
|
||||
QElapsedTimer timer;
|
||||
|
|
|
|||
|
|
@ -114,6 +114,11 @@ namespace GL
|
|||
{
|
||||
}
|
||||
|
||||
void Widget::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
ogreWindow->destroy();
|
||||
}
|
||||
|
||||
QPaintEngine *Widget::paintEngine() const
|
||||
{
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <App/V8/Tree/Instance.hpp>
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QTreeWidget>
|
||||
#include <QTimer>
|
||||
|
|
@ -22,7 +24,9 @@ class MainWindow : public QMainWindow
|
|||
QMenuBar* menubar;
|
||||
|
||||
void createToolbar();
|
||||
void updateTree(RNR::Instance* root_instance);
|
||||
protected:
|
||||
void recurseTreeAddInstance(QTreeWidgetItem* parent, RNR::Instance* instance);
|
||||
void closeEvent(QCloseEvent* event);
|
||||
void resizeEvent(QResizeEvent* event);
|
||||
};
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
#include <MainWindow.hpp>
|
||||
#include <QGridLayout>
|
||||
#include <QTreeView>
|
||||
#include <QVariant>
|
||||
|
||||
#include "Resources/StudioResources.hpp"
|
||||
|
||||
|
|
@ -17,10 +18,10 @@ MainWindow::MainWindow()
|
|||
ogreRoot->initialise(false);
|
||||
|
||||
menubar = new QMenuBar();
|
||||
grid->addWidget(menubar, 0, 0, 1, 1);
|
||||
grid->addWidget(menubar, 0, 0, 1, 2);
|
||||
|
||||
toolbar = new QToolBar();
|
||||
grid->addWidget(toolbar, 1, 0, 1, 1);
|
||||
grid->addWidget(toolbar, 1, 0, 1, 2);
|
||||
|
||||
createToolbar();
|
||||
|
||||
|
|
@ -35,12 +36,36 @@ MainWindow::MainWindow()
|
|||
grid->setContentsMargins(0, 0, 0, 0);
|
||||
grid->setSpacing(0);
|
||||
|
||||
|
||||
setWindowTitle(QString("RNR Studio"));
|
||||
setWindowIcon(QIcon(pixmap));
|
||||
setCentralWidget(content_widget);
|
||||
}
|
||||
|
||||
void MainWindow::recurseTreeAddInstance(QTreeWidgetItem* parent, RNR::Instance* instance)
|
||||
{
|
||||
for(auto& child : *instance->getChildren())
|
||||
{
|
||||
QTreeWidgetItem* instance_w = new QTreeWidgetItem();
|
||||
instance_w->setText(0, QString(child->getName().c_str()));
|
||||
instance_w->setData(0, Qt::UserRole, QVariant::fromValue(child));
|
||||
recurseTreeAddInstance(instance_w, child);
|
||||
parent->addChild(instance_w);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateTree(RNR::Instance* root_instance)
|
||||
{
|
||||
for(auto& child : *root_instance->getChildren())
|
||||
{
|
||||
QTreeWidgetItem* parent = new QTreeWidgetItem();
|
||||
parent->setData(0, Qt::UserRole, QVariant::fromValue(child));
|
||||
parent->setText(0, QString(child->getName().c_str()));
|
||||
|
||||
recurseTreeAddInstance(parent, child);
|
||||
explorer->addTopLevelItem(parent);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::createToolbar()
|
||||
{
|
||||
QMenu* file_menu = menubar->addMenu("File");
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <QApplication>
|
||||
#include <QSurfaceFormat>
|
||||
#include <QStatusBar>
|
||||
#include <App/V8/World/World.hpp>
|
||||
|
||||
#include <MainWindow.hpp>
|
||||
|
||||
|
|
@ -19,11 +20,16 @@ int main(int argc, char** argv)
|
|||
window.show();
|
||||
window.widget->initializeOgre();
|
||||
|
||||
RNR::World* world = new RNR::World();
|
||||
window.updateTree(world->getDatamodel());
|
||||
|
||||
while (window.isVisible())
|
||||
{
|
||||
window.statusBar()->showMessage(QString::asprintf("Dt=%f, Rt=%f", window.widget->delta, window.widget->render_time));
|
||||
|
||||
app.processEvents();
|
||||
window.widget->render();
|
||||
world->preStep();
|
||||
world->step(window.widget->delta);
|
||||
world->update();
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ add_library(Engine STATIC
|
|||
Header/Helpers/Strings.hpp
|
||||
Header/App/Humanoid/Humanoid.hpp
|
||||
Header/App/V8/DataModel/ForceField.hpp
|
||||
Header/App/V8/Tree/Instance.hpp
|
||||
Header/App/V8/World/World.hpp
|
||||
Header/Network/GUID.hpp
|
||||
Header/Rendering/Adorn.hpp
|
||||
|
|
@ -14,6 +15,7 @@ add_library(Engine STATIC
|
|||
Source/Helpers/Strings.cpp
|
||||
Source/App/Humanoid/Humanoid.cpp
|
||||
Source/App/V8/DataModel/ForceField.cpp
|
||||
Source/App/V8/Tree/Instance.cpp
|
||||
Source/App/V8/World/World.cpp
|
||||
Source/Network/GUID.cpp
|
||||
Source/Rendering/Adorn.cpp
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace RNR
|
|||
private:
|
||||
std::string m_name;
|
||||
RNR::Instance* m_parent;
|
||||
std::vector<boost::shared_ptr<RNR::Instance>> m_children;
|
||||
std::vector<RNR::Instance*> m_children;
|
||||
bool m_archivable;
|
||||
|
||||
public:
|
||||
|
|
@ -30,14 +30,14 @@ namespace RNR
|
|||
virtual bool askAddChild(RNR::Instance* instance); // derive this
|
||||
bool canAddChild(RNR::Instance* instance);
|
||||
|
||||
void createChild(boost::shared_ptr<RNR::Instance>* result, const RNR::Name *className);
|
||||
RNR::Instance* createChild(const RNR::Name *className);
|
||||
|
||||
RNR::Instance* getParent() { return this->m_parent; };
|
||||
std::string getName() { return this->m_name; };
|
||||
|
||||
void setParent(RNR::Instance* newParent);
|
||||
void setName(std::string name);
|
||||
std::vector<boost::shared_ptr<RNR::Instance>>* getChildren() { return &this->m_children; };
|
||||
std::vector<RNR::Instance*>* getChildren() { return &this->m_children; };
|
||||
int numChildren() { return this->m_children.size(); };
|
||||
|
||||
void onChildAdded(RNR::Instance* childAdded);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include <App/V8/Tree/Instance.hpp>
|
||||
|
||||
namespace RNR
|
||||
{
|
||||
class World
|
||||
{
|
||||
private:
|
||||
Instance* m_datamodel;
|
||||
|
||||
public:
|
||||
World();
|
||||
~World();
|
||||
|
|
@ -11,5 +16,8 @@ namespace RNR
|
|||
void preStep();
|
||||
double step(float timestep);
|
||||
void update();
|
||||
|
||||
Instance* getDatamodel() { return m_datamodel; }
|
||||
void setDatamodel(Instance* instance) { m_datamodel = instance; }
|
||||
};
|
||||
}
|
||||
|
|
@ -4,17 +4,19 @@ namespace RNR
|
|||
{
|
||||
Instance::Instance()
|
||||
{
|
||||
//
|
||||
m_parent = 0;
|
||||
setName("Instance");
|
||||
}
|
||||
|
||||
Instance::Instance(std::string name)
|
||||
{
|
||||
//
|
||||
m_parent = 0;
|
||||
setName(name);
|
||||
}
|
||||
|
||||
bool Instance::contains(RNR::Instance* child)
|
||||
{
|
||||
auto child_it = std::find(m_children.begin(), m_children.end(), (boost::shared_ptr<RNR::Instance>)child);
|
||||
auto child_it = std::find(m_children.begin(), m_children.end(), child);
|
||||
|
||||
return child_it != m_children.end();
|
||||
}
|
||||
|
|
@ -86,8 +88,8 @@ namespace RNR
|
|||
|
||||
if (m_parent)
|
||||
{
|
||||
std::vector<boost::shared_ptr<RNR::Instance>>* children = m_parent->getChildren();
|
||||
auto child_it = std::find(children->begin(), children->end(), (boost::shared_ptr<RNR::Instance>)this);
|
||||
std::vector<RNR::Instance*>* children = m_parent->getChildren();
|
||||
auto child_it = std::find(children->begin(), children->end(), this);
|
||||
|
||||
if (child_it != children->end())
|
||||
children->erase(child_it);
|
||||
|
|
@ -99,7 +101,7 @@ namespace RNR
|
|||
}
|
||||
|
||||
m_parent = newParent;
|
||||
m_parent->m_children.push_back((boost::shared_ptr<RNR::Instance>)this);
|
||||
m_parent->m_children.push_back(this);
|
||||
newParent->onChildAdded(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,17 @@ namespace RNR
|
|||
{
|
||||
World::World()
|
||||
{
|
||||
//
|
||||
m_datamodel = new Instance();
|
||||
m_datamodel->setName("DataModel");
|
||||
|
||||
Instance* test = new Instance();
|
||||
Instance* test2 = new Instance();
|
||||
test->setParent(m_datamodel);
|
||||
test2->setParent(test);
|
||||
test = new Instance();
|
||||
test->setParent(m_datamodel);
|
||||
test = new Instance();
|
||||
test->setParent(m_datamodel);
|
||||
}
|
||||
|
||||
World::~World()
|
||||
|
|
|
|||
Loading…
Reference in New Issue