Shader can now be set for the rendering pass, using the shader combo box in MaterialWidget.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 12 years ago
parent cc86cdd3ef
commit 96eb64ecbe

@ -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(); }

@ -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 );
}
}

@ -63,6 +63,8 @@ namespace MaterialEditor
void onPassEditClicked();
void onShaderEditClicked();
void onPassCBChanged( const QString &text );
void onShaderCBChanged( const QString &text );
};
}

@ -54,10 +54,19 @@
<item row="3" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QComboBox" name="shaderCB"/>
<widget class="QComboBox" name="shaderCB">
<item>
<property name="text">
<string/>
</property>
</item>
</widget>
</item>
<item>
<widget class="QPushButton" name="shaderButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>

@ -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();

@ -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 );

Loading…
Cancel
Save