Material widget now retrieves the passes when loading a material.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 12 years ago
parent 067676c049
commit 94fe455a1a

@ -82,6 +82,7 @@ namespace NL3D
void movePassDown( const std::string &name );
SRenderPass* getPass( const std::string &name );
void getPassList( std::vector< std::string > &l );
private:
std::vector< SRenderPass* > passes;

@ -20,20 +20,43 @@ namespace NL3D
{
void SDynMaterialProp::serial( NLMISC::IStream &f )
{
f.serial( std::string( prop ) );
f.serial( std::string( label ) );
f.serial( uint8( type ) );
f.serial( std::string( value ) );
f.xmlPush( "property" );
f.xmlPush( "id" );
f.serial( prop );
f.xmlPop();
f.xmlPush( "label" );
f.serial( label );
f.xmlPop();
f.xmlPush( "type" );
f.serial( type );
f.xmlPop();
f.xmlPush( "value" );
f.serial( value );
f.xmlPop();
f.xmlPop();
}
void SRenderPass::serial( NLMISC::IStream &f )
{
f.serial( std::string( name ) );
f.xmlPush( "pass" );
f.xmlPush( "name" );
f.serial( name );
f.xmlPop();
f.xmlPush( "properties" );
if( !f.isReading() )
{
uint32 n = properties.size();
f.xmlPush( "count" );
f.serial( n );
f.xmlPop();
std::vector< SDynMaterialProp >::iterator itr = properties.begin();
while( itr != properties.end() )
@ -45,7 +68,9 @@ namespace NL3D
else
{
uint32 n;
f.xmlPush( "count" );
f.serial( n );
f.xmlPop();
for( uint32 i = 0; i < n; i++ )
{
@ -55,6 +80,9 @@ namespace NL3D
}
}
f.xmlPop();
f.xmlPop();
}
void SRenderPass::addProperty( const SDynMaterialProp &prop )
@ -124,12 +152,18 @@ namespace NL3D
void CDynMaterial::serial( NLMISC::IStream &f )
{
f.xmlPush( "Material" );
int version = f.serialVersion( 1 );
f.xmlPush( "passes" );
if( !f.isReading() )
{
uint32 n = passes.size();
f.xmlPush( "count" );
f.serial( n );
f.xmlPop();
std::vector< SRenderPass* >::iterator itr = passes.begin();
while( itr != passes.end() )
@ -141,15 +175,21 @@ namespace NL3D
else
{
uint32 n;
f.xmlPush( "count" );
f.serial( n );
f.xmlPop();
for( uint32 i = 0; i < n; n++ )
for( uint32 i = 0; i < n; i++ )
{
SRenderPass *pass = new SRenderPass();
pass->serial( f );
passes.push_back( pass );
}
}
f.xmlPop();
f.xmlPop();
}
void CDynMaterial::addPass( const SRenderPass &pass )
@ -269,6 +309,20 @@ namespace NL3D
else
return *itr;
}
void CDynMaterial::getPassList( std::vector< std::string > &l )
{
std::vector< SRenderPass* >::iterator itr = passes.begin();
while( itr != passes.end() )
{
std::string name;
(*itr)->getName( name );
l.push_back( name );
++itr;
}
}
}

@ -39,9 +39,11 @@ namespace MaterialEditor
{
m_ui.setupUi(this);
nl3dIface = new CNel3DInterface();
materialWidget = new MaterialWidget();
shaderWidget = new ShaderWidget();
passesWidget = new RenderPassesWidget();
passesWidget->setNel3dIface( nl3dIface );
materialWidget->setNel3DIface( nl3dIface );
createMenus();
createDockWidgets();
@ -72,6 +74,7 @@ namespace MaterialEditor
void MaterialEditorWindow::onNewMaterialClicked()
{
nl3dIface->newMaterial();
materialWidget->onNewMaterial();
}
void MaterialEditorWindow::onOpenMaterialClicked()
@ -96,6 +99,8 @@ namespace MaterialEditor
QMessageBox::Ok
);
}
materialWidget->onMaterialLoaded();
}
void MaterialEditorWindow::onSaveMaterialClicked()
@ -173,9 +178,8 @@ namespace MaterialEditor
QDockWidget *dock = new QDockWidget( tr( "Material" ), this );
dock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
MaterialWidget *mw = new MaterialWidget();
passesWidget->setMaterialObserver( mw );
dock->setWidget( mw );
passesWidget->setMaterialObserver( materialWidget );
dock->setWidget( materialWidget );
addDockWidget( Qt::RightDockWidgetArea, dock );
}

