diff --git a/code/nel/src/3d/dynamic_material.cpp b/code/nel/src/3d/dynamic_material.cpp index 57c0aa54b..7d192c257 100644 --- a/code/nel/src/3d/dynamic_material.cpp +++ b/code/nel/src/3d/dynamic_material.cpp @@ -144,6 +144,9 @@ namespace NL3D CDynMaterial::CDynMaterial() { + SRenderPass *p = new SRenderPass(); + p->setName( "pass1" ); + passes.push_back( p ); } CDynMaterial::~CDynMaterial() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_editor_window.cpp index b37ff97dd..88da0791d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_editor_window.cpp @@ -49,6 +49,8 @@ namespace MaterialEditor passesWidget = new RenderPassesWidget(); passesWidget->setMaterialObserver( materialSplitter ); passesWidget->setNel3dIface( nl3dIface ); + passesWidget->onMaterialLoaded(); + materialSplitter->onMaterialLoaded(); createMenus(); createDockWidgets(); @@ -80,6 +82,7 @@ namespace MaterialEditor { nl3dIface->newMaterial(); materialSplitter->onNewMaterial(); + passesWidget->onMaterialLoaded(); } void MaterialEditorWindow::onOpenMaterialClicked() @@ -105,6 +108,7 @@ namespace MaterialEditor ); } + passesWidget->onMaterialLoaded(); materialSplitter->onMaterialLoaded(); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_properties.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_properties.cpp index c0cb2e281..c21989165 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_properties.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_properties.cpp @@ -22,12 +22,13 @@ namespace MaterialEditor { MatPropWidget::MatPropWidget( QWidget *parent ) : - QWidget( parent ) + QDialog( parent ) { setupUi( this ); matPropEditWidget = new MatPropEditWidget(); setupConnections(); edit = false; + changed = false; proxy = NULL; } @@ -73,6 +74,7 @@ namespace MaterialEditor { treeWidget->clear(); nameEdit->clear(); + changed = false; if( this->proxy != NULL ) { delete this->proxy; @@ -105,18 +107,21 @@ namespace MaterialEditor } clear(); + setResult( QDialog::Accepted ); close(); } void MatPropWidget::onCancelClicked() { clear(); + setResult( QDialog::Rejected ); close(); } void MatPropWidget::onAddClicked() { edit = false; + changed = true; matPropEditWidget->clear(); matPropEditWidget->show(); } @@ -144,6 +149,7 @@ namespace MaterialEditor return; delete item; + changed = true; } void MatPropWidget::onEditorOKClicked() @@ -166,6 +172,7 @@ namespace MaterialEditor item->setData( 2, Qt::DisplayRole, prop.type ); treeWidget->addTopLevelItem( item ); } + changed = true; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_properties.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_properties.h index 31afd08d9..3471420c1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_properties.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_properties.h @@ -25,7 +25,7 @@ namespace MaterialEditor class MatPropEditWidget; class CRenderPassProxy; - class MatPropWidget : public QWidget, public Ui::MatPropWidget + class MatPropWidget : public QDialog, public Ui::MatPropWidget { Q_OBJECT public: @@ -33,6 +33,7 @@ namespace MaterialEditor ~MatPropWidget(); void load( CRenderPassProxy *proxy ); void clear(); + bool getChanged() const{ return changed; } private Q_SLOTS: void onOKClicked(); @@ -45,6 +46,7 @@ namespace MaterialEditor private: void setupConnections(); bool edit; + bool changed; MatPropEditWidget *matPropEditWidget; CRenderPassProxy *proxy; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_properties.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_properties.ui index c6fcd7a6d..6bdbe616c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_properties.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_properties.ui @@ -1,7 +1,7 @@ MatPropWidget - + Qt::ApplicationModal @@ -9,8 +9,8 @@ 0 0 - 669 - 504 + 685 + 441 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_splitter.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_splitter.cpp index 6ba64a505..3bd161dc4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_splitter.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_splitter.cpp @@ -32,6 +32,7 @@ namespace MaterialEditor browserCtrl->setBrowser( browser ); setup(); + setupConnections(); } MaterialSplitter::~MaterialSplitter() @@ -43,6 +44,11 @@ namespace MaterialEditor browser = NULL; } + void MaterialSplitter::setupConnections() + { + connect( materialWidget, SIGNAL( propsChanged() ), this, SLOT( onPropsChanged() ) ); + } + void MaterialSplitter::setup() { setOrientation( Qt::Vertical ); @@ -91,5 +97,12 @@ namespace MaterialEditor { materialWidget->onPassRenamed( from, to ); } + + void MaterialSplitter::onPropsChanged() + { + QString pass; + materialWidget->getCurrentPass( pass ); + browserCtrl->onPropsChanged(); + } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_splitter.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_splitter.h index 4d0e219e5..8b259cc19 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_splitter.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_splitter.h @@ -36,6 +36,8 @@ namespace MaterialEditor MaterialSplitter( QWidget *parent = NULL ); ~MaterialSplitter(); + void setupConnections(); + void setup(); void setNel3DIface( CNel3DInterface *iface ); @@ -53,6 +55,9 @@ namespace MaterialEditor MaterialWidget *materialWidget; CPropBrowserCtrl *browserCtrl; QtTreePropertyBrowser *browser; + + private Q_SLOTS: + void onPropsChanged(); }; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.cpp index ba07ff9fd..00d349425 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.cpp @@ -119,6 +119,11 @@ namespace MaterialEditor passCB->setItemText( i, to ); } + void MaterialWidget::getCurrentPass( QString &pass ) + { + pass = passCB->currentText(); + } + void MaterialWidget::setupConnections() { connect( passButton, SIGNAL( clicked( bool ) ), this, SLOT( onPassEditClicked() ) ); @@ -134,7 +139,9 @@ namespace MaterialEditor CRenderPassProxy p = nl3dIface->getMaterial().getPass( passCB->currentText().toUtf8().data() ); matPropWidget->load( &p ); - matPropWidget->show(); + matPropWidget->exec(); + if( matPropWidget->getChanged() ) + Q_EMIT propsChanged(); } void MaterialWidget::onShaderEditClicked() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.h index fef1d840a..5869eaa92 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.h @@ -44,6 +44,11 @@ namespace MaterialEditor void setNel3DIface( CNel3DInterface *iface ){ nl3dIface = iface; } + void getCurrentPass( QString &pass ); + + Q_SIGNALS: + void propsChanged(); + private: void setupConnections(); ShaderEditorWidget *shaderEditorWidget; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/prop_browser_ctrl.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/prop_browser_ctrl.cpp index 57e985a38..a266cb156 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/prop_browser_ctrl.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/prop_browser_ctrl.cpp @@ -44,7 +44,25 @@ namespace MaterialEditor void CPropBrowserCtrl::setupConnections() { + } + void CPropBrowserCtrl::onPropsChanged() + { + clearProps(); + loadPropsForPass( currentPass ); + } + + void CPropBrowserCtrl::clearProps() + { + browser->clear(); } + + void CPropBrowserCtrl::loadPropsForPass( const QString &pass ) + { + currentPass = pass; + CNelMaterialProxy m = nel3dIface->getMaterial(); + CRenderPassProxy p = m.getPass( pass.toUtf8().data() ); + } + } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/prop_browser_ctrl.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/prop_browser_ctrl.h index f345380f2..0b4d69caa 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/prop_browser_ctrl.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/prop_browser_ctrl.h @@ -35,10 +35,14 @@ namespace MaterialEditor void setBrowser( QtTreePropertyBrowser *b ); void setNel3DIface( CNel3DInterface *iface ); void setupConnections(); + void onPropsChanged(); + void clearProps(); + void loadPropsForPass( const QString &pass ); private: QtTreePropertyBrowser *browser; CNel3DInterface *nel3dIface; + QString currentPass; }; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.cpp index 0673a6060..a77161c34 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.cpp @@ -59,6 +59,21 @@ namespace MaterialEditor listWidget->clear(); } + void RenderPassesWidget::onMaterialLoaded() + { + clear(); + CNelMaterialProxy m = nl3dIface->getMaterial(); + std::vector< std::string > pl; + m.getPassList( pl ); + + std::vector< std::string >::const_iterator itr = pl.begin(); + while( itr != pl.end() ) + { + listWidget->addItem( QString( itr->c_str() ) ); + ++itr; + } + } + void RenderPassesWidget::setupConnections() { connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) ); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.h index 7c7aa4fa2..4388b2cd5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.h @@ -34,8 +34,8 @@ namespace MaterialEditor void fillList( const QStringList &list ); void getList( QStringList &list ); void clear(); + void onMaterialLoaded(); void setNel3dIface( CNel3DInterface *iface ){ nl3dIface = iface; } - void setMaterialObserver( CMaterialObserver *obs ){ observer = obs; } private: