From 96eb64ecbe61cb009b2c037fd710a050d8f261a1 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 7 Jul 2013 04:29:31 +0200 Subject: [PATCH] Shader can now be set for the rendering pass, using the shader combo box in MaterialWidget. --HG-- branch : gsoc2013-dfighter --- code/nel/include/nel/3d/dynamic_material.h | 1 + .../material_editor/material_widget.cpp | 29 +++++++++++++++++++ .../plugins/material_editor/material_widget.h | 2 ++ .../material_editor/material_widget.ui | 11 ++++++- .../material_editor/nel3d_interface.cpp | 10 +++++++ .../plugins/material_editor/nel3d_interface.h | 2 ++ 6 files changed, 54 insertions(+), 1 deletion(-) diff --git a/code/nel/include/nel/3d/dynamic_material.h b/code/nel/include/nel/3d/dynamic_material.h index b22b69a83..93f648cfe 100644 --- a/code/nel/include/nel/3d/dynamic_material.h +++ b/code/nel/include/nel/3d/dynamic_material.h @@ -58,6 +58,7 @@ namespace NL3D void setName( const std::string &n ){ name = n; } void getName( std::string &n ) const { n = name; } void getShaderRef( std::string &s ) const{ s = shaderRef; } + void setShaderRef( const std::string &s ){ shaderRef = s; } void serial( NLMISC::IStream &f ); uint32 count(){ return properties.size(); } 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 13e88141e..0575a1929 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 @@ -149,6 +149,7 @@ namespace MaterialEditor connect( passButton, SIGNAL( clicked( bool ) ), this, SLOT( onPassEditClicked() ) ); connect( shaderButton, SIGNAL( clicked( bool ) ), this, SLOT( onShaderEditClicked() ) ); connect( passCB, SIGNAL( currentIndexChanged( const QString& ) ), this, SLOT( onPassCBChanged( const QString& ) ) ); + connect( shaderCB, SIGNAL( currentIndexChanged( const QString& ) ), this, SLOT( onShaderCBChanged( const QString& ) ) ); connect( shaderEditorWidget, SIGNAL( okClicked() ), this, SLOT( onShaderEditOKClicked() ) ); } @@ -167,6 +168,9 @@ namespace MaterialEditor void MaterialWidget::onShaderEditClicked() { + if( shaderCB->currentIndex() == 0 ) + return; + shaderEditorWidget->load( shaderCB->currentText() ); int result = shaderEditorWidget->exec(); } @@ -176,7 +180,32 @@ namespace MaterialEditor if( text.isEmpty() ) return; + CNelMaterialProxy m = nl3dIface->getMaterial(); + CRenderPassProxy pass = m.getPass( text.toUtf8().data() ); + std::string s; + pass.getShaderRef( s ); + + int i = shaderCB->findText( s.c_str() ); + if( i >= 0 ) + shaderCB->setCurrentIndex( i ); + else + shaderCB->setCurrentIndex( 0 ); + Q_EMIT passChanged( text ); } + + void MaterialWidget::onShaderCBChanged( const QString &text ) + { + QString p = passCB->currentText(); + + CNelMaterialProxy m = nl3dIface->getMaterial(); + CRenderPassProxy pass = m.getPass( p.toUtf8().data() ); + pass.setShaderRef( text.toUtf8().data() ); + + if( text.isEmpty() ) + shaderButton->setEnabled( false ); + else + shaderButton->setEnabled( true ); + } } 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 6909c0ac3..963f4ed19 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 @@ -63,6 +63,8 @@ namespace MaterialEditor void onPassEditClicked(); void onShaderEditClicked(); void onPassCBChanged( const QString &text ); + void onShaderCBChanged( const QString &text ); + }; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.ui index 8e0229798..c33748e88 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/material_widget.ui @@ -54,10 +54,19 @@ - + + + + + + + + + false + 0 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/nel3d_interface.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/nel3d_interface.cpp index a30e560cc..b29ef7e2e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/nel3d_interface.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/nel3d_interface.cpp @@ -102,6 +102,16 @@ namespace MaterialEditor pass->setName( name ); } + void CRenderPassProxy::getShaderRef( std::string &s ) + { + pass->getShaderRef( s ); + } + + void CRenderPassProxy::setShaderRef( const std::string &s ) + { + pass->setShaderRef( s ); + } + bool CRenderPassProxy::getProperty( const std::string &name, SMatProp &p ) { uint32 count = pass->count(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/nel3d_interface.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/nel3d_interface.h index ae77d31ab..1d38af3fe 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/nel3d_interface.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/nel3d_interface.h @@ -72,6 +72,8 @@ namespace MaterialEditor void setProperties( std::vector< SMatProp > &v ); void getName( std::string &name ); void setName( const std::string &name ); + void getShaderRef( std::string &s ); + void setShaderRef( const std::string &s ); bool getProperty( const std::string &name, SMatProp &p ); bool changeProperty( const SMatProp &p );