From 9306bd71e67558f2c60d6b06751a44f8312c2800 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 15 Jul 2013 00:51:52 +0200 Subject: [PATCH] Added GUI code for multi/sub-material. --HG-- branch : gsoc2013-dfighter --- .../material_editor_window.cpp | 6 ++++ .../material_editor/material_splitter.cpp | 5 +++ .../material_editor/material_splitter.h | 3 +- .../material_editor/material_widget.cpp | 23 ++++++++++++++ .../plugins/material_editor/material_widget.h | 2 ++ .../material_editor/material_widget.ui | 31 +++++++++++++++---- .../material_editor/nel3d_interface.cpp | 8 +++++ .../plugins/material_editor/nel3d_interface.h | 2 ++ 8 files changed, 73 insertions(+), 7 deletions(-) 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 01acffe42..b92f5ef1c 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 @@ -106,6 +106,7 @@ namespace MaterialEditor ); } + materialSplitter->onShapeChanged(); viewPort->startTimedUpdates( 20 ); } @@ -203,6 +204,7 @@ namespace MaterialEditor ); return; } + materialSplitter->onShapeChanged(); viewPort->startTimedUpdates( 20 ); } @@ -217,6 +219,7 @@ namespace MaterialEditor ); return; } + materialSplitter->onShapeChanged(); viewPort->startTimedUpdates( 20 ); } @@ -231,6 +234,7 @@ namespace MaterialEditor ); return; } + materialSplitter->onShapeChanged(); viewPort->startTimedUpdates( 20 ); } @@ -245,12 +249,14 @@ namespace MaterialEditor ); return; } + materialSplitter->onShapeChanged(); viewPort->startTimedUpdates( 20 ); } void MaterialEditorWindow::onClearSceneClicked() { nl3dIface->clearScene(); + materialSplitter->onShapeChanged(); viewPort->stopTimedUpdates(); } 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 583fcea8d..3d790afd5 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 @@ -74,6 +74,11 @@ namespace MaterialEditor materialWidget->onMaterialLoaded(); } + void MaterialSplitter::onShapeChanged() + { + materialWidget->onShapeChanged(); + } + void MaterialSplitter::onPassAdded( const char *name ) { materialWidget->onPassAdded( name ); 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 a289a72d4..526975504 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 @@ -43,7 +43,8 @@ namespace MaterialEditor void setNel3DIface( CNel3DInterface *iface ); void onNewMaterial(); - void onMaterialLoaded(); + void onMaterialLoaded(); + void onShapeChanged(); void onPassAdded( const char *name ); void onPassRemoved( const char *name ); void onPassMovedUp( const char *name ); 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 0575a1929..8472b50b0 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 @@ -66,6 +66,23 @@ namespace MaterialEditor 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 ) { passCB->addItem( name ); @@ -148,6 +165,7 @@ namespace MaterialEditor { connect( passButton, SIGNAL( clicked( bool ) ), this, SLOT( onPassEditClicked() ) ); 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( shaderCB, SIGNAL( currentIndexChanged( const QString& ) ), this, SLOT( onShaderCBChanged( const QString& ) ) ); @@ -175,6 +193,11 @@ namespace MaterialEditor int result = shaderEditorWidget->exec(); } + void MaterialWidget::onSubMatCBChanged( int i ) + { + // Update the material to the current submaterial + } + void MaterialWidget::onPassCBChanged( const QString &text ) { if( text.isEmpty() ) 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 963f4ed19..c6a8fb000 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 @@ -35,6 +35,7 @@ namespace MaterialEditor void onNewMaterial(); void onMaterialLoaded(); + void onShapeChanged(); void onPassAdded( const char *name ); void onPassRemoved( const char *name ); @@ -62,6 +63,7 @@ namespace MaterialEditor private Q_SLOTS: void onPassEditClicked(); void onShaderEditClicked(); + void onSubMatCBChanged( int i ); 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 c33748e88..ccf56a214 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 @@ -6,8 +6,8 @@ 0 0 - 338 - 139 + 255 + 179 @@ -15,13 +15,32 @@ + + + Sub-material + + + + + + + false + + + + 0 + + + + + Pass - + @@ -44,14 +63,14 @@ - + Shader - + @@ -80,7 +99,7 @@ - + Qt::Vertical 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 ed5adef61..be291b874 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 @@ -442,6 +442,14 @@ namespace MaterialEditor } } + unsigned long CNel3DInterface::getShapeMatCount() const + { + if( currentShape.empty() ) + return 0; + + return currentShape.getNumMaterials(); + } + void CNel3DInterface::setupCamera() { NLMISC::CAABBox bbox; 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 c0ac10c40..6bec77b61 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 @@ -159,6 +159,8 @@ namespace MaterialEditor void updateInput(); void renderScene(); + unsigned long getShapeMatCount() const; + private: void setupCamera();