Added GUI code for multi/sub-material.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 12 years ago
parent c2296a2a93
commit 9306bd71e6

@ -106,6 +106,7 @@ namespace MaterialEditor
); );
} }
materialSplitter->onShapeChanged();
viewPort->startTimedUpdates( 20 ); viewPort->startTimedUpdates( 20 );
} }
@ -203,6 +204,7 @@ namespace MaterialEditor
); );
return; return;
} }
materialSplitter->onShapeChanged();
viewPort->startTimedUpdates( 20 ); viewPort->startTimedUpdates( 20 );
} }
@ -217,6 +219,7 @@ namespace MaterialEditor
); );
return; return;
} }
materialSplitter->onShapeChanged();
viewPort->startTimedUpdates( 20 ); viewPort->startTimedUpdates( 20 );
} }
@ -231,6 +234,7 @@ namespace MaterialEditor
); );
return; return;
} }
materialSplitter->onShapeChanged();
viewPort->startTimedUpdates( 20 ); viewPort->startTimedUpdates( 20 );
} }
@ -245,12 +249,14 @@ namespace MaterialEditor
); );
return; return;
} }
materialSplitter->onShapeChanged();
viewPort->startTimedUpdates( 20 ); viewPort->startTimedUpdates( 20 );
} }
void MaterialEditorWindow::onClearSceneClicked() void MaterialEditorWindow::onClearSceneClicked()
{ {
nl3dIface->clearScene(); nl3dIface->clearScene();
materialSplitter->onShapeChanged();
viewPort->stopTimedUpdates(); viewPort->stopTimedUpdates();
} }

@ -74,6 +74,11 @@ namespace MaterialEditor
materialWidget->onMaterialLoaded(); materialWidget->onMaterialLoaded();
} }
void MaterialSplitter::onShapeChanged()
{
materialWidget->onShapeChanged();
}
void MaterialSplitter::onPassAdded( const char *name ) void MaterialSplitter::onPassAdded( const char *name )
{ {
materialWidget->onPassAdded( name ); materialWidget->onPassAdded( name );

@ -44,6 +44,7 @@ namespace MaterialEditor
void onNewMaterial(); void onNewMaterial();
void onMaterialLoaded(); void onMaterialLoaded();
void onShapeChanged();
void onPassAdded( const char *name ); void onPassAdded( const char *name );
void onPassRemoved( const char *name ); void onPassRemoved( const char *name );
void onPassMovedUp( const char *name ); void onPassMovedUp( const char *name );

@ -66,6 +66,23 @@ namespace MaterialEditor
passButton->setEnabled( true ); passButton->setEnabled( true );
} }
void MaterialWidget::onShapeChanged()
{
unsigned long c = nl3dIface->getShapeMatCount();
subMatCB->clear();
subMatCB->addItem( "0" );
for( unsigned long i = 1; i < c; i++ )
subMatCB->addItem( QString::number( i ) );
subMatCB->setCurrentIndex( 0 );
if( subMatCB->count() > 1 )
subMatCB->setEnabled( true );
else
subMatCB->setEnabled( false );
}
void MaterialWidget::onPassAdded( const char *name ) void MaterialWidget::onPassAdded( const char *name )
{ {
passCB->addItem( name ); passCB->addItem( name );
@ -148,6 +165,7 @@ namespace MaterialEditor
{ {
connect( passButton, SIGNAL( clicked( bool ) ), this, SLOT( onPassEditClicked() ) ); connect( passButton, SIGNAL( clicked( bool ) ), this, SLOT( onPassEditClicked() ) );
connect( shaderButton, SIGNAL( clicked( bool ) ), this, SLOT( onShaderEditClicked() ) ); connect( shaderButton, SIGNAL( clicked( bool ) ), this, SLOT( onShaderEditClicked() ) );
connect( subMatCB, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onSubMatCBChanged( int ) ) );
connect( passCB, SIGNAL( currentIndexChanged( const QString& ) ), this, SLOT( onPassCBChanged( const QString& ) ) ); connect( passCB, SIGNAL( currentIndexChanged( const QString& ) ), this, SLOT( onPassCBChanged( const QString& ) ) );
connect( shaderCB, SIGNAL( currentIndexChanged( const QString& ) ), this, SLOT( onShaderCBChanged( const QString& ) ) ); connect( shaderCB, SIGNAL( currentIndexChanged( const QString& ) ), this, SLOT( onShaderCBChanged( const QString& ) ) );
@ -175,6 +193,11 @@ namespace MaterialEditor
int result = shaderEditorWidget->exec(); int result = shaderEditorWidget->exec();
} }
void MaterialWidget::onSubMatCBChanged( int i )
{
// Update the material to the current submaterial
}
void MaterialWidget::onPassCBChanged( const QString &text ) void MaterialWidget::onPassCBChanged( const QString &text )
{ {
if( text.isEmpty() ) if( text.isEmpty() )

@ -35,6 +35,7 @@ namespace MaterialEditor
void onNewMaterial(); void onNewMaterial();
void onMaterialLoaded(); void onMaterialLoaded();
void onShapeChanged();
void onPassAdded( const char *name ); void onPassAdded( const char *name );
void onPassRemoved( const char *name ); void onPassRemoved( const char *name );
@ -62,6 +63,7 @@ namespace MaterialEditor
private Q_SLOTS: private Q_SLOTS:
void onPassEditClicked(); void onPassEditClicked();
void onShaderEditClicked(); void onShaderEditClicked();
void onSubMatCBChanged( int i );
void onPassCBChanged( const QString &text ); void onPassCBChanged( const QString &text );
void onShaderCBChanged( const QString &text ); void onShaderCBChanged( const QString &text );

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>338</width> <width>255</width>
<height>139</height> <height>179</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -15,13 +15,32 @@
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Sub-material</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QComboBox" name="subMatCB">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>0</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Pass</string> <string>Pass</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="2"> <item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QComboBox" name="passCB"/> <widget class="QComboBox" name="passCB"/>
@ -44,14 +63,14 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="0"> <item row="4" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>Shader</string> <string>Shader</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="2"> <item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<widget class="QComboBox" name="shaderCB"> <widget class="QComboBox" name="shaderCB">
@ -80,7 +99,7 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="4" column="1"> <item row="6" column="1">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>

@ -442,6 +442,14 @@ namespace MaterialEditor
} }
} }
unsigned long CNel3DInterface::getShapeMatCount() const
{
if( currentShape.empty() )
return 0;
return currentShape.getNumMaterials();
}
void CNel3DInterface::setupCamera() void CNel3DInterface::setupCamera()
{ {
NLMISC::CAABBox bbox; NLMISC::CAABBox bbox;

@ -159,6 +159,8 @@ namespace MaterialEditor
void updateInput(); void updateInput();
void renderScene(); void renderScene();
unsigned long getShapeMatCount() const;
private: private:
void setupCamera(); void setupCamera();

Loading…
Cancel
Save