@ -25,6 +25,7 @@ namespace MaterialEditor
class ShaderWidget;
class RenderPassesWidget;
class CNel3DInterface;
class MaterialWidget;
class MaterialEditorWindow: public QMainWindow
{
@ -50,6 +51,7 @@ private:
ShaderWidget *shaderWidget;
RenderPassesWidget *passesWidget;
MaterialWidget *materialWidget;
Ui::MaterialEditorWindow m_ui;
};

@ -26,6 +26,9 @@ namespace MaterialEditor
CMaterialObserver(){}
virtual ~CMaterialObserver(){}
virtual void onNewMaterial() = 0;
virtual void onMaterialLoaded() = 0;
virtual void onPassAdded( const char *name ) = 0;
virtual void onPassRemoved( const char *name ) = 0;
virtual void onPassMovedUp( const char *name ) = 0;

@ -17,6 +17,7 @@
#include "material_widget.h"
#include "shader_editor.h"
#include "material_properties.h"
#include "nel3d_interface.h"
namespace MaterialEditor
{
@ -38,6 +39,28 @@ namespace MaterialEditor
matPropWidget = NULL;
}
void MaterialWidget::onNewMaterial()
{
passCB->clear();
}
void MaterialWidget::onMaterialLoaded()
{
CNelMaterialProxy mat = this->nl3dIface->getMaterial();
std::vector< std::string > l;
mat.getPassList( l );
passCB->clear();
std::vector< std::string >::const_iterator itr = l.begin();
while( itr != l.end() )
{
passCB->addItem( itr->c_str() );
++itr;
}
}
void MaterialWidget::onPassAdded( const char *name )
{
passCB->addItem( name );

@ -24,6 +24,7 @@ namespace MaterialEditor
{
class ShaderEditorWidget;
class MatPropWidget;
class CNel3DInterface;
class MaterialWidget : public QWidget, public Ui::MaterialWidget, public CMaterialObserver
{
@ -32,16 +33,22 @@ namespace MaterialEditor
MaterialWidget( QWidget *parent = NULL );
~MaterialWidget();
void onNewMaterial();
void onMaterialLoaded();
void onPassAdded( const char *name );
void onPassRemoved( const char *name );
void onPassMovedUp( const char *name );
void onPassMovedDown( const char *name );
void onPassRenamed( const char *from, const char *to );
void setNel3DIface( CNel3DInterface *iface ){ nl3dIface = iface; }
private:
void setupConnections();
ShaderEditorWidget *shaderEditorWidget;
MatPropWidget *matPropWidget;
CNel3DInterface *nl3dIface;
private Q_SLOTS:
void onPassEditClicked();

@ -22,6 +22,11 @@
namespace MaterialEditor
{
void CNelMaterialProxy::getPassList( std::vector< std::string > &l )
{
material->getPassList( l );
}
void CNelMaterialProxy::addPass( const char *name )
{
NL3D::SRenderPass pass;

@ -18,6 +18,9 @@
#ifndef NEL3D_INTERFACE_H
#define NEL3D_INTERFACE_H
#include <vector>
#include <string>
namespace NL3D
{
class CDynMaterial;
@ -35,6 +38,8 @@ namespace MaterialEditor
~CNelMaterialProxy(){}
void getPassList( std::vector< std::string > &l );
void addPass( const char *name );
void removePass( const char *name );
void movePassUp( const char *name );

Loading…
Cancel
Save