parent
2ca40f10eb
commit
3738aa71ce
@ -1,45 +1,45 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef DYN_MAT_LOADER_H
|
||||
#define DYN_MAT_LOADER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class CDynMaterial;
|
||||
|
||||
class CDynMatLoader
|
||||
{
|
||||
public:
|
||||
CDynMatLoader();
|
||||
~CDynMatLoader();
|
||||
|
||||
bool loadFrom( const std::string &fileName );
|
||||
|
||||
CDynMaterial* getDynMat() const{ return mat; }
|
||||
|
||||
private:
|
||||
CDynMaterial *mat;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef DYN_MAT_LOADER_H
|
||||
#define DYN_MAT_LOADER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class CDynMaterial;
|
||||
|
||||
class CDynMatLoader
|
||||
{
|
||||
public:
|
||||
CDynMatLoader();
|
||||
~CDynMatLoader();
|
||||
|
||||
bool loadFrom( const std::string &fileName );
|
||||
|
||||
CDynMaterial* getDynMat() const{ return mat; }
|
||||
|
||||
private:
|
||||
CDynMaterial *mat;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1,121 +1,121 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef DYN_MATERIAL_H
|
||||
#define DYN_MATERIAL_H
|
||||
|
||||
#include "nel/misc/stream.h"
|
||||
#include "nel/misc/variant.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
/// Rendering property
|
||||
struct SDynMaterialProp
|
||||
{
|
||||
enum EPropertyType
|
||||
{
|
||||
Color,
|
||||
Vector4,
|
||||
Float,
|
||||
Double,
|
||||
Int,
|
||||
Uint,
|
||||
Matrix4,
|
||||
Texture
|
||||
};
|
||||
|
||||
/// Id of the property
|
||||
std::string prop;
|
||||
|
||||
/// Label of the property ( user-friendly name )
|
||||
std::string label;
|
||||
|
||||
/// type of the property ( see EPropertyType )
|
||||
uint8 type;
|
||||
|
||||
NLMISC::CVariant value;
|
||||
|
||||
void serial( NLMISC::IStream &f );
|
||||
};
|
||||
|
||||
|
||||
/// Rendering pass data, contains the rendering properties for the pass
|
||||
struct SRenderPass
|
||||
{
|
||||
public:
|
||||
void addProperty( const SDynMaterialProp &prop );
|
||||
void removeProperty( const std::string &name );
|
||||
bool changeProperty( const std::string &name, const SDynMaterialProp &prop );
|
||||
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 );
|
||||
|
||||
/// Returns the number of properties this pass has
|
||||
uint32 count(){ return properties.size(); }
|
||||
|
||||
/// Clears all properties
|
||||
void clear(){ properties.clear(); }
|
||||
|
||||
const SDynMaterialProp* getProperty( uint32 i ) const;
|
||||
|
||||
private:
|
||||
std::vector< SDynMaterialProp > properties;
|
||||
std::string shaderRef;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// Multi-pass material for rendering using user shaders
|
||||
class CDynMaterial : public NLMISC::IStreamable
|
||||
{
|
||||
public:
|
||||
CDynMaterial();
|
||||
~CDynMaterial();
|
||||
CDynMaterial& operator=( const CDynMaterial &other );
|
||||
|
||||
/// Clears all passes, and then adds a new pass
|
||||
void reconstruct();
|
||||
|
||||
/// Clears all passes
|
||||
void clear();
|
||||
void serial( NLMISC::IStream &f );
|
||||
std::string getClassName(){ return "CDynMaterial"; }
|
||||
|
||||
void addPass( const SRenderPass &pass );
|
||||
void removePass( const std::string &name );
|
||||
void renamePass( const std::string &from, const std::string &to );
|
||||
void movePassUp( const std::string &name );
|
||||
void movePassDown( const std::string &name );
|
||||
|
||||
SRenderPass* getPass( const std::string &name );
|
||||
SRenderPass* getPass( uint32 i );
|
||||
uint32 getPassCount(){ return passes.size(); }
|
||||
void getPassList( std::vector< std::string > &l );
|
||||
|
||||
private:
|
||||
std::vector< SRenderPass* > passes;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef DYN_MATERIAL_H
|
||||
#define DYN_MATERIAL_H
|
||||
|
||||
#include "nel/misc/stream.h"
|
||||
#include "nel/misc/variant.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
/// Rendering property
|
||||
struct SDynMaterialProp
|
||||
{
|
||||
enum EPropertyType
|
||||
{
|
||||
Color,
|
||||
Vector4,
|
||||
Float,
|
||||
Double,
|
||||
Int,
|
||||
Uint,
|
||||
Matrix4,
|
||||
Texture
|
||||
};
|
||||
|
||||
/// Id of the property
|
||||
std::string prop;
|
||||
|
||||
/// Label of the property ( user-friendly name )
|
||||
std::string label;
|
||||
|
||||
/// type of the property ( see EPropertyType )
|
||||
uint8 type;
|
||||
|
||||
NLMISC::CVariant value;
|
||||
|
||||
void serial( NLMISC::IStream &f );
|
||||
};
|
||||
|
||||
|
||||
/// Rendering pass data, contains the rendering properties for the pass
|
||||
struct SRenderPass
|
||||
{
|
||||
public:
|
||||
void addProperty( const SDynMaterialProp &prop );
|
||||
void removeProperty( const std::string &name );
|
||||
bool changeProperty( const std::string &name, const SDynMaterialProp &prop );
|
||||
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 );
|
||||
|
||||
/// Returns the number of properties this pass has
|
||||
uint32 count(){ return properties.size(); }
|
||||
|
||||
/// Clears all properties
|
||||
void clear(){ properties.clear(); }
|
||||
|
||||
const SDynMaterialProp* getProperty( uint32 i ) const;
|
||||
|
||||
private:
|
||||
std::vector< SDynMaterialProp > properties;
|
||||
std::string shaderRef;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// Multi-pass material for rendering using user shaders
|
||||
class CDynMaterial : public NLMISC::IStreamable
|
||||
{
|
||||
public:
|
||||
CDynMaterial();
|
||||
~CDynMaterial();
|
||||
CDynMaterial& operator=( const CDynMaterial &other );
|
||||
|
||||
/// Clears all passes, and then adds a new pass
|
||||
void reconstruct();
|
||||
|
||||
/// Clears all passes
|
||||
void clear();
|
||||
void serial( NLMISC::IStream &f );
|
||||
std::string getClassName(){ return "CDynMaterial"; }
|
||||
|
||||
void addPass( const SRenderPass &pass );
|
||||
void removePass( const std::string &name );
|
||||
void renamePass( const std::string &from, const std::string &to );
|
||||
void movePassUp( const std::string &name );
|
||||
void movePassDown( const std::string &name );
|
||||
|
||||
SRenderPass* getPass( const std::string &name );
|
||||
SRenderPass* getPass( uint32 i );
|
||||
uint32 getPassCount(){ return passes.size(); }
|
||||
void getPassList( std::vector< std::string > &l );
|
||||
|
||||
private:
|
||||
std::vector< SRenderPass* > passes;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1,37 +1,37 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef SHAPE_MAT_SERIALIZER_H
|
||||
#define SHAPE_MAT_SERIALIZER_H
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class IShape;
|
||||
|
||||
class ShapeMatSerial
|
||||
{
|
||||
public:
|
||||
ShapeMatSerial();
|
||||
~ShapeMatSerial();
|
||||
void setShape( IShape *s ){ shape = s; }
|
||||
void serial( const char *sPath );
|
||||
|
||||
private:
|
||||
IShape *shape;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef SHAPE_MAT_SERIALIZER_H
|
||||
#define SHAPE_MAT_SERIALIZER_H
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class IShape;
|
||||
|
||||
class ShapeMatSerial
|
||||
{
|
||||
public:
|
||||
ShapeMatSerial();
|
||||
~ShapeMatSerial();
|
||||
void setShape( IShape *s ){ shape = s; }
|
||||
void serial( const char *sPath );
|
||||
|
||||
private:
|
||||
IShape *shape;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,44 +1,44 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef SHADER_LOADER_H
|
||||
#define SHADER_LOADER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class CUsrShaderManager;
|
||||
|
||||
class CUsrShaderLoader
|
||||
{
|
||||
public:
|
||||
CUsrShaderLoader();
|
||||
~CUsrShaderLoader();
|
||||
void setManager( CUsrShaderManager *mgr ){ manager = mgr; }
|
||||
void loadShaders( const std::string &directory );
|
||||
|
||||
private:
|
||||
void loadShader( const std::string &file );
|
||||
|
||||
CUsrShaderManager *manager;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef SHADER_LOADER_H
|
||||
#define SHADER_LOADER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class CUsrShaderManager;
|
||||
|
||||
class CUsrShaderLoader
|
||||
{
|
||||
public:
|
||||
CUsrShaderLoader();
|
||||
~CUsrShaderLoader();
|
||||
void setManager( CUsrShaderManager *mgr ){ manager = mgr; }
|
||||
void loadShaders( const std::string &directory );
|
||||
|
||||
private:
|
||||
void loadShader( const std::string &file );
|
||||
|
||||
CUsrShaderManager *manager;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,65 +1,65 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef USR_SHADER_MANAGER_H
|
||||
#define USR_SHADER_MANAGER_H
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class CUsrShaderProgram;
|
||||
class IUsrShaderVisitor;
|
||||
|
||||
/// Manages user defined shaders ( add, remove, change )
|
||||
class CUsrShaderManager
|
||||
{
|
||||
public:
|
||||
CUsrShaderManager();
|
||||
~CUsrShaderManager();
|
||||
|
||||
/// Throw away the currently loaded shaders
|
||||
void clear();
|
||||
|
||||
/// Returns a list of the currently loaded shaders
|
||||
void getShaderList( std::vector< std::string > &v );
|
||||
|
||||
/// Adds a shader
|
||||
bool addShader( CUsrShaderProgram *program );
|
||||
|
||||
/// Removes a shader
|
||||
bool removeShader( const std::string &name );
|
||||
|
||||
/// Changes a shader
|
||||
bool changeShader( const std::string &name, CUsrShaderProgram *program );
|
||||
|
||||
/// Looks up and returns a shader
|
||||
bool getShader( const std::string &name, CUsrShaderProgram *program );
|
||||
|
||||
|
||||
void visitShaders( IUsrShaderVisitor *visitor );
|
||||
void visitShader( const std::string &name, IUsrShaderVisitor *visitor );
|
||||
|
||||
private:
|
||||
std::map< std::string, CUsrShaderProgram* > programs;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef USR_SHADER_MANAGER_H
|
||||
#define USR_SHADER_MANAGER_H
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class CUsrShaderProgram;
|
||||
class IUsrShaderVisitor;
|
||||
|
||||
/// Manages user defined shaders ( add, remove, change )
|
||||
class CUsrShaderManager
|
||||
{
|
||||
public:
|
||||
CUsrShaderManager();
|
||||
~CUsrShaderManager();
|
||||
|
||||
/// Throw away the currently loaded shaders
|
||||
void clear();
|
||||
|
||||
/// Returns a list of the currently loaded shaders
|
||||
void getShaderList( std::vector< std::string > &v );
|
||||
|
||||
/// Adds a shader
|
||||
bool addShader( CUsrShaderProgram *program );
|
||||
|
||||
/// Removes a shader
|
||||
bool removeShader( const std::string &name );
|
||||
|
||||
/// Changes a shader
|
||||
bool changeShader( const std::string &name, CUsrShaderProgram *program );
|
||||
|
||||
/// Looks up and returns a shader
|
||||
bool getShader( const std::string &name, CUsrShaderProgram *program );
|
||||
|
||||
|
||||
void visitShaders( IUsrShaderVisitor *visitor );
|
||||
void visitShader( const std::string &name, IUsrShaderVisitor *visitor );
|
||||
|
||||
private:
|
||||
std::map< std::string, CUsrShaderProgram* > programs;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,71 +1,71 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef SHADER_PROGRAM_H
|
||||
#define SHADER_PROGRAM_H
|
||||
|
||||
#include "nel/misc/stream.h"
|
||||
#include <string>
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class CUsrShaderProgram : public NLMISC::IStreamable
|
||||
{
|
||||
public:
|
||||
CUsrShaderProgram();
|
||||
|
||||
~CUsrShaderProgram();
|
||||
|
||||
std::string getClassName(){ return "CUsrShaderProgram"; }
|
||||
|
||||
void serial( NLMISC::IStream &f );
|
||||
|
||||
void getName( std::string &n ) const{ n = name; }
|
||||
void getDescription( std::string &d ) const{ d = description; }
|
||||
void getVP( std::string &vp ) const{ vp = vertexProgram; }
|
||||
void getFP( std::string &fp ) const{ fp = fragmentProgram; }
|
||||
|
||||
void setName( const std::string &n ){ name = n; }
|
||||
void setDescription( const std::string &d ){ description = d; }
|
||||
void setVP( const std::string &vp ){ vertexProgram = vp; }
|
||||
void setFP( const std::string &fp ){ fragmentProgram = fp; }
|
||||
|
||||
uint32 getVPId() const{ return vpId; }
|
||||
uint32 getFPId() const{ return fpId; }
|
||||
uint32 getPId() const{ return pId; }
|
||||
|
||||
void setVPId( uint32 id ){ vpId = id; }
|
||||
void setFPId( uint32 id ){ fpId = id;}
|
||||
void setPid( uint32 id ){ pId = id; }
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
std::string description;
|
||||
std::string vertexProgram;
|
||||
std::string fragmentProgram;
|
||||
|
||||
|
||||
uint32 vpId;
|
||||
uint32 fpId;
|
||||
uint32 pId;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef SHADER_PROGRAM_H
|
||||
#define SHADER_PROGRAM_H
|
||||
|
||||
#include "nel/misc/stream.h"
|
||||
#include <string>
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class CUsrShaderProgram : public NLMISC::IStreamable
|
||||
{
|
||||
public:
|
||||
CUsrShaderProgram();
|
||||
|
||||
~CUsrShaderProgram();
|
||||
|
||||
std::string getClassName(){ return "CUsrShaderProgram"; }
|
||||
|
||||
void serial( NLMISC::IStream &f );
|
||||
|
||||
void getName( std::string &n ) const{ n = name; }
|
||||
void getDescription( std::string &d ) const{ d = description; }
|
||||
void getVP( std::string &vp ) const{ vp = vertexProgram; }
|
||||
void getFP( std::string &fp ) const{ fp = fragmentProgram; }
|
||||
|
||||
void setName( const std::string &n ){ name = n; }
|
||||
void setDescription( const std::string &d ){ description = d; }
|
||||
void setVP( const std::string &vp ){ vertexProgram = vp; }
|
||||
void setFP( const std::string &fp ){ fragmentProgram = fp; }
|
||||
|
||||
uint32 getVPId() const{ return vpId; }
|
||||
uint32 getFPId() const{ return fpId; }
|
||||
uint32 getPId() const{ return pId; }
|
||||
|
||||
void setVPId( uint32 id ){ vpId = id; }
|
||||
void setFPId( uint32 id ){ fpId = id;}
|
||||
void setPid( uint32 id ){ pId = id; }
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
std::string description;
|
||||
std::string vertexProgram;
|
||||
std::string fragmentProgram;
|
||||
|
||||
|
||||
uint32 vpId;
|
||||
uint32 fpId;
|
||||
uint32 pId;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1,50 +1,50 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef USR_SHADER_SAVER_H
|
||||
#define USR_SHADER_SAVER_H
|
||||
|
||||
#include "nel/3d/usr_shader_visitor.h"
|
||||
#include <string>
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class CUsrShaderProgram;
|
||||
class CUsrShaderManager;
|
||||
|
||||
class CUsrShaderSaver : public IUsrShaderVisitor
|
||||
{
|
||||
public:
|
||||
CUsrShaderSaver();
|
||||
~CUsrShaderSaver();
|
||||
|
||||
void setManager( CUsrShaderManager *mgr ){ manager = mgr; }
|
||||
|
||||
void visit( CUsrShaderProgram *program );
|
||||
|
||||
void saveShaders( const std::string &directory );
|
||||
void saveShader( const std::string &directory, const std::string &name );
|
||||
|
||||
private:
|
||||
CUsrShaderManager *manager;
|
||||
std::string outputDir;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef USR_SHADER_SAVER_H
|
||||
#define USR_SHADER_SAVER_H
|
||||
|
||||
#include "nel/3d/usr_shader_visitor.h"
|
||||
#include <string>
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class CUsrShaderProgram;
|
||||
class CUsrShaderManager;
|
||||
|
||||
class CUsrShaderSaver : public IUsrShaderVisitor
|
||||
{
|
||||
public:
|
||||
CUsrShaderSaver();
|
||||
~CUsrShaderSaver();
|
||||
|
||||
void setManager( CUsrShaderManager *mgr ){ manager = mgr; }
|
||||
|
||||
void visit( CUsrShaderProgram *program );
|
||||
|
||||
void saveShaders( const std::string &directory );
|
||||
void saveShader( const std::string &directory, const std::string &name );
|
||||
|
||||
private:
|
||||
CUsrShaderManager *manager;
|
||||
std::string outputDir;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1,40 +1,40 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef USR_SHADER_VISITOR_H
|
||||
#define USR_SHADER_VISITOR_H
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class CUsrShaderProgram;
|
||||
|
||||
class IUsrShaderVisitor
|
||||
{
|
||||
public:
|
||||
IUsrShaderVisitor(){}
|
||||
~IUsrShaderVisitor(){}
|
||||
|
||||
virtual void visit( CUsrShaderProgram *program ) = 0;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef USR_SHADER_VISITOR_H
|
||||
#define USR_SHADER_VISITOR_H
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class CUsrShaderProgram;
|
||||
|
||||
class IUsrShaderVisitor
|
||||
{
|
||||
public:
|
||||
IUsrShaderVisitor(){}
|
||||
~IUsrShaderVisitor(){}
|
||||
|
||||
virtual void visit( CUsrShaderProgram *program ) = 0;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1,109 +1,109 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef NLVARIANT_H
|
||||
#define NLVARIANT_H
|
||||
|
||||
#include "nel/misc/stream.h"
|
||||
#include <string>
|
||||
|
||||
#define VARIANT_VVAL_END 16
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
class CVariant : public IStreamable
|
||||
{
|
||||
public:
|
||||
|
||||
enum EVarType
|
||||
{
|
||||
Float,
|
||||
Double,
|
||||
Int,
|
||||
UInt,
|
||||
String,
|
||||
Vector4,
|
||||
Matrix4
|
||||
};
|
||||
|
||||
CVariant();
|
||||
~CVariant();
|
||||
|
||||
std::string getClassName(){ return "CVariant"; }
|
||||
|
||||
void serial( IStream &f );
|
||||
|
||||
void setDouble( double d ){
|
||||
type = Double;
|
||||
uvalue.dval = d;
|
||||
}
|
||||
|
||||
void setFloat( float f ){
|
||||
type = Float;
|
||||
uvalue.fval = f;
|
||||
}
|
||||
|
||||
void setInt( int i ){
|
||||
type = Int;
|
||||
uvalue.ival = i;
|
||||
}
|
||||
|
||||
void setUInt( unsigned int u ){
|
||||
type = UInt;
|
||||
uvalue.uval = u;
|
||||
}
|
||||
|
||||
void setString( const std::string &s ){
|
||||
type = String;
|
||||
sval = s;
|
||||
}
|
||||
|
||||
void setVector4( const float *v );
|
||||
void setMatrix4( const float *m );
|
||||
|
||||
double toDouble() const{ return uvalue.dval; }
|
||||
float toFloat() const{ return uvalue.fval; }
|
||||
int toInt() const{ return uvalue.ival; }
|
||||
unsigned int toUInt() const{ return uvalue.uval; }
|
||||
std::string toString() const{ return sval; }
|
||||
void getVector4( float *v ) const;
|
||||
void getMatrix4( float *m ) const;
|
||||
|
||||
bool valueAsString( std::string &s ) const;
|
||||
void fromString( const std::string &s, EVarType t );
|
||||
|
||||
EVarType getType() const{ return type; }
|
||||
|
||||
private:
|
||||
|
||||
union{
|
||||
double dval;
|
||||
float fval;
|
||||
int ival;
|
||||
unsigned int uval;
|
||||
float vval[ VARIANT_VVAL_END ];
|
||||
}uvalue;
|
||||
|
||||
std::string sval;
|
||||
|
||||
EVarType type;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef NLVARIANT_H
|
||||
#define NLVARIANT_H
|
||||
|
||||
#include "nel/misc/stream.h"
|
||||
#include <string>
|
||||
|
||||
#define VARIANT_VVAL_END 16
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
class CVariant : public IStreamable
|
||||
{
|
||||
public:
|
||||
|
||||
enum EVarType
|
||||
{
|
||||
Float,
|
||||
Double,
|
||||
Int,
|
||||
UInt,
|
||||
String,
|
||||
Vector4,
|
||||
Matrix4
|
||||
};
|
||||
|
||||
CVariant();
|
||||
~CVariant();
|
||||
|
||||
std::string getClassName(){ return "CVariant"; }
|
||||
|
||||
void serial( IStream &f );
|
||||
|
||||
void setDouble( double d ){
|
||||
type = Double;
|
||||
uvalue.dval = d;
|
||||
}
|
||||
|
||||
void setFloat( float f ){
|
||||
type = Float;
|
||||
uvalue.fval = f;
|
||||
}
|
||||
|
||||
void setInt( int i ){
|
||||
type = Int;
|
||||
uvalue.ival = i;
|
||||
}
|
||||
|
||||
void setUInt( unsigned int u ){
|
||||
type = UInt;
|
||||
uvalue.uval = u;
|
||||
}
|
||||
|
||||
void setString( const std::string &s ){
|
||||
type = String;
|
||||
sval = s;
|
||||
}
|
||||
|
||||
void setVector4( const float *v );
|
||||
void setMatrix4( const float *m );
|
||||
|
||||
double toDouble() const{ return uvalue.dval; }
|
||||
float toFloat() const{ return uvalue.fval; }
|
||||
int toInt() const{ return uvalue.ival; }
|
||||
unsigned int toUInt() const{ return uvalue.uval; }
|
||||
std::string toString() const{ return sval; }
|
||||
void getVector4( float *v ) const;
|
||||
void getMatrix4( float *m ) const;
|
||||
|
||||
bool valueAsString( std::string &s ) const;
|
||||
void fromString( const std::string &s, EVarType t );
|
||||
|
||||
EVarType getType() const{ return type; }
|
||||
|
||||
private:
|
||||
|
||||
union{
|
||||
double dval;
|
||||
float fval;
|
||||
int ival;
|
||||
unsigned int uval;
|
||||
float vval[ VARIANT_VVAL_END ];
|
||||
}uvalue;
|
||||
|
||||
std::string sval;
|
||||
|
||||
EVarType type;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,175 +1,175 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef GLSL_SHADER_GENERATOR
|
||||
#define GLSL_SHADER_GENERATOR
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class CMaterial;
|
||||
class CShaderDesc;
|
||||
|
||||
/// GLSL 330+ shader program generator
|
||||
class CGLSLShaderGenerator
|
||||
{
|
||||
public:
|
||||
CGLSLShaderGenerator();
|
||||
~CGLSLShaderGenerator();
|
||||
|
||||
/// Resets the generator to 0.
|
||||
void reset();
|
||||
|
||||
/// Generate Vertex Shader based on the data provided in material, descriptor and vertexbuffer flags
|
||||
void generateVS( std::string &vs );
|
||||
|
||||
/// Generate Pixel Shader based on the data provided in material, descriptor and vertexbuffer flags
|
||||
void generatePS( std::string &ps );
|
||||
|
||||
void setMaterial( CMaterial *mat ){ material = mat; }
|
||||
void setVBFormat( uint16 format ){ vbFormat = format; }
|
||||
void setShaderDesc( CShaderDesc *d ){ desc = d; }
|
||||
|
||||
private:
|
||||
/// Adds ambient color constant uniform declaration to the program
|
||||
void addAmbient();
|
||||
|
||||
/// Adds diffuse constant uniform declaration to the program
|
||||
void addDiffuse();
|
||||
|
||||
/// Adds specular color constant uniform declaration to the program
|
||||
void addSpecular();
|
||||
|
||||
/// Adds Color constant uniform declaration to the program
|
||||
void addColor();
|
||||
|
||||
/// Adds constant uniform declarations to the program
|
||||
void addConstants();
|
||||
|
||||
/// Adds the normal matrix declaration to the program
|
||||
void addNormalMatrix();
|
||||
|
||||
void addViewMatrix();
|
||||
|
||||
//////////////////////////// Alpha Threshold //////////////////
|
||||
|
||||
/// Adds the alpha threshold uniform to the program
|
||||
void addAlphaTreshold();
|
||||
|
||||
/// Adds the actual alpha test to the program ( discards fragment if below threshold )
|
||||
void addAlphaTest();
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////// Fog ///////////////////////////////
|
||||
|
||||
/// Adds the fog uniforms to the program
|
||||
void addFogUniform();
|
||||
|
||||
/// Adds the fog function to the program
|
||||
void addFogFunction();
|
||||
|
||||
/// Adds the fog call to the program
|
||||
void addFog();
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////// Lights ///////////////////////////
|
||||
|
||||
/// Adds the Vertex Shader light uniforms to the program
|
||||
void addLightUniformsVS();
|
||||
|
||||
/// Adds the Pixel Shader light uniforms to the program
|
||||
void addLightUniformsFS();
|
||||
|
||||
/// Adds the Vertex Shader light output variables to the program
|
||||
void addLightOutsVS();
|
||||
|
||||
/// Adds the Pixel Shader light output variables to the program
|
||||
void addLightInsFS();
|
||||
|
||||
/// Adds the directional light Vertex Shader function, num is the light number
|
||||
void addDirectionalFunctionVS( int num );
|
||||
|
||||
/// Adds the point-light Vertex Shader function, num is the light number
|
||||
void addPointLightFunctionVS( int num );
|
||||
|
||||
/// Adds the appropriate light functions to the Vertex Shader
|
||||
void addLightsFunctionVS();
|
||||
|
||||
/// Adds the appropriate light functions to the Pixel Shader
|
||||
void addLightsFunctionFS();
|
||||
|
||||
/// Adds the lights to the Vertex Shader ( calls the appropriate functions )
|
||||
void addLightsVS();
|
||||
|
||||
/// Adds the lights to the Fragment Shader ( calls the appropriate functions )
|
||||
void addLightsFS();
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////// Vertex Shader generation ////////////////////////////////////
|
||||
|
||||
|
||||
void generateNormalVS();
|
||||
void generateSpecularVS();
|
||||
|
||||
/// Per-Pixel Lighting
|
||||
void generatePPLVS();
|
||||
|
||||
void generateWaterVS();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////// Pixel Shader generation ///////////////////////////////////////
|
||||
|
||||
void generateNormalPS();
|
||||
|
||||
|
||||
void generateTexEnv();
|
||||
void generateTexEnvRGB( unsigned int stage );
|
||||
void generateTexEnvAlpha( unsigned int stage );
|
||||
void buildArg( unsigned int stage, unsigned int n, bool alpha, std::string &arg );
|
||||
|
||||
void generateLightMapPS();
|
||||
void generateSpecularPS();
|
||||
|
||||
/// Per-Pixel Lighting
|
||||
void generatePPLPS();
|
||||
|
||||
void generateWaterPS();
|
||||
|
||||
void generateCloudPS();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::stringstream ss;
|
||||
uint16 vbFormat;
|
||||
CMaterial const *material;
|
||||
CShaderDesc const *desc;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef GLSL_SHADER_GENERATOR
|
||||
#define GLSL_SHADER_GENERATOR
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class CMaterial;
|
||||
class CShaderDesc;
|
||||
|
||||
/// GLSL 330+ shader program generator
|
||||
class CGLSLShaderGenerator
|
||||
{
|
||||
public:
|
||||
CGLSLShaderGenerator();
|
||||
~CGLSLShaderGenerator();
|
||||
|
||||
/// Resets the generator to 0.
|
||||
void reset();
|
||||
|
||||
/// Generate Vertex Shader based on the data provided in material, descriptor and vertexbuffer flags
|
||||
void generateVS( std::string &vs );
|
||||
|
||||
/// Generate Pixel Shader based on the data provided in material, descriptor and vertexbuffer flags
|
||||
void generatePS( std::string &ps );
|
||||
|
||||
void setMaterial( CMaterial *mat ){ material = mat; }
|
||||
void setVBFormat( uint16 format ){ vbFormat = format; }
|
||||
void setShaderDesc( CShaderDesc *d ){ desc = d; }
|
||||
|
||||
private:
|
||||
/// Adds ambient color constant uniform declaration to the program
|
||||
void addAmbient();
|
||||
|
||||
/// Adds diffuse constant uniform declaration to the program
|
||||
void addDiffuse();
|
||||
|
||||
/// Adds specular color constant uniform declaration to the program
|
||||
void addSpecular();
|
||||
|
||||
/// Adds Color constant uniform declaration to the program
|
||||
void addColor();
|
||||
|
||||
/// Adds constant uniform declarations to the program
|
||||
void addConstants();
|
||||
|
||||
/// Adds the normal matrix declaration to the program
|
||||
void addNormalMatrix();
|
||||
|
||||
void addViewMatrix();
|
||||
|
||||
//////////////////////////// Alpha Threshold //////////////////
|
||||
|
||||
/// Adds the alpha threshold uniform to the program
|
||||
void addAlphaTreshold();
|
||||
|
||||
/// Adds the actual alpha test to the program ( discards fragment if below threshold )
|
||||
void addAlphaTest();
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////// Fog ///////////////////////////////
|
||||
|
||||
/// Adds the fog uniforms to the program
|
||||
void addFogUniform();
|
||||
|
||||
/// Adds the fog function to the program
|
||||
void addFogFunction();
|
||||
|
||||
/// Adds the fog call to the program
|
||||
void addFog();
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////// Lights ///////////////////////////
|
||||
|
||||
/// Adds the Vertex Shader light uniforms to the program
|
||||
void addLightUniformsVS();
|
||||
|
||||
/// Adds the Pixel Shader light uniforms to the program
|
||||
void addLightUniformsFS();
|
||||
|
||||
/// Adds the Vertex Shader light output variables to the program
|
||||
void addLightOutsVS();
|
||||
|
||||
/// Adds the Pixel Shader light output variables to the program
|
||||
void addLightInsFS();
|
||||
|
||||
/// Adds the directional light Vertex Shader function, num is the light number
|
||||
void addDirectionalFunctionVS( int num );
|
||||
|
||||
/// Adds the point-light Vertex Shader function, num is the light number
|
||||
void addPointLightFunctionVS( int num );
|
||||
|
||||
/// Adds the appropriate light functions to the Vertex Shader
|
||||
void addLightsFunctionVS();
|
||||
|
||||
/// Adds the appropriate light functions to the Pixel Shader
|
||||
void addLightsFunctionFS();
|
||||
|
||||
/// Adds the lights to the Vertex Shader ( calls the appropriate functions )
|
||||
void addLightsVS();
|
||||
|
||||
/// Adds the lights to the Fragment Shader ( calls the appropriate functions )
|
||||
void addLightsFS();
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////// Vertex Shader generation ////////////////////////////////////
|
||||
|
||||
|
||||
void generateNormalVS();
|
||||
void generateSpecularVS();
|
||||
|
||||
/// Per-Pixel Lighting
|
||||
void generatePPLVS();
|
||||
|
||||
void generateWaterVS();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////// Pixel Shader generation ///////////////////////////////////////
|
||||
|
||||
void generateNormalPS();
|
||||
|
||||
|
||||
void generateTexEnv();
|
||||
void generateTexEnvRGB( unsigned int stage );
|
||||
void generateTexEnvAlpha( unsigned int stage );
|
||||
void buildArg( unsigned int stage, unsigned int n, bool alpha, std::string &arg );
|
||||
|
||||
void generateLightMapPS();
|
||||
void generateSpecularPS();
|
||||
|
||||
/// Per-Pixel Lighting
|
||||
void generatePPLPS();
|
||||
|
||||
void generateWaterPS();
|
||||
|
||||
void generateCloudPS();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::stringstream ss;
|
||||
uint16 vbFormat;
|
||||
CMaterial const *material;
|
||||
CShaderDesc const *desc;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,62 +1,62 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "driver_opengl_shader_cache.h"
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
CShaderCache::CShaderCache()
|
||||
{
|
||||
}
|
||||
|
||||
CShaderCache::~CShaderCache()
|
||||
{
|
||||
clearCache();
|
||||
}
|
||||
|
||||
SShaderPair CShaderCache::findShader( const CShaderDesc &desc ) const
|
||||
{
|
||||
for( int i = 0; i < shaders.size(); i++ )
|
||||
{
|
||||
if( shaders[ i ] == desc )
|
||||
return shaders[ i ].getShaders();
|
||||
}
|
||||
|
||||
return SShaderPair();
|
||||
}
|
||||
|
||||
void CShaderCache::cacheShader( CShaderDesc &desc )
|
||||
{
|
||||
shaders.push_back( desc );
|
||||
}
|
||||
|
||||
void CShaderCache::clearCache()
|
||||
{
|
||||
std::vector< CShaderDesc >::iterator itr = shaders.begin();
|
||||
while( itr != shaders.end() )
|
||||
{
|
||||
SShaderPair sp;
|
||||
sp = itr->getShaders();
|
||||
delete sp.vp;
|
||||
delete sp.pp;
|
||||
++itr;
|
||||
}
|
||||
|
||||
shaders.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "driver_opengl_shader_cache.h"
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
CShaderCache::CShaderCache()
|
||||
{
|
||||
}
|
||||
|
||||
CShaderCache::~CShaderCache()
|
||||
{
|
||||
clearCache();
|
||||
}
|
||||
|
||||
SShaderPair CShaderCache::findShader( const CShaderDesc &desc ) const
|
||||
{
|
||||
for( int i = 0; i < shaders.size(); i++ )
|
||||
{
|
||||
if( shaders[ i ] == desc )
|
||||
return shaders[ i ].getShaders();
|
||||
}
|
||||
|
||||
return SShaderPair();
|
||||
}
|
||||
|
||||
void CShaderCache::cacheShader( CShaderDesc &desc )
|
||||
{
|
||||
shaders.push_back( desc );
|
||||
}
|
||||
|
||||
void CShaderCache::clearCache()
|
||||
{
|
||||
std::vector< CShaderDesc >::iterator itr = shaders.begin();
|
||||
while( itr != shaders.end() )
|
||||
{
|
||||
SShaderPair sp;
|
||||
sp = itr->getShaders();
|
||||
delete sp.vp;
|
||||
delete sp.pp;
|
||||
++itr;
|
||||
}
|
||||
|
||||
shaders.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,50 +1,50 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef OPENGL_SHADER_CACHE
|
||||
#define OPENGL_SHADER_CACHE
|
||||
|
||||
#include "driver_opengl_shader_desc.h"
|
||||
#include <vector>
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
/// Caches generated shaders, so they don't have to be generated every frame
|
||||
class CShaderCache
|
||||
{
|
||||
public:
|
||||
CShaderCache();
|
||||
~CShaderCache();
|
||||
|
||||
/// Checks if there's a shader cached that was generated from the specified descriptor
|
||||
SShaderPair findShader( const CShaderDesc &desc ) const;
|
||||
|
||||
/// Caches a shader with the specified descriptor as key
|
||||
void cacheShader( CShaderDesc &desc );
|
||||
|
||||
/// Clears the caches, removes the cached shaders
|
||||
void clearCache();
|
||||
|
||||
private:
|
||||
std::vector< CShaderDesc > shaders;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef OPENGL_SHADER_CACHE
|
||||
#define OPENGL_SHADER_CACHE
|
||||
|
||||
#include "driver_opengl_shader_desc.h"
|
||||
#include <vector>
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
/// Caches generated shaders, so they don't have to be generated every frame
|
||||
class CShaderCache
|
||||
{
|
||||
public:
|
||||
CShaderCache();
|
||||
~CShaderCache();
|
||||
|
||||
/// Checks if there's a shader cached that was generated from the specified descriptor
|
||||
SShaderPair findShader( const CShaderDesc &desc ) const;
|
||||
|
||||
/// Caches a shader with the specified descriptor as key
|
||||
void cacheShader( CShaderDesc &desc );
|
||||
|
||||
/// Clears the caches, removes the cached shaders
|
||||
void clearCache();
|
||||
|
||||
private:
|
||||
std::vector< CShaderDesc > shaders;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,278 +1,278 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef SHADER_DESC
|
||||
#define SHADER_DESC
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
|
||||
#define SHADER_MAX_TEXTURES 4
|
||||
#define SHADER_MAX_LIGHTS 8
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class CVertexProgram;
|
||||
class CPixelProgram;
|
||||
|
||||
struct SShaderPair
|
||||
{
|
||||
SShaderPair()
|
||||
{
|
||||
vp = NULL;
|
||||
pp = NULL;
|
||||
}
|
||||
|
||||
~SShaderPair()
|
||||
{
|
||||
vp = NULL;
|
||||
pp = NULL;
|
||||
}
|
||||
|
||||
bool empty() const{
|
||||
if( ( vp == NULL ) && ( pp == NULL ) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
CVertexProgram *vp;
|
||||
CPixelProgram *pp;
|
||||
};
|
||||
|
||||
class CShaderDesc
|
||||
{
|
||||
public:
|
||||
|
||||
enum TShaderType
|
||||
{
|
||||
Normal,
|
||||
Bump_unused,
|
||||
UserColor,
|
||||
LightMap,
|
||||
Specular,
|
||||
Caustics_unused,
|
||||
PerPixelLighting,
|
||||
PerPixelNoSpecular,
|
||||
Cloud,
|
||||
Water
|
||||
};
|
||||
|
||||
enum TFogMode
|
||||
{
|
||||
Exponential,
|
||||
Exponential2,
|
||||
Linear
|
||||
};
|
||||
|
||||
enum TLightMode
|
||||
{
|
||||
Nolight,
|
||||
Directional,
|
||||
Point,
|
||||
Spot
|
||||
};
|
||||
|
||||
CShaderDesc(){
|
||||
for( int i = 0; i < SHADER_MAX_TEXTURES; i++ )
|
||||
texEnvMode[ i ] = 0;
|
||||
|
||||
for( int i = 0; i < SHADER_MAX_LIGHTS; i++ )
|
||||
lightMode[ i ] = Nolight;
|
||||
|
||||
for( int i = 0; i < SHADER_MAX_TEXTURES; i++ )
|
||||
useTextureStage[ i ] = false;
|
||||
useFirstTextureCoordSet = false;
|
||||
noTextures = true;
|
||||
|
||||
features = None;
|
||||
shaderType = Normal;
|
||||
vbFlags = 0;
|
||||
nlightmaps = 0;
|
||||
alphaTestTreshold = 0.5f;
|
||||
fogMode = Linear;
|
||||
pointLight = false;
|
||||
}
|
||||
|
||||
~CShaderDesc(){
|
||||
}
|
||||
|
||||
bool operator==( const CShaderDesc &o ) const
|
||||
{
|
||||
if( noTextures != o.noTextures )
|
||||
return false;
|
||||
|
||||
if( shaderType != o.shaderType )
|
||||
return false;
|
||||
|
||||
if( vbFlags != o.vbFlags )
|
||||
return false;
|
||||
|
||||
if( nlightmaps != o.nlightmaps )
|
||||
return false;
|
||||
|
||||
if( features != o.features )
|
||||
return false;
|
||||
|
||||
if( ( features & AlphaTest ) != 0 )
|
||||
{
|
||||
if( alphaTestTreshold > o.alphaTestTreshold + 0.0001f )
|
||||
return false;
|
||||
|
||||
if( alphaTestTreshold < o.alphaTestTreshold - 0.0001f )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( fogEnabled() )
|
||||
{
|
||||
if( fogMode != o.fogMode )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( shaderType == Normal )
|
||||
{
|
||||
if( useFirstTextureCoordSet != o.useFirstTextureCoordSet )
|
||||
return false;
|
||||
|
||||
for( int i = 0; i < SHADER_MAX_TEXTURES; i++ )
|
||||
if( texEnvMode[ i ] != o.texEnvMode[ i ] )
|
||||
return false;
|
||||
|
||||
for( int i = 0; i < SHADER_MAX_TEXTURES; i++ )
|
||||
if( useTextureStage[ i ] != o.useTextureStage[ i ] )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( lightingEnabled() )
|
||||
{
|
||||
for( int i = 0; i < SHADER_MAX_LIGHTS; i++ )
|
||||
if( lightMode[ i ] != o.lightMode[ i ] )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void setTexEnvMode( uint32 index, uint32 mode ){ texEnvMode[ index ] = mode; }
|
||||
|
||||
void setUseFirstTexCoords( bool b ){ useFirstTextureCoordSet = b; }
|
||||
bool getUseFirstTexCoords() const{ return useFirstTextureCoordSet; }
|
||||
|
||||
void setUseTexStage( uint8 stage, bool b ){ useTextureStage[ stage ] = b; }
|
||||
bool getUseTexStage( uint8 stage ) const{ return useTextureStage[ stage ]; }
|
||||
|
||||
void setNoTextures( bool b ){ noTextures = b; }
|
||||
bool useTextures() const{ return !noTextures; }
|
||||
|
||||
void setVBFlags( uint32 flags ){ vbFlags = flags; }
|
||||
bool hasVBFlags( uint32 flags ) const{
|
||||
if( ( vbFlags & flags ) != 0 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void setShaderType( uint32 type ){ shaderType = type; }
|
||||
void setNLightMaps( uint32 n ){ nlightmaps = n; }
|
||||
|
||||
void setAlphaTest( bool b )
|
||||
{
|
||||
if( b )
|
||||
features |= AlphaTest;
|
||||
else
|
||||
features &= ~AlphaTest;
|
||||
}
|
||||
|
||||
void setAlphaTestThreshold( float t ){ alphaTestTreshold = t; }
|
||||
|
||||
void setFog( bool b )
|
||||
{
|
||||
if( b )
|
||||
features |= Fog;
|
||||
else
|
||||
features &= ~Fog;
|
||||
}
|
||||
|
||||
bool fogEnabled() const
|
||||
{
|
||||
if( ( features & Fog ) != 0 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void setFogMode( TFogMode mode ){ fogMode = mode; }
|
||||
|
||||
uint32 getFogMode() const{ return fogMode; }
|
||||
|
||||
void setLighting( bool b )
|
||||
{
|
||||
if( b )
|
||||
features |= Lighting;
|
||||
else
|
||||
features &= ~Lighting;
|
||||
}
|
||||
|
||||
bool lightingEnabled() const
|
||||
{
|
||||
if( ( features & Lighting ) != 0 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void setLight( int idx, TLightMode mode )
|
||||
{
|
||||
lightMode[ idx ] = mode;
|
||||
if( mode == Point )
|
||||
pointLight = true;
|
||||
}
|
||||
|
||||
TLightMode getLight( int idx ) const{ return lightMode[ idx ]; }
|
||||
|
||||
bool hasPointLight() const{ return pointLight; }
|
||||
|
||||
void setShaders( SShaderPair sp ){ shaderPair = sp; }
|
||||
SShaderPair getShaders() const{ return shaderPair; }
|
||||
|
||||
private:
|
||||
|
||||
enum TShaderFeatures
|
||||
{
|
||||
None = 0,
|
||||
AlphaTest = 1,
|
||||
Fog = 2,
|
||||
Lighting = 4
|
||||
};
|
||||
|
||||
uint32 features;
|
||||
uint32 texEnvMode[ SHADER_MAX_TEXTURES ];
|
||||
bool useTextureStage[ SHADER_MAX_TEXTURES ];
|
||||
bool useFirstTextureCoordSet;
|
||||
bool noTextures;
|
||||
uint32 vbFlags;
|
||||
uint32 shaderType;
|
||||
uint32 nlightmaps;
|
||||
float alphaTestTreshold;
|
||||
uint32 fogMode;
|
||||
TLightMode lightMode[ SHADER_MAX_LIGHTS ];
|
||||
bool pointLight;
|
||||
|
||||
SShaderPair shaderPair;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef SHADER_DESC
|
||||
#define SHADER_DESC
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
|
||||
#define SHADER_MAX_TEXTURES 4
|
||||
#define SHADER_MAX_LIGHTS 8
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class CVertexProgram;
|
||||
class CPixelProgram;
|
||||
|
||||
struct SShaderPair
|
||||
{
|
||||
SShaderPair()
|
||||
{
|
||||
vp = NULL;
|
||||
pp = NULL;
|
||||
}
|
||||
|
||||
~SShaderPair()
|
||||
{
|
||||
vp = NULL;
|
||||
pp = NULL;
|
||||
}
|
||||
|
||||
bool empty() const{
|
||||
if( ( vp == NULL ) && ( pp == NULL ) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
CVertexProgram *vp;
|
||||
CPixelProgram *pp;
|
||||
};
|
||||
|
||||
class CShaderDesc
|
||||
{
|
||||
public:
|
||||
|
||||
enum TShaderType
|
||||
{
|
||||
Normal,
|
||||
Bump_unused,
|
||||
UserColor,
|
||||
LightMap,
|
||||
Specular,
|
||||
Caustics_unused,
|
||||
PerPixelLighting,
|
||||
PerPixelNoSpecular,
|
||||
Cloud,
|
||||
Water
|
||||
};
|
||||
|
||||
enum TFogMode
|
||||
{
|
||||
Exponential,
|
||||
Exponential2,
|
||||
Linear
|
||||
};
|
||||
|
||||
enum TLightMode
|
||||
{
|
||||
Nolight,
|
||||
Directional,
|
||||
Point,
|
||||
Spot
|
||||
};
|
||||
|
||||
CShaderDesc(){
|
||||
for( int i = 0; i < SHADER_MAX_TEXTURES; i++ )
|
||||
texEnvMode[ i ] = 0;
|
||||
|
||||
for( int i = 0; i < SHADER_MAX_LIGHTS; i++ )
|
||||
lightMode[ i ] = Nolight;
|
||||
|
||||
for( int i = 0; i < SHADER_MAX_TEXTURES; i++ )
|
||||
useTextureStage[ i ] = false;
|
||||
useFirstTextureCoordSet = false;
|
||||
noTextures = true;
|
||||
|
||||
features = None;
|
||||
shaderType = Normal;
|
||||
vbFlags = 0;
|
||||
nlightmaps = 0;
|
||||
alphaTestTreshold = 0.5f;
|
||||
fogMode = Linear;
|
||||
pointLight = false;
|
||||
}
|
||||
|
||||
~CShaderDesc(){
|
||||
}
|
||||
|
||||
bool operator==( const CShaderDesc &o ) const
|
||||
{
|
||||
if( noTextures != o.noTextures )
|
||||
return false;
|
||||
|
||||
if( shaderType != o.shaderType )
|
||||
return false;
|
||||
|
||||
if( vbFlags != o.vbFlags )
|
||||
return false;
|
||||
|
||||
if( nlightmaps != o.nlightmaps )
|
||||
return false;
|
||||
|
||||
if( features != o.features )
|
||||
return false;
|
||||
|
||||
if( ( features & AlphaTest ) != 0 )
|
||||
{
|
||||
if( alphaTestTreshold > o.alphaTestTreshold + 0.0001f )
|
||||
return false;
|
||||
|
||||
if( alphaTestTreshold < o.alphaTestTreshold - 0.0001f )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( fogEnabled() )
|
||||
{
|
||||
if( fogMode != o.fogMode )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( shaderType == Normal )
|
||||
{
|
||||
if( useFirstTextureCoordSet != o.useFirstTextureCoordSet )
|
||||
return false;
|
||||
|
||||
for( int i = 0; i < SHADER_MAX_TEXTURES; i++ )
|
||||
if( texEnvMode[ i ] != o.texEnvMode[ i ] )
|
||||
return false;
|
||||
|
||||
for( int i = 0; i < SHADER_MAX_TEXTURES; i++ )
|
||||
if( useTextureStage[ i ] != o.useTextureStage[ i ] )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( lightingEnabled() )
|
||||
{
|
||||
for( int i = 0; i < SHADER_MAX_LIGHTS; i++ )
|
||||
if( lightMode[ i ] != o.lightMode[ i ] )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void setTexEnvMode( uint32 index, uint32 mode ){ texEnvMode[ index ] = mode; }
|
||||
|
||||
void setUseFirstTexCoords( bool b ){ useFirstTextureCoordSet = b; }
|
||||
bool getUseFirstTexCoords() const{ return useFirstTextureCoordSet; }
|
||||
|
||||
void setUseTexStage( uint8 stage, bool b ){ useTextureStage[ stage ] = b; }
|
||||
bool getUseTexStage( uint8 stage ) const{ return useTextureStage[ stage ]; }
|
||||
|
||||
void setNoTextures( bool b ){ noTextures = b; }
|
||||
bool useTextures() const{ return !noTextures; }
|
||||
|
||||
void setVBFlags( uint32 flags ){ vbFlags = flags; }
|
||||
bool hasVBFlags( uint32 flags ) const{
|
||||
if( ( vbFlags & flags ) != 0 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void setShaderType( uint32 type ){ shaderType = type; }
|
||||
void setNLightMaps( uint32 n ){ nlightmaps = n; }
|
||||
|
||||
void setAlphaTest( bool b )
|
||||
{
|
||||
if( b )
|
||||
features |= AlphaTest;
|
||||
else
|
||||
features &= ~AlphaTest;
|
||||
}
|
||||
|
||||
void setAlphaTestThreshold( float t ){ alphaTestTreshold = t; }
|
||||
|
||||
void setFog( bool b )
|
||||
{
|
||||
if( b )
|
||||
features |= Fog;
|
||||
else
|
||||
features &= ~Fog;
|
||||
}
|
||||
|
||||
bool fogEnabled() const
|
||||
{
|
||||
if( ( features & Fog ) != 0 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void setFogMode( TFogMode mode ){ fogMode = mode; }
|
||||
|
||||
uint32 getFogMode() const{ return fogMode; }
|
||||
|
||||
void setLighting( bool b )
|
||||
{
|
||||
if( b )
|
||||
features |= Lighting;
|
||||
else
|
||||
features &= ~Lighting;
|
||||
}
|
||||
|
||||
bool lightingEnabled() const
|
||||
{
|
||||
if( ( features & Lighting ) != 0 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void setLight( int idx, TLightMode mode )
|
||||
{
|
||||
lightMode[ idx ] = mode;
|
||||
if( mode == Point )
|
||||
pointLight = true;
|
||||
}
|
||||
|
||||
TLightMode getLight( int idx ) const{ return lightMode[ idx ]; }
|
||||
|
||||
bool hasPointLight() const{ return pointLight; }
|
||||
|
||||
void setShaders( SShaderPair sp ){ shaderPair = sp; }
|
||||
SShaderPair getShaders() const{ return shaderPair; }
|
||||
|
||||
private:
|
||||
|
||||
enum TShaderFeatures
|
||||
{
|
||||
None = 0,
|
||||
AlphaTest = 1,
|
||||
Fog = 2,
|
||||
Lighting = 4
|
||||
};
|
||||
|
||||
uint32 features;
|
||||
uint32 texEnvMode[ SHADER_MAX_TEXTURES ];
|
||||
bool useTextureStage[ SHADER_MAX_TEXTURES ];
|
||||
bool useFirstTextureCoordSet;
|
||||
bool noTextures;
|
||||
uint32 vbFlags;
|
||||
uint32 shaderType;
|
||||
uint32 nlightmaps;
|
||||
float alphaTestTreshold;
|
||||
uint32 fogMode;
|
||||
TLightMode lightMode[ SHADER_MAX_LIGHTS ];
|
||||
bool pointLight;
|
||||
|
||||
SShaderPair shaderPair;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,61 +1,61 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "nel/3d/dyn_mat_loader.h"
|
||||
#include "nel/3d/dynamic_material.h"
|
||||
#include "nel/misc/file.h"
|
||||
#include "nel/misc/i_xml.h"
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
CDynMatLoader::CDynMatLoader()
|
||||
{
|
||||
mat = NULL;
|
||||
}
|
||||
|
||||
CDynMatLoader::~CDynMatLoader()
|
||||
{
|
||||
mat = NULL;
|
||||
}
|
||||
|
||||
bool CDynMatLoader::loadFrom( const std::string &fileName )
|
||||
{
|
||||
NLMISC::CIFile ifile;
|
||||
if( !ifile.open( fileName, true ) )
|
||||
{
|
||||
nlinfo( "Error opening file %s", fileName.c_str() );
|
||||
return false;
|
||||
}
|
||||
|
||||
NLMISC::CIXml xml;
|
||||
if( !xml.init( ifile ) )
|
||||
{
|
||||
ifile.close();
|
||||
nlinfo( "Error initializing XML stream for file %s", fileName.c_str() );
|
||||
return false;
|
||||
}
|
||||
|
||||
mat = new CDynMaterial();
|
||||
mat->serial( xml );
|
||||
|
||||
ifile.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "nel/3d/dyn_mat_loader.h"
|
||||
#include "nel/3d/dynamic_material.h"
|
||||
#include "nel/misc/file.h"
|
||||
#include "nel/misc/i_xml.h"
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
CDynMatLoader::CDynMatLoader()
|
||||
{
|
||||
mat = NULL;
|
||||
}
|
||||
|
||||
CDynMatLoader::~CDynMatLoader()
|
||||
{
|
||||
mat = NULL;
|
||||
}
|
||||
|
||||
bool CDynMatLoader::loadFrom( const std::string &fileName )
|
||||
{
|
||||
NLMISC::CIFile ifile;
|
||||
if( !ifile.open( fileName, true ) )
|
||||
{
|
||||
nlinfo( "Error opening file %s", fileName.c_str() );
|
||||
return false;
|
||||
}
|
||||
|
||||
NLMISC::CIXml xml;
|
||||
if( !xml.init( ifile ) )
|
||||
{
|
||||
ifile.close();
|
||||
nlinfo( "Error initializing XML stream for file %s", fileName.c_str() );
|
||||
return false;
|
||||
}
|
||||
|
||||
mat = new CDynMaterial();
|
||||
mat->serial( xml );
|
||||
|
||||
ifile.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,383 +1,383 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "nel/3d/dynamic_material.h"
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
void SDynMaterialProp::serial( NLMISC::IStream &f )
|
||||
{
|
||||
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.xmlPush( "pass" );
|
||||
|
||||
f.xmlPush( "name" );
|
||||
f.serial( name );
|
||||
f.xmlPop();
|
||||
|
||||
f.xmlPush( "shader" );
|
||||
f.serial( shaderRef );
|
||||
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() )
|
||||
{
|
||||
itr->serial( f );
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 n;
|
||||
f.xmlPush( "count" );
|
||||
f.serial( n );
|
||||
f.xmlPop();
|
||||
|
||||
for( uint32 i = 0; i < n; i++ )
|
||||
{
|
||||
SDynMaterialProp prop;
|
||||
prop.serial( f );
|
||||
properties.push_back( prop );
|
||||
}
|
||||
}
|
||||
|
||||
f.xmlPop();
|
||||
|
||||
f.xmlPop();
|
||||
}
|
||||
|
||||
void SRenderPass::addProperty( const SDynMaterialProp &prop )
|
||||
{
|
||||
std::vector< SDynMaterialProp >::const_iterator itr = properties.begin();
|
||||
while( itr != properties.end() )
|
||||
{
|
||||
if( itr->prop == prop.prop )
|
||||
break;
|
||||
++itr;
|
||||
}
|
||||
if( itr != properties.end() )
|
||||
return;
|
||||
|
||||
properties.push_back( prop );
|
||||
}
|
||||
|
||||
void SRenderPass::removeProperty( const std::string &name )
|
||||
{
|
||||
std::vector< SDynMaterialProp >::iterator itr = properties.begin();
|
||||
while( itr != properties.end() )
|
||||
{
|
||||
if( itr->prop == name )
|
||||
break;
|
||||
++itr;
|
||||
}
|
||||
if( itr == properties.end() )
|
||||
return;
|
||||
|
||||
properties.erase( itr );
|
||||
}
|
||||
|
||||
bool SRenderPass::changeProperty( const std::string &name, const SDynMaterialProp &prop )
|
||||
{
|
||||
std::vector< SDynMaterialProp >::iterator itr = properties.begin();
|
||||
while( itr != properties.end() )
|
||||
{
|
||||
if( itr->prop == name )
|
||||
break;
|
||||
++itr;
|
||||
}
|
||||
if( itr == properties.end() )
|
||||
return false;
|
||||
|
||||
itr->prop = prop.prop;
|
||||
itr->label = prop.label;
|
||||
itr->type = prop.type;
|
||||
itr->value = prop.value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const SDynMaterialProp* SRenderPass::getProperty( uint32 i ) const
|
||||
{
|
||||
if( i >= properties.size() )
|
||||
return NULL;
|
||||
|
||||
return &( properties[ i ] );
|
||||
}
|
||||
|
||||
CDynMaterial::CDynMaterial()
|
||||
{
|
||||
reconstruct();
|
||||
}
|
||||
|
||||
CDynMaterial::~CDynMaterial()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
CDynMaterial& CDynMaterial::operator=( const CDynMaterial &other )
|
||||
{
|
||||
if( &other != this )
|
||||
{
|
||||
clear();
|
||||
|
||||
std::vector< SRenderPass* >::const_iterator itr = other.passes.begin();
|
||||
while( itr != other.passes.end() )
|
||||
{
|
||||
SRenderPass *pass = new SRenderPass();
|
||||
*pass = *(*itr);
|
||||
passes.push_back( pass );
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void CDynMaterial::reconstruct()
|
||||
{
|
||||
clear();
|
||||
SRenderPass *p = new SRenderPass();
|
||||
p->setName( "pass1" );
|
||||
passes.push_back( p );
|
||||
}
|
||||
|
||||
void CDynMaterial::clear()
|
||||
{
|
||||
std::vector< SRenderPass* >::iterator itr = passes.begin();
|
||||
while( itr != passes.end() )
|
||||
{
|
||||
delete *itr;
|
||||
++itr;
|
||||
}
|
||||
passes.clear();
|
||||
}
|
||||
|
||||
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() )
|
||||
{
|
||||
(*itr)->serial( f );
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
clear();
|
||||
uint32 n;
|
||||
f.xmlPush( "count" );
|
||||
f.serial( n );
|
||||
f.xmlPop();
|
||||
|
||||
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 )
|
||||
{
|
||||
std::string n;
|
||||
std::string name;
|
||||
pass.getName( name );
|
||||
|
||||
std::vector< SRenderPass* >::iterator itr = passes.begin();
|
||||
while( itr != passes.end() )
|
||||
{
|
||||
(*itr)->getName( n );
|
||||
if( n == name )
|
||||
break;
|
||||
++itr;
|
||||
}
|
||||
if( itr != passes.end() )
|
||||
return;
|
||||
|
||||
SRenderPass *p = new SRenderPass();
|
||||
*p = pass;
|
||||
passes.push_back( p );
|
||||
}
|
||||
|
||||
void CDynMaterial::removePass( const std::string &name )
|
||||
{
|
||||
std::string n;
|
||||
std::vector< SRenderPass* >::iterator itr = passes.begin();
|
||||
while( itr != passes.end() )
|
||||
{
|
||||
(*itr)->getName( n );
|
||||
if( n == name )
|
||||
break;
|
||||
++itr;
|
||||
}
|
||||
|
||||
if( itr != passes.end() )
|
||||
{
|
||||
delete *itr;
|
||||
passes.erase( itr );
|
||||
}
|
||||
}
|
||||
|
||||
void CDynMaterial::renamePass( const std::string &from, const std::string &to )
|
||||
{
|
||||
std::string n;
|
||||
std::vector< SRenderPass* >::iterator itr = passes.begin();
|
||||
while( itr != passes.end() )
|
||||
{
|
||||
(*itr)->getName( n );
|
||||
if( n == from )
|
||||
break;
|
||||
++itr;
|
||||
}
|
||||
|
||||
if( itr != passes.end() )
|
||||
(*itr)->setName( to );
|
||||
}
|
||||
|
||||
void CDynMaterial::movePassUp( const std::string &name )
|
||||
{
|
||||
std::string n;
|
||||
uint32 i = 0;
|
||||
for( i = 0; i < passes.size(); i++ )
|
||||
{
|
||||
passes[ i ]->getName( n );
|
||||
if( n == name )
|
||||
break;
|
||||
}
|
||||
|
||||
if( i >= passes.size() )
|
||||
return;
|
||||
|
||||
if( i == 0 )
|
||||
return;
|
||||
|
||||
SRenderPass *temp = passes[ i ];
|
||||
passes[ i ] = passes[ i - 1 ];
|
||||
passes[ i - 1 ] = temp;
|
||||
}
|
||||
|
||||
void CDynMaterial::movePassDown( const std::string &name )
|
||||
{
|
||||
std::string n;
|
||||
uint32 i = 0;
|
||||
for( i = 0; i < passes.size(); i++ )
|
||||
{
|
||||
passes[ i ]->getName( n );
|
||||
if( n == name )
|
||||
break;
|
||||
}
|
||||
|
||||
if( i >= passes.size() )
|
||||
return;
|
||||
|
||||
if( i == ( passes.size() - 1 ) )
|
||||
return;
|
||||
|
||||
SRenderPass *temp = passes[ i ];
|
||||
passes[ i ] = passes[ i + 1 ];
|
||||
passes[ i + 1 ] = temp;
|
||||
}
|
||||
|
||||
SRenderPass* CDynMaterial::getPass( const std::string &name )
|
||||
{
|
||||
std::string n;
|
||||
std::vector< SRenderPass* >::iterator itr = passes.begin();
|
||||
while( itr != passes.end() )
|
||||
{
|
||||
(*itr)->getName( n );
|
||||
if( n == name )
|
||||
break;
|
||||
++itr;
|
||||
}
|
||||
if( itr == passes.end() )
|
||||
return NULL;
|
||||
else
|
||||
return *itr;
|
||||
}
|
||||
|
||||
SRenderPass* CDynMaterial::getPass( uint32 i )
|
||||
{
|
||||
if( i >= passes.size() )
|
||||
return NULL;
|
||||
else
|
||||
return passes[ i ];
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "nel/3d/dynamic_material.h"
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
void SDynMaterialProp::serial( NLMISC::IStream &f )
|
||||
{
|
||||
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.xmlPush( "pass" );
|
||||
|
||||
f.xmlPush( "name" );
|
||||
f.serial( name );
|
||||
f.xmlPop();
|
||||
|
||||
f.xmlPush( "shader" );
|
||||
f.serial( shaderRef );
|
||||
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() )
|
||||
{
|
||||
itr->serial( f );
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 n;
|
||||
f.xmlPush( "count" );
|
||||
f.serial( n );
|
||||
f.xmlPop();
|
||||
|
||||
for( uint32 i = 0; i < n; i++ )
|
||||
{
|
||||
SDynMaterialProp prop;
|
||||
prop.serial( f );
|
||||
properties.push_back( prop );
|
||||
}
|
||||
}
|
||||
|
||||
f.xmlPop();
|
||||
|
||||
f.xmlPop();
|
||||
}
|
||||
|
||||
void SRenderPass::addProperty( const SDynMaterialProp &prop )
|
||||
{
|
||||
std::vector< SDynMaterialProp >::const_iterator itr = properties.begin();
|
||||
while( itr != properties.end() )
|
||||
{
|
||||
if( itr->prop == prop.prop )
|
||||
break;
|
||||
++itr;
|
||||
}
|
||||
if( itr != properties.end() )
|
||||
return;
|
||||
|
||||
properties.push_back( prop );
|
||||
}
|
||||
|
||||
void SRenderPass::removeProperty( const std::string &name )
|
||||
{
|
||||
std::vector< SDynMaterialProp >::iterator itr = properties.begin();
|
||||
while( itr != properties.end() )
|
||||
{
|
||||
if( itr->prop == name )
|
||||
break;
|
||||
++itr;
|
||||
}
|
||||
if( itr == properties.end() )
|
||||
return;
|
||||
|
||||
properties.erase( itr );
|
||||
}
|
||||
|
||||
bool SRenderPass::changeProperty( const std::string &name, const SDynMaterialProp &prop )
|
||||
{
|
||||
std::vector< SDynMaterialProp >::iterator itr = properties.begin();
|
||||
while( itr != properties.end() )
|
||||
{
|
||||
if( itr->prop == name )
|
||||
break;
|
||||
++itr;
|
||||
}
|
||||
if( itr == properties.end() )
|
||||
return false;
|
||||
|
||||
itr->prop = prop.prop;
|
||||
itr->label = prop.label;
|
||||
itr->type = prop.type;
|
||||
itr->value = prop.value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const SDynMaterialProp* SRenderPass::getProperty( uint32 i ) const
|
||||
{
|
||||
if( i >= properties.size() )
|
||||
return NULL;
|
||||
|
||||
return &( properties[ i ] );
|
||||
}
|
||||
|
||||
CDynMaterial::CDynMaterial()
|
||||
{
|
||||
reconstruct();
|
||||
}
|
||||
|
||||
CDynMaterial::~CDynMaterial()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
CDynMaterial& CDynMaterial::operator=( const CDynMaterial &other )
|
||||
{
|
||||
if( &other != this )
|
||||
{
|
||||
clear();
|
||||
|
||||
std::vector< SRenderPass* >::const_iterator itr = other.passes.begin();
|
||||
while( itr != other.passes.end() )
|
||||
{
|
||||
SRenderPass *pass = new SRenderPass();
|
||||
*pass = *(*itr);
|
||||
passes.push_back( pass );
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void CDynMaterial::reconstruct()
|
||||
{
|
||||
clear();
|
||||
SRenderPass *p = new SRenderPass();
|
||||
p->setName( "pass1" );
|
||||
passes.push_back( p );
|
||||
}
|
||||
|
||||
void CDynMaterial::clear()
|
||||
{
|
||||
std::vector< SRenderPass* >::iterator itr = passes.begin();
|
||||
while( itr != passes.end() )
|
||||
{
|
||||
delete *itr;
|
||||
++itr;
|
||||
}
|
||||
passes.clear();
|
||||
}
|
||||
|
||||
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() )
|
||||
{
|
||||
(*itr)->serial( f );
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
clear();
|
||||
uint32 n;
|
||||
f.xmlPush( "count" );
|
||||
f.serial( n );
|
||||
f.xmlPop();
|
||||
|
||||
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 )
|
||||
{
|
||||
std::string n;
|
||||
std::string name;
|
||||
pass.getName( name );
|
||||
|
||||
std::vector< SRenderPass* >::iterator itr = passes.begin();
|
||||
while( itr != passes.end() )
|
||||
{
|
||||
(*itr)->getName( n );
|
||||
if( n == name )
|
||||
break;
|
||||
++itr;
|
||||
}
|
||||
if( itr != passes.end() )
|
||||
return;
|
||||
|
||||
SRenderPass *p = new SRenderPass();
|
||||
*p = pass;
|
||||
passes.push_back( p );
|
||||
}
|
||||
|
||||
void CDynMaterial::removePass( const std::string &name )
|
||||
{
|
||||
std::string n;
|
||||
std::vector< SRenderPass* >::iterator itr = passes.begin();
|
||||
while( itr != passes.end() )
|
||||
{
|
||||
(*itr)->getName( n );
|
||||
if( n == name )
|
||||
break;
|
||||
++itr;
|
||||
}
|
||||
|
||||
if( itr != passes.end() )
|
||||
{
|
||||
delete *itr;
|
||||
passes.erase( itr );
|
||||
}
|
||||
}
|
||||
|
||||
void CDynMaterial::renamePass( const std::string &from, const std::string &to )
|
||||
{
|
||||
std::string n;
|
||||
std::vector< SRenderPass* >::iterator itr = passes.begin();
|
||||
while( itr != passes.end() )
|
||||
{
|
||||
(*itr)->getName( n );
|
||||
if( n == from )
|
||||
break;
|
||||
++itr;
|
||||
}
|
||||
|
||||
if( itr != passes.end() )
|
||||
(*itr)->setName( to );
|
||||
}
|
||||
|
||||
void CDynMaterial::movePassUp( const std::string &name )
|
||||
{
|
||||
std::string n;
|
||||
uint32 i = 0;
|
||||
for( i = 0; i < passes.size(); i++ )
|
||||
{
|
||||
passes[ i ]->getName( n );
|
||||
if( n == name )
|
||||
break;
|
||||
}
|
||||
|
||||
if( i >= passes.size() )
|
||||
return;
|
||||
|
||||
if( i == 0 )
|
||||
return;
|
||||
|
||||
SRenderPass *temp = passes[ i ];
|
||||
passes[ i ] = passes[ i - 1 ];
|
||||
passes[ i - 1 ] = temp;
|
||||
}
|
||||
|
||||
void CDynMaterial::movePassDown( const std::string &name )
|
||||
{
|
||||
std::string n;
|
||||
uint32 i = 0;
|
||||
for( i = 0; i < passes.size(); i++ )
|
||||
{
|
||||
passes[ i ]->getName( n );
|
||||
if( n == name )
|
||||
break;
|
||||
}
|
||||
|
||||
if( i >= passes.size() )
|
||||
return;
|
||||
|
||||
if( i == ( passes.size() - 1 ) )
|
||||
return;
|
||||
|
||||
SRenderPass *temp = passes[ i ];
|
||||
passes[ i ] = passes[ i + 1 ];
|
||||
passes[ i + 1 ] = temp;
|
||||
}
|
||||
|
||||
SRenderPass* CDynMaterial::getPass( const std::string &name )
|
||||
{
|
||||
std::string n;
|
||||
std::vector< SRenderPass* >::iterator itr = passes.begin();
|
||||
while( itr != passes.end() )
|
||||
{
|
||||
(*itr)->getName( n );
|
||||
if( n == name )
|
||||
break;
|
||||
++itr;
|
||||
}
|
||||
if( itr == passes.end() )
|
||||
return NULL;
|
||||
else
|
||||
return *itr;
|
||||
}
|
||||
|
||||
SRenderPass* CDynMaterial::getPass( uint32 i )
|
||||
{
|
||||
if( i >= passes.size() )
|
||||
return NULL;
|
||||
else
|
||||
return passes[ i ];
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,102 +1,102 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "nel/3d/shape_material_serializer.h"
|
||||
#include "nel/3d/shape.h"
|
||||
#include "nel/3d/material.h"
|
||||
#include "nel/3d/dynamic_material.h"
|
||||
#include "nel/3d/mesh_base.h"
|
||||
#include "nel/misc/file.h"
|
||||
#include "nel/misc/o_xml.h"
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
ShapeMatSerial::ShapeMatSerial()
|
||||
{
|
||||
shape = NULL;
|
||||
}
|
||||
|
||||
ShapeMatSerial::~ShapeMatSerial()
|
||||
{
|
||||
shape = NULL;
|
||||
}
|
||||
|
||||
void ShapeMatSerial::serial( const char *sPath )
|
||||
{
|
||||
if( shape == NULL )
|
||||
return;
|
||||
|
||||
nlinfo( "Exporting materials of %s", sPath );
|
||||
|
||||
std::string path = sPath;
|
||||
std::string fname;
|
||||
std::string::size_type idx;
|
||||
|
||||
idx = path.find_last_of( '.' );
|
||||
path = path.substr( 0, idx );
|
||||
|
||||
CMeshBase *mb = dynamic_cast< CMeshBase* >( shape );
|
||||
if( mb != NULL )
|
||||
{
|
||||
uint n = mb->getNbMaterial();
|
||||
nlinfo( "exporting %u materials", n );
|
||||
|
||||
for( int i = 0; i < n; i++ )
|
||||
{
|
||||
CMaterial &m = mb->getMaterial( i );
|
||||
CDynMaterial *dm = m.getDynMat();
|
||||
if( dm == NULL )
|
||||
{
|
||||
m.createDynMat();
|
||||
dm = m.getDynMat();
|
||||
}
|
||||
|
||||
fname = path + "_";
|
||||
fname += char( '0' + i );
|
||||
fname += ".nelmat";
|
||||
|
||||
nlinfo( "exporting to %s", fname.c_str() );
|
||||
|
||||
NLMISC::COFile o;
|
||||
if( o.open( fname ) )
|
||||
{
|
||||
NLMISC::COXml xml;
|
||||
if( xml.init( &o ) )
|
||||
{
|
||||
dm->serial( xml );
|
||||
xml.flush();
|
||||
}
|
||||
else
|
||||
{
|
||||
nlerror( "Error initializing XML output stream for %s", fname.c_str() );
|
||||
}
|
||||
o.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
nlerror( "Error creating file %s", fname.c_str() );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "nel/3d/shape_material_serializer.h"
|
||||
#include "nel/3d/shape.h"
|
||||
#include "nel/3d/material.h"
|
||||
#include "nel/3d/dynamic_material.h"
|
||||
#include "nel/3d/mesh_base.h"
|
||||
#include "nel/misc/file.h"
|
||||
#include "nel/misc/o_xml.h"
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
ShapeMatSerial::ShapeMatSerial()
|
||||
{
|
||||
shape = NULL;
|
||||
}
|
||||
|
||||
ShapeMatSerial::~ShapeMatSerial()
|
||||
{
|
||||
shape = NULL;
|
||||
}
|
||||
|
||||
void ShapeMatSerial::serial( const char *sPath )
|
||||
{
|
||||
if( shape == NULL )
|
||||
return;
|
||||
|
||||
nlinfo( "Exporting materials of %s", sPath );
|
||||
|
||||
std::string path = sPath;
|
||||
std::string fname;
|
||||
std::string::size_type idx;
|
||||
|
||||
idx = path.find_last_of( '.' );
|
||||
path = path.substr( 0, idx );
|
||||
|
||||
CMeshBase *mb = dynamic_cast< CMeshBase* >( shape );
|
||||
if( mb != NULL )
|
||||
{
|
||||
uint n = mb->getNbMaterial();
|
||||
nlinfo( "exporting %u materials", n );
|
||||
|
||||
for( int i = 0; i < n; i++ )
|
||||
{
|
||||
CMaterial &m = mb->getMaterial( i );
|
||||
CDynMaterial *dm = m.getDynMat();
|
||||
if( dm == NULL )
|
||||
{
|
||||
m.createDynMat();
|
||||
dm = m.getDynMat();
|
||||
}
|
||||
|
||||
fname = path + "_";
|
||||
fname += char( '0' + i );
|
||||
fname += ".nelmat";
|
||||
|
||||
nlinfo( "exporting to %s", fname.c_str() );
|
||||
|
||||
NLMISC::COFile o;
|
||||
if( o.open( fname ) )
|
||||
{
|
||||
NLMISC::COXml xml;
|
||||
if( xml.init( &o ) )
|
||||
{
|
||||
dm->serial( xml );
|
||||
xml.flush();
|
||||
}
|
||||
else
|
||||
{
|
||||
nlerror( "Error initializing XML output stream for %s", fname.c_str() );
|
||||
}
|
||||
o.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
nlerror( "Error creating file %s", fname.c_str() );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,74 +1,74 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "nel/3d/usr_shader_loader.h"
|
||||
#include "nel/3d/usr_shader_manager.h"
|
||||
#include "nel/3d/usr_shader_program.h"
|
||||
#include "nel/misc/file.h"
|
||||
#include "nel/misc/path.h"
|
||||
#include "nel/misc/i_xml.h"
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
CUsrShaderLoader::CUsrShaderLoader()
|
||||
{
|
||||
manager = NULL;
|
||||
}
|
||||
|
||||
CUsrShaderLoader::~CUsrShaderLoader()
|
||||
{
|
||||
}
|
||||
|
||||
void CUsrShaderLoader::loadShaders( const std::string &directory )
|
||||
{
|
||||
if( manager == NULL )
|
||||
return;
|
||||
|
||||
std::vector< std::string > files;
|
||||
|
||||
NLMISC::CPath::getPathContent( directory, true, false, true, files );
|
||||
|
||||
std::vector< std::string >::iterator itr = files.begin();
|
||||
while( itr != files.end() )
|
||||
{
|
||||
if( NLMISC::CFile::getExtension( *itr ) == "nlshdr" )
|
||||
{
|
||||
loadShader( *itr );
|
||||
}
|
||||
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
void CUsrShaderLoader::loadShader( const std::string &file )
|
||||
{
|
||||
NLMISC::CIFile f;
|
||||
if( !f.open( file, true ) )
|
||||
return;
|
||||
|
||||
NLMISC::CIXml xml;
|
||||
if( !xml.init( f ) )
|
||||
return;
|
||||
|
||||
CUsrShaderProgram *p = new CUsrShaderProgram();
|
||||
p->serial( xml );
|
||||
manager->addShader( p );
|
||||
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "nel/3d/usr_shader_loader.h"
|
||||
#include "nel/3d/usr_shader_manager.h"
|
||||
#include "nel/3d/usr_shader_program.h"
|
||||
#include "nel/misc/file.h"
|
||||
#include "nel/misc/path.h"
|
||||
#include "nel/misc/i_xml.h"
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
CUsrShaderLoader::CUsrShaderLoader()
|
||||
{
|
||||
manager = NULL;
|
||||
}
|
||||
|
||||
CUsrShaderLoader::~CUsrShaderLoader()
|
||||
{
|
||||
}
|
||||
|
||||
void CUsrShaderLoader::loadShaders( const std::string &directory )
|
||||
{
|
||||
if( manager == NULL )
|
||||
return;
|
||||
|
||||
std::vector< std::string > files;
|
||||
|
||||
NLMISC::CPath::getPathContent( directory, true, false, true, files );
|
||||
|
||||
std::vector< std::string >::iterator itr = files.begin();
|
||||
while( itr != files.end() )
|
||||
{
|
||||
if( NLMISC::CFile::getExtension( *itr ) == "nlshdr" )
|
||||
{
|
||||
loadShader( *itr );
|
||||
}
|
||||
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
void CUsrShaderLoader::loadShader( const std::string &file )
|
||||
{
|
||||
NLMISC::CIFile f;
|
||||
if( !f.open( file, true ) )
|
||||
return;
|
||||
|
||||
NLMISC::CIXml xml;
|
||||
if( !xml.init( f ) )
|
||||
return;
|
||||
|
||||
CUsrShaderProgram *p = new CUsrShaderProgram();
|
||||
p->serial( xml );
|
||||
manager->addShader( p );
|
||||
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,157 +1,157 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "nel/3d/usr_shader_manager.h"
|
||||
#include "nel/3d/usr_shader_program.h"
|
||||
#include "nel/3d/usr_shader_visitor.h"
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
CUsrShaderManager::CUsrShaderManager()
|
||||
{
|
||||
}
|
||||
|
||||
CUsrShaderManager::~CUsrShaderManager()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
void CUsrShaderManager::clear()
|
||||
{
|
||||
std::map< std::string, CUsrShaderProgram* >::iterator itr = programs.begin();
|
||||
while( itr != programs.end() )
|
||||
{
|
||||
delete itr->second;
|
||||
++itr;
|
||||
}
|
||||
programs.clear();
|
||||
}
|
||||
|
||||
void CUsrShaderManager::getShaderList( std::vector< std::string > &v )
|
||||
{
|
||||
v.clear();
|
||||
|
||||
std::string n;
|
||||
std::map< std::string, CUsrShaderProgram* >::iterator itr = programs.begin();
|
||||
while( itr != programs.end() )
|
||||
{
|
||||
itr->second->getName( n );
|
||||
v.push_back( n );
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
bool CUsrShaderManager::addShader( CUsrShaderProgram *program )
|
||||
{
|
||||
std::string n;
|
||||
program->getName( n );
|
||||
|
||||
std::map< std::string, CUsrShaderProgram* >::iterator itr
|
||||
= programs.find( n );
|
||||
if( itr != programs.end() )
|
||||
return false;
|
||||
|
||||
programs[ n ] = program;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CUsrShaderManager::removeShader( const std::string &name )
|
||||
{
|
||||
std::map< std::string, CUsrShaderProgram* >::iterator itr
|
||||
= programs.find( name );
|
||||
if( itr == programs.end() )
|
||||
return false;
|
||||
|
||||
delete itr->second;
|
||||
itr->second = NULL;
|
||||
programs.erase( itr );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CUsrShaderManager::changeShader( const std::string &name, CUsrShaderProgram *program )
|
||||
{
|
||||
std::map< std::string, CUsrShaderProgram* >::iterator itr
|
||||
= programs.find( name );
|
||||
if( itr == programs.end() )
|
||||
return false;
|
||||
|
||||
CUsrShaderProgram *p = itr->second;
|
||||
std::string s;
|
||||
|
||||
program->getName( s );
|
||||
p->setName( s );
|
||||
|
||||
program->getDescription( s );
|
||||
p->setDescription( s );
|
||||
|
||||
program->getVP( s );
|
||||
p->setVP( s );
|
||||
|
||||
program->getFP( s );
|
||||
p->setFP( s );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CUsrShaderManager::getShader( const std::string &name, CUsrShaderProgram *program )
|
||||
{
|
||||
std::map< std::string, CUsrShaderProgram* >::iterator itr
|
||||
= programs.find( name );
|
||||
if( itr == programs.end() )
|
||||
return false;
|
||||
|
||||
CUsrShaderProgram *p = itr->second;
|
||||
std::string s;
|
||||
|
||||
program->setName( name );
|
||||
|
||||
p->getDescription( s );
|
||||
program->setDescription( s );
|
||||
|
||||
p->getVP( s );
|
||||
program->setVP( s );
|
||||
|
||||
p->getFP( s );
|
||||
program->setFP( s );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CUsrShaderManager::visitShaders( IUsrShaderVisitor *visitor )
|
||||
{
|
||||
std::map< std::string, CUsrShaderProgram* >::iterator itr = programs.begin();
|
||||
while( itr != programs.end() )
|
||||
{
|
||||
visitor->visit( itr->second );
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
void CUsrShaderManager::visitShader( const std::string &name, IUsrShaderVisitor *visitor )
|
||||
{
|
||||
std::map< std::string, CUsrShaderProgram* >::iterator itr =
|
||||
programs.find( name );
|
||||
if( itr == programs.end() )
|
||||
return;
|
||||
|
||||
visitor->visit( itr->second );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "nel/3d/usr_shader_manager.h"
|
||||
#include "nel/3d/usr_shader_program.h"
|
||||
#include "nel/3d/usr_shader_visitor.h"
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
CUsrShaderManager::CUsrShaderManager()
|
||||
{
|
||||
}
|
||||
|
||||
CUsrShaderManager::~CUsrShaderManager()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
void CUsrShaderManager::clear()
|
||||
{
|
||||
std::map< std::string, CUsrShaderProgram* >::iterator itr = programs.begin();
|
||||
while( itr != programs.end() )
|
||||
{
|
||||
delete itr->second;
|
||||
++itr;
|
||||
}
|
||||
programs.clear();
|
||||
}
|
||||
|
||||
void CUsrShaderManager::getShaderList( std::vector< std::string > &v )
|
||||
{
|
||||
v.clear();
|
||||
|
||||
std::string n;
|
||||
std::map< std::string, CUsrShaderProgram* >::iterator itr = programs.begin();
|
||||
while( itr != programs.end() )
|
||||
{
|
||||
itr->second->getName( n );
|
||||
v.push_back( n );
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
bool CUsrShaderManager::addShader( CUsrShaderProgram *program )
|
||||
{
|
||||
std::string n;
|
||||
program->getName( n );
|
||||
|
||||
std::map< std::string, CUsrShaderProgram* >::iterator itr
|
||||
= programs.find( n );
|
||||
if( itr != programs.end() )
|
||||
return false;
|
||||
|
||||
programs[ n ] = program;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CUsrShaderManager::removeShader( const std::string &name )
|
||||
{
|
||||
std::map< std::string, CUsrShaderProgram* >::iterator itr
|
||||
= programs.find( name );
|
||||
if( itr == programs.end() )
|
||||
return false;
|
||||
|
||||
delete itr->second;
|
||||
itr->second = NULL;
|
||||
programs.erase( itr );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CUsrShaderManager::changeShader( const std::string &name, CUsrShaderProgram *program )
|
||||
{
|
||||
std::map< std::string, CUsrShaderProgram* >::iterator itr
|
||||
= programs.find( name );
|
||||
if( itr == programs.end() )
|
||||
return false;
|
||||
|
||||
CUsrShaderProgram *p = itr->second;
|
||||
std::string s;
|
||||
|
||||
program->getName( s );
|
||||
p->setName( s );
|
||||
|
||||
program->getDescription( s );
|
||||
p->setDescription( s );
|
||||
|
||||
program->getVP( s );
|
||||
p->setVP( s );
|
||||
|
||||
program->getFP( s );
|
||||
p->setFP( s );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CUsrShaderManager::getShader( const std::string &name, CUsrShaderProgram *program )
|
||||
{
|
||||
std::map< std::string, CUsrShaderProgram* >::iterator itr
|
||||
= programs.find( name );
|
||||
if( itr == programs.end() )
|
||||
return false;
|
||||
|
||||
CUsrShaderProgram *p = itr->second;
|
||||
std::string s;
|
||||
|
||||
program->setName( name );
|
||||
|
||||
p->getDescription( s );
|
||||
program->setDescription( s );
|
||||
|
||||
p->getVP( s );
|
||||
program->setVP( s );
|
||||
|
||||
p->getFP( s );
|
||||
program->setFP( s );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CUsrShaderManager::visitShaders( IUsrShaderVisitor *visitor )
|
||||
{
|
||||
std::map< std::string, CUsrShaderProgram* >::iterator itr = programs.begin();
|
||||
while( itr != programs.end() )
|
||||
{
|
||||
visitor->visit( itr->second );
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
void CUsrShaderManager::visitShader( const std::string &name, IUsrShaderVisitor *visitor )
|
||||
{
|
||||
std::map< std::string, CUsrShaderProgram* >::iterator itr =
|
||||
programs.find( name );
|
||||
if( itr == programs.end() )
|
||||
return;
|
||||
|
||||
visitor->visit( itr->second );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,59 +1,59 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "nel/3d/usr_shader_program.h"
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
CUsrShaderProgram::CUsrShaderProgram()
|
||||
{
|
||||
vpId = 0;
|
||||
fpId = 0;
|
||||
pId = 0;
|
||||
}
|
||||
|
||||
CUsrShaderProgram::~CUsrShaderProgram()
|
||||
{
|
||||
}
|
||||
|
||||
void CUsrShaderProgram::serial( NLMISC::IStream &f )
|
||||
{
|
||||
f.xmlPush( "ShaderProgram" );
|
||||
|
||||
int version = f.serialVersion( 1 );
|
||||
|
||||
f.xmlPush( "Name" );
|
||||
f.serial( name );
|
||||
f.xmlPop();
|
||||
|
||||
f.xmlPush( "Description" );
|
||||
f.serial( description );
|
||||
f.xmlPop();
|
||||
|
||||
f.xmlPush( "VertexProgram" );
|
||||
f.serial( vertexProgram );
|
||||
f.xmlPop();
|
||||
|
||||
f.xmlPush( "FragmentProgram" );
|
||||
f.serial( fragmentProgram );
|
||||
f.xmlPop();
|
||||
|
||||
f.xmlPop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "nel/3d/usr_shader_program.h"
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
CUsrShaderProgram::CUsrShaderProgram()
|
||||
{
|
||||
vpId = 0;
|
||||
fpId = 0;
|
||||
pId = 0;
|
||||
}
|
||||
|
||||
CUsrShaderProgram::~CUsrShaderProgram()
|
||||
{
|
||||
}
|
||||
|
||||
void CUsrShaderProgram::serial( NLMISC::IStream &f )
|
||||
{
|
||||
f.xmlPush( "ShaderProgram" );
|
||||
|
||||
int version = f.serialVersion( 1 );
|
||||
|
||||
f.xmlPush( "Name" );
|
||||
f.serial( name );
|
||||
f.xmlPop();
|
||||
|
||||
f.xmlPush( "Description" );
|
||||
f.serial( description );
|
||||
f.xmlPop();
|
||||
|
||||
f.xmlPush( "VertexProgram" );
|
||||
f.serial( vertexProgram );
|
||||
f.xmlPop();
|
||||
|
||||
f.xmlPush( "FragmentProgram" );
|
||||
f.serial( fragmentProgram );
|
||||
f.xmlPop();
|
||||
|
||||
f.xmlPop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,71 +1,71 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "nel/3d/usr_shader_saver.h"
|
||||
#include "nel/3d/usr_shader_manager.h"
|
||||
#include "nel/3d/usr_shader_program.h"
|
||||
#include "nel/misc/file.h"
|
||||
#include "nel/misc/o_xml.h"
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
CUsrShaderSaver::CUsrShaderSaver()
|
||||
{
|
||||
manager = NULL;
|
||||
}
|
||||
|
||||
CUsrShaderSaver::~CUsrShaderSaver()
|
||||
{
|
||||
}
|
||||
|
||||
void CUsrShaderSaver::visit( CUsrShaderProgram *program )
|
||||
{
|
||||
std::string fn;
|
||||
program->getName( fn );
|
||||
fn += ".nlshdr";
|
||||
|
||||
fn = outputDir + "/" + fn;
|
||||
|
||||
NLMISC::COFile of;
|
||||
if( !of.open( fn, false, true ) )
|
||||
return;
|
||||
|
||||
NLMISC::COXml xml;
|
||||
if( !xml.init( &of ) )
|
||||
return;
|
||||
|
||||
program->serial( xml );
|
||||
|
||||
xml.flush();
|
||||
of.close();
|
||||
|
||||
}
|
||||
|
||||
void CUsrShaderSaver::saveShaders( const std::string &directory )
|
||||
{
|
||||
outputDir = directory;
|
||||
manager->visitShaders( this );
|
||||
}
|
||||
|
||||
void CUsrShaderSaver::saveShader( const std::string &directory, const std::string &name )
|
||||
{
|
||||
outputDir = directory;
|
||||
manager->visitShader( name, this );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "nel/3d/usr_shader_saver.h"
|
||||
#include "nel/3d/usr_shader_manager.h"
|
||||
#include "nel/3d/usr_shader_program.h"
|
||||
#include "nel/misc/file.h"
|
||||
#include "nel/misc/o_xml.h"
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
CUsrShaderSaver::CUsrShaderSaver()
|
||||
{
|
||||
manager = NULL;
|
||||
}
|
||||
|
||||
CUsrShaderSaver::~CUsrShaderSaver()
|
||||
{
|
||||
}
|
||||
|
||||
void CUsrShaderSaver::visit( CUsrShaderProgram *program )
|
||||
{
|
||||
std::string fn;
|
||||
program->getName( fn );
|
||||
fn += ".nlshdr";
|
||||
|
||||
fn = outputDir + "/" + fn;
|
||||
|
||||
NLMISC::COFile of;
|
||||
if( !of.open( fn, false, true ) )
|
||||
return;
|
||||
|
||||
NLMISC::COXml xml;
|
||||
if( !xml.init( &of ) )
|
||||
return;
|
||||
|
||||
program->serial( xml );
|
||||
|
||||
xml.flush();
|
||||
of.close();
|
||||
|
||||
}
|
||||
|
||||
void CUsrShaderSaver::saveShaders( const std::string &directory )
|
||||
{
|
||||
outputDir = directory;
|
||||
manager->visitShaders( this );
|
||||
}
|
||||
|
||||
void CUsrShaderSaver::saveShader( const std::string &directory, const std::string &name )
|
||||
{
|
||||
outputDir = directory;
|
||||
manager->visitShader( name, this );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,320 +1,320 @@
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "nel/misc/variant.h"
|
||||
#include <sstream>
|
||||
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
CVariant::CVariant()
|
||||
{
|
||||
std::fill( uvalue.vval, uvalue.vval + VARIANT_VVAL_END, 0.0f );
|
||||
type = String;
|
||||
}
|
||||
|
||||
CVariant::~CVariant()
|
||||
{
|
||||
}
|
||||
|
||||
void CVariant::serial( IStream &f )
|
||||
{
|
||||
uint v = f.serialVersion( 1 );
|
||||
|
||||
f.xmlPush( "type" );
|
||||
|
||||
if( !f.isReading() )
|
||||
{
|
||||
uint t = type;
|
||||
f.serial( t );
|
||||
}
|
||||
else
|
||||
{
|
||||
uint t;
|
||||
f.serial( t );
|
||||
type = EVarType( t );
|
||||
}
|
||||
|
||||
f.xmlPop();
|
||||
|
||||
f.xmlPush( "value" );
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case Double:
|
||||
{
|
||||
f.serial( uvalue.dval );
|
||||
break;
|
||||
}
|
||||
|
||||
case Float:
|
||||
{
|
||||
f.serial( uvalue.fval );
|
||||
break;
|
||||
}
|
||||
|
||||
case Int:
|
||||
{
|
||||
f.serial( uvalue.ival );
|
||||
break;
|
||||
}
|
||||
|
||||
case UInt:
|
||||
{
|
||||
f.serial( uvalue.uval );
|
||||
break;
|
||||
}
|
||||
|
||||
case String:
|
||||
{
|
||||
f.serial( sval );
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if( !f.isReading() )
|
||||
{
|
||||
switch( type )
|
||||
{
|
||||
case Vector4:
|
||||
{
|
||||
float fval;
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
fval = uvalue.vval[ i ];
|
||||
f.serial( fval );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Matrix4:
|
||||
{
|
||||
float fval;
|
||||
for( int i = 0; i < 16; i++ )
|
||||
{
|
||||
fval = uvalue.vval[ i ];
|
||||
f.serial( fval );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
switch( type )
|
||||
{
|
||||
|
||||
case Vector4:
|
||||
{
|
||||
float fval;
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
f.serial( fval );
|
||||
uvalue.vval[ i ] = fval;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Matrix4:
|
||||
{
|
||||
float fval;
|
||||
for( int i = 0; i < 16; i++ )
|
||||
{
|
||||
f.serial( fval );
|
||||
uvalue.vval[ i ] = fval;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
f.xmlPop();
|
||||
}
|
||||
|
||||
void CVariant::setVector4( const float *v )
|
||||
{
|
||||
for( int i = 0; i < 4; i++ )
|
||||
uvalue.vval[ i ] = v[ i ];
|
||||
type = Vector4;
|
||||
}
|
||||
|
||||
void CVariant::setMatrix4( const float *m )
|
||||
{
|
||||
for( int i = 0; i < 16; i++ )
|
||||
uvalue.vval[ i ] = m[ i ];
|
||||
type = Matrix4;
|
||||
}
|
||||
|
||||
void CVariant::getVector4( float *v ) const
|
||||
{
|
||||
for( int i = 0; i < 4; i++ )
|
||||
v[ i ] = uvalue.vval[ i ];
|
||||
}
|
||||
|
||||
void CVariant::getMatrix4( float *m ) const
|
||||
{
|
||||
for( int i = 0; i < 16; i++ )
|
||||
m[ i ] = uvalue.vval[ i ];
|
||||
}
|
||||
|
||||
bool CVariant::valueAsString( std::string &s ) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case Double:
|
||||
{
|
||||
ss << uvalue.dval;
|
||||
s = ss.str();
|
||||
break;
|
||||
}
|
||||
|
||||
case Float:
|
||||
{
|
||||
ss << uvalue.fval;
|
||||
s = ss.str();
|
||||
break;
|
||||
}
|
||||
|
||||
case Int:
|
||||
{
|
||||
ss << uvalue.ival;
|
||||
s = ss.str();
|
||||
break;
|
||||
}
|
||||
|
||||
case UInt:
|
||||
{
|
||||
ss << uvalue.uval;
|
||||
s = ss.str();
|
||||
break;
|
||||
}
|
||||
|
||||
case String:
|
||||
{
|
||||
s = sval;
|
||||
break;
|
||||
}
|
||||
|
||||
case Vector4:
|
||||
{
|
||||
for( int i = 0; i < 4; i++ )
|
||||
ss << uvalue.vval[ i ] << " ";
|
||||
s = ss.str();
|
||||
s.resize( s.size() - 1 );
|
||||
break;
|
||||
}
|
||||
|
||||
case Matrix4:
|
||||
{
|
||||
for( int i = 0; i < 16; i++ )
|
||||
ss << uvalue.vval[ i ] << " ";
|
||||
s = ss.str();
|
||||
s.resize( s.size() - 1 );
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CVariant::fromString( const std::string &s, EVarType t )
|
||||
{
|
||||
type = t;
|
||||
sval = "";
|
||||
std::fill( uvalue.vval, uvalue.vval + VARIANT_VVAL_END, 0.0 );
|
||||
|
||||
if( s.empty() )
|
||||
return;
|
||||
|
||||
switch( t )
|
||||
{
|
||||
case Double:
|
||||
{
|
||||
uvalue.dval = strtod( s.c_str(), NULL );
|
||||
break;
|
||||
}
|
||||
|
||||
case Float:
|
||||
{
|
||||
uvalue.fval = strtod( s.c_str(), NULL );
|
||||
break;
|
||||
}
|
||||
|
||||
case Int:
|
||||
{
|
||||
uvalue.ival = strtod( s.c_str(), NULL );
|
||||
break;
|
||||
}
|
||||
|
||||
case UInt:
|
||||
{
|
||||
uvalue.uval = strtod( s.c_str(), NULL );
|
||||
break;
|
||||
}
|
||||
|
||||
case String:
|
||||
{
|
||||
sval = s;
|
||||
break;
|
||||
}
|
||||
|
||||
case Vector4:
|
||||
{
|
||||
std::stringstream ss( s );
|
||||
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
ss >> uvalue.vval[ i ];
|
||||
if( !ss.good() )
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case Matrix4:
|
||||
{
|
||||
std::stringstream ss( s );
|
||||
|
||||
for( int i = 0; i < 16; i++ )
|
||||
{
|
||||
ss >> uvalue.vval[ i ];
|
||||
if( !ss.good() )
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "nel/misc/variant.h"
|
||||
#include <sstream>
|
||||
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
CVariant::CVariant()
|
||||
{
|
||||
std::fill( uvalue.vval, uvalue.vval + VARIANT_VVAL_END, 0.0f );
|
||||
type = String;
|
||||
}
|
||||
|
||||
CVariant::~CVariant()
|
||||
{
|
||||
}
|
||||
|
||||
void CVariant::serial( IStream &f )
|
||||
{
|
||||
uint v = f.serialVersion( 1 );
|
||||
|
||||
f.xmlPush( "type" );
|
||||
|
||||
if( !f.isReading() )
|
||||
{
|
||||
uint t = type;
|
||||
f.serial( t );
|
||||
}
|
||||
else
|
||||
{
|
||||
uint t;
|
||||
f.serial( t );
|
||||
type = EVarType( t );
|
||||
}
|
||||
|
||||
f.xmlPop();
|
||||
|
||||
f.xmlPush( "value" );
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case Double:
|
||||
{
|
||||
f.serial( uvalue.dval );
|
||||
break;
|
||||
}
|
||||
|
||||
case Float:
|
||||
{
|
||||
f.serial( uvalue.fval );
|
||||
break;
|
||||
}
|
||||
|
||||
case Int:
|
||||
{
|
||||
f.serial( uvalue.ival );
|
||||
break;
|
||||
}
|
||||
|
||||
case UInt:
|
||||
{
|
||||
f.serial( uvalue.uval );
|
||||
break;
|
||||
}
|
||||
|
||||
case String:
|
||||
{
|
||||
f.serial( sval );
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if( !f.isReading() )
|
||||
{
|
||||
switch( type )
|
||||
{
|
||||
case Vector4:
|
||||
{
|
||||
float fval;
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
fval = uvalue.vval[ i ];
|
||||
f.serial( fval );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Matrix4:
|
||||
{
|
||||
float fval;
|
||||
for( int i = 0; i < 16; i++ )
|
||||
{
|
||||
fval = uvalue.vval[ i ];
|
||||
f.serial( fval );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
switch( type )
|
||||
{
|
||||
|
||||
case Vector4:
|
||||
{
|
||||
float fval;
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
f.serial( fval );
|
||||
uvalue.vval[ i ] = fval;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Matrix4:
|
||||
{
|
||||
float fval;
|
||||
for( int i = 0; i < 16; i++ )
|
||||
{
|
||||
f.serial( fval );
|
||||
uvalue.vval[ i ] = fval;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
f.xmlPop();
|
||||
}
|
||||
|
||||
void CVariant::setVector4( const float *v )
|
||||
{
|
||||
for( int i = 0; i < 4; i++ )
|
||||
uvalue.vval[ i ] = v[ i ];
|
||||
type = Vector4;
|
||||
}
|
||||
|
||||
void CVariant::setMatrix4( const float *m )
|
||||
{
|
||||
for( int i = 0; i < 16; i++ )
|
||||
uvalue.vval[ i ] = m[ i ];
|
||||
type = Matrix4;
|
||||
}
|
||||
|
||||
void CVariant::getVector4( float *v ) const
|
||||
{
|
||||
for( int i = 0; i < 4; i++ )
|
||||
v[ i ] = uvalue.vval[ i ];
|
||||
}
|
||||
|
||||
void CVariant::getMatrix4( float *m ) const
|
||||
{
|
||||
for( int i = 0; i < 16; i++ )
|
||||
m[ i ] = uvalue.vval[ i ];
|
||||
}
|
||||
|
||||
bool CVariant::valueAsString( std::string &s ) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case Double:
|
||||
{
|
||||
ss << uvalue.dval;
|
||||
s = ss.str();
|
||||
break;
|
||||
}
|
||||
|
||||
case Float:
|
||||
{
|
||||
ss << uvalue.fval;
|
||||
s = ss.str();
|
||||
break;
|
||||
}
|
||||
|
||||
case Int:
|
||||
{
|
||||
ss << uvalue.ival;
|
||||
s = ss.str();
|
||||
break;
|
||||
}
|
||||
|
||||
case UInt:
|
||||
{
|
||||
ss << uvalue.uval;
|
||||
s = ss.str();
|
||||
break;
|
||||
}
|
||||
|
||||
case String:
|
||||
{
|
||||
s = sval;
|
||||
break;
|
||||
}
|
||||
|
||||
case Vector4:
|
||||
{
|
||||
for( int i = 0; i < 4; i++ )
|
||||
ss << uvalue.vval[ i ] << " ";
|
||||
s = ss.str();
|
||||
s.resize( s.size() - 1 );
|
||||
break;
|
||||
}
|
||||
|
||||
case Matrix4:
|
||||
{
|
||||
for( int i = 0; i < 16; i++ )
|
||||
ss << uvalue.vval[ i ] << " ";
|
||||
s = ss.str();
|
||||
s.resize( s.size() - 1 );
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CVariant::fromString( const std::string &s, EVarType t )
|
||||
{
|
||||
type = t;
|
||||
sval = "";
|
||||
std::fill( uvalue.vval, uvalue.vval + VARIANT_VVAL_END, 0.0 );
|
||||
|
||||
if( s.empty() )
|
||||
return;
|
||||
|
||||
switch( t )
|
||||
{
|
||||
case Double:
|
||||
{
|
||||
uvalue.dval = strtod( s.c_str(), NULL );
|
||||
break;
|
||||
}
|
||||
|
||||
case Float:
|
||||
{
|
||||
uvalue.fval = strtod( s.c_str(), NULL );
|
||||
break;
|
||||
}
|
||||
|
||||
case Int:
|
||||
{
|
||||
uvalue.ival = strtod( s.c_str(), NULL );
|
||||
break;
|
||||
}
|
||||
|
||||
case UInt:
|
||||
{
|
||||
uvalue.uval = strtod( s.c_str(), NULL );
|
||||
break;
|
||||
}
|
||||
|
||||
case String:
|
||||
{
|
||||
sval = s;
|
||||
break;
|
||||
}
|
||||
|
||||
case Vector4:
|
||||
{
|
||||
std::stringstream ss( s );
|
||||
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
ss >> uvalue.vval[ i ];
|
||||
if( !ss.good() )
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case Matrix4:
|
||||
{
|
||||
std::stringstream ss( s );
|
||||
|
||||
for( int i = 0; i < 16; i++ )
|
||||
{
|
||||
ss >> uvalue.vval[ i ];
|
||||
if( !ss.good() )
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,116 +1,116 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "fog_widget.h"
|
||||
#include "nel3d_interface.h"
|
||||
#include <QColorDialog>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
FogWidget::FogWidget( QWidget *parent ) :
|
||||
QWidget( parent )
|
||||
{
|
||||
iface = NULL;
|
||||
setupUi( this );
|
||||
setupConnections();
|
||||
}
|
||||
|
||||
FogWidget::~FogWidget()
|
||||
{
|
||||
iface = NULL;
|
||||
}
|
||||
|
||||
void FogWidget::loadValues()
|
||||
{
|
||||
SFogSettings s;
|
||||
iface->getFogSettings( s );
|
||||
|
||||
fogCB->setChecked( s.enable );
|
||||
startSB->setValue( s.start );
|
||||
endSB->setValue( s.end );
|
||||
setColorButtonColor( s.color[ 0 ], s.color[ 1 ], s.color[ 2 ] );
|
||||
}
|
||||
|
||||
void FogWidget::setupConnections()
|
||||
{
|
||||
connect( fogCB, SIGNAL( clicked( bool ) ), this, SLOT( onFogCBClicked() ) );
|
||||
connect( startSB, SIGNAL( valueChanged( double ) ), this, SLOT( onStartSBChanged() ) );
|
||||
connect( endSB, SIGNAL( valueChanged( double ) ), this, SLOT( onEndSBChanged() ) );
|
||||
connect( colorButton, SIGNAL( clicked( bool ) ), this, SLOT( onColorButtonClicked() ) );
|
||||
}
|
||||
|
||||
void FogWidget::onFogCBClicked()
|
||||
{
|
||||
SFogSettings s;
|
||||
iface->getFogSettings( s );
|
||||
|
||||
s.enable = fogCB->isChecked();
|
||||
|
||||
iface->setFogSettings( s );
|
||||
|
||||
if( !s.enable )
|
||||
iface->setBGColor( 255, 255, 255, 255 );
|
||||
}
|
||||
|
||||
void FogWidget::onStartSBChanged()
|
||||
{
|
||||
SFogSettings s;
|
||||
iface->getFogSettings( s );
|
||||
|
||||
s.start = startSB->value();
|
||||
|
||||
iface->setFogSettings( s );
|
||||
}
|
||||
|
||||
void FogWidget::onEndSBChanged()
|
||||
{
|
||||
SFogSettings s;
|
||||
iface->getFogSettings( s );
|
||||
|
||||
s.end = endSB->value();
|
||||
|
||||
iface->setFogSettings( s );
|
||||
}
|
||||
|
||||
void FogWidget::onColorButtonClicked()
|
||||
{
|
||||
QColor c = QColorDialog::getColor();
|
||||
|
||||
setColorButtonColor( c.red(), c.green(), c.blue() );
|
||||
|
||||
SFogSettings s;
|
||||
iface->getFogSettings( s );
|
||||
|
||||
s.color[ 0 ] = c.red();
|
||||
s.color[ 1 ] = c.green();
|
||||
s.color[ 2 ] = c.blue();
|
||||
s.color[ 3 ] = 255;
|
||||
|
||||
iface->setFogSettings( s );
|
||||
}
|
||||
|
||||
void FogWidget::setColorButtonColor( int r, int g, int b )
|
||||
{
|
||||
QString sh;
|
||||
sh = QString( "background-color: rgb(%1, %2, %3);" ).arg( r ).arg( g ).arg( b );
|
||||
colorButton->setStyleSheet( sh );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "fog_widget.h"
|
||||
#include "nel3d_interface.h"
|
||||
#include <QColorDialog>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
FogWidget::FogWidget( QWidget *parent ) :
|
||||
QWidget( parent )
|
||||
{
|
||||
iface = NULL;
|
||||
setupUi( this );
|
||||
setupConnections();
|
||||
}
|
||||
|
||||
FogWidget::~FogWidget()
|
||||
{
|
||||
iface = NULL;
|
||||
}
|
||||
|
||||
void FogWidget::loadValues()
|
||||
{
|
||||
SFogSettings s;
|
||||
iface->getFogSettings( s );
|
||||
|
||||
fogCB->setChecked( s.enable );
|
||||
startSB->setValue( s.start );
|
||||
endSB->setValue( s.end );
|
||||
setColorButtonColor( s.color[ 0 ], s.color[ 1 ], s.color[ 2 ] );
|
||||
}
|
||||
|
||||
void FogWidget::setupConnections()
|
||||
{
|
||||
connect( fogCB, SIGNAL( clicked( bool ) ), this, SLOT( onFogCBClicked() ) );
|
||||
connect( startSB, SIGNAL( valueChanged( double ) ), this, SLOT( onStartSBChanged() ) );
|
||||
connect( endSB, SIGNAL( valueChanged( double ) ), this, SLOT( onEndSBChanged() ) );
|
||||
connect( colorButton, SIGNAL( clicked( bool ) ), this, SLOT( onColorButtonClicked() ) );
|
||||
}
|
||||
|
||||
void FogWidget::onFogCBClicked()
|
||||
{
|
||||
SFogSettings s;
|
||||
iface->getFogSettings( s );
|
||||
|
||||
s.enable = fogCB->isChecked();
|
||||
|
||||
iface->setFogSettings( s );
|
||||
|
||||
if( !s.enable )
|
||||
iface->setBGColor( 255, 255, 255, 255 );
|
||||
}
|
||||
|
||||
void FogWidget::onStartSBChanged()
|
||||
{
|
||||
SFogSettings s;
|
||||
iface->getFogSettings( s );
|
||||
|
||||
s.start = startSB->value();
|
||||
|
||||
iface->setFogSettings( s );
|
||||
}
|
||||
|
||||
void FogWidget::onEndSBChanged()
|
||||
{
|
||||
SFogSettings s;
|
||||
iface->getFogSettings( s );
|
||||
|
||||
s.end = endSB->value();
|
||||
|
||||
iface->setFogSettings( s );
|
||||
}
|
||||
|
||||
void FogWidget::onColorButtonClicked()
|
||||
{
|
||||
QColor c = QColorDialog::getColor();
|
||||
|
||||
setColorButtonColor( c.red(), c.green(), c.blue() );
|
||||
|
||||
SFogSettings s;
|
||||
iface->getFogSettings( s );
|
||||
|
||||
s.color[ 0 ] = c.red();
|
||||
s.color[ 1 ] = c.green();
|
||||
s.color[ 2 ] = c.blue();
|
||||
s.color[ 3 ] = 255;
|
||||
|
||||
iface->setFogSettings( s );
|
||||
}
|
||||
|
||||
void FogWidget::setColorButtonColor( int r, int g, int b )
|
||||
{
|
||||
QString sh;
|
||||
sh = QString( "background-color: rgb(%1, %2, %3);" ).arg( r ).arg( g ).arg( b );
|
||||
colorButton->setStyleSheet( sh );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,56 +1,56 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef FOG_WIDGET_H
|
||||
#define FOG_WIDGET_H
|
||||
|
||||
#include "ui_fog_widget.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
class CNel3DInterface;
|
||||
|
||||
class FogWidget : public QWidget, public Ui::FogWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FogWidget( QWidget *parent = NULL );
|
||||
~FogWidget();
|
||||
|
||||
void loadValues();
|
||||
|
||||
void setNl3DIface( CNel3DInterface *iface ){ this->iface = iface; }
|
||||
|
||||
private Q_SLOTS:
|
||||
void onFogCBClicked();
|
||||
void onStartSBChanged();
|
||||
void onEndSBChanged();
|
||||
void onColorButtonClicked();
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
void setColorButtonColor( int r, int g, int b );
|
||||
|
||||
|
||||
CNel3DInterface *iface;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef FOG_WIDGET_H
|
||||
#define FOG_WIDGET_H
|
||||
|
||||
#include "ui_fog_widget.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
class CNel3DInterface;
|
||||
|
||||
class FogWidget : public QWidget, public Ui::FogWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FogWidget( QWidget *parent = NULL );
|
||||
~FogWidget();
|
||||
|
||||
void loadValues();
|
||||
|
||||
void setNl3DIface( CNel3DInterface *iface ){ this->iface = iface; }
|
||||
|
||||
private Q_SLOTS:
|
||||
void onFogCBClicked();
|
||||
void onStartSBChanged();
|
||||
void onEndSBChanged();
|
||||
void onColorButtonClicked();
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
void setColorButtonColor( int r, int g, int b );
|
||||
|
||||
|
||||
CNel3DInterface *iface;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,270 +1,270 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "lights_widget.h"
|
||||
#include <QColorDialog>
|
||||
#include "nel3d_interface.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
enum LWLightTypes
|
||||
{
|
||||
DIRECTIONAL,
|
||||
POINT,
|
||||
SPOT
|
||||
};
|
||||
|
||||
enum LWColorButton
|
||||
{
|
||||
AMBIENT,
|
||||
DIFFUSE,
|
||||
SPECULAR
|
||||
};
|
||||
|
||||
void LightsWidget::setButtonColor( unsigned char butt, int r, int g, int b )
|
||||
{
|
||||
QString sh;
|
||||
QPushButton *button;
|
||||
|
||||
if( butt > SPECULAR )
|
||||
return;
|
||||
|
||||
switch( butt )
|
||||
{
|
||||
case AMBIENT:
|
||||
button = ambientButton;
|
||||
break;
|
||||
|
||||
case DIFFUSE:
|
||||
button = diffuseButton;
|
||||
break;
|
||||
|
||||
case SPECULAR:
|
||||
button = specularButton;
|
||||
break;
|
||||
}
|
||||
|
||||
sh = QString( "background-color: rgb(%1, %2, %3);" ).arg( r ).arg( g ).arg( b );
|
||||
button->setStyleSheet( sh );
|
||||
|
||||
buttonColors[ butt ][ 0 ] = r;
|
||||
buttonColors[ butt ][ 1 ] = g;
|
||||
buttonColors[ butt ][ 2 ] = b;
|
||||
}
|
||||
|
||||
|
||||
|
||||
LightsWidget::LightsWidget( QWidget *parent ) :
|
||||
QWidget( parent )
|
||||
{
|
||||
setupUi( this );
|
||||
setupConnections();
|
||||
|
||||
typeCB->addItem( "Directional light" );
|
||||
typeCB->addItem( "Point light" );
|
||||
typeCB->addItem( "Spot light" );
|
||||
}
|
||||
|
||||
LightsWidget::~LightsWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void LightsWidget::loadValues()
|
||||
{
|
||||
disableChangeConnections();
|
||||
|
||||
unsigned char c = iface->getMaxLights();
|
||||
|
||||
lightList->clear();
|
||||
|
||||
for( unsigned char i = 0; i < c; i++ )
|
||||
{
|
||||
QString s = "light";
|
||||
s += QString::number( i );
|
||||
lightList->addItem( s );
|
||||
}
|
||||
|
||||
lightList->setCurrentRow( 0 );
|
||||
loadLight( 0 );
|
||||
|
||||
// loadLight enables it anyways
|
||||
//setupChangeConnections();
|
||||
}
|
||||
|
||||
void LightsWidget::setupConnections()
|
||||
{
|
||||
}
|
||||
|
||||
void LightsWidget::setupChangeConnections()
|
||||
{
|
||||
connect( enableCB, SIGNAL( toggled( bool ) ), this, SLOT( onChanges() ) );
|
||||
connect( ambientButton, SIGNAL( clicked( bool ) ), this, SLOT( onAmbButtonClicked() ) );
|
||||
connect( diffuseButton, SIGNAL( clicked( bool ) ), this, SLOT( onDiffButtonClicked() ) );
|
||||
connect( specularButton, SIGNAL( clicked( bool ) ), this, SLOT( onSpecButtonClicked() ) );
|
||||
connect( lightList, SIGNAL( currentRowChanged( int ) ), this, SLOT( onLightChanged( int ) ) );
|
||||
|
||||
connect( typeCB, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChanges() ) );
|
||||
connect( xSB, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
connect( ySB, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
connect( zSB, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
connect( constAttnButton, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
connect( linearAttnButton, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
connect( quadAttnButton, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
}
|
||||
|
||||
void LightsWidget::disableChangeConnections()
|
||||
{
|
||||
disconnect( enableCB, SIGNAL( toggled( bool ) ), this, SLOT( onChanges() ) );
|
||||
disconnect( ambientButton, SIGNAL( clicked( bool ) ), this, SLOT( onAmbButtonClicked() ) );
|
||||
disconnect( diffuseButton, SIGNAL( clicked( bool ) ), this, SLOT( onDiffButtonClicked() ) );
|
||||
disconnect( specularButton, SIGNAL( clicked( bool ) ), this, SLOT( onSpecButtonClicked() ) );
|
||||
disconnect( lightList, SIGNAL( currentRowChanged( int ) ), this, SLOT( onLightChanged( int ) ) );
|
||||
|
||||
disconnect( typeCB, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChanges() ) );
|
||||
disconnect( xSB, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
disconnect( ySB, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
disconnect( zSB, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
disconnect( constAttnButton, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
disconnect( linearAttnButton, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
disconnect( quadAttnButton, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
}
|
||||
|
||||
void LightsWidget::onAmbButtonClicked()
|
||||
{
|
||||
QColor c = QColorDialog::getColor();
|
||||
setButtonColor( AMBIENT, c.red(), c.green(), c.blue() );
|
||||
applyChanges();
|
||||
}
|
||||
|
||||
void LightsWidget::onDiffButtonClicked()
|
||||
{
|
||||
QColor c = QColorDialog::getColor();
|
||||
setButtonColor( DIFFUSE, c.red(), c.green(), c.blue() );
|
||||
applyChanges();
|
||||
}
|
||||
|
||||
void LightsWidget::onSpecButtonClicked()
|
||||
{
|
||||
QColor c = QColorDialog::getColor();
|
||||
setButtonColor( SPECULAR, c.red(), c.green(), c.blue() );
|
||||
applyChanges();
|
||||
}
|
||||
|
||||
void LightsWidget::onLightChanged( int light )
|
||||
{
|
||||
loadLight( light );
|
||||
}
|
||||
|
||||
void LightsWidget::onChanges()
|
||||
{
|
||||
applyChanges();
|
||||
}
|
||||
|
||||
void LightsWidget::loadLight( unsigned char light )
|
||||
{
|
||||
disableChangeConnections();
|
||||
|
||||
SLightInfo info;
|
||||
iface->getLightInfo( light, info );
|
||||
|
||||
if( info.enabled )
|
||||
enableCB->setChecked( true );
|
||||
else
|
||||
enableCB->setChecked( false );
|
||||
|
||||
switch( info.type )
|
||||
{
|
||||
case SLightInfo::Directional:
|
||||
typeCB->setCurrentIndex( DIRECTIONAL );
|
||||
break;
|
||||
case SLightInfo::Point:
|
||||
typeCB->setCurrentIndex( POINT );
|
||||
break;
|
||||
case SLightInfo::Spot:
|
||||
typeCB->setCurrentIndex( SPOT );
|
||||
break;
|
||||
}
|
||||
|
||||
xSB->setValue( info.posOrDir[ 0 ] );
|
||||
ySB->setValue( info.posOrDir[ 1 ] );
|
||||
zSB->setValue( info.posOrDir[ 2 ] );
|
||||
|
||||
constAttnButton->setValue( info.constAttn );
|
||||
linearAttnButton->setValue( info.linAttn );
|
||||
quadAttnButton->setValue( info.quadAttn );
|
||||
|
||||
setButtonColor( AMBIENT, info.ambColor[ 0 ] * 255.0f,
|
||||
info.ambColor[ 1 ] * 255.0f,
|
||||
info.ambColor[ 2 ] * 255.0f );
|
||||
|
||||
setButtonColor( DIFFUSE, info.diffColor[ 0 ] * 255.0f,
|
||||
info.diffColor[ 1 ] * 255.0f,
|
||||
info.diffColor[ 2 ] * 255.0f );
|
||||
|
||||
setButtonColor( SPECULAR, info.specColor[ 0 ] * 255.0f,
|
||||
info.specColor[ 1 ] * 255.0f,
|
||||
info.specColor[ 2 ] * 255.0f );
|
||||
|
||||
setupChangeConnections();
|
||||
}
|
||||
|
||||
void LightsWidget::saveLight( unsigned char light )
|
||||
{
|
||||
SLightInfo info;
|
||||
|
||||
info.enabled = enableCB->isChecked();
|
||||
switch( typeCB->currentIndex() )
|
||||
{
|
||||
case DIRECTIONAL:
|
||||
info.type = SLightInfo::Directional;
|
||||
break;
|
||||
case POINT:
|
||||
info.type = SLightInfo::Point;
|
||||
break;
|
||||
case SPOT:
|
||||
info.type = SLightInfo::Spot;
|
||||
break;
|
||||
}
|
||||
|
||||
info.posOrDir[ 0 ] = static_cast< float >( xSB->value() );
|
||||
info.posOrDir[ 1 ] = static_cast< float >( ySB->value() );
|
||||
info.posOrDir[ 2 ] = static_cast< float >( zSB->value() );
|
||||
|
||||
info.constAttn = static_cast< float >( constAttnButton->value() );
|
||||
info.linAttn = static_cast< float >( linearAttnButton->value() );
|
||||
info.quadAttn = static_cast< float >( quadAttnButton->value() );
|
||||
|
||||
info.ambColor[ 0 ] = buttonColors[ AMBIENT ][ 0 ] / 255.0f;
|
||||
info.ambColor[ 1 ] = buttonColors[ AMBIENT ][ 1 ] / 255.0f;
|
||||
info.ambColor[ 2 ] = buttonColors[ AMBIENT ][ 2 ] / 255.0f;
|
||||
info.diffColor[ 0 ] = buttonColors[ DIFFUSE ][ 0 ] / 255.0f;
|
||||
info.diffColor[ 1 ] = buttonColors[ DIFFUSE ][ 1 ] / 255.0f;
|
||||
info.diffColor[ 2 ] = buttonColors[ DIFFUSE ][ 2 ] / 255.0f;
|
||||
info.specColor[ 0 ] = buttonColors[ SPECULAR ][ 0 ] / 255.0f;
|
||||
info.specColor[ 1 ] = buttonColors[ SPECULAR ][ 1 ] / 255.0f;
|
||||
info.specColor[ 2 ] = buttonColors[ SPECULAR ][ 2 ] / 255.0f;
|
||||
|
||||
iface->setLightInfo( light, info );
|
||||
}
|
||||
|
||||
void LightsWidget::applyChanges()
|
||||
{
|
||||
int row = lightList->currentRow();
|
||||
saveLight( static_cast< unsigned char >( row ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "lights_widget.h"
|
||||
#include <QColorDialog>
|
||||
#include "nel3d_interface.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
enum LWLightTypes
|
||||
{
|
||||
DIRECTIONAL,
|
||||
POINT,
|
||||
SPOT
|
||||
};
|
||||
|
||||
enum LWColorButton
|
||||
{
|
||||
AMBIENT,
|
||||
DIFFUSE,
|
||||
SPECULAR
|
||||
};
|
||||
|
||||
void LightsWidget::setButtonColor( unsigned char butt, int r, int g, int b )
|
||||
{
|
||||
QString sh;
|
||||
QPushButton *button;
|
||||
|
||||
if( butt > SPECULAR )
|
||||
return;
|
||||
|
||||
switch( butt )
|
||||
{
|
||||
case AMBIENT:
|
||||
button = ambientButton;
|
||||
break;
|
||||
|
||||
case DIFFUSE:
|
||||
button = diffuseButton;
|
||||
break;
|
||||
|
||||
case SPECULAR:
|
||||
button = specularButton;
|
||||
break;
|
||||
}
|
||||
|
||||
sh = QString( "background-color: rgb(%1, %2, %3);" ).arg( r ).arg( g ).arg( b );
|
||||
button->setStyleSheet( sh );
|
||||
|
||||
buttonColors[ butt ][ 0 ] = r;
|
||||
buttonColors[ butt ][ 1 ] = g;
|
||||
buttonColors[ butt ][ 2 ] = b;
|
||||
}
|
||||
|
||||
|
||||
|
||||
LightsWidget::LightsWidget( QWidget *parent ) :
|
||||
QWidget( parent )
|
||||
{
|
||||
setupUi( this );
|
||||
setupConnections();
|
||||
|
||||
typeCB->addItem( "Directional light" );
|
||||
typeCB->addItem( "Point light" );
|
||||
typeCB->addItem( "Spot light" );
|
||||
}
|
||||
|
||||
LightsWidget::~LightsWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void LightsWidget::loadValues()
|
||||
{
|
||||
disableChangeConnections();
|
||||
|
||||
unsigned char c = iface->getMaxLights();
|
||||
|
||||
lightList->clear();
|
||||
|
||||
for( unsigned char i = 0; i < c; i++ )
|
||||
{
|
||||
QString s = "light";
|
||||
s += QString::number( i );
|
||||
lightList->addItem( s );
|
||||
}
|
||||
|
||||
lightList->setCurrentRow( 0 );
|
||||
loadLight( 0 );
|
||||
|
||||
// loadLight enables it anyways
|
||||
//setupChangeConnections();
|
||||
}
|
||||
|
||||
void LightsWidget::setupConnections()
|
||||
{
|
||||
}
|
||||
|
||||
void LightsWidget::setupChangeConnections()
|
||||
{
|
||||
connect( enableCB, SIGNAL( toggled( bool ) ), this, SLOT( onChanges() ) );
|
||||
connect( ambientButton, SIGNAL( clicked( bool ) ), this, SLOT( onAmbButtonClicked() ) );
|
||||
connect( diffuseButton, SIGNAL( clicked( bool ) ), this, SLOT( onDiffButtonClicked() ) );
|
||||
connect( specularButton, SIGNAL( clicked( bool ) ), this, SLOT( onSpecButtonClicked() ) );
|
||||
connect( lightList, SIGNAL( currentRowChanged( int ) ), this, SLOT( onLightChanged( int ) ) );
|
||||
|
||||
connect( typeCB, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChanges() ) );
|
||||
connect( xSB, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
connect( ySB, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
connect( zSB, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
connect( constAttnButton, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
connect( linearAttnButton, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
connect( quadAttnButton, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
}
|
||||
|
||||
void LightsWidget::disableChangeConnections()
|
||||
{
|
||||
disconnect( enableCB, SIGNAL( toggled( bool ) ), this, SLOT( onChanges() ) );
|
||||
disconnect( ambientButton, SIGNAL( clicked( bool ) ), this, SLOT( onAmbButtonClicked() ) );
|
||||
disconnect( diffuseButton, SIGNAL( clicked( bool ) ), this, SLOT( onDiffButtonClicked() ) );
|
||||
disconnect( specularButton, SIGNAL( clicked( bool ) ), this, SLOT( onSpecButtonClicked() ) );
|
||||
disconnect( lightList, SIGNAL( currentRowChanged( int ) ), this, SLOT( onLightChanged( int ) ) );
|
||||
|
||||
disconnect( typeCB, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChanges() ) );
|
||||
disconnect( xSB, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
disconnect( ySB, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
disconnect( zSB, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
disconnect( constAttnButton, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
disconnect( linearAttnButton, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
disconnect( quadAttnButton, SIGNAL( valueChanged( double ) ), this, SLOT( onChanges() ) );
|
||||
}
|
||||
|
||||
void LightsWidget::onAmbButtonClicked()
|
||||
{
|
||||
QColor c = QColorDialog::getColor();
|
||||
setButtonColor( AMBIENT, c.red(), c.green(), c.blue() );
|
||||
applyChanges();
|
||||
}
|
||||
|
||||
void LightsWidget::onDiffButtonClicked()
|
||||
{
|
||||
QColor c = QColorDialog::getColor();
|
||||
setButtonColor( DIFFUSE, c.red(), c.green(), c.blue() );
|
||||
applyChanges();
|
||||
}
|
||||
|
||||
void LightsWidget::onSpecButtonClicked()
|
||||
{
|
||||
QColor c = QColorDialog::getColor();
|
||||
setButtonColor( SPECULAR, c.red(), c.green(), c.blue() );
|
||||
applyChanges();
|
||||
}
|
||||
|
||||
void LightsWidget::onLightChanged( int light )
|
||||
{
|
||||
loadLight( light );
|
||||
}
|
||||
|
||||
void LightsWidget::onChanges()
|
||||
{
|
||||
applyChanges();
|
||||
}
|
||||
|
||||
void LightsWidget::loadLight( unsigned char light )
|
||||
{
|
||||
disableChangeConnections();
|
||||
|
||||
SLightInfo info;
|
||||
iface->getLightInfo( light, info );
|
||||
|
||||
if( info.enabled )
|
||||
enableCB->setChecked( true );
|
||||
else
|
||||
enableCB->setChecked( false );
|
||||
|
||||
switch( info.type )
|
||||
{
|
||||
case SLightInfo::Directional:
|
||||
typeCB->setCurrentIndex( DIRECTIONAL );
|
||||
break;
|
||||
case SLightInfo::Point:
|
||||
typeCB->setCurrentIndex( POINT );
|
||||
break;
|
||||
case SLightInfo::Spot:
|
||||
typeCB->setCurrentIndex( SPOT );
|
||||
break;
|
||||
}
|
||||
|
||||
xSB->setValue( info.posOrDir[ 0 ] );
|
||||
ySB->setValue( info.posOrDir[ 1 ] );
|
||||
zSB->setValue( info.posOrDir[ 2 ] );
|
||||
|
||||
constAttnButton->setValue( info.constAttn );
|
||||
linearAttnButton->setValue( info.linAttn );
|
||||
quadAttnButton->setValue( info.quadAttn );
|
||||
|
||||
setButtonColor( AMBIENT, info.ambColor[ 0 ] * 255.0f,
|
||||
info.ambColor[ 1 ] * 255.0f,
|
||||
info.ambColor[ 2 ] * 255.0f );
|
||||
|
||||
setButtonColor( DIFFUSE, info.diffColor[ 0 ] * 255.0f,
|
||||
info.diffColor[ 1 ] * 255.0f,
|
||||
info.diffColor[ 2 ] * 255.0f );
|
||||
|
||||
setButtonColor( SPECULAR, info.specColor[ 0 ] * 255.0f,
|
||||
info.specColor[ 1 ] * 255.0f,
|
||||
info.specColor[ 2 ] * 255.0f );
|
||||
|
||||
setupChangeConnections();
|
||||
}
|
||||
|
||||
void LightsWidget::saveLight( unsigned char light )
|
||||
{
|
||||
SLightInfo info;
|
||||
|
||||
info.enabled = enableCB->isChecked();
|
||||
switch( typeCB->currentIndex() )
|
||||
{
|
||||
case DIRECTIONAL:
|
||||
info.type = SLightInfo::Directional;
|
||||
break;
|
||||
case POINT:
|
||||
info.type = SLightInfo::Point;
|
||||
break;
|
||||
case SPOT:
|
||||
info.type = SLightInfo::Spot;
|
||||
break;
|
||||
}
|
||||
|
||||
info.posOrDir[ 0 ] = static_cast< float >( xSB->value() );
|
||||
info.posOrDir[ 1 ] = static_cast< float >( ySB->value() );
|
||||
info.posOrDir[ 2 ] = static_cast< float >( zSB->value() );
|
||||
|
||||
info.constAttn = static_cast< float >( constAttnButton->value() );
|
||||
info.linAttn = static_cast< float >( linearAttnButton->value() );
|
||||
info.quadAttn = static_cast< float >( quadAttnButton->value() );
|
||||
|
||||
info.ambColor[ 0 ] = buttonColors[ AMBIENT ][ 0 ] / 255.0f;
|
||||
info.ambColor[ 1 ] = buttonColors[ AMBIENT ][ 1 ] / 255.0f;
|
||||
info.ambColor[ 2 ] = buttonColors[ AMBIENT ][ 2 ] / 255.0f;
|
||||
info.diffColor[ 0 ] = buttonColors[ DIFFUSE ][ 0 ] / 255.0f;
|
||||
info.diffColor[ 1 ] = buttonColors[ DIFFUSE ][ 1 ] / 255.0f;
|
||||
info.diffColor[ 2 ] = buttonColors[ DIFFUSE ][ 2 ] / 255.0f;
|
||||
info.specColor[ 0 ] = buttonColors[ SPECULAR ][ 0 ] / 255.0f;
|
||||
info.specColor[ 1 ] = buttonColors[ SPECULAR ][ 1 ] / 255.0f;
|
||||
info.specColor[ 2 ] = buttonColors[ SPECULAR ][ 2 ] / 255.0f;
|
||||
|
||||
iface->setLightInfo( light, info );
|
||||
}
|
||||
|
||||
void LightsWidget::applyChanges()
|
||||
{
|
||||
int row = lightList->currentRow();
|
||||
saveLight( static_cast< unsigned char >( row ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,72 +1,72 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef LIGHTS_WIDGET_H
|
||||
#define LIGHTS_WIDGET_H
|
||||
|
||||
#include "ui_lights_widget.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
class CNel3DInterface;
|
||||
|
||||
class LightsWidget : public QWidget, public Ui::LightsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
void setButtonColor( unsigned char butt, int r, int g, int b );
|
||||
|
||||
public:
|
||||
LightsWidget( QWidget *parent = NULL );
|
||||
~LightsWidget();
|
||||
void setNL3DIface( CNel3DInterface *iface ){ this->iface = iface; }
|
||||
void loadValues();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAmbButtonClicked();
|
||||
void onDiffButtonClicked();
|
||||
void onSpecButtonClicked();
|
||||
void onLightChanged( int light );
|
||||
void onChanges();
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
void setupChangeConnections();
|
||||
void disableChangeConnections();
|
||||
void loadLight( unsigned char light );
|
||||
void saveLight( unsigned char light );
|
||||
void applyChanges();
|
||||
|
||||
CNel3DInterface *iface;
|
||||
|
||||
enum LightType
|
||||
{
|
||||
Directional,
|
||||
Point,
|
||||
Spot
|
||||
};
|
||||
|
||||
int buttonColors[ 3 ][ 3 ];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef LIGHTS_WIDGET_H
|
||||
#define LIGHTS_WIDGET_H
|
||||
|
||||
#include "ui_lights_widget.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
class CNel3DInterface;
|
||||
|
||||
class LightsWidget : public QWidget, public Ui::LightsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
void setButtonColor( unsigned char butt, int r, int g, int b );
|
||||
|
||||
public:
|
||||
LightsWidget( QWidget *parent = NULL );
|
||||
~LightsWidget();
|
||||
void setNL3DIface( CNel3DInterface *iface ){ this->iface = iface; }
|
||||
void loadValues();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAmbButtonClicked();
|
||||
void onDiffButtonClicked();
|
||||
void onSpecButtonClicked();
|
||||
void onLightChanged( int light );
|
||||
void onChanges();
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
void setupChangeConnections();
|
||||
void disableChangeConnections();
|
||||
void loadLight( unsigned char light );
|
||||
void saveLight( unsigned char light );
|
||||
void applyChanges();
|
||||
|
||||
CNel3DInterface *iface;
|
||||
|
||||
enum LightType
|
||||
{
|
||||
Directional,
|
||||
Point,
|
||||
Spot
|
||||
};
|
||||
|
||||
int buttonColors[ 3 ][ 3 ];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1,43 +1,43 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef MATERIAL_OBSERVER_H
|
||||
#define MATERIAL_OBSERVER_H
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
/// Observes material changes
|
||||
class CMaterialObserver
|
||||
{
|
||||
public:
|
||||
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;
|
||||
virtual void onPassMovedDown( const char *name ) = 0;
|
||||
virtual void onPassRenamed( const char *from, const char *to ) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef MATERIAL_OBSERVER_H
|
||||
#define MATERIAL_OBSERVER_H
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
/// Observes material changes
|
||||
class CMaterialObserver
|
||||
{
|
||||
public:
|
||||
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;
|
||||
virtual void onPassMovedDown( const char *name ) = 0;
|
||||
virtual void onPassRenamed( const char *from, const char *to ) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,274 +1,274 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "material_properties.h"
|
||||
#include "material_property_editor.h"
|
||||
#include "nel3d_interface.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
|
||||
MatPropWidget::MatPropWidget( QWidget *parent ) :
|
||||
QDialog( parent )
|
||||
{
|
||||
setupUi( this );
|
||||
matPropEditWidget = new MatPropEditWidget();
|
||||
setupConnections();
|
||||
edit = false;
|
||||
changed = false;
|
||||
proxy = NULL;
|
||||
}
|
||||
|
||||
MatPropWidget::~MatPropWidget()
|
||||
{
|
||||
clear();
|
||||
|
||||
delete matPropEditWidget;
|
||||
matPropEditWidget = NULL;
|
||||
}
|
||||
|
||||
void MatPropWidget::load( CRenderPassProxy *proxy )
|
||||
{
|
||||
clear();
|
||||
changed = false;
|
||||
this->proxy = new CRenderPassProxy( *proxy );
|
||||
|
||||
std::string n;
|
||||
proxy->getName( n );
|
||||
nameEdit->setText( n.c_str() );
|
||||
|
||||
std::vector< SMatProp > v;
|
||||
proxy->getProperties( v );
|
||||
|
||||
std::vector< SMatProp >::iterator itr = v.begin();
|
||||
while( itr != v.end() )
|
||||
{
|
||||
SMatProp &mp = *itr;
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
|
||||
item->setData( 0, Qt::DisplayRole, QString( mp.id.c_str() ) );
|
||||
item->setData( 1, Qt::DisplayRole, QString( mp.label.c_str() ) );
|
||||
|
||||
QString type = SMatProp::typeIdToString( mp.type ).c_str();
|
||||
item->setData( 2, Qt::DisplayRole, type );
|
||||
|
||||
item->setData( 3, Qt::DisplayRole, mp.value.c_str() );
|
||||
|
||||
treeWidget->addTopLevelItem( item );
|
||||
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
void MatPropWidget::clear()
|
||||
{
|
||||
treeWidget->clear();
|
||||
nameEdit->clear();
|
||||
if( this->proxy != NULL )
|
||||
{
|
||||
delete this->proxy;
|
||||
this->proxy = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void MatPropWidget::onOKClicked()
|
||||
{
|
||||
if( proxy != NULL )
|
||||
{
|
||||
std::vector< SMatProp > v;
|
||||
SMatProp p;
|
||||
QTreeWidgetItem *item = NULL;
|
||||
std::string s;
|
||||
|
||||
for( int i = 0; i < treeWidget->topLevelItemCount(); i++ )
|
||||
{
|
||||
item = treeWidget->topLevelItem( i );
|
||||
p.id = item->text( 0 ).toUtf8().data();
|
||||
p.label = item->text( 1 ).toUtf8().data();
|
||||
|
||||
s = item->text( 2 ).toUtf8().data();
|
||||
p.type = SMatProp::typeStringToId( s );
|
||||
|
||||
p.value = item->text( 3 ).toUtf8().data();
|
||||
|
||||
v.push_back( p );
|
||||
}
|
||||
|
||||
proxy->setProperties( v );
|
||||
}
|
||||
|
||||
clear();
|
||||
setResult( QDialog::Accepted );
|
||||
close();
|
||||
}
|
||||
|
||||
void MatPropWidget::onCancelClicked()
|
||||
{
|
||||
clear();
|
||||
setResult( QDialog::Rejected );
|
||||
close();
|
||||
}
|
||||
|
||||
void MatPropWidget::onAddClicked()
|
||||
{
|
||||
edit = false;
|
||||
changed = true;
|
||||
matPropEditWidget->clear();
|
||||
matPropEditWidget->show();
|
||||
}
|
||||
|
||||
void MatPropWidget::onEditClicked()
|
||||
{
|
||||
QTreeWidgetItem *item = treeWidget->currentItem();
|
||||
if( item == NULL )
|
||||
return;
|
||||
|
||||
MaterialProperty prop;
|
||||
prop.prop = item->data( 0, Qt::DisplayRole ).toString();
|
||||
prop.label = item->data( 1, Qt::DisplayRole ).toString();
|
||||
prop.type = item->data( 2, Qt::DisplayRole ).toString();
|
||||
|
||||
edit = true;
|
||||
matPropEditWidget->setProperty( prop );
|
||||
matPropEditWidget->show();
|
||||
}
|
||||
|
||||
void MatPropWidget::onRemoveClicked()
|
||||
{
|
||||
QTreeWidgetItem *item = treeWidget->currentItem();
|
||||
if( item == NULL )
|
||||
return;
|
||||
|
||||
delete item;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
void MatPropWidget::onEditorOKClicked()
|
||||
{
|
||||
MaterialProperty prop;
|
||||
matPropEditWidget->getProperty( prop );
|
||||
|
||||
if( edit )
|
||||
{
|
||||
QTreeWidgetItem *item = treeWidget->currentItem();
|
||||
|
||||
MaterialProperty old;
|
||||
old.prop = item->text( 0 );
|
||||
old.label = item->text( 1 );
|
||||
old.type = item->text( 2 );
|
||||
|
||||
if( old == prop )
|
||||
return;
|
||||
|
||||
|
||||
if( idExists( prop.prop ) )
|
||||
{
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr( "Property Id" ),
|
||||
tr( "A property with that Id already exists" )
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( labelExists( prop.label ) )
|
||||
{
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr( "Property label" ),
|
||||
tr( "A property with that label already exists" )
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
item->setData( 0, Qt::DisplayRole, prop.prop );
|
||||
item->setData( 1, Qt::DisplayRole, prop.label );
|
||||
item->setData( 2, Qt::DisplayRole, prop.type );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if( idExists( prop.prop ) )
|
||||
{
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr( "Property Id" ),
|
||||
tr( "A property with that Id already exists" )
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( labelExists( prop.label ) )
|
||||
{
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr( "Property label" ),
|
||||
tr( "A property with that label already exists" )
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
item->setData( 0, Qt::DisplayRole, prop.prop );
|
||||
item->setData( 1, Qt::DisplayRole, prop.label );
|
||||
item->setData( 2, Qt::DisplayRole, prop.type );
|
||||
treeWidget->addTopLevelItem( item );
|
||||
}
|
||||
changed = true;
|
||||
|
||||
}
|
||||
|
||||
void MatPropWidget::setupConnections()
|
||||
{
|
||||
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) );
|
||||
connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) );
|
||||
connect( addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) );
|
||||
connect( editButton, SIGNAL( clicked( bool ) ), this, SLOT( onEditClicked() ) );
|
||||
connect( removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveClicked() ) );
|
||||
connect( matPropEditWidget, SIGNAL( okClicked() ), this, SLOT( onEditorOKClicked() ) );
|
||||
}
|
||||
|
||||
bool MatPropWidget::idExists( const QString &id )
|
||||
{
|
||||
int c = treeWidget->topLevelItemCount();
|
||||
for( int i = 0; i < c; i++ )
|
||||
{
|
||||
if( id == treeWidget->topLevelItem( i )->text( 0 ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MatPropWidget::labelExists( const QString &label )
|
||||
{
|
||||
int c = treeWidget->topLevelItemCount();
|
||||
for( int i = 0; i < c; i++ )
|
||||
{
|
||||
if( label == treeWidget->topLevelItem( i )->text( 1 ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "material_properties.h"
|
||||
#include "material_property_editor.h"
|
||||
#include "nel3d_interface.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
|
||||
MatPropWidget::MatPropWidget( QWidget *parent ) :
|
||||
QDialog( parent )
|
||||
{
|
||||
setupUi( this );
|
||||
matPropEditWidget = new MatPropEditWidget();
|
||||
setupConnections();
|
||||
edit = false;
|
||||
changed = false;
|
||||
proxy = NULL;
|
||||
}
|
||||
|
||||
MatPropWidget::~MatPropWidget()
|
||||
{
|
||||
clear();
|
||||
|
||||
delete matPropEditWidget;
|
||||
matPropEditWidget = NULL;
|
||||
}
|
||||
|
||||
void MatPropWidget::load( CRenderPassProxy *proxy )
|
||||
{
|
||||
clear();
|
||||
changed = false;
|
||||
this->proxy = new CRenderPassProxy( *proxy );
|
||||
|
||||
std::string n;
|
||||
proxy->getName( n );
|
||||
nameEdit->setText( n.c_str() );
|
||||
|
||||
std::vector< SMatProp > v;
|
||||
proxy->getProperties( v );
|
||||
|
||||
std::vector< SMatProp >::iterator itr = v.begin();
|
||||
while( itr != v.end() )
|
||||
{
|
||||
SMatProp &mp = *itr;
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
|
||||
item->setData( 0, Qt::DisplayRole, QString( mp.id.c_str() ) );
|
||||
item->setData( 1, Qt::DisplayRole, QString( mp.label.c_str() ) );
|
||||
|
||||
QString type = SMatProp::typeIdToString( mp.type ).c_str();
|
||||
item->setData( 2, Qt::DisplayRole, type );
|
||||
|
||||
item->setData( 3, Qt::DisplayRole, mp.value.c_str() );
|
||||
|
||||
treeWidget->addTopLevelItem( item );
|
||||
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
void MatPropWidget::clear()
|
||||
{
|
||||
treeWidget->clear();
|
||||
nameEdit->clear();
|
||||
if( this->proxy != NULL )
|
||||
{
|
||||
delete this->proxy;
|
||||
this->proxy = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void MatPropWidget::onOKClicked()
|
||||
{
|
||||
if( proxy != NULL )
|
||||
{
|
||||
std::vector< SMatProp > v;
|
||||
SMatProp p;
|
||||
QTreeWidgetItem *item = NULL;
|
||||
std::string s;
|
||||
|
||||
for( int i = 0; i < treeWidget->topLevelItemCount(); i++ )
|
||||
{
|
||||
item = treeWidget->topLevelItem( i );
|
||||
p.id = item->text( 0 ).toUtf8().data();
|
||||
p.label = item->text( 1 ).toUtf8().data();
|
||||
|
||||
s = item->text( 2 ).toUtf8().data();
|
||||
p.type = SMatProp::typeStringToId( s );
|
||||
|
||||
p.value = item->text( 3 ).toUtf8().data();
|
||||
|
||||
v.push_back( p );
|
||||
}
|
||||
|
||||
proxy->setProperties( v );
|
||||
}
|
||||
|
||||
clear();
|
||||
setResult( QDialog::Accepted );
|
||||
close();
|
||||
}
|
||||
|
||||
void MatPropWidget::onCancelClicked()
|
||||
{
|
||||
clear();
|
||||
setResult( QDialog::Rejected );
|
||||
close();
|
||||
}
|
||||
|
||||
void MatPropWidget::onAddClicked()
|
||||
{
|
||||
edit = false;
|
||||
changed = true;
|
||||
matPropEditWidget->clear();
|
||||
matPropEditWidget->show();
|
||||
}
|
||||
|
||||
void MatPropWidget::onEditClicked()
|
||||
{
|
||||
QTreeWidgetItem *item = treeWidget->currentItem();
|
||||
if( item == NULL )
|
||||
return;
|
||||
|
||||
MaterialProperty prop;
|
||||
prop.prop = item->data( 0, Qt::DisplayRole ).toString();
|
||||
prop.label = item->data( 1, Qt::DisplayRole ).toString();
|
||||
prop.type = item->data( 2, Qt::DisplayRole ).toString();
|
||||
|
||||
edit = true;
|
||||
matPropEditWidget->setProperty( prop );
|
||||
matPropEditWidget->show();
|
||||
}
|
||||
|
||||
void MatPropWidget::onRemoveClicked()
|
||||
{
|
||||
QTreeWidgetItem *item = treeWidget->currentItem();
|
||||
if( item == NULL )
|
||||
return;
|
||||
|
||||
delete item;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
void MatPropWidget::onEditorOKClicked()
|
||||
{
|
||||
MaterialProperty prop;
|
||||
matPropEditWidget->getProperty( prop );
|
||||
|
||||
if( edit )
|
||||
{
|
||||
QTreeWidgetItem *item = treeWidget->currentItem();
|
||||
|
||||
MaterialProperty old;
|
||||
old.prop = item->text( 0 );
|
||||
old.label = item->text( 1 );
|
||||
old.type = item->text( 2 );
|
||||
|
||||
if( old == prop )
|
||||
return;
|
||||
|
||||
|
||||
if( idExists( prop.prop ) )
|
||||
{
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr( "Property Id" ),
|
||||
tr( "A property with that Id already exists" )
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( labelExists( prop.label ) )
|
||||
{
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr( "Property label" ),
|
||||
tr( "A property with that label already exists" )
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
item->setData( 0, Qt::DisplayRole, prop.prop );
|
||||
item->setData( 1, Qt::DisplayRole, prop.label );
|
||||
item->setData( 2, Qt::DisplayRole, prop.type );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if( idExists( prop.prop ) )
|
||||
{
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr( "Property Id" ),
|
||||
tr( "A property with that Id already exists" )
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( labelExists( prop.label ) )
|
||||
{
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr( "Property label" ),
|
||||
tr( "A property with that label already exists" )
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
item->setData( 0, Qt::DisplayRole, prop.prop );
|
||||
item->setData( 1, Qt::DisplayRole, prop.label );
|
||||
item->setData( 2, Qt::DisplayRole, prop.type );
|
||||
treeWidget->addTopLevelItem( item );
|
||||
}
|
||||
changed = true;
|
||||
|
||||
}
|
||||
|
||||
void MatPropWidget::setupConnections()
|
||||
{
|
||||
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) );
|
||||
connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) );
|
||||
connect( addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) );
|
||||
connect( editButton, SIGNAL( clicked( bool ) ), this, SLOT( onEditClicked() ) );
|
||||
connect( removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveClicked() ) );
|
||||
connect( matPropEditWidget, SIGNAL( okClicked() ), this, SLOT( onEditorOKClicked() ) );
|
||||
}
|
||||
|
||||
bool MatPropWidget::idExists( const QString &id )
|
||||
{
|
||||
int c = treeWidget->topLevelItemCount();
|
||||
for( int i = 0; i < c; i++ )
|
||||
{
|
||||
if( id == treeWidget->topLevelItem( i )->text( 0 ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MatPropWidget::labelExists( const QString &label )
|
||||
{
|
||||
int c = treeWidget->topLevelItemCount();
|
||||
for( int i = 0; i < c; i++ )
|
||||
{
|
||||
if( label == treeWidget->topLevelItem( i )->text( 1 ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,60 +1,60 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef MATERIAL_PROPERTIES_H
|
||||
#define MATERIAL_PROPERTIES_H
|
||||
|
||||
#include "ui_material_properties.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
|
||||
class MatPropEditWidget;
|
||||
class CRenderPassProxy;
|
||||
|
||||
class MatPropWidget : public QDialog, public Ui::MatPropWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MatPropWidget( QWidget *parent = NULL );
|
||||
~MatPropWidget();
|
||||
void load( CRenderPassProxy *proxy );
|
||||
void clear();
|
||||
bool getChanged() const{ return changed; }
|
||||
|
||||
private Q_SLOTS:
|
||||
void onOKClicked();
|
||||
void onCancelClicked();
|
||||
void onAddClicked();
|
||||
void onEditClicked();
|
||||
void onRemoveClicked();
|
||||
void onEditorOKClicked();
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
bool idExists( const QString &id );
|
||||
bool labelExists( const QString &id );
|
||||
|
||||
|
||||
bool edit;
|
||||
bool changed;
|
||||
MatPropEditWidget *matPropEditWidget;
|
||||
CRenderPassProxy *proxy;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef MATERIAL_PROPERTIES_H
|
||||
#define MATERIAL_PROPERTIES_H
|
||||
|
||||
#include "ui_material_properties.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
|
||||
class MatPropEditWidget;
|
||||
class CRenderPassProxy;
|
||||
|
||||
class MatPropWidget : public QDialog, public Ui::MatPropWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MatPropWidget( QWidget *parent = NULL );
|
||||
~MatPropWidget();
|
||||
void load( CRenderPassProxy *proxy );
|
||||
void clear();
|
||||
bool getChanged() const{ return changed; }
|
||||
|
||||
private Q_SLOTS:
|
||||
void onOKClicked();
|
||||
void onCancelClicked();
|
||||
void onAddClicked();
|
||||
void onEditClicked();
|
||||
void onRemoveClicked();
|
||||
void onEditorOKClicked();
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
bool idExists( const QString &id );
|
||||
bool labelExists( const QString &id );
|
||||
|
||||
|
||||
bool edit;
|
||||
bool changed;
|
||||
MatPropEditWidget *matPropEditWidget;
|
||||
CRenderPassProxy *proxy;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,73 +1,73 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "material_property_editor.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
MatPropEditWidget::MatPropEditWidget( QWidget *parent ) :
|
||||
QWidget( parent )
|
||||
{
|
||||
setupUi( this );
|
||||
setupConnections();
|
||||
}
|
||||
|
||||
MatPropEditWidget::~MatPropEditWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void MatPropEditWidget::getProperty( MaterialProperty &prop )
|
||||
{
|
||||
prop.prop = propertyEdit->text();
|
||||
prop.label = labelEdit->text();
|
||||
prop.type = typeCB->currentText();
|
||||
}
|
||||
|
||||
void MatPropEditWidget::setProperty( const MaterialProperty &prop )
|
||||
{
|
||||
propertyEdit->setText( prop.prop );
|
||||
labelEdit->setText( prop.label );
|
||||
int i = typeCB->findText( prop.type );
|
||||
if( i != -1 )
|
||||
typeCB->setCurrentIndex( i );
|
||||
|
||||
}
|
||||
|
||||
void MatPropEditWidget::clear()
|
||||
{
|
||||
propertyEdit->clear();
|
||||
labelEdit->clear();
|
||||
typeCB->setCurrentIndex( 0 );
|
||||
}
|
||||
|
||||
void MatPropEditWidget::onOKClicked()
|
||||
{
|
||||
close();
|
||||
Q_EMIT okClicked();
|
||||
}
|
||||
|
||||
void MatPropEditWidget::onCancelClicked()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void MatPropEditWidget::setupConnections()
|
||||
{
|
||||
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) );
|
||||
connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "material_property_editor.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
MatPropEditWidget::MatPropEditWidget( QWidget *parent ) :
|
||||
QWidget( parent )
|
||||
{
|
||||
setupUi( this );
|
||||
setupConnections();
|
||||
}
|
||||
|
||||
MatPropEditWidget::~MatPropEditWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void MatPropEditWidget::getProperty( MaterialProperty &prop )
|
||||
{
|
||||
prop.prop = propertyEdit->text();
|
||||
prop.label = labelEdit->text();
|
||||
prop.type = typeCB->currentText();
|
||||
}
|
||||
|
||||
void MatPropEditWidget::setProperty( const MaterialProperty &prop )
|
||||
{
|
||||
propertyEdit->setText( prop.prop );
|
||||
labelEdit->setText( prop.label );
|
||||
int i = typeCB->findText( prop.type );
|
||||
if( i != -1 )
|
||||
typeCB->setCurrentIndex( i );
|
||||
|
||||
}
|
||||
|
||||
void MatPropEditWidget::clear()
|
||||
{
|
||||
propertyEdit->clear();
|
||||
labelEdit->clear();
|
||||
typeCB->setCurrentIndex( 0 );
|
||||
}
|
||||
|
||||
void MatPropEditWidget::onOKClicked()
|
||||
{
|
||||
close();
|
||||
Q_EMIT okClicked();
|
||||
}
|
||||
|
||||
void MatPropEditWidget::onCancelClicked()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void MatPropEditWidget::setupConnections()
|
||||
{
|
||||
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) );
|
||||
connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,70 +1,70 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef MATERIAL_PROPERTY_EDITOR_H
|
||||
#define MATERIAL_PROPERTY_EDITOR_H
|
||||
|
||||
#include "ui_material_property_editor.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
|
||||
struct MaterialProperty
|
||||
{
|
||||
QString prop;
|
||||
QString label;
|
||||
QString type;
|
||||
|
||||
bool operator==( const MaterialProperty &o )
|
||||
{
|
||||
if( o.prop != prop )
|
||||
return false;
|
||||
|
||||
if( o.label != label )
|
||||
return false;
|
||||
|
||||
if( o.type != type )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class MatPropEditWidget : public QWidget, public Ui::MatPropEditWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MatPropEditWidget( QWidget *parent = NULL );
|
||||
~MatPropEditWidget();
|
||||
void getProperty( MaterialProperty &prop );
|
||||
void setProperty( const MaterialProperty &prop );
|
||||
void clear();
|
||||
|
||||
Q_SIGNALS:
|
||||
void okClicked();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onOKClicked();
|
||||
void onCancelClicked();
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef MATERIAL_PROPERTY_EDITOR_H
|
||||
#define MATERIAL_PROPERTY_EDITOR_H
|
||||
|
||||
#include "ui_material_property_editor.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
|
||||
struct MaterialProperty
|
||||
{
|
||||
QString prop;
|
||||
QString label;
|
||||
QString type;
|
||||
|
||||
bool operator==( const MaterialProperty &o )
|
||||
{
|
||||
if( o.prop != prop )
|
||||
return false;
|
||||
|
||||
if( o.label != label )
|
||||
return false;
|
||||
|
||||
if( o.type != type )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class MatPropEditWidget : public QWidget, public Ui::MatPropEditWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MatPropEditWidget( QWidget *parent = NULL );
|
||||
~MatPropEditWidget();
|
||||
void getProperty( MaterialProperty &prop );
|
||||
void setProperty( const MaterialProperty &prop );
|
||||
void clear();
|
||||
|
||||
Q_SIGNALS:
|
||||
void okClicked();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onOKClicked();
|
||||
void onCancelClicked();
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,141 +1,141 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "material_splitter.h"
|
||||
#include "nel3d_interface.h"
|
||||
#include "material_widget.h"
|
||||
#include "prop_browser_ctrl.h"
|
||||
#include "3rdparty/qtpropertybrowser/qttreepropertybrowser.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
MaterialSplitter::MaterialSplitter( QWidget *parent ) :
|
||||
QSplitter( parent )
|
||||
{
|
||||
materialWidget = new MaterialWidget();
|
||||
browserCtrl = new CPropBrowserCtrl();
|
||||
browser = new QtTreePropertyBrowser();
|
||||
browserCtrl->setBrowser( browser );
|
||||
|
||||
setup();
|
||||
setupConnections();
|
||||
}
|
||||
|
||||
MaterialSplitter::~MaterialSplitter()
|
||||
{
|
||||
delete browserCtrl;
|
||||
browserCtrl = NULL;
|
||||
nl3dIface = NULL;
|
||||
materialWidget = NULL;
|
||||
browser = NULL;
|
||||
}
|
||||
|
||||
void MaterialSplitter::setupConnections()
|
||||
{
|
||||
connect( materialWidget, SIGNAL( propsChanged() ), this, SLOT( onPropsChanged() ) );
|
||||
connect( materialWidget, SIGNAL( passChanged( const QString& ) ), this, SLOT( onPassChanged( const QString& ) ) );
|
||||
connect( materialWidget, SIGNAL( subMatChanged( int ) ), this, SLOT( onSubMatChanged( int ) ) );
|
||||
}
|
||||
|
||||
void MaterialSplitter::setup()
|
||||
{
|
||||
setOrientation( Qt::Vertical );
|
||||
addWidget( materialWidget );
|
||||
addWidget( browser );
|
||||
}
|
||||
|
||||
void MaterialSplitter::setNel3DIface( CNel3DInterface *iface )
|
||||
{
|
||||
nl3dIface = iface;
|
||||
materialWidget->setNel3DIface( iface );
|
||||
browserCtrl->setNel3DIface( iface );
|
||||
}
|
||||
|
||||
void MaterialSplitter::onNewMaterial()
|
||||
{
|
||||
materialWidget->onNewMaterial();
|
||||
}
|
||||
|
||||
void MaterialSplitter::onMaterialLoaded()
|
||||
{
|
||||
materialWidget->onMaterialLoaded();
|
||||
}
|
||||
|
||||
void MaterialSplitter::onSceneCleared()
|
||||
{
|
||||
materialWidget->onSceneCleared();
|
||||
browserCtrl->onSceneCleared();
|
||||
}
|
||||
|
||||
void MaterialSplitter::onShapeChanged()
|
||||
{
|
||||
materialWidget->onShapeChanged();
|
||||
}
|
||||
|
||||
void MaterialSplitter::onPassAdded( const char *name )
|
||||
{
|
||||
materialWidget->onPassAdded( name );
|
||||
}
|
||||
|
||||
void MaterialSplitter::onPassRemoved( const char *name )
|
||||
{
|
||||
materialWidget->onPassRemoved( name );
|
||||
}
|
||||
|
||||
void MaterialSplitter::onPassMovedUp( const char *name )
|
||||
{
|
||||
materialWidget->onPassMovedUp( name );
|
||||
}
|
||||
|
||||
void MaterialSplitter::onPassMovedDown( const char *name )
|
||||
{
|
||||
materialWidget->onPassMovedDown( name );
|
||||
}
|
||||
|
||||
void MaterialSplitter::onPassRenamed( const char *from, const char *to )
|
||||
{
|
||||
materialWidget->onPassRenamed( from, to );
|
||||
}
|
||||
|
||||
void MaterialSplitter::onShaderAdded( const QString &name )
|
||||
{
|
||||
materialWidget->onShaderAdded( name );
|
||||
}
|
||||
|
||||
void MaterialSplitter::onShaderRemoved( const QString &name )
|
||||
{
|
||||
materialWidget->onShaderRemoved( name );
|
||||
}
|
||||
|
||||
void MaterialSplitter::onPropsChanged()
|
||||
{
|
||||
QString pass;
|
||||
materialWidget->getCurrentPass( pass );
|
||||
browserCtrl->onPropsChanged();
|
||||
}
|
||||
|
||||
void MaterialSplitter::onPassChanged( const QString &pass )
|
||||
{
|
||||
browserCtrl->loadPropsForPass( pass );
|
||||
}
|
||||
|
||||
void MaterialSplitter::onSubMatChanged( int i )
|
||||
{
|
||||
browserCtrl->loadPropsForPass( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "material_splitter.h"
|
||||
#include "nel3d_interface.h"
|
||||
#include "material_widget.h"
|
||||
#include "prop_browser_ctrl.h"
|
||||
#include "3rdparty/qtpropertybrowser/qttreepropertybrowser.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
MaterialSplitter::MaterialSplitter( QWidget *parent ) :
|
||||
QSplitter( parent )
|
||||
{
|
||||
materialWidget = new MaterialWidget();
|
||||
browserCtrl = new CPropBrowserCtrl();
|
||||
browser = new QtTreePropertyBrowser();
|
||||
browserCtrl->setBrowser( browser );
|
||||
|
||||
setup();
|
||||
setupConnections();
|
||||
}
|
||||
|
||||
MaterialSplitter::~MaterialSplitter()
|
||||
{
|
||||
delete browserCtrl;
|
||||
browserCtrl = NULL;
|
||||
nl3dIface = NULL;
|
||||
materialWidget = NULL;
|
||||
browser = NULL;
|
||||
}
|
||||
|
||||
void MaterialSplitter::setupConnections()
|
||||
{
|
||||
connect( materialWidget, SIGNAL( propsChanged() ), this, SLOT( onPropsChanged() ) );
|
||||
connect( materialWidget, SIGNAL( passChanged( const QString& ) ), this, SLOT( onPassChanged( const QString& ) ) );
|
||||
connect( materialWidget, SIGNAL( subMatChanged( int ) ), this, SLOT( onSubMatChanged( int ) ) );
|
||||
}
|
||||
|
||||
void MaterialSplitter::setup()
|
||||
{
|
||||
setOrientation( Qt::Vertical );
|
||||
addWidget( materialWidget );
|
||||
addWidget( browser );
|
||||
}
|
||||
|
||||
void MaterialSplitter::setNel3DIface( CNel3DInterface *iface )
|
||||
{
|
||||
nl3dIface = iface;
|
||||
materialWidget->setNel3DIface( iface );
|
||||
browserCtrl->setNel3DIface( iface );
|
||||
}
|
||||
|
||||
void MaterialSplitter::onNewMaterial()
|
||||
{
|
||||
materialWidget->onNewMaterial();
|
||||
}
|
||||
|
||||
void MaterialSplitter::onMaterialLoaded()
|
||||
{
|
||||
materialWidget->onMaterialLoaded();
|
||||
}
|
||||
|
||||
void MaterialSplitter::onSceneCleared()
|
||||
{
|
||||
materialWidget->onSceneCleared();
|
||||
browserCtrl->onSceneCleared();
|
||||
}
|
||||
|
||||
void MaterialSplitter::onShapeChanged()
|
||||
{
|
||||
materialWidget->onShapeChanged();
|
||||
}
|
||||
|
||||
void MaterialSplitter::onPassAdded( const char *name )
|
||||
{
|
||||
materialWidget->onPassAdded( name );
|
||||
}
|
||||
|
||||
void MaterialSplitter::onPassRemoved( const char *name )
|
||||
{
|
||||
materialWidget->onPassRemoved( name );
|
||||
}
|
||||
|
||||
void MaterialSplitter::onPassMovedUp( const char *name )
|
||||
{
|
||||
materialWidget->onPassMovedUp( name );
|
||||
}
|
||||
|
||||
void MaterialSplitter::onPassMovedDown( const char *name )
|
||||
{
|
||||
materialWidget->onPassMovedDown( name );
|
||||
}
|
||||
|
||||
void MaterialSplitter::onPassRenamed( const char *from, const char *to )
|
||||
{
|
||||
materialWidget->onPassRenamed( from, to );
|
||||
}
|
||||
|
||||
void MaterialSplitter::onShaderAdded( const QString &name )
|
||||
{
|
||||
materialWidget->onShaderAdded( name );
|
||||
}
|
||||
|
||||
void MaterialSplitter::onShaderRemoved( const QString &name )
|
||||
{
|
||||
materialWidget->onShaderRemoved( name );
|
||||
}
|
||||
|
||||
void MaterialSplitter::onPropsChanged()
|
||||
{
|
||||
QString pass;
|
||||
materialWidget->getCurrentPass( pass );
|
||||
browserCtrl->onPropsChanged();
|
||||
}
|
||||
|
||||
void MaterialSplitter::onPassChanged( const QString &pass )
|
||||
{
|
||||
browserCtrl->loadPropsForPass( pass );
|
||||
}
|
||||
|
||||
void MaterialSplitter::onSubMatChanged( int i )
|
||||
{
|
||||
browserCtrl->loadPropsForPass( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,73 +1,73 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef MATERIAL_SPLITTER_H
|
||||
#define MATERIAL_SPLITTER_H
|
||||
|
||||
#include <QSplitter>
|
||||
#include "material_observer.h"
|
||||
|
||||
class QtTreePropertyBrowser;
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
class CNel3DInterface;
|
||||
class MaterialWidget;
|
||||
class CPropBrowserCtrl;
|
||||
|
||||
class MaterialSplitter : public QSplitter, public CMaterialObserver
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MaterialSplitter( QWidget *parent = NULL );
|
||||
~MaterialSplitter();
|
||||
|
||||
void setupConnections();
|
||||
|
||||
void setup();
|
||||
|
||||
void setNel3DIface( CNel3DInterface *iface );
|
||||
|
||||
void onNewMaterial();
|
||||
void onMaterialLoaded();
|
||||
void onSceneCleared();
|
||||
void onShapeChanged();
|
||||
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 );
|
||||
|
||||
public Q_SLOTS:
|
||||
void onShaderAdded( const QString &name );
|
||||
void onShaderRemoved( const QString &name );
|
||||
|
||||
private:
|
||||
CNel3DInterface *nl3dIface;
|
||||
MaterialWidget *materialWidget;
|
||||
CPropBrowserCtrl *browserCtrl;
|
||||
QtTreePropertyBrowser *browser;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onPropsChanged();
|
||||
void onPassChanged( const QString &pass );
|
||||
void onSubMatChanged( int i );
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef MATERIAL_SPLITTER_H
|
||||
#define MATERIAL_SPLITTER_H
|
||||
|
||||
#include <QSplitter>
|
||||
#include "material_observer.h"
|
||||
|
||||
class QtTreePropertyBrowser;
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
class CNel3DInterface;
|
||||
class MaterialWidget;
|
||||
class CPropBrowserCtrl;
|
||||
|
||||
class MaterialSplitter : public QSplitter, public CMaterialObserver
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MaterialSplitter( QWidget *parent = NULL );
|
||||
~MaterialSplitter();
|
||||
|
||||
void setupConnections();
|
||||
|
||||
void setup();
|
||||
|
||||
void setNel3DIface( CNel3DInterface *iface );
|
||||
|
||||
void onNewMaterial();
|
||||
void onMaterialLoaded();
|
||||
void onSceneCleared();
|
||||
void onShapeChanged();
|
||||
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 );
|
||||
|
||||
public Q_SLOTS:
|
||||
void onShaderAdded( const QString &name );
|
||||
void onShaderRemoved( const QString &name );
|
||||
|
||||
private:
|
||||
CNel3DInterface *nl3dIface;
|
||||
MaterialWidget *materialWidget;
|
||||
CPropBrowserCtrl *browserCtrl;
|
||||
QtTreePropertyBrowser *browser;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onPropsChanged();
|
||||
void onPassChanged( const QString &pass );
|
||||
void onSubMatChanged( int i );
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,76 +1,76 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef MATERIAL_WIDGET_H
|
||||
#define MATERIAL_WIDGET_H
|
||||
|
||||
#include "ui_material_widget.h"
|
||||
#include "material_observer.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
class ShaderEditorWidget;
|
||||
class MatPropWidget;
|
||||
class CNel3DInterface;
|
||||
|
||||
class MaterialWidget : public QWidget, public Ui::MaterialWidget, public CMaterialObserver
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MaterialWidget( QWidget *parent = NULL );
|
||||
~MaterialWidget();
|
||||
|
||||
void onSceneCleared();
|
||||
void onNewMaterial();
|
||||
void onMaterialLoaded();
|
||||
void onShapeChanged();
|
||||
|
||||
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 onShaderAdded( const QString &name );
|
||||
void onShaderRemoved( const QString &name );
|
||||
|
||||
void setNel3DIface( CNel3DInterface *iface );
|
||||
|
||||
void getCurrentPass( QString &pass );
|
||||
|
||||
Q_SIGNALS:
|
||||
void propsChanged();
|
||||
void passChanged( const QString &pass );
|
||||
void subMatChanged( int i );
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
ShaderEditorWidget *shaderEditorWidget;
|
||||
MatPropWidget *matPropWidget;
|
||||
CNel3DInterface *nl3dIface;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onPassEditClicked();
|
||||
void onShaderEditClicked();
|
||||
void onSubMatCBChanged( int i );
|
||||
void onPassCBChanged( const QString &text );
|
||||
void onShaderCBChanged( const QString &text );
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef MATERIAL_WIDGET_H
|
||||
#define MATERIAL_WIDGET_H
|
||||
|
||||
#include "ui_material_widget.h"
|
||||
#include "material_observer.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
class ShaderEditorWidget;
|
||||
class MatPropWidget;
|
||||
class CNel3DInterface;
|
||||
|
||||
class MaterialWidget : public QWidget, public Ui::MaterialWidget, public CMaterialObserver
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MaterialWidget( QWidget *parent = NULL );
|
||||
~MaterialWidget();
|
||||
|
||||
void onSceneCleared();
|
||||
void onNewMaterial();
|
||||
void onMaterialLoaded();
|
||||
void onShapeChanged();
|
||||
|
||||
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 onShaderAdded( const QString &name );
|
||||
void onShaderRemoved( const QString &name );
|
||||
|
||||
void setNel3DIface( CNel3DInterface *iface );
|
||||
|
||||
void getCurrentPass( QString &pass );
|
||||
|
||||
Q_SIGNALS:
|
||||
void propsChanged();
|
||||
void passChanged( const QString &pass );
|
||||
void subMatChanged( int i );
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
ShaderEditorWidget *shaderEditorWidget;
|
||||
MatPropWidget *matPropWidget;
|
||||
CNel3DInterface *nl3dIface;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onPassEditClicked();
|
||||
void onShaderEditClicked();
|
||||
void onSubMatCBChanged( int i );
|
||||
void onPassCBChanged( const QString &text );
|
||||
void onShaderCBChanged( const QString &text );
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,331 +1,331 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef NEL3D_INTERFACE_H
|
||||
#define NEL3D_INTERFACE_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class CDynMaterial;
|
||||
struct SRenderPass;
|
||||
class CUsrShaderManager;
|
||||
class UDriver;
|
||||
class UScene;
|
||||
class U3dMouseListener;
|
||||
}
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
/// Material Property, holds the user shader parameters as string ( for the editor )
|
||||
struct SMatProp
|
||||
{
|
||||
enum EType
|
||||
{
|
||||
Color,
|
||||
Vector4,
|
||||
Float,
|
||||
Double,
|
||||
Int,
|
||||
Uint,
|
||||
Matrix4,
|
||||
Texture,
|
||||
EType_count
|
||||
};
|
||||
|
||||
/// Creates a string representation of the type id
|
||||
static std::string typeIdToString( unsigned char type );
|
||||
|
||||
/// Turns the type id string back to Id
|
||||
static unsigned char typeStringToId( const std::string &s );
|
||||
|
||||
std::string id;
|
||||
std::string label;
|
||||
unsigned char type;
|
||||
std::string value;
|
||||
|
||||
private:
|
||||
static const char *idToString[];
|
||||
};
|
||||
|
||||
|
||||
/// Proxy class for the rendering pass
|
||||
class CRenderPassProxy
|
||||
{
|
||||
public:
|
||||
CRenderPassProxy( NL3D::SRenderPass *p )
|
||||
{
|
||||
pass = p;
|
||||
}
|
||||
|
||||
~CRenderPassProxy(){}
|
||||
|
||||
/// Retrieves the rendering properties as a vector
|
||||
void getProperties( std::vector< SMatProp > &v );
|
||||
|
||||
/// Clears the properties and then copies the ones from the vector specified
|
||||
void setProperties( std::vector< SMatProp > &v );
|
||||
|
||||
/// Retrieves the name of the pass
|
||||
void getName( std::string &name );
|
||||
|
||||
/// Sets the name of the pass
|
||||
void setName( const std::string &name );
|
||||
|
||||
/// Returns the reference ( just a string ) to the user shader associated
|
||||
void getShaderRef( std::string &s );
|
||||
|
||||
/// Sets the reference ( just a string ) to the user shader associated
|
||||
void setShaderRef( const std::string &s );
|
||||
|
||||
/// Retrieves a single rendering property
|
||||
bool getProperty( const std::string &name, SMatProp &p );
|
||||
|
||||
/// Changes a single rendering property
|
||||
bool changeProperty( const SMatProp &p );
|
||||
|
||||
private:
|
||||
NL3D::SRenderPass *pass;
|
||||
};
|
||||
|
||||
/// Proxy class for the dynamic material
|
||||
class CNelMaterialProxy
|
||||
{
|
||||
public:
|
||||
CNelMaterialProxy( NL3D::CDynMaterial *mat )
|
||||
{
|
||||
material = mat;
|
||||
}
|
||||
|
||||
~CNelMaterialProxy(){}
|
||||
|
||||
/// Retrieves the list of rendering passes
|
||||
void getPassList( std::vector< std::string > &l );
|
||||
|
||||
/// Adds a new pass
|
||||
void addPass( const char *name );
|
||||
|
||||
/// Removes the specified pass, if exists
|
||||
void removePass( const char *name );
|
||||
|
||||
/// Moves the pass up by one position
|
||||
void movePassUp( const char *name );
|
||||
|
||||
/// Moves the pass down by one position
|
||||
void movePassDown( const char *name );
|
||||
|
||||
/// Renames the specified pass
|
||||
void renamePass( const char *from, const char *to );
|
||||
|
||||
/// Retrieves the specified pass, by position
|
||||
CRenderPassProxy getPass( unsigned long i );
|
||||
|
||||
/// Retrieves the specified pass, by name
|
||||
CRenderPassProxy getPass( const char *name );
|
||||
|
||||
bool isEmpty() const{
|
||||
if( material == NULL )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
NL3D::CDynMaterial *material;
|
||||
};
|
||||
|
||||
|
||||
struct SShaderInfo
|
||||
{
|
||||
std::string name;
|
||||
std::string description;
|
||||
std::string vp;
|
||||
std::string fp;
|
||||
};
|
||||
|
||||
struct SFogSettings
|
||||
{
|
||||
bool enable;
|
||||
float start;
|
||||
float end;
|
||||
unsigned char color[ 4 ];
|
||||
|
||||
SFogSettings()
|
||||
{
|
||||
enable = false;
|
||||
start = 0.0f;
|
||||
end = 0.0f;
|
||||
color[ 0 ] = 0.0f;
|
||||
color[ 1 ] = 0.0f;
|
||||
color[ 2 ] = 0.0f;
|
||||
color[ 3 ] = 0.0f;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct SLightInfo
|
||||
{
|
||||
enum LightType
|
||||
{
|
||||
Directional,
|
||||
Point,
|
||||
Spot
|
||||
};
|
||||
|
||||
bool enabled;
|
||||
unsigned char type;
|
||||
float posOrDir[ 3 ];
|
||||
float ambColor[ 3 ];
|
||||
float diffColor[ 3 ];
|
||||
float specColor[ 3 ];
|
||||
float constAttn;
|
||||
float linAttn;
|
||||
float quadAttn;
|
||||
|
||||
SLightInfo()
|
||||
{
|
||||
enabled = true;
|
||||
type = Directional;
|
||||
posOrDir[ 0 ] = posOrDir[ 1 ] = posOrDir[ 2 ] = 0.0f;
|
||||
ambColor[ 0 ] = ambColor[ 1 ] = ambColor[ 2 ] = 255;
|
||||
diffColor[ 0 ] = diffColor[ 1 ] = diffColor[ 2 ] = 255;
|
||||
specColor[ 0 ] = specColor[ 1 ] = specColor[ 2 ] = 255;
|
||||
constAttn = 1.0f;
|
||||
linAttn = quadAttn = 0.0f;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/// Proxy class for Nel3D, so the material editor and Nel3D can interface
|
||||
class CNel3DInterface
|
||||
{
|
||||
public:
|
||||
CNel3DInterface();
|
||||
~CNel3DInterface();
|
||||
|
||||
/// Load a material for the current (sub)object
|
||||
bool loadMaterial( const char *fname );
|
||||
|
||||
/// Save the current (sub)object's material
|
||||
bool saveMaterial( const char *fname );
|
||||
|
||||
/// Generate materials from the current (sub)object(s) "old" material(s)
|
||||
void genMaterials();
|
||||
|
||||
/// Creates new material(s) for the current (sub)object(s)
|
||||
void newMaterial();
|
||||
|
||||
/// Makes the specified sub-material current
|
||||
bool selectSubMaterial( int id );
|
||||
|
||||
/// Returns a proxy object to the current sub-material
|
||||
CNelMaterialProxy getMaterial();
|
||||
|
||||
/// Retrieves a list of user shaders loaded
|
||||
void getShaderList( std::vector< std::string > &v );
|
||||
|
||||
/// Retrieves the specified user shader if exists
|
||||
bool getShaderInfo( const std::string &name, SShaderInfo &info );
|
||||
|
||||
/// Updates a user shader
|
||||
bool updateShaderInfo( const SShaderInfo &info );
|
||||
|
||||
/// Adds a new user shader
|
||||
bool addShader( const SShaderInfo &info );
|
||||
|
||||
/// Removes a user shader
|
||||
bool removeShader( const std::string &name );
|
||||
|
||||
/// Loads the user shaders
|
||||
void loadShaders();
|
||||
|
||||
/// Saves the specified user shader
|
||||
void saveShader( const std::string &name );
|
||||
|
||||
/// Deletes the specified user shader
|
||||
void deleteShader( const std::string &name );
|
||||
|
||||
/// Sets up the viewport widget
|
||||
void initViewPort( unsigned long wnd, unsigned long w, unsigned long h );
|
||||
|
||||
/// Shuts down the viewport widget
|
||||
void killViewPort();
|
||||
|
||||
/// Resizes the viewport widget
|
||||
void resizeViewPort( unsigned long w, unsigned long h );
|
||||
NL3D::UDriver* getDriver(){ return driver; }
|
||||
|
||||
/// Clears the scene then adds a cube
|
||||
bool addCube();
|
||||
|
||||
/// Clears the scene then adds a sphere
|
||||
bool addSphere();
|
||||
|
||||
/// Clears the scene then add a cylinder
|
||||
bool addCylinder();
|
||||
|
||||
/// Clears the scene the adds a teapot
|
||||
bool addTeaPot();
|
||||
|
||||
|
||||
/// Clears the scene then loads a shape
|
||||
bool loadShape( const std::string &fileName );
|
||||
|
||||
/// Clears the scene, as the name suggests
|
||||
void clearScene();
|
||||
|
||||
/// Sends the input events to Nel3D
|
||||
void updateInput();
|
||||
|
||||
/// Renders the scene
|
||||
void renderScene();
|
||||
|
||||
unsigned long getShapeMatCount() const;
|
||||
|
||||
void getFogSettings( SFogSettings &s );
|
||||
void setFogSettings( const SFogSettings &s );
|
||||
|
||||
unsigned char getMaxLights() const;
|
||||
void getLightInfo( unsigned char light, SLightInfo &info );
|
||||
void setLightInfo( unsigned char light, const SLightInfo &info );
|
||||
|
||||
void setBGColor( unsigned char R, unsigned char G, unsigned char B, unsigned char A ){
|
||||
bgColor[ 0 ] = R;
|
||||
bgColor[ 1 ] = G;
|
||||
bgColor[ 2 ] = B;
|
||||
bgColor[ 3 ] = A;
|
||||
}
|
||||
|
||||
private:
|
||||
void setupCamera();
|
||||
|
||||
unsigned long subMatId;
|
||||
|
||||
NL3D::CUsrShaderManager *shaderManager;
|
||||
NL3D::UDriver *driver;
|
||||
NL3D::UScene *scene;
|
||||
NL3D::U3dMouseListener *mouseListener;
|
||||
unsigned char bgColor[ 4 ];
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef NEL3D_INTERFACE_H
|
||||
#define NEL3D_INTERFACE_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class CDynMaterial;
|
||||
struct SRenderPass;
|
||||
class CUsrShaderManager;
|
||||
class UDriver;
|
||||
class UScene;
|
||||
class U3dMouseListener;
|
||||
}
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
/// Material Property, holds the user shader parameters as string ( for the editor )
|
||||
struct SMatProp
|
||||
{
|
||||
enum EType
|
||||
{
|
||||
Color,
|
||||
Vector4,
|
||||
Float,
|
||||
Double,
|
||||
Int,
|
||||
Uint,
|
||||
Matrix4,
|
||||
Texture,
|
||||
EType_count
|
||||
};
|
||||
|
||||
/// Creates a string representation of the type id
|
||||
static std::string typeIdToString( unsigned char type );
|
||||
|
||||
/// Turns the type id string back to Id
|
||||
static unsigned char typeStringToId( const std::string &s );
|
||||
|
||||
std::string id;
|
||||
std::string label;
|
||||
unsigned char type;
|
||||
std::string value;
|
||||
|
||||
private:
|
||||
static const char *idToString[];
|
||||
};
|
||||
|
||||
|
||||
/// Proxy class for the rendering pass
|
||||
class CRenderPassProxy
|
||||
{
|
||||
public:
|
||||
CRenderPassProxy( NL3D::SRenderPass *p )
|
||||
{
|
||||
pass = p;
|
||||
}
|
||||
|
||||
~CRenderPassProxy(){}
|
||||
|
||||
/// Retrieves the rendering properties as a vector
|
||||
void getProperties( std::vector< SMatProp > &v );
|
||||
|
||||
/// Clears the properties and then copies the ones from the vector specified
|
||||
void setProperties( std::vector< SMatProp > &v );
|
||||
|
||||
/// Retrieves the name of the pass
|
||||
void getName( std::string &name );
|
||||
|
||||
/// Sets the name of the pass
|
||||
void setName( const std::string &name );
|
||||
|
||||
/// Returns the reference ( just a string ) to the user shader associated
|
||||
void getShaderRef( std::string &s );
|
||||
|
||||
/// Sets the reference ( just a string ) to the user shader associated
|
||||
void setShaderRef( const std::string &s );
|
||||
|
||||
/// Retrieves a single rendering property
|
||||
bool getProperty( const std::string &name, SMatProp &p );
|
||||
|
||||
/// Changes a single rendering property
|
||||
bool changeProperty( const SMatProp &p );
|
||||
|
||||
private:
|
||||
NL3D::SRenderPass *pass;
|
||||
};
|
||||
|
||||
/// Proxy class for the dynamic material
|
||||
class CNelMaterialProxy
|
||||
{
|
||||
public:
|
||||
CNelMaterialProxy( NL3D::CDynMaterial *mat )
|
||||
{
|
||||
material = mat;
|
||||
}
|
||||
|
||||
~CNelMaterialProxy(){}
|
||||
|
||||
/// Retrieves the list of rendering passes
|
||||
void getPassList( std::vector< std::string > &l );
|
||||
|
||||
/// Adds a new pass
|
||||
void addPass( const char *name );
|
||||
|
||||
/// Removes the specified pass, if exists
|
||||
void removePass( const char *name );
|
||||
|
||||
/// Moves the pass up by one position
|
||||
void movePassUp( const char *name );
|
||||
|
||||
/// Moves the pass down by one position
|
||||
void movePassDown( const char *name );
|
||||
|
||||
/// Renames the specified pass
|
||||
void renamePass( const char *from, const char *to );
|
||||
|
||||
/// Retrieves the specified pass, by position
|
||||
CRenderPassProxy getPass( unsigned long i );
|
||||
|
||||
/// Retrieves the specified pass, by name
|
||||
CRenderPassProxy getPass( const char *name );
|
||||
|
||||
bool isEmpty() const{
|
||||
if( material == NULL )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
NL3D::CDynMaterial *material;
|
||||
};
|
||||
|
||||
|
||||
struct SShaderInfo
|
||||
{
|
||||
std::string name;
|
||||
std::string description;
|
||||
std::string vp;
|
||||
std::string fp;
|
||||
};
|
||||
|
||||
struct SFogSettings
|
||||
{
|
||||
bool enable;
|
||||
float start;
|
||||
float end;
|
||||
unsigned char color[ 4 ];
|
||||
|
||||
SFogSettings()
|
||||
{
|
||||
enable = false;
|
||||
start = 0.0f;
|
||||
end = 0.0f;
|
||||
color[ 0 ] = 0.0f;
|
||||
color[ 1 ] = 0.0f;
|
||||
color[ 2 ] = 0.0f;
|
||||
color[ 3 ] = 0.0f;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct SLightInfo
|
||||
{
|
||||
enum LightType
|
||||
{
|
||||
Directional,
|
||||
Point,
|
||||
Spot
|
||||
};
|
||||
|
||||
bool enabled;
|
||||
unsigned char type;
|
||||
float posOrDir[ 3 ];
|
||||
float ambColor[ 3 ];
|
||||
float diffColor[ 3 ];
|
||||
float specColor[ 3 ];
|
||||
float constAttn;
|
||||
float linAttn;
|
||||
float quadAttn;
|
||||
|
||||
SLightInfo()
|
||||
{
|
||||
enabled = true;
|
||||
type = Directional;
|
||||
posOrDir[ 0 ] = posOrDir[ 1 ] = posOrDir[ 2 ] = 0.0f;
|
||||
ambColor[ 0 ] = ambColor[ 1 ] = ambColor[ 2 ] = 255;
|
||||
diffColor[ 0 ] = diffColor[ 1 ] = diffColor[ 2 ] = 255;
|
||||
specColor[ 0 ] = specColor[ 1 ] = specColor[ 2 ] = 255;
|
||||
constAttn = 1.0f;
|
||||
linAttn = quadAttn = 0.0f;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/// Proxy class for Nel3D, so the material editor and Nel3D can interface
|
||||
class CNel3DInterface
|
||||
{
|
||||
public:
|
||||
CNel3DInterface();
|
||||
~CNel3DInterface();
|
||||
|
||||
/// Load a material for the current (sub)object
|
||||
bool loadMaterial( const char *fname );
|
||||
|
||||
/// Save the current (sub)object's material
|
||||
bool saveMaterial( const char *fname );
|
||||
|
||||
/// Generate materials from the current (sub)object(s) "old" material(s)
|
||||
void genMaterials();
|
||||
|
||||
/// Creates new material(s) for the current (sub)object(s)
|
||||
void newMaterial();
|
||||
|
||||
/// Makes the specified sub-material current
|
||||
bool selectSubMaterial( int id );
|
||||
|
||||
/// Returns a proxy object to the current sub-material
|
||||
CNelMaterialProxy getMaterial();
|
||||
|
||||
/// Retrieves a list of user shaders loaded
|
||||
void getShaderList( std::vector< std::string > &v );
|
||||
|
||||
/// Retrieves the specified user shader if exists
|
||||
bool getShaderInfo( const std::string &name, SShaderInfo &info );
|
||||
|
||||
/// Updates a user shader
|
||||
bool updateShaderInfo( const SShaderInfo &info );
|
||||
|
||||
/// Adds a new user shader
|
||||
bool addShader( const SShaderInfo &info );
|
||||
|
||||
/// Removes a user shader
|
||||
bool removeShader( const std::string &name );
|
||||
|
||||
/// Loads the user shaders
|
||||
void loadShaders();
|
||||
|
||||
/// Saves the specified user shader
|
||||
void saveShader( const std::string &name );
|
||||
|
||||
/// Deletes the specified user shader
|
||||
void deleteShader( const std::string &name );
|
||||
|
||||
/// Sets up the viewport widget
|
||||
void initViewPort( unsigned long wnd, unsigned long w, unsigned long h );
|
||||
|
||||
/// Shuts down the viewport widget
|
||||
void killViewPort();
|
||||
|
||||
/// Resizes the viewport widget
|
||||
void resizeViewPort( unsigned long w, unsigned long h );
|
||||
NL3D::UDriver* getDriver(){ return driver; }
|
||||
|
||||
/// Clears the scene then adds a cube
|
||||
bool addCube();
|
||||
|
||||
/// Clears the scene then adds a sphere
|
||||
bool addSphere();
|
||||
|
||||
/// Clears the scene then add a cylinder
|
||||
bool addCylinder();
|
||||
|
||||
/// Clears the scene the adds a teapot
|
||||
bool addTeaPot();
|
||||
|
||||
|
||||
/// Clears the scene then loads a shape
|
||||
bool loadShape( const std::string &fileName );
|
||||
|
||||
/// Clears the scene, as the name suggests
|
||||
void clearScene();
|
||||
|
||||
/// Sends the input events to Nel3D
|
||||
void updateInput();
|
||||
|
||||
/// Renders the scene
|
||||
void renderScene();
|
||||
|
||||
unsigned long getShapeMatCount() const;
|
||||
|
||||
void getFogSettings( SFogSettings &s );
|
||||
void setFogSettings( const SFogSettings &s );
|
||||
|
||||
unsigned char getMaxLights() const;
|
||||
void getLightInfo( unsigned char light, SLightInfo &info );
|
||||
void setLightInfo( unsigned char light, const SLightInfo &info );
|
||||
|
||||
void setBGColor( unsigned char R, unsigned char G, unsigned char B, unsigned char A ){
|
||||
bgColor[ 0 ] = R;
|
||||
bgColor[ 1 ] = G;
|
||||
bgColor[ 2 ] = B;
|
||||
bgColor[ 3 ] = A;
|
||||
}
|
||||
|
||||
private:
|
||||
void setupCamera();
|
||||
|
||||
unsigned long subMatId;
|
||||
|
||||
NL3D::CUsrShaderManager *shaderManager;
|
||||
NL3D::UDriver *driver;
|
||||
NL3D::UScene *scene;
|
||||
NL3D::U3dMouseListener *mouseListener;
|
||||
unsigned char bgColor[ 4 ];
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1,394 +1,394 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "prop_browser_ctrl.h"
|
||||
#include "3rdparty/qtpropertybrowser/qttreepropertybrowser.h"
|
||||
#include "3rdparty/qtpropertybrowser/qtvariantproperty.h"
|
||||
#include "nel3d_interface.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include <QMatrix4x4>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
bool QStringToQMatrix4x4( const QString &s, QMatrix4x4 &m )
|
||||
{
|
||||
QString ms = s;
|
||||
bool ok = false;
|
||||
bool success = true;
|
||||
double da[ 16 ];
|
||||
|
||||
QStringList sl = ms.split( " " );
|
||||
QStringListIterator it( sl );
|
||||
int i = 0;
|
||||
|
||||
while( it.hasNext() )
|
||||
{
|
||||
double d = it.next().toDouble( &ok );
|
||||
|
||||
if( ok )
|
||||
{
|
||||
da[ i ] = d;
|
||||
}
|
||||
else
|
||||
{
|
||||
da[ i ] = 0.0;
|
||||
success = false;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
m = QMatrix4x4( da );
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
int propToQVariant( unsigned char t )
|
||||
{
|
||||
int type = 0;
|
||||
|
||||
switch( t )
|
||||
{
|
||||
case SMatProp::Color:
|
||||
type = QVariant::Color;
|
||||
break;
|
||||
|
||||
case SMatProp::Double:
|
||||
type = QVariant::Double;
|
||||
break;
|
||||
|
||||
case SMatProp::Float:
|
||||
type = QVariant::Double;
|
||||
break;
|
||||
|
||||
case SMatProp::Int:
|
||||
type = QVariant::Int;
|
||||
break;
|
||||
|
||||
case SMatProp::Matrix4:
|
||||
type = QVariant::String;
|
||||
break;
|
||||
|
||||
case SMatProp::Texture:
|
||||
type = QVariant::String;
|
||||
break;
|
||||
|
||||
case SMatProp::Uint:
|
||||
type = QVariant::Int;
|
||||
break;
|
||||
|
||||
case SMatProp::Vector4:
|
||||
type = QVariant::String;
|
||||
break;
|
||||
|
||||
default:
|
||||
type = QVariant::String;
|
||||
break;
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
void propValToQVariant( const SMatProp &p, QVariant &v )
|
||||
{
|
||||
bool ok = false;
|
||||
QString s;
|
||||
|
||||
switch( p.type )
|
||||
{
|
||||
case SMatProp::Color:
|
||||
{
|
||||
std::stringstream ss = p.value;
|
||||
float c[ 4 ];
|
||||
std::fill( c, c + 4, 0.0f );
|
||||
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
ss >> c[ i ];
|
||||
if( !ss.good() )
|
||||
break;
|
||||
}
|
||||
|
||||
QColor color;
|
||||
color.setRedF( c[ 0 ] / 255.0f );
|
||||
color.setGreenF( c[ 1 ] / 255.0f );
|
||||
color.setBlueF( c[ 2 ] / 255.0f );
|
||||
color.setAlphaF( c[ 3 ] / 255.0f );
|
||||
|
||||
v = color;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case SMatProp::Double:
|
||||
double d;
|
||||
|
||||
s = p.value.c_str();
|
||||
d = s.toDouble( &ok );
|
||||
if( ok )
|
||||
v = d;
|
||||
else
|
||||
v = 0.0;
|
||||
|
||||
break;
|
||||
|
||||
case SMatProp::Float:
|
||||
float f;
|
||||
|
||||
s = p.value.c_str();
|
||||
f = s.toFloat( &ok );
|
||||
if( ok )
|
||||
v = f;
|
||||
else
|
||||
v = 0.0f;
|
||||
|
||||
break;
|
||||
|
||||
case SMatProp::Int:
|
||||
int i;
|
||||
|
||||
s = p.value.c_str();
|
||||
i = s.toInt( &ok );
|
||||
if( ok )
|
||||
v = i;
|
||||
else
|
||||
v = 0;
|
||||
|
||||
break;
|
||||
|
||||
case SMatProp::Matrix4:
|
||||
{
|
||||
/*
|
||||
QMatrix4x4 m;
|
||||
m.fill( 0.0 );
|
||||
QStringToQMatrix4x4( p.value.c_str(), m );
|
||||
v = QVariant( m );
|
||||
*/
|
||||
v = p.value.c_str();
|
||||
}
|
||||
break;
|
||||
|
||||
case SMatProp::Texture:
|
||||
v = p.value.c_str();
|
||||
break;
|
||||
|
||||
case SMatProp::Uint:
|
||||
unsigned int u;
|
||||
|
||||
s = p.value.c_str();
|
||||
u = s.toUInt( &ok );
|
||||
if( ok )
|
||||
v = u;
|
||||
else
|
||||
v = 0u;
|
||||
|
||||
break;
|
||||
|
||||
case SMatProp::Vector4:
|
||||
v = p.value.c_str();
|
||||
break;
|
||||
|
||||
default:
|
||||
v = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CPropBrowserCtrl::CPropBrowserCtrl( QObject *parent ) :
|
||||
QObject( parent )
|
||||
{
|
||||
browser = NULL;
|
||||
nel3dIface = NULL;
|
||||
manager = new QtVariantPropertyManager();
|
||||
factory = new QtVariantEditorFactory();
|
||||
|
||||
setupConnections();
|
||||
}
|
||||
|
||||
CPropBrowserCtrl::~CPropBrowserCtrl()
|
||||
{
|
||||
browser = NULL;
|
||||
nel3dIface = NULL;
|
||||
delete manager;
|
||||
manager = NULL;
|
||||
delete factory;
|
||||
factory = NULL;
|
||||
}
|
||||
|
||||
void CPropBrowserCtrl::setBrowser( QtTreePropertyBrowser *b )
|
||||
{
|
||||
browser = b;
|
||||
browser->setFactoryForManager( manager, factory );
|
||||
}
|
||||
|
||||
void CPropBrowserCtrl::setNel3DIface( CNel3DInterface *iface )
|
||||
{
|
||||
nel3dIface = iface;
|
||||
}
|
||||
|
||||
void CPropBrowserCtrl::setupConnections()
|
||||
{
|
||||
connect( manager, SIGNAL( valueChanged( QtProperty*, const QVariant& ) ),
|
||||
this, SLOT( onValueChanged( QtProperty*, const QVariant& ) ) );
|
||||
}
|
||||
|
||||
void CPropBrowserCtrl::onSceneCleared()
|
||||
{
|
||||
clearProps();
|
||||
}
|
||||
|
||||
void CPropBrowserCtrl::onPropsChanged()
|
||||
{
|
||||
clearProps();
|
||||
loadPropsForPass( currentPass );
|
||||
}
|
||||
|
||||
void CPropBrowserCtrl::clearProps()
|
||||
{
|
||||
browser->clear();
|
||||
propToId.clear();
|
||||
}
|
||||
|
||||
void CPropBrowserCtrl::loadPropsForPass( const QString &pass )
|
||||
{
|
||||
currentPass = pass;
|
||||
clearProps();
|
||||
|
||||
if( pass.isEmpty() )
|
||||
return;
|
||||
|
||||
CNelMaterialProxy m = nel3dIface->getMaterial();
|
||||
if( m.isEmpty() )
|
||||
return;
|
||||
|
||||
CRenderPassProxy p = m.getPass( pass.toUtf8().data() );
|
||||
|
||||
std::vector< SMatProp > v;
|
||||
p.getProperties( v );
|
||||
|
||||
QtVariantProperty *vp = NULL;
|
||||
int type = 0;
|
||||
QVariant qv;
|
||||
|
||||
std::vector< SMatProp >::const_iterator itr = v.begin();
|
||||
while( itr != v.end() )
|
||||
{
|
||||
const SMatProp &prop = *itr;
|
||||
|
||||
type = propToQVariant( prop.type );
|
||||
|
||||
vp = manager->addProperty( type, prop.label.c_str() );
|
||||
|
||||
if( vp != NULL )
|
||||
{
|
||||
propValToQVariant( prop, qv );
|
||||
vp->setValue( qv );
|
||||
browser->addProperty( vp );
|
||||
propToId[ vp ] = prop.id;
|
||||
}
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
void CPropBrowserCtrl::loadPropsForPass( int i )
|
||||
{
|
||||
clearProps();
|
||||
|
||||
CNelMaterialProxy m = nel3dIface->getMaterial();
|
||||
if( m.isEmpty() )
|
||||
return;
|
||||
|
||||
CRenderPassProxy p = m.getPass( i );
|
||||
|
||||
std::string n;
|
||||
p.getName( n );
|
||||
currentPass = n.c_str();
|
||||
|
||||
std::vector< SMatProp > v;
|
||||
p.getProperties( v );
|
||||
|
||||
QtVariantProperty *vp = NULL;
|
||||
int type = 0;
|
||||
QVariant qv;
|
||||
|
||||
std::vector< SMatProp >::const_iterator itr = v.begin();
|
||||
while( itr != v.end() )
|
||||
{
|
||||
const SMatProp &prop = *itr;
|
||||
|
||||
type = propToQVariant( prop.type );
|
||||
|
||||
vp = manager->addProperty( type, prop.label.c_str() );
|
||||
|
||||
if( vp != NULL )
|
||||
{
|
||||
propValToQVariant( prop, qv );
|
||||
vp->setValue( qv );
|
||||
browser->addProperty( vp );
|
||||
propToId[ vp ] = prop.id;
|
||||
}
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
void CPropBrowserCtrl::onValueChanged( QtProperty *p, const QVariant &v )
|
||||
{
|
||||
QString label = p->propertyName();
|
||||
std::string value = p->valueText().toUtf8().data();
|
||||
|
||||
if( v.type() == QVariant::Color )
|
||||
{
|
||||
QColor c = v.value< QColor >();
|
||||
value.clear();
|
||||
QString val = "%1 %2 %3 %4";
|
||||
val = val.arg( c.red() ).arg( c.green() ).arg( c.blue() ).arg( c.alpha() );
|
||||
value = val.toUtf8().data();
|
||||
}
|
||||
|
||||
CNelMaterialProxy m = nel3dIface->getMaterial();
|
||||
if( m.isEmpty() )
|
||||
return;
|
||||
|
||||
CRenderPassProxy pass = m.getPass( currentPass.toUtf8().data() );
|
||||
|
||||
std::map< QtProperty*, std::string >::const_iterator itr
|
||||
= propToId.find( p );
|
||||
if( itr == propToId.end() )
|
||||
return;
|
||||
|
||||
SMatProp prop;
|
||||
bool ok = pass.getProperty( itr->second, prop );
|
||||
if( !ok )
|
||||
return;
|
||||
|
||||
prop.value = value;
|
||||
pass.changeProperty( prop );
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "prop_browser_ctrl.h"
|
||||
#include "3rdparty/qtpropertybrowser/qttreepropertybrowser.h"
|
||||
#include "3rdparty/qtpropertybrowser/qtvariantproperty.h"
|
||||
#include "nel3d_interface.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include <QMatrix4x4>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
bool QStringToQMatrix4x4( const QString &s, QMatrix4x4 &m )
|
||||
{
|
||||
QString ms = s;
|
||||
bool ok = false;
|
||||
bool success = true;
|
||||
double da[ 16 ];
|
||||
|
||||
QStringList sl = ms.split( " " );
|
||||
QStringListIterator it( sl );
|
||||
int i = 0;
|
||||
|
||||
while( it.hasNext() )
|
||||
{
|
||||
double d = it.next().toDouble( &ok );
|
||||
|
||||
if( ok )
|
||||
{
|
||||
da[ i ] = d;
|
||||
}
|
||||
else
|
||||
{
|
||||
da[ i ] = 0.0;
|
||||
success = false;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
m = QMatrix4x4( da );
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
int propToQVariant( unsigned char t )
|
||||
{
|
||||
int type = 0;
|
||||
|
||||
switch( t )
|
||||
{
|
||||
case SMatProp::Color:
|
||||
type = QVariant::Color;
|
||||
break;
|
||||
|
||||
case SMatProp::Double:
|
||||
type = QVariant::Double;
|
||||
break;
|
||||
|
||||
case SMatProp::Float:
|
||||
type = QVariant::Double;
|
||||
break;
|
||||
|
||||
case SMatProp::Int:
|
||||
type = QVariant::Int;
|
||||
break;
|
||||
|
||||
case SMatProp::Matrix4:
|
||||
type = QVariant::String;
|
||||
break;
|
||||
|
||||
case SMatProp::Texture:
|
||||
type = QVariant::String;
|
||||
break;
|
||||
|
||||
case SMatProp::Uint:
|
||||
type = QVariant::Int;
|
||||
break;
|
||||
|
||||
case SMatProp::Vector4:
|
||||
type = QVariant::String;
|
||||
break;
|
||||
|
||||
default:
|
||||
type = QVariant::String;
|
||||
break;
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
void propValToQVariant( const SMatProp &p, QVariant &v )
|
||||
{
|
||||
bool ok = false;
|
||||
QString s;
|
||||
|
||||
switch( p.type )
|
||||
{
|
||||
case SMatProp::Color:
|
||||
{
|
||||
std::stringstream ss = p.value;
|
||||
float c[ 4 ];
|
||||
std::fill( c, c + 4, 0.0f );
|
||||
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
ss >> c[ i ];
|
||||
if( !ss.good() )
|
||||
break;
|
||||
}
|
||||
|
||||
QColor color;
|
||||
color.setRedF( c[ 0 ] / 255.0f );
|
||||
color.setGreenF( c[ 1 ] / 255.0f );
|
||||
color.setBlueF( c[ 2 ] / 255.0f );
|
||||
color.setAlphaF( c[ 3 ] / 255.0f );
|
||||
|
||||
v = color;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case SMatProp::Double:
|
||||
double d;
|
||||
|
||||
s = p.value.c_str();
|
||||
d = s.toDouble( &ok );
|
||||
if( ok )
|
||||
v = d;
|
||||
else
|
||||
v = 0.0;
|
||||
|
||||
break;
|
||||
|
||||
case SMatProp::Float:
|
||||
float f;
|
||||
|
||||
s = p.value.c_str();
|
||||
f = s.toFloat( &ok );
|
||||
if( ok )
|
||||
v = f;
|
||||
else
|
||||
v = 0.0f;
|
||||
|
||||
break;
|
||||
|
||||
case SMatProp::Int:
|
||||
int i;
|
||||
|
||||
s = p.value.c_str();
|
||||
i = s.toInt( &ok );
|
||||
if( ok )
|
||||
v = i;
|
||||
else
|
||||
v = 0;
|
||||
|
||||
break;
|
||||
|
||||
case SMatProp::Matrix4:
|
||||
{
|
||||
/*
|
||||
QMatrix4x4 m;
|
||||
m.fill( 0.0 );
|
||||
QStringToQMatrix4x4( p.value.c_str(), m );
|
||||
v = QVariant( m );
|
||||
*/
|
||||
v = p.value.c_str();
|
||||
}
|
||||
break;
|
||||
|
||||
case SMatProp::Texture:
|
||||
v = p.value.c_str();
|
||||
break;
|
||||
|
||||
case SMatProp::Uint:
|
||||
unsigned int u;
|
||||
|
||||
s = p.value.c_str();
|
||||
u = s.toUInt( &ok );
|
||||
if( ok )
|
||||
v = u;
|
||||
else
|
||||
v = 0u;
|
||||
|
||||
break;
|
||||
|
||||
case SMatProp::Vector4:
|
||||
v = p.value.c_str();
|
||||
break;
|
||||
|
||||
default:
|
||||
v = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CPropBrowserCtrl::CPropBrowserCtrl( QObject *parent ) :
|
||||
QObject( parent )
|
||||
{
|
||||
browser = NULL;
|
||||
nel3dIface = NULL;
|
||||
manager = new QtVariantPropertyManager();
|
||||
factory = new QtVariantEditorFactory();
|
||||
|
||||
setupConnections();
|
||||
}
|
||||
|
||||
CPropBrowserCtrl::~CPropBrowserCtrl()
|
||||
{
|
||||
browser = NULL;
|
||||
nel3dIface = NULL;
|
||||
delete manager;
|
||||
manager = NULL;
|
||||
delete factory;
|
||||
factory = NULL;
|
||||
}
|
||||
|
||||
void CPropBrowserCtrl::setBrowser( QtTreePropertyBrowser *b )
|
||||
{
|
||||
browser = b;
|
||||
browser->setFactoryForManager( manager, factory );
|
||||
}
|
||||
|
||||
void CPropBrowserCtrl::setNel3DIface( CNel3DInterface *iface )
|
||||
{
|
||||
nel3dIface = iface;
|
||||
}
|
||||
|
||||
void CPropBrowserCtrl::setupConnections()
|
||||
{
|
||||
connect( manager, SIGNAL( valueChanged( QtProperty*, const QVariant& ) ),
|
||||
this, SLOT( onValueChanged( QtProperty*, const QVariant& ) ) );
|
||||
}
|
||||
|
||||
void CPropBrowserCtrl::onSceneCleared()
|
||||
{
|
||||
clearProps();
|
||||
}
|
||||
|
||||
void CPropBrowserCtrl::onPropsChanged()
|
||||
{
|
||||
clearProps();
|
||||
loadPropsForPass( currentPass );
|
||||
}
|
||||
|
||||
void CPropBrowserCtrl::clearProps()
|
||||
{
|
||||
browser->clear();
|
||||
propToId.clear();
|
||||
}
|
||||
|
||||
void CPropBrowserCtrl::loadPropsForPass( const QString &pass )
|
||||
{
|
||||
currentPass = pass;
|
||||
clearProps();
|
||||
|
||||
if( pass.isEmpty() )
|
||||
return;
|
||||
|
||||
CNelMaterialProxy m = nel3dIface->getMaterial();
|
||||
if( m.isEmpty() )
|
||||
return;
|
||||
|
||||
CRenderPassProxy p = m.getPass( pass.toUtf8().data() );
|
||||
|
||||
std::vector< SMatProp > v;
|
||||
p.getProperties( v );
|
||||
|
||||
QtVariantProperty *vp = NULL;
|
||||
int type = 0;
|
||||
QVariant qv;
|
||||
|
||||
std::vector< SMatProp >::const_iterator itr = v.begin();
|
||||
while( itr != v.end() )
|
||||
{
|
||||
const SMatProp &prop = *itr;
|
||||
|
||||
type = propToQVariant( prop.type );
|
||||
|
||||
vp = manager->addProperty( type, prop.label.c_str() );
|
||||
|
||||
if( vp != NULL )
|
||||
{
|
||||
propValToQVariant( prop, qv );
|
||||
vp->setValue( qv );
|
||||
browser->addProperty( vp );
|
||||
propToId[ vp ] = prop.id;
|
||||
}
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
void CPropBrowserCtrl::loadPropsForPass( int i )
|
||||
{
|
||||
clearProps();
|
||||
|
||||
CNelMaterialProxy m = nel3dIface->getMaterial();
|
||||
if( m.isEmpty() )
|
||||
return;
|
||||
|
||||
CRenderPassProxy p = m.getPass( i );
|
||||
|
||||
std::string n;
|
||||
p.getName( n );
|
||||
currentPass = n.c_str();
|
||||
|
||||
std::vector< SMatProp > v;
|
||||
p.getProperties( v );
|
||||
|
||||
QtVariantProperty *vp = NULL;
|
||||
int type = 0;
|
||||
QVariant qv;
|
||||
|
||||
std::vector< SMatProp >::const_iterator itr = v.begin();
|
||||
while( itr != v.end() )
|
||||
{
|
||||
const SMatProp &prop = *itr;
|
||||
|
||||
type = propToQVariant( prop.type );
|
||||
|
||||
vp = manager->addProperty( type, prop.label.c_str() );
|
||||
|
||||
if( vp != NULL )
|
||||
{
|
||||
propValToQVariant( prop, qv );
|
||||
vp->setValue( qv );
|
||||
browser->addProperty( vp );
|
||||
propToId[ vp ] = prop.id;
|
||||
}
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
void CPropBrowserCtrl::onValueChanged( QtProperty *p, const QVariant &v )
|
||||
{
|
||||
QString label = p->propertyName();
|
||||
std::string value = p->valueText().toUtf8().data();
|
||||
|
||||
if( v.type() == QVariant::Color )
|
||||
{
|
||||
QColor c = v.value< QColor >();
|
||||
value.clear();
|
||||
QString val = "%1 %2 %3 %4";
|
||||
val = val.arg( c.red() ).arg( c.green() ).arg( c.blue() ).arg( c.alpha() );
|
||||
value = val.toUtf8().data();
|
||||
}
|
||||
|
||||
CNelMaterialProxy m = nel3dIface->getMaterial();
|
||||
if( m.isEmpty() )
|
||||
return;
|
||||
|
||||
CRenderPassProxy pass = m.getPass( currentPass.toUtf8().data() );
|
||||
|
||||
std::map< QtProperty*, std::string >::const_iterator itr
|
||||
= propToId.find( p );
|
||||
if( itr == propToId.end() )
|
||||
return;
|
||||
|
||||
SMatProp prop;
|
||||
bool ok = pass.getProperty( itr->second, prop );
|
||||
if( !ok )
|
||||
return;
|
||||
|
||||
prop.value = value;
|
||||
pass.changeProperty( prop );
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,64 +1,64 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef PROP_BROWSER_CTRL_H
|
||||
#define PROP_BROWSER_CTRL_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
#include <map>
|
||||
|
||||
class QtTreePropertyBrowser;
|
||||
class QtVariantPropertyManager;
|
||||
class QtVariantEditorFactory;
|
||||
class QtProperty;
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
class CNel3DInterface;
|
||||
|
||||
class CPropBrowserCtrl : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CPropBrowserCtrl( QObject *parent = NULL );
|
||||
~CPropBrowserCtrl();
|
||||
void setBrowser( QtTreePropertyBrowser *b );
|
||||
void setNel3DIface( CNel3DInterface *iface );
|
||||
void setupConnections();
|
||||
void onSceneCleared();
|
||||
void onPropsChanged();
|
||||
void clearProps();
|
||||
void loadPropsForPass( const QString &pass );
|
||||
void loadPropsForPass( int i );
|
||||
|
||||
private Q_SLOTS:
|
||||
void onValueChanged( QtProperty *p, const QVariant &v );
|
||||
|
||||
private:
|
||||
QtTreePropertyBrowser *browser;
|
||||
QtVariantPropertyManager *manager;
|
||||
QtVariantEditorFactory *factory;
|
||||
|
||||
CNel3DInterface *nel3dIface;
|
||||
QString currentPass;
|
||||
|
||||
std::map< QtProperty*, std::string > propToId;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef PROP_BROWSER_CTRL_H
|
||||
#define PROP_BROWSER_CTRL_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
#include <map>
|
||||
|
||||
class QtTreePropertyBrowser;
|
||||
class QtVariantPropertyManager;
|
||||
class QtVariantEditorFactory;
|
||||
class QtProperty;
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
class CNel3DInterface;
|
||||
|
||||
class CPropBrowserCtrl : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CPropBrowserCtrl( QObject *parent = NULL );
|
||||
~CPropBrowserCtrl();
|
||||
void setBrowser( QtTreePropertyBrowser *b );
|
||||
void setNel3DIface( CNel3DInterface *iface );
|
||||
void setupConnections();
|
||||
void onSceneCleared();
|
||||
void onPropsChanged();
|
||||
void clearProps();
|
||||
void loadPropsForPass( const QString &pass );
|
||||
void loadPropsForPass( int i );
|
||||
|
||||
private Q_SLOTS:
|
||||
void onValueChanged( QtProperty *p, const QVariant &v );
|
||||
|
||||
private:
|
||||
QtTreePropertyBrowser *browser;
|
||||
QtVariantPropertyManager *manager;
|
||||
QtVariantEditorFactory *factory;
|
||||
|
||||
CNel3DInterface *nel3dIface;
|
||||
QString currentPass;
|
||||
|
||||
std::map< QtProperty*, std::string > propToId;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,257 +1,257 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "render_passes.h"
|
||||
#include "nel3d_interface.h"
|
||||
#include "material_observer.h"
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
RenderPassesWidget::RenderPassesWidget( QWidget *parent ) :
|
||||
QWidget( parent )
|
||||
{
|
||||
setupUi( this );
|
||||
setupConnections();
|
||||
nl3dIface = NULL;
|
||||
observer = NULL;
|
||||
}
|
||||
|
||||
RenderPassesWidget::~RenderPassesWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void RenderPassesWidget::fillList( const QStringList &list )
|
||||
{
|
||||
listWidget->clear();
|
||||
|
||||
QStringListIterator itr( list );
|
||||
while( itr.hasNext() )
|
||||
{
|
||||
listWidget->addItem( itr.next() );
|
||||
}
|
||||
}
|
||||
|
||||
void RenderPassesWidget::getList( QStringList &list )
|
||||
{
|
||||
for( int i = 0; i < listWidget->count(); i++ )
|
||||
{
|
||||
list.push_back( listWidget->item( i )->text() );
|
||||
}
|
||||
}
|
||||
|
||||
void RenderPassesWidget::clear()
|
||||
{
|
||||
listWidget->clear();
|
||||
}
|
||||
|
||||
void RenderPassesWidget::onMaterialLoaded()
|
||||
{
|
||||
clear();
|
||||
CNelMaterialProxy m = nl3dIface->getMaterial();
|
||||
if( m.isEmpty() )
|
||||
return;
|
||||
|
||||
std::vector< std::string > pl;
|
||||
m.getPassList( pl );
|
||||
|
||||
std::vector< std::string >::const_iterator itr = pl.begin();
|
||||
while( itr != pl.end() )
|
||||
{
|
||||
listWidget->addItem( QString( itr->c_str() ) );
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
void RenderPassesWidget::setupConnections()
|
||||
{
|
||||
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) );
|
||||
connect( addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) );
|
||||
connect( removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveClicked() ) );
|
||||
connect( editButton, SIGNAL( clicked( bool ) ), this, SLOT( onEditClicked() ) );
|
||||
connect( upButton, SIGNAL( clicked( bool ) ), this, SLOT( onUpClicked() ) );
|
||||
connect( downButton, SIGNAL( clicked( bool ) ), this, SLOT( onDownClicked() ) );
|
||||
}
|
||||
|
||||
bool RenderPassesWidget::passExists( const QString &label )
|
||||
{
|
||||
int c = listWidget->count();
|
||||
|
||||
for( int i = 0; i < c; i++ )
|
||||
{
|
||||
if( label == listWidget->item( i )->text() )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void RenderPassesWidget::onOKClicked()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void RenderPassesWidget::onAddClicked()
|
||||
{
|
||||
QString label =
|
||||
QInputDialog::getText(
|
||||
NULL,
|
||||
tr( "Pass label" ),
|
||||
tr( "Please enter the new pass' label" )
|
||||
);
|
||||
|
||||
if( label.isEmpty() )
|
||||
return;
|
||||
|
||||
if( passExists( label ) )
|
||||
{
|
||||
QMessageBox::warning(
|
||||
NULL,
|
||||
tr( "Pass label" ),
|
||||
tr( "Pass label already exists!" )
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
listWidget->addItem( label );
|
||||
|
||||
CNelMaterialProxy material = nl3dIface->getMaterial();
|
||||
material.addPass( label.toUtf8().data() );
|
||||
|
||||
if( observer != NULL )
|
||||
observer->onPassAdded( label.toUtf8().data() );
|
||||
}
|
||||
|
||||
void RenderPassesWidget::onRemoveClicked()
|
||||
{
|
||||
int row = listWidget->currentRow();
|
||||
if( row == -1 )
|
||||
return;
|
||||
QString pass;
|
||||
|
||||
QListWidgetItem *item = listWidget->takeItem( row );
|
||||
pass = item->text();
|
||||
delete item;
|
||||
|
||||
CNelMaterialProxy material = nl3dIface->getMaterial();
|
||||
if( material.isEmpty() )
|
||||
return;
|
||||
|
||||
material.removePass( pass.toUtf8().data() );
|
||||
|
||||
if( observer != NULL )
|
||||
observer->onPassRemoved( pass.toUtf8().data() );
|
||||
}
|
||||
|
||||
void RenderPassesWidget::onEditClicked()
|
||||
{
|
||||
QListWidgetItem *item = listWidget->currentItem();
|
||||
if( item == NULL )
|
||||
return;
|
||||
|
||||
QString from = item->text();
|
||||
QString to =
|
||||
QInputDialog::getText(
|
||||
NULL,
|
||||
tr( "Editing pass label" ),
|
||||
tr( "Please enter the new label" ),
|
||||
QLineEdit::Normal,
|
||||
from
|
||||
);
|
||||
|
||||
if( to.isEmpty() )
|
||||
return;
|
||||
|
||||
if( from == to )
|
||||
return;
|
||||
|
||||
if( passExists( to ) )
|
||||
{
|
||||
QMessageBox::warning(
|
||||
NULL,
|
||||
tr( "Pass label" ),
|
||||
tr( "Pass label already exists!" )
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
item->setText( to );
|
||||
|
||||
CNelMaterialProxy material = nl3dIface->getMaterial();
|
||||
if( material.isEmpty() )
|
||||
return;
|
||||
|
||||
material.renamePass( from.toUtf8().data(), to.toUtf8().data() );
|
||||
|
||||
if( observer != NULL )
|
||||
observer->onPassRenamed( from.toUtf8().data(), to.toUtf8().data() );
|
||||
}
|
||||
|
||||
void RenderPassesWidget::onUpClicked()
|
||||
{
|
||||
QListWidgetItem *item = listWidget->currentItem();
|
||||
if( item == NULL )
|
||||
return;
|
||||
|
||||
int row = listWidget->currentRow();
|
||||
if( row == 0 )
|
||||
return;
|
||||
|
||||
item = listWidget->takeItem( row );
|
||||
listWidget->insertItem( row - 1, item );
|
||||
listWidget->setCurrentRow( row - 1 );
|
||||
|
||||
QString s = item->text();
|
||||
|
||||
CNelMaterialProxy material = nl3dIface->getMaterial();
|
||||
if( material.isEmpty() )
|
||||
return;
|
||||
|
||||
material.movePassUp( s.toUtf8().data() );
|
||||
|
||||
if( observer != NULL )
|
||||
observer->onPassMovedUp( s.toUtf8().data() );
|
||||
}
|
||||
|
||||
void RenderPassesWidget::onDownClicked()
|
||||
{
|
||||
QListWidgetItem *item = listWidget->currentItem();
|
||||
if( item == NULL )
|
||||
return;
|
||||
|
||||
int row = listWidget->currentRow();
|
||||
if( row == ( listWidget->count() - 1 ) )
|
||||
return;
|
||||
|
||||
item = listWidget->takeItem( row );
|
||||
listWidget->insertItem( row + 1, item );
|
||||
listWidget->setCurrentRow( row + 1 );
|
||||
|
||||
QString s = item->text();
|
||||
|
||||
CNelMaterialProxy material = nl3dIface->getMaterial();
|
||||
if( material.isEmpty() )
|
||||
return;
|
||||
|
||||
material.movePassDown( s.toUtf8().data() );
|
||||
|
||||
if( observer != NULL )
|
||||
observer->onPassMovedDown( s.toUtf8().data() );
|
||||
}
|
||||
}
|
||||
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "render_passes.h"
|
||||
#include "nel3d_interface.h"
|
||||
#include "material_observer.h"
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
RenderPassesWidget::RenderPassesWidget( QWidget *parent ) :
|
||||
QWidget( parent )
|
||||
{
|
||||
setupUi( this );
|
||||
setupConnections();
|
||||
nl3dIface = NULL;
|
||||
observer = NULL;
|
||||
}
|
||||
|
||||
RenderPassesWidget::~RenderPassesWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void RenderPassesWidget::fillList( const QStringList &list )
|
||||
{
|
||||
listWidget->clear();
|
||||
|
||||
QStringListIterator itr( list );
|
||||
while( itr.hasNext() )
|
||||
{
|
||||
listWidget->addItem( itr.next() );
|
||||
}
|
||||
}
|
||||
|
||||
void RenderPassesWidget::getList( QStringList &list )
|
||||
{
|
||||
for( int i = 0; i < listWidget->count(); i++ )
|
||||
{
|
||||
list.push_back( listWidget->item( i )->text() );
|
||||
}
|
||||
}
|
||||
|
||||
void RenderPassesWidget::clear()
|
||||
{
|
||||
listWidget->clear();
|
||||
}
|
||||
|
||||
void RenderPassesWidget::onMaterialLoaded()
|
||||
{
|
||||
clear();
|
||||
CNelMaterialProxy m = nl3dIface->getMaterial();
|
||||
if( m.isEmpty() )
|
||||
return;
|
||||
|
||||
std::vector< std::string > pl;
|
||||
m.getPassList( pl );
|
||||
|
||||
std::vector< std::string >::const_iterator itr = pl.begin();
|
||||
while( itr != pl.end() )
|
||||
{
|
||||
listWidget->addItem( QString( itr->c_str() ) );
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
void RenderPassesWidget::setupConnections()
|
||||
{
|
||||
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) );
|
||||
connect( addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) );
|
||||
connect( removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveClicked() ) );
|
||||
connect( editButton, SIGNAL( clicked( bool ) ), this, SLOT( onEditClicked() ) );
|
||||
connect( upButton, SIGNAL( clicked( bool ) ), this, SLOT( onUpClicked() ) );
|
||||
connect( downButton, SIGNAL( clicked( bool ) ), this, SLOT( onDownClicked() ) );
|
||||
}
|
||||
|
||||
bool RenderPassesWidget::passExists( const QString &label )
|
||||
{
|
||||
int c = listWidget->count();
|
||||
|
||||
for( int i = 0; i < c; i++ )
|
||||
{
|
||||
if( label == listWidget->item( i )->text() )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void RenderPassesWidget::onOKClicked()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void RenderPassesWidget::onAddClicked()
|
||||
{
|
||||
QString label =
|
||||
QInputDialog::getText(
|
||||
NULL,
|
||||
tr( "Pass label" ),
|
||||
tr( "Please enter the new pass' label" )
|
||||
);
|
||||
|
||||
if( label.isEmpty() )
|
||||
return;
|
||||
|
||||
if( passExists( label ) )
|
||||
{
|
||||
QMessageBox::warning(
|
||||
NULL,
|
||||
tr( "Pass label" ),
|
||||
tr( "Pass label already exists!" )
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
listWidget->addItem( label );
|
||||
|
||||
CNelMaterialProxy material = nl3dIface->getMaterial();
|
||||
material.addPass( label.toUtf8().data() );
|
||||
|
||||
if( observer != NULL )
|
||||
observer->onPassAdded( label.toUtf8().data() );
|
||||
}
|
||||
|
||||
void RenderPassesWidget::onRemoveClicked()
|
||||
{
|
||||
int row = listWidget->currentRow();
|
||||
if( row == -1 )
|
||||
return;
|
||||
QString pass;
|
||||
|
||||
QListWidgetItem *item = listWidget->takeItem( row );
|
||||
pass = item->text();
|
||||
delete item;
|
||||
|
||||
CNelMaterialProxy material = nl3dIface->getMaterial();
|
||||
if( material.isEmpty() )
|
||||
return;
|
||||
|
||||
material.removePass( pass.toUtf8().data() );
|
||||
|
||||
if( observer != NULL )
|
||||
observer->onPassRemoved( pass.toUtf8().data() );
|
||||
}
|
||||
|
||||
void RenderPassesWidget::onEditClicked()
|
||||
{
|
||||
QListWidgetItem *item = listWidget->currentItem();
|
||||
if( item == NULL )
|
||||
return;
|
||||
|
||||
QString from = item->text();
|
||||
QString to =
|
||||
QInputDialog::getText(
|
||||
NULL,
|
||||
tr( "Editing pass label" ),
|
||||
tr( "Please enter the new label" ),
|
||||
QLineEdit::Normal,
|
||||
from
|
||||
);
|
||||
|
||||
if( to.isEmpty() )
|
||||
return;
|
||||
|
||||
if( from == to )
|
||||
return;
|
||||
|
||||
if( passExists( to ) )
|
||||
{
|
||||
QMessageBox::warning(
|
||||
NULL,
|
||||
tr( "Pass label" ),
|
||||
tr( "Pass label already exists!" )
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
item->setText( to );
|
||||
|
||||
CNelMaterialProxy material = nl3dIface->getMaterial();
|
||||
if( material.isEmpty() )
|
||||
return;
|
||||
|
||||
material.renamePass( from.toUtf8().data(), to.toUtf8().data() );
|
||||
|
||||
if( observer != NULL )
|
||||
observer->onPassRenamed( from.toUtf8().data(), to.toUtf8().data() );
|
||||
}
|
||||
|
||||
void RenderPassesWidget::onUpClicked()
|
||||
{
|
||||
QListWidgetItem *item = listWidget->currentItem();
|
||||
if( item == NULL )
|
||||
return;
|
||||
|
||||
int row = listWidget->currentRow();
|
||||
if( row == 0 )
|
||||
return;
|
||||
|
||||
item = listWidget->takeItem( row );
|
||||
listWidget->insertItem( row - 1, item );
|
||||
listWidget->setCurrentRow( row - 1 );
|
||||
|
||||
QString s = item->text();
|
||||
|
||||
CNelMaterialProxy material = nl3dIface->getMaterial();
|
||||
if( material.isEmpty() )
|
||||
return;
|
||||
|
||||
material.movePassUp( s.toUtf8().data() );
|
||||
|
||||
if( observer != NULL )
|
||||
observer->onPassMovedUp( s.toUtf8().data() );
|
||||
}
|
||||
|
||||
void RenderPassesWidget::onDownClicked()
|
||||
{
|
||||
QListWidgetItem *item = listWidget->currentItem();
|
||||
if( item == NULL )
|
||||
return;
|
||||
|
||||
int row = listWidget->currentRow();
|
||||
if( row == ( listWidget->count() - 1 ) )
|
||||
return;
|
||||
|
||||
item = listWidget->takeItem( row );
|
||||
listWidget->insertItem( row + 1, item );
|
||||
listWidget->setCurrentRow( row + 1 );
|
||||
|
||||
QString s = item->text();
|
||||
|
||||
CNelMaterialProxy material = nl3dIface->getMaterial();
|
||||
if( material.isEmpty() )
|
||||
return;
|
||||
|
||||
material.movePassDown( s.toUtf8().data() );
|
||||
|
||||
if( observer != NULL )
|
||||
observer->onPassMovedDown( s.toUtf8().data() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,59 +1,59 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef RENDER_PASSES_H
|
||||
#define RENDER_PASSES_H
|
||||
|
||||
#include "ui_render_passes.h"
|
||||
#include <QStringList>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
class CNel3DInterface;
|
||||
class CMaterialObserver;
|
||||
|
||||
class RenderPassesWidget : public QWidget, public Ui::RenderPassesWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RenderPassesWidget( QWidget *parent = NULL );
|
||||
~RenderPassesWidget();
|
||||
void fillList( const QStringList &list );
|
||||
void getList( QStringList &list );
|
||||
void clear();
|
||||
void onMaterialLoaded();
|
||||
void setNel3dIface( CNel3DInterface *iface ){ nl3dIface = iface; }
|
||||
void setMaterialObserver( CMaterialObserver *obs ){ observer = obs; }
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
bool passExists( const QString &label );
|
||||
|
||||
CNel3DInterface *nl3dIface;
|
||||
CMaterialObserver *observer;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onOKClicked();
|
||||
void onAddClicked();
|
||||
void onRemoveClicked();
|
||||
void onEditClicked();
|
||||
void onUpClicked();
|
||||
void onDownClicked();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef RENDER_PASSES_H
|
||||
#define RENDER_PASSES_H
|
||||
|
||||
#include "ui_render_passes.h"
|
||||
#include <QStringList>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
class CNel3DInterface;
|
||||
class CMaterialObserver;
|
||||
|
||||
class RenderPassesWidget : public QWidget, public Ui::RenderPassesWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RenderPassesWidget( QWidget *parent = NULL );
|
||||
~RenderPassesWidget();
|
||||
void fillList( const QStringList &list );
|
||||
void getList( QStringList &list );
|
||||
void clear();
|
||||
void onMaterialLoaded();
|
||||
void setNel3dIface( CNel3DInterface *iface ){ nl3dIface = iface; }
|
||||
void setMaterialObserver( CMaterialObserver *obs ){ observer = obs; }
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
bool passExists( const QString &label );
|
||||
|
||||
CNel3DInterface *nl3dIface;
|
||||
CMaterialObserver *observer;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onOKClicked();
|
||||
void onAddClicked();
|
||||
void onRemoveClicked();
|
||||
void onEditClicked();
|
||||
void onUpClicked();
|
||||
void onDownClicked();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,90 +1,90 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "shader_editor.h"
|
||||
#include "nel3d_interface.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
ShaderEditorWidget::ShaderEditorWidget( QDialog *parent ) :
|
||||
QDialog( parent )
|
||||
{
|
||||
setupUi( this );
|
||||
nl3dIface = NULL;
|
||||
setupConnections();
|
||||
}
|
||||
|
||||
ShaderEditorWidget::~ShaderEditorWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void ShaderEditorWidget::getDescription( QString &desc )
|
||||
{
|
||||
desc = descriptionEdit->toPlainText();
|
||||
}
|
||||
|
||||
void ShaderEditorWidget::setupConnections()
|
||||
{
|
||||
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) ) ;
|
||||
connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) );
|
||||
}
|
||||
|
||||
void ShaderEditorWidget::onOKClicked()
|
||||
{
|
||||
SShaderInfo info;
|
||||
info.name = nameEdit->text().toUtf8().data();
|
||||
info.description = descriptionEdit->toPlainText().toUtf8().data();
|
||||
info.vp = vsEdit->toPlainText().toUtf8().data();
|
||||
info.fp = fsEdit->toPlainText().toUtf8().data();
|
||||
|
||||
bool ok = nl3dIface->updateShaderInfo( info );
|
||||
if( ok )
|
||||
nl3dIface->saveShader( info.name );
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
void ShaderEditorWidget::onCancelClicked()
|
||||
{
|
||||
reject();
|
||||
}
|
||||
|
||||
void ShaderEditorWidget::reset()
|
||||
{
|
||||
QString empty;
|
||||
nameEdit->setText( empty );
|
||||
descriptionEdit->setPlainText( empty );
|
||||
vsEdit->setPlainText( empty );
|
||||
fsEdit->setPlainText( empty );
|
||||
setResult( QDialog::Rejected );
|
||||
}
|
||||
|
||||
bool ShaderEditorWidget::load( const QString &name )
|
||||
{
|
||||
SShaderInfo info;
|
||||
if( !nl3dIface->getShaderInfo( name.toUtf8().data(), info ) )
|
||||
return false;
|
||||
|
||||
nameEdit->setText( info.name.c_str() );
|
||||
descriptionEdit->setPlainText( info.description.c_str() );
|
||||
vsEdit->setPlainText( info.vp.c_str() );
|
||||
fsEdit->setPlainText( info.fp.c_str() );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "shader_editor.h"
|
||||
#include "nel3d_interface.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
ShaderEditorWidget::ShaderEditorWidget( QDialog *parent ) :
|
||||
QDialog( parent )
|
||||
{
|
||||
setupUi( this );
|
||||
nl3dIface = NULL;
|
||||
setupConnections();
|
||||
}
|
||||
|
||||
ShaderEditorWidget::~ShaderEditorWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void ShaderEditorWidget::getDescription( QString &desc )
|
||||
{
|
||||
desc = descriptionEdit->toPlainText();
|
||||
}
|
||||
|
||||
void ShaderEditorWidget::setupConnections()
|
||||
{
|
||||
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) ) ;
|
||||
connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) );
|
||||
}
|
||||
|
||||
void ShaderEditorWidget::onOKClicked()
|
||||
{
|
||||
SShaderInfo info;
|
||||
info.name = nameEdit->text().toUtf8().data();
|
||||
info.description = descriptionEdit->toPlainText().toUtf8().data();
|
||||
info.vp = vsEdit->toPlainText().toUtf8().data();
|
||||
info.fp = fsEdit->toPlainText().toUtf8().data();
|
||||
|
||||
bool ok = nl3dIface->updateShaderInfo( info );
|
||||
if( ok )
|
||||
nl3dIface->saveShader( info.name );
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
void ShaderEditorWidget::onCancelClicked()
|
||||
{
|
||||
reject();
|
||||
}
|
||||
|
||||
void ShaderEditorWidget::reset()
|
||||
{
|
||||
QString empty;
|
||||
nameEdit->setText( empty );
|
||||
descriptionEdit->setPlainText( empty );
|
||||
vsEdit->setPlainText( empty );
|
||||
fsEdit->setPlainText( empty );
|
||||
setResult( QDialog::Rejected );
|
||||
}
|
||||
|
||||
bool ShaderEditorWidget::load( const QString &name )
|
||||
{
|
||||
SShaderInfo info;
|
||||
if( !nl3dIface->getShaderInfo( name.toUtf8().data(), info ) )
|
||||
return false;
|
||||
|
||||
nameEdit->setText( info.name.c_str() );
|
||||
descriptionEdit->setPlainText( info.description.c_str() );
|
||||
vsEdit->setPlainText( info.vp.c_str() );
|
||||
fsEdit->setPlainText( info.fp.c_str() );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,52 +1,52 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef SHADER_EDITOR_H
|
||||
#define SHADER_EDITOR_H
|
||||
|
||||
#include "ui_shader_editor.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
class CNel3DInterface;
|
||||
|
||||
class ShaderEditorWidget : public QDialog, public Ui::ShaderEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ShaderEditorWidget( QDialog *parent = NULL );
|
||||
~ShaderEditorWidget();
|
||||
|
||||
void getDescription( QString &desc );
|
||||
|
||||
void setNel3DInterface( CNel3DInterface *iface ){ nl3dIface = iface; }
|
||||
|
||||
void reset();
|
||||
bool load( const QString &name );
|
||||
|
||||
private Q_SLOTS:
|
||||
void onOKClicked();
|
||||
void onCancelClicked();
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
CNel3DInterface *nl3dIface;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef SHADER_EDITOR_H
|
||||
#define SHADER_EDITOR_H
|
||||
|
||||
#include "ui_shader_editor.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
class CNel3DInterface;
|
||||
|
||||
class ShaderEditorWidget : public QDialog, public Ui::ShaderEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ShaderEditorWidget( QDialog *parent = NULL );
|
||||
~ShaderEditorWidget();
|
||||
|
||||
void getDescription( QString &desc );
|
||||
|
||||
void setNel3DInterface( CNel3DInterface *iface ){ nl3dIface = iface; }
|
||||
|
||||
void reset();
|
||||
bool load( const QString &name );
|
||||
|
||||
private Q_SLOTS:
|
||||
void onOKClicked();
|
||||
void onCancelClicked();
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
CNel3DInterface *nl3dIface;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,220 +1,220 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "shader_widget.h"
|
||||
#include "shader_editor.h"
|
||||
#include "nel3d_interface.h"
|
||||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
ShaderWidget::ShaderWidget( QWidget *parent ) :
|
||||
QWidget( parent )
|
||||
{
|
||||
setupUi( this );
|
||||
setupConnections();
|
||||
|
||||
shaderEditorWidget = new ShaderEditorWidget();
|
||||
nl3dIface = NULL;
|
||||
}
|
||||
|
||||
ShaderWidget::~ShaderWidget()
|
||||
{
|
||||
delete shaderEditorWidget;
|
||||
shaderEditorWidget = NULL;
|
||||
}
|
||||
|
||||
void ShaderWidget::setNel3DInterface( CNel3DInterface *iface )
|
||||
{
|
||||
nl3dIface = iface;
|
||||
shaderEditorWidget->setNel3DInterface( iface );
|
||||
}
|
||||
|
||||
void ShaderWidget::load()
|
||||
{
|
||||
std::vector< std::string > v;
|
||||
|
||||
nl3dIface->getShaderList( v );
|
||||
|
||||
shaderList->clear();
|
||||
|
||||
QString name;
|
||||
|
||||
std::vector< std::string >::const_iterator itr = v.begin();
|
||||
while( itr != v.end() )
|
||||
{
|
||||
name = itr->c_str();
|
||||
shaderList->addItem( name );
|
||||
Q_EMIT shaderAdded( name );
|
||||
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderWidget::setupConnections()
|
||||
{
|
||||
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) );
|
||||
|
||||
connect( addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) );
|
||||
connect( removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveClicked() ) );
|
||||
connect( editButton, SIGNAL( clicked( bool ) ), this, SLOT( onEditClicked() ) );
|
||||
|
||||
connect( shaderList, SIGNAL( currentRowChanged( int ) ), this, SLOT( onRowChanged( int ) ) );
|
||||
}
|
||||
|
||||
void ShaderWidget::onOKClicked()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
bool ShaderWidget::nameExists( const QString &name )
|
||||
{
|
||||
for( int i = 0; i < shaderList->count(); i++ )
|
||||
{
|
||||
if( shaderList->item( i )->text() == name )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ShaderWidget::nameExistsMessage()
|
||||
{
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr( "Shader already exists" ),
|
||||
tr( "A shader with that name already exists!" ),
|
||||
QMessageBox::Ok
|
||||
);
|
||||
}
|
||||
|
||||
void ShaderWidget::onAddClicked()
|
||||
{
|
||||
QString name =
|
||||
QInputDialog::getText(
|
||||
this,
|
||||
tr( "New shader" ),
|
||||
tr( "Enter the new shader's name" )
|
||||
);
|
||||
|
||||
if( name.isEmpty() )
|
||||
{
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr( "New shader" ),
|
||||
tr( "You must enter a name for the new shader" ),
|
||||
QMessageBox::Ok
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if( nameExists( name ) )
|
||||
{
|
||||
nameExistsMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
SShaderInfo info;
|
||||
info.name = name.toUtf8().data();
|
||||
bool ok = nl3dIface->addShader( info );
|
||||
nl3dIface->saveShader( info.name );
|
||||
if( !ok )
|
||||
{
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr( "Error adding shader" ),
|
||||
tr( "There was an error while trying to add the shader" )
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
shaderList->addItem( name );
|
||||
|
||||
Q_EMIT shaderAdded( name );
|
||||
}
|
||||
|
||||
void ShaderWidget::onRemoveClicked()
|
||||
{
|
||||
int i = shaderList->currentRow();
|
||||
if( i < 0 )
|
||||
return;
|
||||
|
||||
int selection =
|
||||
QMessageBox::question(
|
||||
this,
|
||||
tr( "Removing shader" ),
|
||||
tr( "Are you sure you want to remove this shader?" ),
|
||||
QMessageBox::Yes,
|
||||
QMessageBox::Cancel
|
||||
);
|
||||
|
||||
if( selection == QMessageBox::Yes )
|
||||
{
|
||||
QListWidgetItem *item = shaderList->takeItem( i );
|
||||
QString name = item->text();
|
||||
std::string n = name.toUtf8().data();
|
||||
delete item;
|
||||
|
||||
nl3dIface->removeShader( n );
|
||||
nl3dIface->deleteShader( n );
|
||||
|
||||
if( shaderList->count() == 0 )
|
||||
description->setPlainText( "" );
|
||||
|
||||
Q_EMIT shaderRemoved( name );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ShaderWidget::onEditClicked()
|
||||
{
|
||||
int i = shaderList->currentRow();
|
||||
if( i < 0 )
|
||||
return;
|
||||
|
||||
QString name = shaderList->item( i )->text();
|
||||
|
||||
shaderEditorWidget->reset();
|
||||
shaderEditorWidget->load( name );
|
||||
|
||||
int res = shaderEditorWidget->exec();
|
||||
if( res == QDialog::Rejected )
|
||||
return;
|
||||
|
||||
QString descr;
|
||||
shaderEditorWidget->getDescription( descr );
|
||||
description->setPlainText( descr );
|
||||
}
|
||||
|
||||
void ShaderWidget::onRowChanged( int i )
|
||||
{
|
||||
if( i < 0 )
|
||||
return;
|
||||
|
||||
std::string s = shaderList->item( i )->text().toUtf8().data();
|
||||
|
||||
SShaderInfo info;
|
||||
bool ok = nl3dIface->getShaderInfo( s, info );
|
||||
if( !ok )
|
||||
return;
|
||||
|
||||
description->setPlainText( info.description.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "shader_widget.h"
|
||||
#include "shader_editor.h"
|
||||
#include "nel3d_interface.h"
|
||||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
ShaderWidget::ShaderWidget( QWidget *parent ) :
|
||||
QWidget( parent )
|
||||
{
|
||||
setupUi( this );
|
||||
setupConnections();
|
||||
|
||||
shaderEditorWidget = new ShaderEditorWidget();
|
||||
nl3dIface = NULL;
|
||||
}
|
||||
|
||||
ShaderWidget::~ShaderWidget()
|
||||
{
|
||||
delete shaderEditorWidget;
|
||||
shaderEditorWidget = NULL;
|
||||
}
|
||||
|
||||
void ShaderWidget::setNel3DInterface( CNel3DInterface *iface )
|
||||
{
|
||||
nl3dIface = iface;
|
||||
shaderEditorWidget->setNel3DInterface( iface );
|
||||
}
|
||||
|
||||
void ShaderWidget::load()
|
||||
{
|
||||
std::vector< std::string > v;
|
||||
|
||||
nl3dIface->getShaderList( v );
|
||||
|
||||
shaderList->clear();
|
||||
|
||||
QString name;
|
||||
|
||||
std::vector< std::string >::const_iterator itr = v.begin();
|
||||
while( itr != v.end() )
|
||||
{
|
||||
name = itr->c_str();
|
||||
shaderList->addItem( name );
|
||||
Q_EMIT shaderAdded( name );
|
||||
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderWidget::setupConnections()
|
||||
{
|
||||
connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) );
|
||||
|
||||
connect( addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) );
|
||||
connect( removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveClicked() ) );
|
||||
connect( editButton, SIGNAL( clicked( bool ) ), this, SLOT( onEditClicked() ) );
|
||||
|
||||
connect( shaderList, SIGNAL( currentRowChanged( int ) ), this, SLOT( onRowChanged( int ) ) );
|
||||
}
|
||||
|
||||
void ShaderWidget::onOKClicked()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
bool ShaderWidget::nameExists( const QString &name )
|
||||
{
|
||||
for( int i = 0; i < shaderList->count(); i++ )
|
||||
{
|
||||
if( shaderList->item( i )->text() == name )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ShaderWidget::nameExistsMessage()
|
||||
{
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr( "Shader already exists" ),
|
||||
tr( "A shader with that name already exists!" ),
|
||||
QMessageBox::Ok
|
||||
);
|
||||
}
|
||||
|
||||
void ShaderWidget::onAddClicked()
|
||||
{
|
||||
QString name =
|
||||
QInputDialog::getText(
|
||||
this,
|
||||
tr( "New shader" ),
|
||||
tr( "Enter the new shader's name" )
|
||||
);
|
||||
|
||||
if( name.isEmpty() )
|
||||
{
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr( "New shader" ),
|
||||
tr( "You must enter a name for the new shader" ),
|
||||
QMessageBox::Ok
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if( nameExists( name ) )
|
||||
{
|
||||
nameExistsMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
SShaderInfo info;
|
||||
info.name = name.toUtf8().data();
|
||||
bool ok = nl3dIface->addShader( info );
|
||||
nl3dIface->saveShader( info.name );
|
||||
if( !ok )
|
||||
{
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr( "Error adding shader" ),
|
||||
tr( "There was an error while trying to add the shader" )
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
shaderList->addItem( name );
|
||||
|
||||
Q_EMIT shaderAdded( name );
|
||||
}
|
||||
|
||||
void ShaderWidget::onRemoveClicked()
|
||||
{
|
||||
int i = shaderList->currentRow();
|
||||
if( i < 0 )
|
||||
return;
|
||||
|
||||
int selection =
|
||||
QMessageBox::question(
|
||||
this,
|
||||
tr( "Removing shader" ),
|
||||
tr( "Are you sure you want to remove this shader?" ),
|
||||
QMessageBox::Yes,
|
||||
QMessageBox::Cancel
|
||||
);
|
||||
|
||||
if( selection == QMessageBox::Yes )
|
||||
{
|
||||
QListWidgetItem *item = shaderList->takeItem( i );
|
||||
QString name = item->text();
|
||||
std::string n = name.toUtf8().data();
|
||||
delete item;
|
||||
|
||||
nl3dIface->removeShader( n );
|
||||
nl3dIface->deleteShader( n );
|
||||
|
||||
if( shaderList->count() == 0 )
|
||||
description->setPlainText( "" );
|
||||
|
||||
Q_EMIT shaderRemoved( name );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ShaderWidget::onEditClicked()
|
||||
{
|
||||
int i = shaderList->currentRow();
|
||||
if( i < 0 )
|
||||
return;
|
||||
|
||||
QString name = shaderList->item( i )->text();
|
||||
|
||||
shaderEditorWidget->reset();
|
||||
shaderEditorWidget->load( name );
|
||||
|
||||
int res = shaderEditorWidget->exec();
|
||||
if( res == QDialog::Rejected )
|
||||
return;
|
||||
|
||||
QString descr;
|
||||
shaderEditorWidget->getDescription( descr );
|
||||
description->setPlainText( descr );
|
||||
}
|
||||
|
||||
void ShaderWidget::onRowChanged( int i )
|
||||
{
|
||||
if( i < 0 )
|
||||
return;
|
||||
|
||||
std::string s = shaderList->item( i )->text().toUtf8().data();
|
||||
|
||||
SShaderInfo info;
|
||||
bool ok = nl3dIface->getShaderInfo( s, info );
|
||||
if( !ok )
|
||||
return;
|
||||
|
||||
description->setPlainText( info.description.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,61 +1,61 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef SHADER_WIDGET_H
|
||||
#define SHADER_WIDGET_H
|
||||
|
||||
#include "ui_shader_widget.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
class ShaderEditorWidget;
|
||||
class CNel3DInterface;
|
||||
|
||||
class ShaderWidget : public QWidget, public Ui::ShaderWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ShaderWidget( QWidget *parent = NULL );
|
||||
~ShaderWidget();
|
||||
|
||||
void setNel3DInterface( CNel3DInterface *iface );
|
||||
void load();
|
||||
|
||||
Q_SIGNALS:
|
||||
void shaderAdded( const QString &name );
|
||||
void shaderRemoved( const QString &name );
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
bool nameExists( const QString &name );
|
||||
void nameExistsMessage();
|
||||
|
||||
ShaderEditorWidget *shaderEditorWidget;
|
||||
CNel3DInterface *nl3dIface;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onOKClicked();
|
||||
void onAddClicked();
|
||||
void onRemoveClicked();
|
||||
void onEditClicked();
|
||||
void onRowChanged( int i );
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef SHADER_WIDGET_H
|
||||
#define SHADER_WIDGET_H
|
||||
|
||||
#include "ui_shader_widget.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
class ShaderEditorWidget;
|
||||
class CNel3DInterface;
|
||||
|
||||
class ShaderWidget : public QWidget, public Ui::ShaderWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ShaderWidget( QWidget *parent = NULL );
|
||||
~ShaderWidget();
|
||||
|
||||
void setNel3DInterface( CNel3DInterface *iface );
|
||||
void load();
|
||||
|
||||
Q_SIGNALS:
|
||||
void shaderAdded( const QString &name );
|
||||
void shaderRemoved( const QString &name );
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
bool nameExists( const QString &name );
|
||||
void nameExistsMessage();
|
||||
|
||||
ShaderEditorWidget *shaderEditorWidget;
|
||||
CNel3DInterface *nl3dIface;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onOKClicked();
|
||||
void onAddClicked();
|
||||
void onRemoveClicked();
|
||||
void onEditClicked();
|
||||
void onRowChanged( int i );
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,154 +1,154 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "viewport_widget.h"
|
||||
#include <QResizeEvent>
|
||||
#include "nel3d_interface.h"
|
||||
#include "nel/3d/driver.h"
|
||||
#include "nel/3d/driver_user.h"
|
||||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
ViewPortWidget::ViewPortWidget( QWidget *parent ) :
|
||||
QWidget( parent )
|
||||
{
|
||||
nl3dIface = NULL;
|
||||
timerId = 0;
|
||||
setAttribute( Qt::WA_PaintOnScreen );
|
||||
}
|
||||
|
||||
ViewPortWidget::~ViewPortWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void ViewPortWidget::init()
|
||||
{
|
||||
nl3dIface->initViewPort( (unsigned long)winId(), width(), height() );
|
||||
|
||||
}
|
||||
|
||||
void ViewPortWidget::resizeEvent( QResizeEvent *evnt )
|
||||
{
|
||||
uint32 w = evnt->size().width();
|
||||
uint32 h = evnt->size().height();
|
||||
|
||||
nl3dIface->resizeViewPort( w, h );
|
||||
|
||||
QWidget::resizeEvent( evnt );
|
||||
}
|
||||
|
||||
void ViewPortWidget::startTimedUpdates( int interval )
|
||||
{
|
||||
if( interval == 0 )
|
||||
return;
|
||||
|
||||
timerId = startTimer( interval );
|
||||
}
|
||||
|
||||
void ViewPortWidget::stopTimedUpdates()
|
||||
{
|
||||
killTimer( timerId );
|
||||
timerId = 0;
|
||||
}
|
||||
|
||||
void ViewPortWidget::timerEvent( QTimerEvent *evnt )
|
||||
{
|
||||
int id = evnt->timerId();
|
||||
if( id == timerId )
|
||||
update();
|
||||
}
|
||||
|
||||
#if defined( NL_OS_WINDOWS )
|
||||
|
||||
typedef bool ( *winProc )( NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam );
|
||||
|
||||
bool ViewPortWidget::winEvent( MSG *message, long *result )
|
||||
{
|
||||
NL3D::UDriver *udriver = nl3dIface->getDriver();
|
||||
if( ( udriver != NULL ) && udriver->isActive() )
|
||||
{
|
||||
NL3D::IDriver *driver = dynamic_cast< NL3D::CDriverUser* >( udriver )->getDriver();
|
||||
if( driver != NULL )
|
||||
{
|
||||
winProc proc = (winProc)driver->getWindowProc();
|
||||
return proc( driver, message->hwnd, message->message, message->wParam, message->lParam );
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#elif defined( NL_OS_MAC )
|
||||
|
||||
typedef bool ( *cocoaProc )( NL3D::IDriver *, const void *e );
|
||||
|
||||
bool ViewPortWidget::macEvent( EventHandlerCallRef caller, EventRef event )
|
||||
{
|
||||
if( caller )
|
||||
nlerror("You are using QtCarbon! Only QtCocoa supported, please upgrade Qt");
|
||||
|
||||
NL3D::UDriver *udriver = nl3dIface->getDriver();
|
||||
if( ( udriver != NULL ) && udriver->isActive() )
|
||||
{
|
||||
NL3D::IDriver *driver = dynamic_cast< NL3D::CDriverUser* >( udriver )->getDriver();
|
||||
if( driver != NULL )
|
||||
{
|
||||
cocoaProc proc = ( cocoaProc )driver->getWindowProc();
|
||||
proc( driver, event );
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#elif defined( NL_OS_UNIX )
|
||||
|
||||
typedef bool ( *x11Proc )( NL3D::IDriver *drv, XEvent *e );
|
||||
|
||||
bool ViewPortWidget::x11Event( XEvent *event )
|
||||
{
|
||||
NL3D::UDriver *udriver = nl3dIface->getDriver();
|
||||
|
||||
if( ( udriver != NULL ) && udriver->isActive() )
|
||||
{
|
||||
NL3D::IDriver *driver = dynamic_cast< NL3D::CDriverUser* >( udriver )->getDriver();
|
||||
if( driver != NULL )
|
||||
{
|
||||
x11Proc proc = ( x11Proc )driver->getWindowProc();
|
||||
proc( driver, event );
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void ViewPortWidget::update()
|
||||
{
|
||||
nl3dIface->updateInput();
|
||||
nl3dIface->renderScene();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "viewport_widget.h"
|
||||
#include <QResizeEvent>
|
||||
#include "nel3d_interface.h"
|
||||
#include "nel/3d/driver.h"
|
||||
#include "nel/3d/driver_user.h"
|
||||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
ViewPortWidget::ViewPortWidget( QWidget *parent ) :
|
||||
QWidget( parent )
|
||||
{
|
||||
nl3dIface = NULL;
|
||||
timerId = 0;
|
||||
setAttribute( Qt::WA_PaintOnScreen );
|
||||
}
|
||||
|
||||
ViewPortWidget::~ViewPortWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void ViewPortWidget::init()
|
||||
{
|
||||
nl3dIface->initViewPort( (unsigned long)winId(), width(), height() );
|
||||
|
||||
}
|
||||
|
||||
void ViewPortWidget::resizeEvent( QResizeEvent *evnt )
|
||||
{
|
||||
uint32 w = evnt->size().width();
|
||||
uint32 h = evnt->size().height();
|
||||
|
||||
nl3dIface->resizeViewPort( w, h );
|
||||
|
||||
QWidget::resizeEvent( evnt );
|
||||
}
|
||||
|
||||
void ViewPortWidget::startTimedUpdates( int interval )
|
||||
{
|
||||
if( interval == 0 )
|
||||
return;
|
||||
|
||||
timerId = startTimer( interval );
|
||||
}
|
||||
|
||||
void ViewPortWidget::stopTimedUpdates()
|
||||
{
|
||||
killTimer( timerId );
|
||||
timerId = 0;
|
||||
}
|
||||
|
||||
void ViewPortWidget::timerEvent( QTimerEvent *evnt )
|
||||
{
|
||||
int id = evnt->timerId();
|
||||
if( id == timerId )
|
||||
update();
|
||||
}
|
||||
|
||||
#if defined( NL_OS_WINDOWS )
|
||||
|
||||
typedef bool ( *winProc )( NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam );
|
||||
|
||||
bool ViewPortWidget::winEvent( MSG *message, long *result )
|
||||
{
|
||||
NL3D::UDriver *udriver = nl3dIface->getDriver();
|
||||
if( ( udriver != NULL ) && udriver->isActive() )
|
||||
{
|
||||
NL3D::IDriver *driver = dynamic_cast< NL3D::CDriverUser* >( udriver )->getDriver();
|
||||
if( driver != NULL )
|
||||
{
|
||||
winProc proc = (winProc)driver->getWindowProc();
|
||||
return proc( driver, message->hwnd, message->message, message->wParam, message->lParam );
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#elif defined( NL_OS_MAC )
|
||||
|
||||
typedef bool ( *cocoaProc )( NL3D::IDriver *, const void *e );
|
||||
|
||||
bool ViewPortWidget::macEvent( EventHandlerCallRef caller, EventRef event )
|
||||
{
|
||||
if( caller )
|
||||
nlerror("You are using QtCarbon! Only QtCocoa supported, please upgrade Qt");
|
||||
|
||||
NL3D::UDriver *udriver = nl3dIface->getDriver();
|
||||
if( ( udriver != NULL ) && udriver->isActive() )
|
||||
{
|
||||
NL3D::IDriver *driver = dynamic_cast< NL3D::CDriverUser* >( udriver )->getDriver();
|
||||
if( driver != NULL )
|
||||
{
|
||||
cocoaProc proc = ( cocoaProc )driver->getWindowProc();
|
||||
proc( driver, event );
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#elif defined( NL_OS_UNIX )
|
||||
|
||||
typedef bool ( *x11Proc )( NL3D::IDriver *drv, XEvent *e );
|
||||
|
||||
bool ViewPortWidget::x11Event( XEvent *event )
|
||||
{
|
||||
NL3D::UDriver *udriver = nl3dIface->getDriver();
|
||||
|
||||
if( ( udriver != NULL ) && udriver->isActive() )
|
||||
{
|
||||
NL3D::IDriver *driver = dynamic_cast< NL3D::CDriverUser* >( udriver )->getDriver();
|
||||
if( driver != NULL )
|
||||
{
|
||||
x11Proc proc = ( x11Proc )driver->getWindowProc();
|
||||
proc( driver, event );
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void ViewPortWidget::update()
|
||||
{
|
||||
nl3dIface->updateInput();
|
||||
nl3dIface->renderScene();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,68 +1,68 @@
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef VIEWPORT_WIDGET_H
|
||||
#define VIEWPORT_WIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/event_emitter.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
class CNel3DInterface;
|
||||
|
||||
class ViewPortWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ViewPortWidget( QWidget *parent = NULL );
|
||||
~ViewPortWidget();
|
||||
void setNel3DInterface( CNel3DInterface *iface ){ nl3dIface = iface; }
|
||||
void init();
|
||||
|
||||
void resizeEvent( QResizeEvent *evnt );
|
||||
|
||||
QPaintEngine* paintEngine() const{ return NULL; }
|
||||
|
||||
void startTimedUpdates( int interval );
|
||||
void stopTimedUpdates();
|
||||
|
||||
protected:
|
||||
|
||||
void timerEvent( QTimerEvent *evnt );
|
||||
|
||||
#if defined ( NL_OS_WINDOWS )
|
||||
bool winEvent( MSG *message, long *result );
|
||||
#elif defined( NL_OS_MAC )
|
||||
bool macEvent( EventHandlerCallRef caller, EventRef event ) ;
|
||||
#elif defined( NL_OS_UNIX )
|
||||
bool x11Event( XEvent *event );
|
||||
#endif
|
||||
|
||||
private:
|
||||
void update();
|
||||
|
||||
CNel3DInterface *nl3dIface;
|
||||
int timerId;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// Object Viewer Qt Material Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef VIEWPORT_WIDGET_H
|
||||
#define VIEWPORT_WIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/event_emitter.h"
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
class CNel3DInterface;
|
||||
|
||||
class ViewPortWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ViewPortWidget( QWidget *parent = NULL );
|
||||
~ViewPortWidget();
|
||||
void setNel3DInterface( CNel3DInterface *iface ){ nl3dIface = iface; }
|
||||
void init();
|
||||
|
||||
void resizeEvent( QResizeEvent *evnt );
|
||||
|
||||
QPaintEngine* paintEngine() const{ return NULL; }
|
||||
|
||||
void startTimedUpdates( int interval );
|
||||
void stopTimedUpdates();
|
||||
|
||||
protected:
|
||||
|
||||
void timerEvent( QTimerEvent *evnt );
|
||||
|
||||
#if defined ( NL_OS_WINDOWS )
|
||||
bool winEvent( MSG *message, long *result );
|
||||
#elif defined( NL_OS_MAC )
|
||||
bool macEvent( EventHandlerCallRef caller, EventRef event ) ;
|
||||
#elif defined( NL_OS_UNIX )
|
||||
bool x11Event( XEvent *event );
|
||||
#endif
|
||||
|
||||
private:
|
||||
void update();
|
||||
|
||||
CNel3DInterface *nl3dIface;
|
||||
int timerId;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue