Remove branch unrelated features (must backout this changeset after merging into parent feature branch)

--HG--
branch : opengl3
hg/feature/opengl3
kaetemi 11 years ago
parent 267e7397c5
commit 4b4ac31a3d

@ -106,8 +106,6 @@ struct EBadDisplay : public NLMISC::Exception
// ****************************************************************************
typedef void (*emptyProc)(void);
class IProgram;
// ****************************************************************************
// *** IMPORTANT ********************
// *** IF YOU MODIFY THE STRUCTURE OF THIS CLASS, PLEASE INCREMENT IDriver::InterfaceVersion TO INVALIDATE OLD DRIVER DLL
@ -1055,9 +1053,6 @@ public:
*/
virtual void setLight(uint8 num, const CLight &light) = 0;
/// Get light data for the specified light
virtual CLight getLight(uint8 num) = 0;
/**
* Enable / disable light.
*
@ -1069,8 +1064,6 @@ public:
*/
virtual void enableLight(uint8 num, bool enable = true) = 0;
virtual bool isLightEnabled(uint8 num) = 0;
/**
* Set ambient.
*
@ -1457,10 +1450,6 @@ protected:
private:
bool _StaticMemoryToVRAM;
public:
/// Reloads the user shaders
virtual void reloadUserShaders(){}
};
// --------------------------------------------------

@ -307,7 +307,7 @@ inline void CMaterial::texConstantColor(uint stage, CRGBA color)
// ***************************************************************************
inline uint32 CMaterial::getTexEnvMode(uint stage)
{
// nlassert(_ShaderType==CMaterial::Normal); // GL3 DEBUG
nlassert(_ShaderType==CMaterial::Normal);
nlassert(stage<IDRV_MAT_MAXTEXTURES);
return _TexEnvs[stage].EnvPacked;
}

@ -197,18 +197,12 @@ public:
virtual void enableFog(bool enable);
/// setup fog parameters. fog must enabled to see result. start and end are in [0,1] range.
virtual void setupFog(float start, float end, CRGBA color);
virtual float getFogStart();
virtual float getFogEnd();
virtual CRGBA getFogColor();
// @}
/// \name Light support.
// @{
virtual void setLight (uint8 num, const ULight& light);
virtual ULight* getLight (uint8 num);
virtual uint8 getMaxDriverLights() const;
virtual void enableLight (uint8 num, bool enable=true);
virtual bool isLightEnabled (uint8 num);
virtual void setAmbientColor (CRGBA color);
// @}

@ -1,45 +0,0 @@
// 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 +0,0 @@
// 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

@ -32,8 +32,6 @@ using NLMISC::CRGBA;
using NLMISC::CSmartPtr;
using NLMISC::CRefPtr;
class CDynMaterial;
// --------------------------------------------------
const uint32 IDRV_MAT_MAXTEXTURES = 4;
@ -263,7 +261,7 @@ public:
*/
CMaterial();
/// see operator=.
CMaterial(const CMaterial &mat);
CMaterial(const CMaterial &mat) : CRefCount() {_Touched= 0;_Flags=0; operator=(mat);}
/// dtor.
~CMaterial();
/// Do not copy DrvInfos, copy all infos and set IDRV_TOUCHED_ALL.
@ -620,7 +618,7 @@ public:
}
// helpers
inline uint getColorArg(uint index) const
inline uint getColorArg(uint index)
{
switch(index)
{
@ -633,7 +631,7 @@ public:
}
return 0;
}
inline uint getAlphaArg(uint index) const
inline uint getAlphaArg(uint index)
{
switch(index)
{
@ -646,7 +644,7 @@ public:
}
return 0;
}
inline uint getColorOperand(uint index) const
inline uint getColorOperand(uint index)
{
switch(index)
{
@ -659,7 +657,7 @@ public:
}
return 0;
}
inline uint getAlphaOperand(uint index) const
inline uint getAlphaOperand(uint index)
{
switch(index)
{
@ -696,20 +694,7 @@ private:
};
std::auto_ptr<CUserTexMat> _TexUserMat; // user texture matrix
/// Dynamic material for the new driver
CDynMaterial *dynMat;
public:
CDynMaterial* getDynMat() const{ return dynMat; }
void setDynMat( CDynMaterial *newDynMat ){ dynMat = newDynMat; }
/// Create the dynamic material from the current material parameters
void createDynMat();
/// Creates a clean dynamic material instance
void createCleanDynMat();
// Private. For Driver only.
CSmartPtr<ITexture> _Textures[IDRV_MAT_MAXTEXTURES];
uint8 _TexAddrMode[IDRV_MAT_MAXTEXTURES]; // texture addressing enum packed as bytes

@ -1,37 +0,0 @@
// 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

@ -265,18 +265,12 @@ public:
virtual void enableFog(bool enable)=0;
/// $ fog parameters. fog must enabled to see result. start and end are in [0,1] range.
virtual void setupFog(float start, float end, CRGBA color)=0;
virtual float getFogStart() = 0;
virtual float getFogEnd() = 0;
virtual CRGBA getFogColor() = 0;
// @}
/// \name Light support.
// @{
virtual void setLight (uint8 num, const ULight& light) = 0;
virtual ULight* getLight (uint8 num) = 0;
virtual uint8 getMaxDriverLights() const = 0;
virtual void enableLight (uint8 num, bool enable=true) = 0;
virtual bool isLightEnabled (uint8 num) = 0;
virtual void setAmbientColor (CRGBA color) = 0;
// @}

@ -1,44 +0,0 @@
// 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 +0,0 @@
// 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 +0,0 @@
// 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 +0,0 @@
// 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 +0,0 @@
// 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

@ -338,15 +338,6 @@ public:
std::swap(R,B);
}
/// Write the RGBA values to a float vector
void toFloatVector( float *v ) const
{
v[ 0 ] = R;
v[ 1 ] = G;
v[ 2 ] = B;
v[ 3 ] = A;
}
/// Red componant.
uint8 R;

@ -1,109 +0,0 @@
// 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

@ -144,10 +144,6 @@ SOURCE_GROUP(Driver FILES
../../include/nel/3d/light.h
material.cpp
../../include/nel/3d/material.h
dynamic_material.cpp
../../include/nel/3d/dynamic_material.h
dyn_mat_loader.cpp
../../include/nel/3d/dyb_mat_loader.h
nelu.cpp
../../include/nel/3d/nelu.h
../../include/nel/3d/occlusion_query.h
@ -157,17 +153,6 @@ SOURCE_GROUP(Driver FILES
../../include/nel/3d/scene.h
scene_group.cpp
../../include/nel/3d/scene_group.h
shader.cpp
../../include/nel/3d/shader.h
shader_loader.cpp
../../include/nel/3d/shader_loader.h
shader_manager.cpp
../../include/nel/3d/shader_manager.h
shader_program.cpp
../../include/nel/3d/shader_program.h
shader_saver.cpp
../../include/nel/3d/shader_saver.h
../../include/nel/3d/shader_visitor.h
texture.cpp
../../include/nel/3d/texture.h
vertex_buffer.cpp
@ -269,8 +254,6 @@ SOURCE_GROUP(Shapes FILES
../../include/nel/3d/shape.h
shape_bank.cpp
../../include/nel/3d/shape_bank.h
shape_material_serializer.cpp
../../include/nel/3d/shape_material_serializer.h
shifted_triangle_cache.cpp
../../include/nel/3d/shifted_triangle_cache.h
skeleton_shape.cpp

@ -1041,9 +1041,7 @@ public:
// Lights
virtual uint getMaxLight () const;
virtual void setLight (uint8 num, const CLight& light);
virtual CLight getLight (uint8 num);
virtual void enableLight (uint8 num, bool enable=true);
virtual bool isLightEnabled (uint8 num);
virtual void setLightMapDynamicLight (bool enable, const CLight& light);
// todo hulud d3d light
virtual void setPerPixelLightingLight(CRGBA /* diffuse */, CRGBA /* specular */, float /* shininess */) {}

@ -59,15 +59,6 @@ void CDriverD3D::setLight (uint8 index, const CLight &light)
}
CLight CDriverD3D::getLight (uint8 index)
{
// Not yet implemented
nlinfo( "This feature isn't yet implemented in this driver!" );
nlassert( false );
return CLight();
}
// ***************************************************************************
void CDriverD3D::enableLight (uint8 index, bool enable)
{
@ -85,14 +76,6 @@ void CDriverD3D::enableLight (uint8 index, bool enable)
_LightMapDynamicLightDirty= true;
}
bool CDriverD3D::isLightEnabled (uint8 num)
{
if(num<MaxLight)
return _UserLightEnable[num];
return false;
}
static const float sqrtFLT_MAX = (float) sqrtf(FLT_MAX);
// ***************************************************************************

@ -577,12 +577,8 @@ public:
virtual void setLight (uint8 num, const CLight& light);
virtual CLight getLight (uint8 num);
virtual void enableLight (uint8 num, bool enable=true);
virtual bool isLightEnabled (uint8 num);
virtual void setPerPixelLightingLight(CRGBA diffuse, CRGBA specular, float shininess);
virtual void setLightMapDynamicLight (bool enable, const CLight& light);

@ -54,14 +54,6 @@ void CDriverGL::setLight (uint8 num, const CLight& light)
}
CLight CDriverGL::getLight (uint8 num)
{
nlinfo( "This feature isn't yet implemented in this driver!" );
nlassert( false );
return CLight();
}
// ***************************************************************************
void CDriverGL::setLightInternal(uint8 num, const CLight& light)
{
@ -188,14 +180,6 @@ void CDriverGL::enableLight (uint8 num, bool enable)
_LightMapDynamicLightDirty= true;
}
bool CDriverGL::isLightEnabled (uint8 num)
{
if(num<_MaxDriverLight)
return _UserLightEnable[num];
return false;
}
// ***************************************************************************
void CDriverGL::enableLightInternal(uint8 num, bool enable)

@ -14,7 +14,7 @@
// 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 "stdopengl.h"
#include "stdopengl.h"
#include "unix_event_emitter.h"
#if defined(NL_OS_UNIX) && !defined(NL_OS_MAC)

@ -57,73 +57,6 @@ namespace NL3D
ss.clear();
}
void CGLSLShaderGenerator::generatePS(std::string &ps)
{
ss.str("");
ss.clear();
ss << "// " << shaderNames[ material->getShader() ] << " Pixel Shader" << std::endl;
ss << std::endl;
ss << "#version 330" << std::endl;
ss << std::endl;
ss << "out vec4 fragColor;" << std::endl;
for (int i = Weight; i < NumOffsets; i++)
{
if (hasFlag(desc->vbFlags, g_VertexFlags[i]))
{
ss << "smooth in vec4 ";
ss << g_AttribNames[i] << ";" << std::endl;
}
}
ss << std::endl;
#if 0 // LIGHTING DEBUG
if (desc->lightingEnabled() || material->getShader() != CMaterial::Normal)
{
generateInvalidPS();
}
else
{
generateNormalPS();
}
#else
switch(material->getShader())
{
case CMaterial::Normal:
case CMaterial::UserColor:
case CMaterial::Specular:
generateNormalPS();
break;
case CMaterial::LightMap:
generateLightMapPS();
break;
/*case CMaterial::Specular:
generateSpecularPS();
break;*/
case CMaterial::PerPixelLighting:
case CMaterial::PerPixelLightingNoSpec:
generatePPLPS();
break;
case CMaterial::Water:
generateWaterPS();
break;
case CMaterial::Cloud:
generateCloudPS();
break;
}
#endif
ps.assign(ss.str());
}
void CGLSLShaderGenerator::addAmbient()
{
ss << "uniform vec4 ambientColor;" << std::endl;
@ -442,399 +375,9 @@ namespace NL3D
ss << "}" << std::endl;
}*/
void CGLSLShaderGenerator::generateInvalidPS()
{
/*uint sampler = 0;
for (int i = 0; i < IDRV_MAT_MAXTEXTURES; i++)
{
if (desc->getUseTexStage(i))
ss << "uniform sampler2D sampler" << sampler << ";" << std::endl;
sampler++;
}
addColor();
addConstants();
addAlphaTreshold();
addFogUniform();*/
if (desc->fogEnabled())
ss << "smooth in vec4 ecPos;" << std::endl;
ss << std::endl;
if (desc->lightingEnabled())
{
addLightUniformsFS();
addLightInsFS();
ss << std::endl;
addLightsFunctionFS();
ss << std::endl;
}
/*if (desc->fogEnabled())
addFogFunction();*/
ss << "void main(void)" << std::endl;
ss << "{" << std::endl;
/*bool textures = false;
sampler = 0;
for (int i = 0; i < IDRV_MAT_MAXTEXTURES; i++)
{
if (desc->getUseTexStage(i))
{
ss << "vec4 texel" << sampler << " = texture(sampler" << sampler << ",";
if (!desc->getUseFirstTexCoords())
ss << g_AttribNames[ TexCoord0 + i ] << ".st);";
else
ss << g_AttribNames[ TexCoord0 ] << ".st);";
ss << std::endl;
textures = true;
}
sampler++;
}
bool vertexColor = false;
if (hasFlag(vbFormat, g_VertexFlags[ PrimaryColor ]))
vertexColor = true;
if (textures && !vertexColor)
ss << "vec4 texel = vec4(1.0, 1.0, 1.0, 1.0);" << std::endl;
else
if (vertexColor)
ss << "vec4 texel = color;" << std::endl;
else
ss << "vec4 texel = vec4(0.5, 0.5, 0.5, 1.0);" << std::endl;
generateTexEnv();
// This is just an idea I had, but it seems to be working.
// Unfortunately it's not documented anywhere I looked in the GL spec, but if I don't have this modulation here,
// the Ryzom UI looks horrific.
if (vertexColor)
ss << "texel = color * texel;" << std::endl;*/
ss << "fragColor = vec4(1.0, 1.0, 1.0, 1.0);" << std::endl;
if (desc->lightingEnabled())
addLightsFS();
ss << "fragColor = fragColor + vec4(0.25, 0.0, 0.0, 0.0);" << std::endl;
/*if (desc->fogEnabled())
addFog();
addAlphaTest();*/
ss << "}" << std::endl;
}
void CGLSLShaderGenerator::generateNormalPS()
{
uint sampler = 0;
for (int i = 0; i < IDRV_MAT_MAXTEXTURES; i++)
{
if (desc->getUseTexStage(i))
{
ss << "uniform "
<< ((desc->textureSamplerMode[i] == SamplerCube) ? "samplerCube" : "sampler2D")
<< " sampler" << sampler << ";" << std::endl;
}
sampler++;
}
addColor();
addConstants();
addAlphaTreshold();
addFogUniform();
if (desc->fogEnabled())
ss << "smooth in vec4 ecPos;" << std::endl;
ss << std::endl;
if (desc->lightingEnabled())
{
addLightUniformsFS();
addLightInsFS();
ss << std::endl;
addLightsFunctionFS();
ss << std::endl;
}
if (desc->fogEnabled())
addFogFunction();
ss << "void main(void)" << std::endl;
ss << "{" << std::endl;
// Light color
ss << "vec4 diffuse = vec4(1.0, 1.0, 1.0, 1.0);" << std::endl;
if (desc->lightingEnabled())
{
ss << "diffuse = applyLights(diffuse);" << std::endl;
ss << "diffuse.a = 1.0;" << std::endl;
}
if (hasFlag(desc->vbFlags, g_VertexFlags[PrimaryColor]))
ss << "diffuse = color * diffuse;" << std::endl; // TODO: If this is the correct location, we should premultiply light and color in VS.
bool textures = false;
for (int i = 0; i < IDRV_MAT_MAXTEXTURES; i++)
{
if (desc->getUseTexStage(i))
{
ss << "vec4 texel" << i << " = texture(sampler" << i << ", ";
if (desc->hasVBFlags(g_VertexFlags[TexCoord0 + i]))
ss << g_AttribNames[TexCoord0 + i];
else
ss << g_AttribNames[TexCoord0];
ss << ((desc->textureSamplerMode[i] == SamplerCube) ? ".str);" : ".st);");
ss << std::endl;
textures = true;
}
}
/*if (textures && !vertexColor)
ss << "vec4 texel = vec4(1.0, 1.0, 1.0, 1.0);" << std::endl;
else if (vertexColor)
ss << "vec4 texel = color;" << std::endl;
else
ss << "vec4 texel = vec4(0.5, 0.5, 0.5, 1.0);" << std::endl;*/
switch (material->getShader())
{
case CMaterial::Specular:
generateSpecular();
break;
default:
generateTexEnv();
break;
}
if (desc->fogEnabled())
addFog();
addAlphaTest();
// ss << "fragColor = fragColor + vec4(0.0, 0.25, 0.0, 0.0);" << std::endl;
// ss << "fragColor.b = diffuse.b;" << std::endl;
ss << "}" << std::endl;
}
void CGLSLShaderGenerator::generateTexEnv()
{
for (uint stage = 0; stage < IDRV_MAT_MAXTEXTURES; ++stage)
{
if (desc->getUseTexStage(stage))
{
for (uint arg = 0; arg < 3; ++arg)
{
// Texop arg
ss << "vec4 texop" << stage << "arg" << arg << ";" << std::endl;
// RGB
uint rgbArg = material->_TexEnvs[stage].getColorArg(arg);
uint rgbOp = material->_TexEnvs[stage].getColorOperand(arg);
std::stringstream rgbArgVec;
switch (rgbArg)
{
case CMaterial::Texture:
rgbArgVec << "texel" << stage;
break;
case CMaterial::Previous:
if (stage > 0)
{
rgbArgVec << "texop" << (stage - 1);
break;
}
case CMaterial::Diffuse:
rgbArgVec << "diffuse";
break;
case CMaterial::Constant:
rgbArgVec << "constant" << stage;
break;
}
ss << "texop" << stage << "arg" << arg << ".rgb = ";
switch (rgbOp) // SrcColor=0, InvSrcColor, SrcAlpha, InvSrcAlpha
{
case CMaterial::SrcColor:
ss << rgbArgVec.str() << ".rgb";
break;
case CMaterial::InvSrcColor:
ss << "vec3(1.0, 1.0, 1.0) - " << rgbArgVec.str() << ".rgb";
break;
case CMaterial::SrcAlpha:
ss << rgbArgVec.str() << ".aaa";
break;
case CMaterial::InvSrcAlpha:
ss << "(1.0 - " << rgbArgVec.str() << ").aaa";
break;
}
ss << ";" << std::endl;
// Alpha
uint alphaArg = material->_TexEnvs[stage].getAlphaArg(arg);
uint alphaOp = material->_TexEnvs[stage].getAlphaOperand(arg);
std::stringstream alphaArgVec;
switch (alphaArg)
{
case CMaterial::Texture:
alphaArgVec << "texel" << stage;
break;
case CMaterial::Previous:
if (stage > 0)
{
alphaArgVec << "texop" << (stage - 1);
break;
}
case CMaterial::Diffuse:
alphaArgVec << "diffuse";
break;
case CMaterial::Constant:
alphaArgVec << "constant" << stage;
break;
}
ss << "texop" << stage << "arg" << arg << ".a = ";
switch (alphaOp) // SrcColor=0, InvSrcColor, SrcAlpha, InvSrcAlpha
{
case CMaterial::SrcColor:
ss << alphaArgVec.str() << ".r";
break;
case CMaterial::InvSrcColor:
ss << "1.0 - " << alphaArgVec.str() << ".r";
break;
case CMaterial::SrcAlpha:
ss << alphaArgVec.str() << ".a";
break;
case CMaterial::InvSrcAlpha:
ss << "1.0 - " << alphaArgVec.str() << ".a";
break;
}
ss << ";" << std::endl;
}
ss << "vec4 texop" << stage << ";" << std::endl;
// RGB
switch (material->_TexEnvs[stage].Env.OpRGB)
{
case CMaterial::InterpolateConstant:
ss << "float texop" << stage << "rgbAs = constant" << stage << ".a;" << std::endl;
break;
case CMaterial::InterpolatePrevious:
if (stage > 0)
{
ss << "float texop" << stage << "rgbAs = texop" << stage << ".a;" << std::endl;
break;
}
case CMaterial::InterpolateDiffuse:
ss << "float texop" << stage << "rgbAs = diffuse.a;" << std::endl;
break;
case CMaterial::InterpolateTexture:
ss << "float texop" << stage << "rgbAs = texel" << stage << ".a;" << std::endl;
break;
}
ss << "texop" << stage << ".rgb = ";
switch (material->_TexEnvs[stage].Env.OpRGB)
{
case CMaterial::Replace:
ss << "texop" << stage << "arg0.rgb";
break;
case CMaterial::Modulate:
ss << "texop" << stage << "arg0.rgb * texop" << stage << "arg1.rgb";
break;
case CMaterial::Add:
ss << "texop" << stage << "arg0.rgb + texop" << stage << "arg1.rgb";
break;
case CMaterial::AddSigned:
ss << "texop" << stage << "arg0.rgb + texop" << stage << "arg1.rgb - vec3(0.5, 0.5, 0.5)";
break;
case CMaterial::InterpolateConstant:
case CMaterial::InterpolateDiffuse:
case CMaterial::InterpolatePrevious:
case CMaterial::InterpolateTexture:
ss << "texop" << stage << "arg0.rgb * texop" << stage << "rgbAs + texop" << stage << "arg1.rgb * (1.0 - texop" << stage << "rgbAs)";
break;
case CMaterial::Mad:
ss << "texop" << stage << "arg0.rgb * texop" << stage << "arg1.rgb + texop" << stage << "arg2.rgb";
break;
}
ss << ";" << std::endl;
// Alpha
switch (material->_TexEnvs[stage].Env.OpAlpha)
{
case CMaterial::InterpolateConstant:
ss << "float texop" << stage << "alphaAs = constant" << stage << ".a;" << std::endl;
break;
case CMaterial::InterpolatePrevious:
if (stage > 0)
{
ss << "float texop" << stage << "alphaAs = texop" << stage << ".a;" << std::endl;
break;
}
case CMaterial::InterpolateDiffuse:
ss << "float texop" << stage << "alphaAs = diffuse.a;" << std::endl;
break;
case CMaterial::InterpolateTexture:
ss << "float texop" << stage << "alphaAs = texel" << stage << ".a;" << std::endl;
break;
}
ss << "texop" << stage << ".a = ";
switch (material->_TexEnvs[stage].Env.OpAlpha)
{
case CMaterial::Replace:
ss << "texop" << stage << "arg0.a";
break;
case CMaterial::Modulate:
ss << "texop" << stage << "arg0.a * texop" << stage << "arg1.a";
break;
case CMaterial::Add:
ss << "texop" << stage << "arg0.a + texop" << stage << "arg1.a";
break;
case CMaterial::AddSigned:
ss << "texop" << stage << "arg0.a + texop" << stage << "arg1.a - 0.5";
break;
case CMaterial::InterpolateConstant:
case CMaterial::InterpolateDiffuse:
case CMaterial::InterpolatePrevious:
case CMaterial::InterpolateTexture:
ss << "texop" << stage << "arg0.a * texop" << stage << "rgbAs + texop" << stage << "arg1.a * (1.0 - texop" << stage << "rgbAs)";
break;
case CMaterial::Mad:
ss << "texop" << stage << "arg0.a * texop" << stage << "arg1.a + texop" << stage << "arg2.a";
break;
}
ss << ";" << std::endl;
}
else if (stage == 0)
{
ss << "vec4 texop" << stage << " = diffuse;" << std::endl;
}
else
{
ss << "vec4 texop" << stage << " = texop" << (stage - 1) << ";" << std::endl;
}
}
ss << "fragColor = texop" << (IDRV_MAT_MAXTEXTURES - 1) << ";" << std::endl;
}
void CGLSLShaderGenerator::generateSpecular()
{
ss << "vec3 specop0 = texel0.rgb * diffuse.rgb;" << std::endl;
ss << "vec4 specop1 = vec4(texel1.rgb * texel0.a + specop0, diffuse.a);" << std::endl;
ss << "fragColor = specop1;" << std::endl;
}
void CGLSLShaderGenerator::generateLightMapPS()
{
#if 0
int ls = material->_LightMaps.size();
ls++; // lightmaps + color texture
@ -925,59 +468,12 @@ namespace NL3D
ss << "}" << std::endl;
ss << std::endl;
}
void CGLSLShaderGenerator::generateSpecularPS()
{
ss << "smooth in vec3 cubeTexCoords;" << std::endl;
ss << "uniform sampler2D sampler0;" << std::endl;
ss << "uniform samplerCube sampler1;" << std::endl;
addDiffuse();
addAlphaTreshold();
addFogUniform();
if (desc->lightingEnabled())
{
addLightUniformsFS();
addLightInsFS();
ss << std::endl;
addLightsFunctionFS();
ss << std::endl;
}
if (desc->fogEnabled())
ss << "smooth in vec4 ecPos;" << std::endl;
ss << std::endl;
if (desc->fogEnabled())
addFogFunction();
ss << "void main(void)" << std::endl;
ss << "{" << std::endl;
ss << "vec4 texel0 = texture(sampler0, texCoord0.st);" << std::endl;
ss << "vec4 texel1 = texture(sampler1, cubeTexCoords);" << std::endl;
ss << "vec4 texel;" << std::endl;
ss << "texel.rgb = texel0.rgb * diffuseColor.rgb;" << std::endl;
ss << "texel.a = texel0.a;" << std::endl;
ss << "texel.rgb = texel1.rgb * texel.a + texel.rgb;" << std::endl;
ss << "texel.a = texel1.a;" << std::endl;
ss << "fragColor = texel;" << std::endl;
if (desc->lightingEnabled())
addLightsFS();
if (desc->fogEnabled())
addFog();
addAlphaTest();
ss << "}" << std::endl;
#endif
}
void CGLSLShaderGenerator::generatePPLPS()
{
#if 0
ss << "smooth in vec3 cubeTexCoords0;" << std::endl;
if (material->getShader() == CMaterial::PerPixelLighting)
ss << "smooth in vec3 cubeTexCoords2;" << std::endl;
@ -1027,11 +523,13 @@ namespace NL3D
ss << "fragColor = texel;" << std::endl;
addAlphaTest();
ss << "}" << std::endl;
#endif
}
void CGLSLShaderGenerator::generateWaterPS()
{
#if 0
bool diffuse = false;
if (material->getTexture(3) != NULL)
diffuse = true;
@ -1089,10 +587,12 @@ namespace NL3D
ss << "}" << std::endl;
ss << std::endl;
#endif
}
void CGLSLShaderGenerator::generateCloudPS()
{
#if 0
ss << "uniform sampler2D sampler0;" << std::endl;
ss << "uniform sampler2D sampler1;" << std::endl;
addDiffuse();
@ -1109,7 +609,7 @@ namespace NL3D
addAlphaTest();
ss << "}" << std::endl;
ss << std::endl;
#endif
}
}

@ -27,8 +27,6 @@
#include "nel/3d/vertex_buffer.h"
#include "nel/3d/light.h"
#include "nel/3d/index_buffer.h"
#include "nel/3d/usr_shader_manager.h"
#include "nel/3d/usr_shader_loader.h"
#include "nel/misc/rect.h"
#include "nel/misc/di_event_emitter.h"
#include "nel/misc/mouse_device.h"
@ -315,13 +313,6 @@ CDriverGL3::CDriverGL3()
m_DriverPixelProgram = NULL;
m_VPBuiltinTouched = true;
shaderGenerator = new CGLSLShaderGenerator();
usrShaderManager = new CUsrShaderManager();
CUsrShaderLoader loader;
loader.setManager(usrShaderManager);
loader.loadShaders("./shaders");
}
// ***************************************************************************
@ -331,11 +322,6 @@ CDriverGL3::~CDriverGL3()
release();
delete shaderGenerator;
shaderGenerator = NULL;
delete usrShaderManager;
usrShaderManager = NULL;
#if defined(NL_OS_MAC)
[_autoreleasePool release];
#endif
@ -1845,15 +1831,6 @@ void CDriverGL3::endDialogMode()
{
}
// ***************************************************************************
void CDriverGL3::reloadUserShaders()
{
usrShaderManager->clear();
NL3D::CUsrShaderLoader loader;
loader.setManager(usrShaderManager);
loader.loadShaders("./shaders");
}
CProgramDrvInfosGL3::CProgramDrvInfosGL3(CDriverGL3 *drv, ItGPUPrgDrvInfoPtrList it) :
IProgramDrvInfos(drv, it)
{
@ -1862,6 +1839,7 @@ IProgramDrvInfos(drv, it)
CProgramDrvInfosGL3::~CProgramDrvInfosGL3()
{
// FIXME GL3: Is this not released?!
programId = 0;
}

@ -1319,11 +1319,7 @@ private:
NLMISC::CRGBA _CurrentBlendConstantColor;
private:
CGLSLShaderGenerator *shaderGenerator;
CUsrShaderManager *usrShaderManager;
private:
bool initProgramPipeline();
uint32 ppoId;
@ -1397,13 +1393,6 @@ private:
*/
inline void setupTextureBasicParameters(ITexture &tex);
private:
CShaderCache shaderCache;
public:
void reloadUserShaders();
};

@ -20,7 +20,6 @@
#include "nel/3d/texture_mem.h"
#include "nel/3d/texture_bump.h"
#include "nel/3d/material.h"
#include "nel/3d/dynamic_material.h"
namespace NL3D {
@ -237,12 +236,6 @@ bool CDriverGL3::setupMaterial(CMaterial& mat)
{
H_AUTO_OGL(CDriverGL3_setupMaterial)
if (mat.getDynMat() != NULL)
{
_CurrentMaterial = &mat;
return true;
}
CMaterialDrvInfosGL3* pShader;
CMaterial::TShader matShader;
GLenum glenum = GL_ZERO;
@ -512,9 +505,6 @@ sint CDriverGL3::beginMultiPass()
{
H_AUTO_OGL(CDriverGL3_beginMultiPass)
if (_CurrentMaterial->getDynMat() != NULL)
return _CurrentMaterial->getDynMat()->getPassCount();
// Depending on material type and hardware, return number of pass required to draw this material.
switch(_CurrentMaterialSupportedShader)
{
@ -543,9 +533,6 @@ bool CDriverGL3::setupPass(uint pass)
{
H_AUTO_OGL(CDriverGL3_setupPass)
if (_CurrentMaterial->getDynMat() != NULL)
return setupDynMatPass(pass);
switch(_CurrentMaterialSupportedShader)
{
case CMaterial::Normal:
@ -581,9 +568,6 @@ bool CDriverGL3::setupPass(uint pass)
void CDriverGL3::endMultiPass()
{
H_AUTO_OGL(CDriverGL3_endMultiPass)
if (_CurrentMaterial->getDynMat() != NULL)
return;
switch(_CurrentMaterialSupportedShader)
{

@ -18,9 +18,6 @@
#include "driver_opengl_program.h"
#include "driver_glsl_shader_generator.h"
#include "driver_opengl_vertex_buffer_hard.h"
#include "nel/3d/dynamic_material.h"
#include "nel/3d/usr_shader_manager.h"
#include "nel/3d/usr_shader_program.h"
namespace NL3D {

@ -1400,21 +1400,6 @@ void CDriverUser::setupFog(float start, float end, CRGBA color)
_Driver->setupFog(start, end, color);
}
float CDriverUser::getFogStart()
{
return _Driver->getFogStart();
}
float CDriverUser::getFogEnd()
{
return _Driver->getFogEnd();
}
CRGBA CDriverUser::getFogColor()
{
return _Driver->getFogColor();
}
// ***************************************************************************
void CDriverUser::setLight (uint8 num, const ULight& light)
@ -1424,23 +1409,6 @@ void CDriverUser::setLight (uint8 num, const ULight& light)
CLightUser *plight= (CLightUser*)&light;
_Driver->setLight (num, plight->_Light);
}
// ***************************************************************************
ULight* CDriverUser::getLight (uint8 num)
{
ULight *l = ULight::createLight();
CLightUser *lu = dynamic_cast< CLightUser* >( l );
nlassert( lu != NULL );
lu->_Light =_Driver->getLight( num );
return l;
}
uint8 CDriverUser::getMaxDriverLights() const
{
return static_cast< uint8 >( _Driver->getMaxLight() );
}
// ***************************************************************************
void CDriverUser::enableLight (uint8 num, bool enable)
{
@ -1448,13 +1416,6 @@ void CDriverUser::enableLight (uint8 num, bool enable)
_Driver->enableLight (num, enable);
}
// ***************************************************************************
bool CDriverUser::isLightEnabled (uint8 num)
{
return _Driver->isLightEnabled (num);
}
// ***************************************************************************
void CDriverUser::setAmbientColor (CRGBA color)
{

@ -1,61 +0,0 @@
// 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 +0,0 @@
// 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;
}
}
}

@ -19,8 +19,6 @@
#include "nel/3d/material.h"
#include "nel/3d/texture.h"
#include "nel/3d/driver.h"
#include "nel/3d/dynamic_material.h"
#include "nel/3d/texture_file.h"
#include "nel/misc/stream.h"
using namespace std;
@ -49,16 +47,6 @@ CMaterial::CMaterial()
_AlphaTestThreshold= 0.5f;
_TexCoordGenMode= 0;
_LightMapsMulx2= false;
dynMat = NULL;
}
CMaterial::CMaterial( const CMaterial &mat ) :
CRefCount()
{
_Touched= 0;
_Flags=0;
dynMat = NULL;
operator=(mat);
}
// ***************************************************************************
@ -131,14 +119,6 @@ CMaterial &CMaterial::operator=(const CMaterial &mat)
// All states of material is modified.
_Touched= IDRV_TOUCHED_ALL;
if( mat.dynMat != NULL )
{
if( dynMat == NULL )
dynMat = new CDynMaterial();
*dynMat = *mat.dynMat;
}
return *this;
}
@ -153,11 +133,6 @@ CMaterial::~CMaterial()
// Must kill the drv mirror of this material.
_MatDrvInfo.kill();
if( dynMat != NULL )
{
delete dynMat;
dynMat = NULL;
}
}
@ -648,175 +623,5 @@ bool CMaterial::isSupportedByDriver(IDriver &drv, bool forceBaseCaps) const
return false;
}
void CMaterial::createDynMat()
{
createCleanDynMat();
SRenderPass *p = dynMat->getPass( 0 );
float v[ 4 ];
float m[ 16 ];
SDynMaterialProp prop;
prop.type = SDynMaterialProp::Color;
prop.prop = "color";
prop.label = "Color";
_Color.toFloatVector( v );
prop.value.setVector4( v );
p->addProperty( prop );
prop.prop = "emissive";
prop.label = "Emissive color";
_Emissive.toFloatVector( v );
prop.value.setVector4( v );
p->addProperty( prop );
prop.prop = "ambient";
prop.label = "Ambient color";
_Ambient.toFloatVector( v );
prop.value.setVector4( v );
p->addProperty( prop );
prop.prop = "diffuse";
prop.label = "Diffuse color";
_Diffuse.toFloatVector( v );
prop.value.setVector4( v );
p->addProperty( prop );
prop.prop = "specular";
prop.label = "Specular color";
_Specular.toFloatVector( v );
prop.value.setVector4( v );
p->addProperty( prop );
prop.type = SDynMaterialProp::Float;
prop.prop = "shininess";
prop.label = "Shininess";
prop.value.setFloat( _Shininess );
p->addProperty( prop );
prop.prop = "alpha_test_threshold";
prop.label = "Alpha test threshold";
prop.value.setFloat( _AlphaTestThreshold );
p->addProperty( prop );
prop.type = SDynMaterialProp::Uint;
prop.prop = "flags";
prop.label = "Flags";
prop.value.setUInt( _Flags );
p->addProperty( prop );
prop.prop = "srcblend";
prop.label = "Source blend";
prop.value.setUInt( _SrcBlend );
p->addProperty( prop );
prop.prop = "dstblend";
prop.label = "Destination blend";
prop.value.setUInt( _DstBlend );
p->addProperty( prop );
prop.prop = "zfunc";
prop.label = "Z function";
prop.value.setUInt( _ZFunction );
p->addProperty( prop );
prop.type = SDynMaterialProp::Float;
prop.prop = "zbias";
prop.label = "Z bias";
prop.value.setFloat( _ZBias );
p->addProperty( prop );
for( int i = 0; i < IDRV_MAT_MAXTEXTURES; i++ )
{
if( _Textures[ i ] == NULL )
continue;
CTextureFile *tf = dynamic_cast< CTextureFile* >( _Textures[ i ].getPtr() );
if( tf == NULL )
continue;
prop.type = SDynMaterialProp::Texture;
prop.prop = "texture";
prop.prop.push_back( char( '0' + i ) );
prop.label = "Texture";
prop.label.push_back( char( '0' + i ) );
prop.value.setString( tf->getFileName() );
p->addProperty( prop );
}
if( _TexUserMat.get() != NULL )
{
prop.type = SDynMaterialProp::Matrix4;
for( int i = 0; i < IDRV_MAT_MAXTEXTURES; i++ )
{
prop.prop = "texmat";
prop.prop.push_back( char( '0' + i ) );
prop.label = "Texture matrix";
prop.label.push_back( char( '0' + i ) );
prop.value.setMatrix4( _TexUserMat->TexMat[ i ].get() );
p->addProperty( prop );
}
}
for( int i = 0; i < _LightMaps.size(); i++ )
{
const CLightMap &lm = _LightMaps[ i ];
ITexture *t = lm.Texture.getPtr();
CTextureFile *cf = dynamic_cast< CTextureFile* >( t );
if( cf != NULL )
{
prop.type = SDynMaterialProp::Texture;
prop.prop = "lightmap";
prop.prop.push_back( char( '0' + i ) );
prop.label = "Lightmap";
prop.prop.push_back( char( '0' + i ) );
prop.value.setString( cf->getFileName() );
p->addProperty( prop );
}
prop.type = SDynMaterialProp::Color;
prop.prop = "lmfactor";
prop.prop.push_back( char( '0' + i ) );
prop.label = "LMFactor";
prop.label.push_back( char( '0' + i ) );
lm.Factor.toFloatVector( v );
prop.value.setVector4( v );
p->addProperty( prop );
prop.prop = "lmcambient";
prop.prop.push_back( char( '0' + i ) );
prop.label = "LMCAmbient";
prop.label.push_back( char( '0' + i ) );
lm.LMCAmbient.toFloatVector( v );
prop.value.setVector4( v );
p->addProperty( prop );
prop.prop = "lmcdiffuse";
prop.prop.push_back( char( '0' + i ) );
prop.label = "LMCDiffuse";
prop.label.push_back( char( '0' + i ) );
lm.LMCDiffuse.toFloatVector( v );
prop.value.setVector4( v );
p->addProperty( prop );
}
}
void CMaterial::createCleanDynMat()
{
if( dynMat == NULL )
dynMat = new CDynMaterial();
else
dynMat->reconstruct();
}
}

@ -97,7 +97,7 @@ MUL R6, v[2], R1; \n\
\n\
#normalize the second vector \n\
DP3 R1, R6, v[9]; \n\
MAD R1, R6, -R1, v[9]; #subtract the normal component, Gramm-Schmidt process \n\
MAD R1, R6, -R1, v[9]; #subtract the normal component \n\
DP3 R2, R1, R1; \n\
RSQ R2, R2.x; \n\
MUL R5, R1, R2; #second basis vector in R5 \n\

@ -1,102 +0,0 @@
// 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 +0,0 @@
// 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 +0,0 @@
// 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 +0,0 @@
// 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 +0,0 @@
// 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 +0,0 @@
// 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;
}
}
}
}

@ -6,7 +6,6 @@ ADD_SUBDIRECTORY(log)
ADD_SUBDIRECTORY(disp_sheet_id)
ADD_SUBDIRECTORY(object_viewer)
ADD_SUBDIRECTORY(georges_editor)
ADD_SUBDIRECTORY(material_editor)
ADD_SUBDIRECTORY(world_editor)
IF(WITH_GUI)

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ActionEditor</class>
<widget class="QWidget" name="ActionEditor">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>340</width>
<height>145</height>
</rect>
</property>
<property name="windowTitle">
<string>Action Editor</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Handler</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="handlerEdit">
<property name="text">
<string>Handler</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Parameters</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="paramsEdit">
<property name="text">
<string>Parameters</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Conditions</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="condEdit">
<property name="text">
<string>Conditions</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>11</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="okButton">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>38</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
<zorder>verticalSpacer</zorder>
<zorder></zorder>
</widget>
<resources/>
<connections/>
</ui>

@ -1,79 +0,0 @@
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${QT_INCLUDES}
)
FILE(GLOB SRC *.cpp *.h)
SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
SET(OVQT_PLUGIN_MATERIAL_EDITOR_HDR
material_editor_context.h
material_editor_plugin.h
material_editor_window.h
material_editor_core_listener.h
material_properties.h
material_property_editor.h
material_widget.h
material_splitter.h
render_passes.h
shader_editor.h
shader_widget.h
prop_browser_ctrl.h
viewport_widget.h
fog_widget.h
lights_widget.h
)
SET(OVQT_PLUGIN_MATERIAL_EDITOR_UIS
material_editor_window.ui
material_properties.ui
material_property_editor.ui
material_widget.ui
render_passes.ui
shader_editor.ui
shader_widget.ui
fog_widget.ui
lights_widget.ui
)
SET(QT_USE_QTGUI TRUE)
SET(QT_USE_QTOPENGL TRUE)
QT4_ADD_RESOURCES(OVQT_PLUGIN_MATERIAL_EDITOR_RC_SRCS ${OVQT_PLUGIN_MATERIAL_EDITOR_RCS})
QT4_WRAP_CPP(OVQT_PLUGIN_MATERIAL_EDITOR_MOC_SRC ${OVQT_PLUGIN_MATERIAL_EDITOR_HDR})
QT4_WRAP_UI(OVQT_PLUGIN_MATERIAL_EDITOR_UI_HDRS ${OVQT_PLUGIN_MATERIAL_EDITOR_UIS})
SOURCE_GROUP(QtResources FILES ${OVQT_PLUGIN_MATERIAL_EDITOR_UIS})
SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_PLUGIN_MATERIAL_EDITOR_UI_HDRS})
SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${OVQT_PLUGIN_MATERIAL_EDITOR_MOC_SRC} OVQT_PLUGIN_MATERIAL_EDITOR_RC_SRCS)
SOURCE_GROUP("Material Editor Plugin" FILES ${SRC})
SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
ADD_LIBRARY(ovqt_plugin_material_editor MODULE ${SRC}
${OVQT_PLUGIN_MATERIAL_EDITOR_MOC_SRC}
${OVQT_EXT_SYS_SRC}
${OVQT_PLUGIN_MATERIAL_EDITOR_UI_HDRS}
${OVQT_PLUGIN_MATERIAL_EDITOR_RC_SRCS}
)
TARGET_LINK_LIBRARIES(
ovqt_plugin_material_editor
ovqt_plugin_core
qt_property_browser
nelmisc
nel3d
${QT_LIBRARIES}
${QT_QTOPENGL_LIBRARY}
)
NL_DEFAULT_PROPS(ovqt_plugin_material_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: Material Editor")
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_material_editor)
NL_ADD_LIB_SUFFIX(ovqt_plugin_material_editor)
ADD_DEFINITIONS(-DMATERIAL_EDITOR_LIBRARY -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS})
INSTALL(TARGETS ovqt_plugin_material_editor LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d)

@ -1,116 +0,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 "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 +0,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/>.
#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,83 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FogWidget</class>
<widget class="QWidget" name="FogWidget">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>278</width>
<height>116</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Fog settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<item row="0" column="0">
<widget class="QCheckBox" name="fogCB">
<property name="text">
<string>Enable fog</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="startSB"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>End</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="endSB"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="colorButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

@ -1,270 +0,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 "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 +0,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/>.
#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,229 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LightsWidget</class>
<widget class="QWidget" name="LightsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>495</width>
<height>434</height>
</rect>
</property>
<property name="windowTitle">
<string>Light settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="2">
<widget class="QCheckBox" name="enableCB">
<property name="text">
<string>Enable</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Type</string>
</property>
<widget class="QComboBox" name="typeCB">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>99</width>
<height>20</height>
</rect>
</property>
</widget>
</widget>
</item>
<item row="2" column="2">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Direction or Position</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>X</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="xSB">
<property name="minimum">
<double>-9999.000000000000000</double>
</property>
<property name="maximum">
<double>9999.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Y</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="ySB">
<property name="minimum">
<double>-9999.000000000000000</double>
</property>
<property name="maximum">
<double>9999.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Z</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="zSB">
<property name="minimum">
<double>-9999.000000000000000</double>
</property>
<property name="maximum">
<double>9999.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="2">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Attenuation</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Constant</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="constAttnButton"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Linear</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="linearAttnButton"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Quadratic</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="quadAttnButton"/>
</item>
</layout>
</widget>
</item>
<item row="4" column="2" rowspan="2">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Color</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Ambient</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="ambientButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Diffuse</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="diffuseButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Specular</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="specularButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0" rowspan="6">
<widget class="QListWidget" name="lightList">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

@ -1,33 +0,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/>.
#ifndef MATERIAL_EDITOR_CONSTANTS_H
#define MATERIAL_EDITOR_CONSTANTS_H
namespace MaterialEditor
{
namespace Constants
{
const char * const GUI_EDITOR_PLUGIN = "MaterialEditor";
const char * const GUI_EDITOR_SECTION = "MaterialEditor";
}
}
#endif

@ -1,58 +0,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_editor_context.h"
#include "material_editor_window.h"
namespace MaterialEditor
{
MaterialEditorContext::MaterialEditorContext( QObject *parent ) :
IContext( parent ),
m_materialEditorWindow( 0 )
{
m_materialEditorWindow = new MaterialEditorWindow();
}
void MaterialEditorContext::open()
{
m_materialEditorWindow->onOpenClicked();
}
void MaterialEditorContext::newDocument()
{
}
void MaterialEditorContext::save()
{
}
void MaterialEditorContext::saveAs()
{
}
void MaterialEditorContext::close()
{
m_materialEditorWindow->close();
}
QWidget *MaterialEditorContext::widget()
{
return m_materialEditorWindow;
}
}

@ -1,64 +0,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/>.
#ifndef MATERIAL_EDITOR_CONTEXT_H
#define MATERIAL_EDITOR_CONTEXT_H
#include "../core/icontext.h"
#include "nel/misc/app_context.h"
#include <QtCore/QObject>
#include <QtGui/QIcon>
namespace MaterialEditor
{
class MaterialEditorWindow;
class MaterialEditorContext: public Core::IContext
{
Q_OBJECT
public:
MaterialEditorContext(QObject *parent = 0);
virtual ~MaterialEditorContext() {}
virtual QString id() const{ return QLatin1String("MaterialEditorContext"); }
virtual QString trName() const{ return tr("Material Editor"); }
virtual QIcon icon() const{ return QIcon(); }
void open();
void newDocument();
void save();
void saveAs();
void close();
virtual QUndoStack *undoStack(){ return NULL; }
virtual QWidget *widget();
MaterialEditorWindow *m_materialEditorWindow;
};
}
#endif

@ -1,28 +0,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_editor_core_listener.h"
#include "material_editor_window.h"
namespace MaterialEditor
{
bool MaterialEditorCoreListener::closeMainWindow() const
{
return mainWindow->close();
}
}

@ -1,41 +0,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/>.
#ifndef MATERIAL_EDITOR_CORE_LISTENER_H
#define MATERIAL_EDITOR_CORE_LISTENER_H
#include "../core/icore_listener.h"
namespace MaterialEditor
{
class MaterialEditorWindow;
class MaterialEditorCoreListener : public Core::ICoreListener
{
Q_OBJECT
public:
MaterialEditorCoreListener( MaterialEditorWindow *mainWindow, QObject *parent = NULL ){ this->mainWindow = mainWindow; }
~MaterialEditorCoreListener(){}
bool closeMainWindow() const;
private:
MaterialEditorWindow *mainWindow;
};
}
#endif

@ -1,30 +0,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/>.
#ifndef MATERIAL_EDITOR_GLOBAL_H
#define MATERIAL_EDITOR_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined( MATERIAL_EDITOR_LIBRARY )
# define MATERIAL_EDITOR_EXPORT Q_DECL_EXPORT
#else
# define MATERIAL_EDITOR_EXPORT Q_DECL_IMPORT
#endif
#endif

@ -1,82 +0,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_editor_plugin.h"
#include "material_editor_window.h"
#include "material_editor_context.h"
#include "material_editor_core_listener.h"
#include "../core/icore.h"
#include "../core/core_constants.h"
#include "nel/misc/debug.h"
#include <QtCore/QObject>
namespace MaterialEditor
{
MaterialEditorPlugin::~MaterialEditorPlugin()
{
Q_FOREACH(QObject *obj, m_autoReleaseObjects)
{
m_plugMan->removeObject(obj);
}
qDeleteAll(m_autoReleaseObjects);
m_autoReleaseObjects.clear();
}
bool MaterialEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
{
Q_UNUSED(errorString);
m_plugMan = pluginManager;
MaterialEditorContext *context = new MaterialEditorContext( this );
MaterialEditorWindow *window = static_cast< MaterialEditorWindow* >( context->widget() );
addAutoReleasedObject( context );
addAutoReleasedObject( new MaterialEditorCoreListener( window, this ) );
return true;
}
void MaterialEditorPlugin::extensionsInitialized()
{
}
void MaterialEditorPlugin::shutdown()
{
}
void MaterialEditorPlugin::setNelContext(NLMISC::INelContext *nelContext)
{
#ifdef NL_OS_WINDOWS
// Ensure that a context doesn't exist yet.
// This only applies to platforms without PIC, e.g. Windows.
nlassert(!NLMISC::INelContext::isContextInitialised());
#endif // NL_OS_WINDOWS
m_libContext = new NLMISC::CLibraryContext(*nelContext);
}
void MaterialEditorPlugin::addAutoReleasedObject(QObject *obj)
{
m_plugMan->addObject(obj);
m_autoReleaseObjects.prepend(obj);
}
}
Q_EXPORT_PLUGIN(MaterialEditor::MaterialEditorPlugin)

@ -1,69 +0,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/>.
#ifndef MATERIAL_EDITOR_PLUGIN_H
#define MATERIAL_EDITOR_PLUGIN_H
#include "material_editor_constants.h"
#include "../../extension_system/iplugin.h"
#include "../core/icontext.h"
#include "nel/misc/app_context.h"
#include <QtCore/QObject>
#include <QtGui/QIcon>
namespace NLMISC
{
class CLibraryContext;
}
namespace ExtensionSystem
{
class IPluginSpec;
}
namespace MaterialEditor
{
class MaterialEditorWindow;
class MaterialEditorPlugin : public QObject, public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_INTERFACES(ExtensionSystem::IPlugin)
public:
virtual ~MaterialEditorPlugin();
bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString);
void extensionsInitialized();
void shutdown();
void setNelContext(NLMISC::INelContext *nelContext);
void addAutoReleasedObject(QObject *obj);
protected:
NLMISC::CLibraryContext *m_libContext;
private:
ExtensionSystem::IPluginManager *m_plugMan;
QList<QObject *> m_autoReleaseObjects;
};
}
#endif

@ -1,381 +0,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_editor_window.h"
#include "material_editor_constants.h"
#include "material_splitter.h"
#include "shader_widget.h"
#include "render_passes.h"
#include "nel3d_interface.h"
#include "viewport_widget.h"
#include "fog_widget.h"
#include "lights_widget.h"
#include "../core/icore.h"
#include "../core/core_constants.h"
#include "../core/core.h"
#include "../core/menu_manager.h"
#include <nel/misc/debug.h>
#include <QSplitter>
#include <QDockWidget>
#include <QFileDialog>
#include <QFileInfo>
#include <QMessageBox>
#include <QTimer>
namespace MaterialEditor
{
MaterialEditorWindow::MaterialEditorWindow(QWidget *parent) :
QMainWindow(parent)
{
m_ui.setupUi(this);
nl3dIface = new CNel3DInterface();
viewPort = new ViewPortWidget();
viewPort->setNel3DInterface( nl3dIface );
shaderWidget = new ShaderWidget();
shaderWidget->setNel3DInterface( nl3dIface );
materialSplitter = new MaterialSplitter();
materialSplitter->setNel3DIface( nl3dIface );
passesWidget = new RenderPassesWidget();
passesWidget->setMaterialObserver( materialSplitter );
passesWidget->setNel3dIface( nl3dIface );
fogWidget = new FogWidget();
fogWidget->setNl3DIface( nl3dIface );
lightsWidget = new LightsWidget();
lightsWidget->setNL3DIface( nl3dIface );
//passesWidget->onMaterialLoaded();
//materialSplitter->onMaterialLoaded();
createMenus();
createDockWidgets();
setupConnections();
setCentralWidget( viewPort );
QTimer::singleShot( 1, this, SLOT( onStartup() ) );
}
MaterialEditorWindow::~MaterialEditorWindow()
{
delete fogWidget;
fogWidget = NULL;
delete lightsWidget;
lightsWidget = NULL;
delete shaderWidget;
shaderWidget = NULL;
delete passesWidget;
passesWidget = NULL;
viewPort = NULL;
delete nl3dIface;
nl3dIface = NULL;
}
void MaterialEditorWindow::onOpenClicked()
{
if( lastShapeDir.isEmpty() )
lastShapeDir = "/";
QString fn = QFileDialog::getOpenFileName(
this,
tr( "Open model" ),
lastShapeDir,
tr( "Shape files ( *.shape )" )
);
if( fn.isEmpty() )
return;
QFileInfo info;
info.setFile( fn );
lastShapeDir = info.absolutePath();
std::string fname = fn.toUtf8().data();
bool ok = nl3dIface->loadShape( fname );
if( !ok )
{
QMessageBox::critical(
this,
tr( "Error loading shape file" ),
tr( "There was an error while loading the shape file." )
);
}
materialSplitter->onShapeChanged();
viewPort->startTimedUpdates( 20 );
}
void MaterialEditorWindow::onNewMaterialClicked()
{
nl3dIface->newMaterial();
materialSplitter->onMaterialLoaded();
passesWidget->onMaterialLoaded();
}
void MaterialEditorWindow::onOpenMaterialClicked()
{
if( lastMatDir.isEmpty() )
lastMatDir = "/";
QString fn = QFileDialog::getOpenFileName(
this,
tr( "Open material" ),
lastMatDir,
tr( "Material files ( *.nelmat )" )
);
if( fn.isEmpty() )
return;
QFileInfo info;
info.setFile( fn );
lastMatDir = info.absolutePath();
bool ok = nl3dIface->loadMaterial( fn.toUtf8().data() );
if( !ok )
{
QMessageBox::critical(
this,
tr( "Error opening material file" ),
tr( "There was an error while trying to open the material file specified!" ),
QMessageBox::Ok
);
}
passesWidget->onMaterialLoaded();
materialSplitter->onMaterialLoaded();
}
void MaterialEditorWindow::onSaveMaterialClicked()
{
QString fn = QFileDialog::getSaveFileName(
this,
tr( "Save material" ),
"/",
tr( "Material files ( *.nelmat )" )
);
if( fn.isEmpty() )
return;
bool ok = nl3dIface->saveMaterial( fn.toUtf8().data() );
if( !ok )
{
QMessageBox::critical(
this,
tr( "Error saving material file" ),
tr( "There was an error while trying to open the material file specified!" ),
QMessageBox::Ok
);
}
}
void MaterialEditorWindow::onGenMaterialsClicked()
{
nl3dIface->genMaterials();
passesWidget->onMaterialLoaded();
materialSplitter->onMaterialLoaded();
}
void MaterialEditorWindow::onShadersClicked()
{
shaderWidget->show();
}
void MaterialEditorWindow::onPassesClicked()
{
passesWidget->show();
}
void MaterialEditorWindow::onStartup()
{
nl3dIface->loadShaders();
shaderWidget->load();
viewPort->init();
}
void MaterialEditorWindow::onAddCubeClicked()
{
if( !nl3dIface->addCube() )
{
QMessageBox::critical(
this,
tr( "Error adding primitive" ),
tr( "There was an error while adding this primitive" )
);
return;
}
materialSplitter->onShapeChanged();
viewPort->startTimedUpdates( 20 );
}
void MaterialEditorWindow::onAddSphereClicked()
{
if( !nl3dIface->addSphere() )
{
QMessageBox::critical(
this,
tr( "Error adding primitive" ),
tr( "There was an error while adding this primitive" )
);
return;
}
materialSplitter->onShapeChanged();
viewPort->startTimedUpdates( 20 );
}
void MaterialEditorWindow::onAddCylinderClicked()
{
if( !nl3dIface->addCylinder() )
{
QMessageBox::critical(
this,
tr( "Error adding primitive" ),
tr( "There was an error while adding this primitive" )
);
return;
}
materialSplitter->onShapeChanged();
viewPort->startTimedUpdates( 20 );
}
void MaterialEditorWindow::onAddTeaPotClicked()
{
if( !nl3dIface->addTeaPot() )
{
QMessageBox::critical(
this,
tr( "Error adding primitive" ),
tr( "There was an error while adding this primitive" )
);
return;
}
materialSplitter->onShapeChanged();
viewPort->startTimedUpdates( 20 );
}
void MaterialEditorWindow::onClearSceneClicked()
{
nl3dIface->clearScene();
materialSplitter->onSceneCleared();
viewPort->stopTimedUpdates();
}
void MaterialEditorWindow::onFogClicked()
{
fogWidget->loadValues();
fogWidget->show();
}
void MaterialEditorWindow::onLightsClicked()
{
lightsWidget->loadValues();
lightsWidget->show();
}
void MaterialEditorWindow::createMenus()
{
Core::MenuManager *mm = Core::ICore::instance()->menuManager();
QMenu *menu = mm->menu( Core::Constants::M_TOOLS );
if( menu != NULL )
{
QMenu *m = menu->addMenu( tr( "Material Editor" ) );
QAction *a;
QMenu *mm = m->addMenu( tr( "Material" ) );
{
a = new QAction( tr( "New material" ), NULL );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onNewMaterialClicked() ) );
mm->addAction( a );
a = new QAction( tr( "Open material" ) , NULL );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onOpenMaterialClicked() ) );
mm->addAction( a );
a = new QAction( tr( "Save material" ), NULL );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onSaveMaterialClicked() ) );
mm->addAction( a );
a = new QAction( tr( "Generate materials" ), NULL );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onGenMaterialsClicked() ) );
mm->addAction( a );
}
mm = m->addMenu( tr( "Scene" ) );
{
QMenu *mmm = mm->addMenu( tr( "Add primitive" ) );
a = new QAction( tr( "Cube" ), NULL );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onAddCubeClicked() ) );
mmm->addAction( a );
a = new QAction( tr( "Sphere" ), NULL );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onAddSphereClicked() ) );
mmm->addAction( a );
a = new QAction( tr( "Cylinder" ), NULL );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onAddCylinderClicked() ) );
mmm->addAction( a );
a = new QAction( tr( "Tea pot" ), NULL );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onAddTeaPotClicked() ) );
mmm->addAction( a );
a = new QAction( tr( "Clear scene" ), NULL );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onClearSceneClicked() ) );
mm->addAction( a );
a = new QAction( tr( "Fog" ), NULL );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onFogClicked() ) );
mm->addAction( a );
a = new QAction( tr( "Lights" ), NULL );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onLightsClicked() ) );
mm->addAction( a );
}
a = new QAction( tr( "Shaders" ), NULL );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onShadersClicked() ) );
m->addAction( a );
a = new QAction( tr( "Render passes" ), NULL );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onPassesClicked() ) );
m->addAction( a );
}
}
void MaterialEditorWindow::createDockWidgets()
{
QDockWidget *dock = new QDockWidget( tr( "Material" ), this );
dock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
dock->setWidget( materialSplitter );
addDockWidget( Qt::RightDockWidgetArea, dock );
}
void MaterialEditorWindow::setupConnections()
{
connect( shaderWidget, SIGNAL( shaderAdded( const QString& ) ),
materialSplitter, SLOT( onShaderAdded( const QString& ) ) );
connect( shaderWidget, SIGNAL( shaderRemoved( const QString& ) ),
materialSplitter, SLOT( onShaderRemoved( const QString& ) ) );
}
}

@ -1,83 +0,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/>.
#ifndef MATERIAL_EDITOR_WINDOW_H
#define MATERIAL_EDITOR_WINDOW_H
#include "ui_material_editor_window.h"
namespace MaterialEditor
{
class ShaderWidget;
class RenderPassesWidget;
class CNel3DInterface;
class MaterialSplitter;
class ViewPortWidget;
class FogWidget;
class LightsWidget;
class MaterialEditorWindow: public QMainWindow
{
Q_OBJECT
public:
MaterialEditorWindow( QWidget *parent = NULL );
~MaterialEditorWindow();
void onOpenClicked();
private Q_SLOTS:
void onNewMaterialClicked();
void onOpenMaterialClicked();
void onSaveMaterialClicked();
void onGenMaterialsClicked();
void onShadersClicked();
void onPassesClicked();
void onStartup();
void onAddCubeClicked();
void onAddSphereClicked();
void onAddCylinderClicked();
void onAddTeaPotClicked();
void onClearSceneClicked();
void onFogClicked();
void onLightsClicked();
private:
void createMenus();
void createDockWidgets();
void setupConnections();
CNel3DInterface *nl3dIface;
ShaderWidget *shaderWidget;
RenderPassesWidget *passesWidget;
MaterialSplitter *materialSplitter;
ViewPortWidget *viewPort;
FogWidget *fogWidget;
LightsWidget *lightsWidget;
Ui::MaterialEditorWindow m_ui;
QString lastShapeDir;
QString lastMatDir;
};
}
#endif

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MaterialEditorWindow</class>
<widget class="QMainWindow" name="MaterialEditorWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout"/>
</widget>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
</widget>
<resources/>
<connections/>
</ui>

@ -1,43 +0,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/>.
#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 +0,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_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 +0,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/>.
#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,183 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MatPropWidget</class>
<widget class="QDialog" name="MatPropWidget">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>685</width>
<height>441</height>
</rect>
</property>
<property name="windowTitle">
<string>Rendering pass properties</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Pass name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="nameEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Pass properties</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTreeWidget" name="treeWidget">
<column>
<property name="text">
<string>Property</string>
</property>
</column>
<column>
<property name="text">
<string>Label</string>
</property>
</column>
<column>
<property name="text">
<string>Type</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="addButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="editButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="okButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

@ -1,73 +0,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_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 +0,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/>.
#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,140 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MatPropEditWidget</class>
<widget class="QWidget" name="MatPropEditWidget">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>300</width>
<height>145</height>
</rect>
</property>
<property name="windowTitle">
<string>Material property editor</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Property</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="propertyEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Label</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="labelEdit"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Type</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QComboBox" name="typeCB">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Color</string>
</property>
</item>
<item>
<property name="text">
<string>Vector4</string>
</property>
</item>
<item>
<property name="text">
<string>Float</string>
</property>
</item>
<item>
<property name="text">
<string>Int</string>
</property>
</item>
<item>
<property name="text">
<string>UInt</string>
</property>
</item>
<item>
<property name="text">
<string>Double</string>
</property>
</item>
<item>
<property name="text">
<string>Matrix4</string>
</property>
</item>
<item>
<property name="text">
<string>Texture</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="okButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="cancelButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="3" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>117</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

@ -1,141 +0,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 +0,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/>.
#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,270 +0,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_widget.h"
#include "shader_editor.h"
#include "material_properties.h"
#include "nel3d_interface.h"
namespace MaterialEditor
{
MaterialWidget::MaterialWidget( QWidget *parent ) :
QWidget( parent )
{
setupUi( this );
shaderEditorWidget = new ShaderEditorWidget();
matPropWidget = new MatPropWidget();
setNel3DIface( NULL );
setupConnections();
}
MaterialWidget::~MaterialWidget()
{
delete shaderEditorWidget;
shaderEditorWidget = NULL;
delete matPropWidget;
matPropWidget = NULL;
}
void MaterialWidget::onSceneCleared()
{
passCB->clear();
subMatCB->clear();
passCB->setEnabled( false );
subMatCB->setEnabled( false );
shaderCB->setEnabled( false );
passButton->setEnabled( false );
shaderButton->setEnabled( false );
}
void MaterialWidget::onNewMaterial()
{
passCB->clear();
passButton->setEnabled( false );
}
void MaterialWidget::onMaterialLoaded()
{
CNelMaterialProxy mat = nl3dIface->getMaterial();
if( mat.isEmpty() )
return;
std::vector< std::string > l;
mat.getPassList( l );
passCB->clear();
std::vector< std::string >::const_iterator itr = l.begin();
while( itr != l.end() )
{
passCB->addItem( itr->c_str() );
++itr;
}
if( passCB->count() > 0 )
passButton->setEnabled( true );
}
void MaterialWidget::onShapeChanged()
{
unsigned long c = nl3dIface->getShapeMatCount();
subMatCB->clear();
subMatCB->addItem( "0" );
for( unsigned long i = 1; i < c; i++ )
subMatCB->addItem( QString::number( i ) );
passCB->setEnabled( true );
passButton->setEnabled( true );
shaderCB->setEnabled( true );
subMatCB->setCurrentIndex( 0 );
if( subMatCB->count() > 1 )
subMatCB->setEnabled( true );
else
subMatCB->setEnabled( false );
}
void MaterialWidget::onPassAdded( const char *name )
{
passCB->addItem( name );
passButton->setEnabled( true );
}
void MaterialWidget::onPassRemoved( const char *name )
{
int i = passCB->findText( name );
if( i == -1 )
return;
passCB->removeItem( i );
if( passCB->count() == 0 )
passButton->setEnabled( false );
}
void MaterialWidget::onPassMovedUp( const char *name )
{
int i = passCB->findText( name );
if( i == -1 )
return;
if( i == 0 )
return;
QString t = passCB->itemText( i - 1 );
passCB->setItemText( i - 1, name );
passCB->setItemText( i, t );
passCB->setCurrentIndex( i - 1 );
}
void MaterialWidget::onPassMovedDown( const char *name )
{
int i = passCB->findText( name );
if( i == -1 )
return;
if( i == ( passCB->count() - 1 ) )
return;
QString t = passCB->itemText( i + 1 );
passCB->setItemText( i + 1, name );
passCB->setItemText( i, t );
passCB->setCurrentIndex( i + 1 );
}
void MaterialWidget::onPassRenamed( const char *from, const char *to )
{
int i = passCB->findText( from );
if( i == -1 )
return;
passCB->setItemText( i, to );
}
void MaterialWidget::onShaderAdded( const QString &name )
{
shaderCB->addItem( name );
}
void MaterialWidget::onShaderRemoved( const QString &name )
{
int i = shaderCB->findText( name );
if( i < 0 )
return;
shaderCB->removeItem( i );
}
void MaterialWidget::setNel3DIface( CNel3DInterface *iface )
{
nl3dIface = iface;
shaderEditorWidget->setNel3DInterface( iface );
}
void MaterialWidget::getCurrentPass( QString &pass )
{
pass = passCB->currentText();
}
void MaterialWidget::setupConnections()
{
connect( passButton, SIGNAL( clicked( bool ) ), this, SLOT( onPassEditClicked() ) );
connect( shaderButton, SIGNAL( clicked( bool ) ), this, SLOT( onShaderEditClicked() ) );
connect( subMatCB, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onSubMatCBChanged( int ) ) );
connect( passCB, SIGNAL( currentIndexChanged( const QString& ) ), this, SLOT( onPassCBChanged( const QString& ) ) );
connect( shaderCB, SIGNAL( currentIndexChanged( const QString& ) ), this, SLOT( onShaderCBChanged( const QString& ) ) );
connect( shaderEditorWidget, SIGNAL( okClicked() ), this, SLOT( onShaderEditOKClicked() ) );
}
void MaterialWidget::onPassEditClicked()
{
if( passCB->count() == 0 )
return;
CNelMaterialProxy m = nl3dIface->getMaterial();
if( m.isEmpty() )
return;
CRenderPassProxy p = m.getPass( passCB->currentText().toUtf8().data() );
matPropWidget->load( &p );
matPropWidget->exec();
if( matPropWidget->getChanged() )
Q_EMIT propsChanged();
}
void MaterialWidget::onShaderEditClicked()
{
if( shaderCB->currentIndex() == 0 )
return;
if( !shaderEditorWidget->load( shaderCB->currentText() ) )
return;
int result = shaderEditorWidget->exec();
}
void MaterialWidget::onSubMatCBChanged( int i )
{
// Update the material to the current submaterial
bool ok = nl3dIface->selectSubMaterial( i );
if( !ok )
{
subMatCB->setCurrentIndex( 0 );
return;
}
onMaterialLoaded();
Q_EMIT subMatChanged( i );
}
void MaterialWidget::onPassCBChanged( const QString &text )
{
if( text.isEmpty() )
return;
CNelMaterialProxy m = nl3dIface->getMaterial();
if( m.isEmpty() )
return;
CRenderPassProxy pass = m.getPass( text.toUtf8().data() );
std::string s;
pass.getShaderRef( s );
int i = shaderCB->findText( s.c_str() );
if( i > 0 )
shaderCB->setCurrentIndex( i );
else
shaderCB->setCurrentIndex( 0 );
Q_EMIT passChanged( text );
}
void MaterialWidget::onShaderCBChanged( const QString &text )
{
QString p = passCB->currentText();
CNelMaterialProxy m = nl3dIface->getMaterial();
if( m.isEmpty() )
return;
CRenderPassProxy pass = m.getPass( p.toUtf8().data() );
pass.setShaderRef( text.toUtf8().data() );
if( !text.isEmpty() )
shaderButton->setEnabled( true );
else
shaderButton->setEnabled( false );
}
}

@ -1,76 +0,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/>.
#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

@ -1,126 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MaterialWidget</class>
<widget class="QWidget" name="MaterialWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>255</width>
<height>179</height>
</rect>
</property>
<property name="windowTitle">
<string>Material</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Sub-material</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QComboBox" name="subMatCB">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>0</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Pass</string>
</property>
</widget>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="passCB">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="passButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Shader</string>
</property>
</widget>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QComboBox" name="shaderCB">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string/>
</property>
</item>
</widget>
</item>
<item>
<widget class="QPushButton" name="shaderButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>18</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

@ -1,743 +0,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 "nel3d_interface.h"
#include "nel/3d/dynamic_material.h"
#include "nel/3d/usr_shader_manager.h"
#include "nel/3d/usr_shader_program.h"
#include "nel/3d/usr_shader_loader.h"
#include "nel/3d/usr_shader_saver.h"
#include "nel/3d/driver_user.h"
#include "nel/3d/scene_user.h"
#include "nel/3d/u_camera.h"
#include "nel/3d/u_instance.h"
#include "nel/3d/u_light.h"
#include "nel/3d/u_3d_mouse_listener.h"
#include "nel/misc/i_xml.h"
#include "nel/misc/o_xml.h"
#include "nel/misc/file.h"
#include "nel/misc/path.h"
namespace MaterialEditor
{
NL3D::UInstance currentShape;
const char *SMatProp::idToString[] =
{
"Color",
"Vector4",
"Float",
"Double",
"Int",
"Uint",
"Matrix4",
"Texture"
};
const NLMISC::CVariant::EVarType evartypes[] =
{
NLMISC::CVariant::Vector4,
NLMISC::CVariant::Vector4,
NLMISC::CVariant::Float,
NLMISC::CVariant::Double,
NLMISC::CVariant::Int,
NLMISC::CVariant::UInt,
NLMISC::CVariant::Matrix4,
NLMISC::CVariant::String
};
NLMISC::CVariant::EVarType toEVarType( uint8 t )
{
NLMISC::CVariant::EVarType rt = NLMISC::CVariant::Float;
unsigned long s = sizeof( evartypes ) / sizeof( NLMISC::CVariant::EVarType );
if( t >= s )
return rt;
else
rt = evartypes[ t ];
return rt;
}
std::string SMatProp::typeIdToString( unsigned char id )
{
if( id >= EType_count )
return std::string();
else
return std::string( idToString[ id ] );
}
unsigned char SMatProp::typeStringToId( const std::string &s )
{
for( unsigned char i = 0; i < EType_count; i++ )
if( s == idToString[ i ] )
return i;
return 0;
}
void CRenderPassProxy::getProperties( std::vector< SMatProp > &v )
{
uint32 count = pass->count();
for( uint32 i = 0; i < count; i++ )
{
const NL3D::SDynMaterialProp &p = *( pass->getProperty( i ) );
SMatProp prop;
prop.id = p.prop;
prop.label = p.label;
prop.type = p.type;
p.value.valueAsString( prop.value );
v.push_back( prop );
}
}
void CRenderPassProxy::setProperties( std::vector< SMatProp > &v )
{
pass->clear();
NL3D::SDynMaterialProp p;
std::vector< SMatProp >::iterator itr = v.begin();
while( itr != v.end() )
{
p.prop = itr->id;
p.label = itr->label;
p.type = itr->type;
p.value.fromString( itr->value, toEVarType( p.type ) );
pass->addProperty( p );
++itr;
}
}
void CRenderPassProxy::getName( std::string &name )
{
pass->getName( name );
}
void CRenderPassProxy::setName( const std::string &name )
{
pass->setName( name );
}
void CRenderPassProxy::getShaderRef( std::string &s )
{
pass->getShaderRef( s );
}
void CRenderPassProxy::setShaderRef( const std::string &s )
{
pass->setShaderRef( s );
}
bool CRenderPassProxy::getProperty( const std::string &name, SMatProp &p )
{
uint32 count = pass->count();
uint32 i = 0;
for( i = 0; i < count; i++ )
{
if( pass->getProperty( i )->prop == name )
break;
}
if( i == count )
return false;
const NL3D::SDynMaterialProp *prop = pass->getProperty( i );
p.id = prop->prop;
p.label = prop->label;
p.type = prop->type;
prop->value.valueAsString( p.value );
return true;
}
bool CRenderPassProxy::changeProperty( const SMatProp &p )
{
NL3D::SDynMaterialProp prop;
prop.prop = p.id;
prop.label = p.label;
prop.type = p.type;
prop.value.fromString( p.value, toEVarType( prop.type ) );
return pass->changeProperty( prop.prop, prop );
}
void CNelMaterialProxy::getPassList( std::vector< std::string > &l )
{
material->getPassList( l );
}
void CNelMaterialProxy::addPass( const char *name )
{
NL3D::SRenderPass pass;
pass.setName( name );
material->addPass( pass );
}
void CNelMaterialProxy::removePass( const char *name )
{
material->removePass( name );
}
void CNelMaterialProxy::movePassUp( const char *name )
{
material->movePassUp( name );
}
void CNelMaterialProxy::movePassDown( const char *name )
{
material->movePassDown( name );
}
void CNelMaterialProxy::renamePass( const char *from, const char *to )
{
material->renamePass( from, to );
}
CRenderPassProxy CNelMaterialProxy::getPass( unsigned long i )
{
if( i >= material->getPassCount() )
return CRenderPassProxy( NULL );
else
return CRenderPassProxy( material->getPass( i ) );
}
CRenderPassProxy CNelMaterialProxy::getPass( const char *name )
{
return CRenderPassProxy( material->getPass( name ) );
}
CNel3DInterface::CNel3DInterface()
{
shaderManager = new NL3D::CUsrShaderManager();
driver = NULL;
scene = NULL;
mouseListener = NULL;
subMatId = 0;
std::fill( bgColor, bgColor + 4, 255 );
}
CNel3DInterface::~CNel3DInterface()
{
delete shaderManager;
shaderManager = NULL;
killViewPort();
}
bool CNel3DInterface::loadMaterial( const char *fname )
{
if( currentShape.empty() )
return false;
NLMISC::CIFile file;
if( !file.open( fname, true ) )
return false;
NLMISC::CIXml xml;
if( !xml.init( file ) )
return false;
NL3D::CDynMaterial *mat = currentShape.getMaterial( subMatId ).getObjectPtr()->getDynMat();
if( mat != NULL )
mat->clear();
else
{
currentShape.getMaterial( subMatId ).getObjectPtr()->createCleanDynMat();
mat = currentShape.getMaterial( subMatId ).getObjectPtr()->getDynMat();
}
mat->serial( xml );
file.close();
return true;
}
bool CNel3DInterface::saveMaterial( const char *fname )
{
if( currentShape.empty() )
return false;
NLMISC::COFile file;
if( !file.open( fname, false, true ) )
return false;
NLMISC::COXml xml;
if( !xml.init( &file ) )
return false;
currentShape.getMaterial( subMatId ).getObjectPtr()->getDynMat()->serial( xml );
xml.flush();
file.close();
return true;
}
void CNel3DInterface::genMaterials()
{
int c = currentShape.getNumMaterials();
for( int i = 0; i < c; i++ )
currentShape.getMaterial( i ).getObjectPtr()->createDynMat();
}
void CNel3DInterface::newMaterial()
{
if( currentShape.empty() )
return;
for( int i = 0; i < currentShape.getNumMaterials(); i++ )
currentShape.getMaterial( i ).getObjectPtr()->createCleanDynMat();
}
bool CNel3DInterface::selectSubMaterial( int id )
{
if( currentShape.empty() )
return false;
if( currentShape.getNumMaterials() < id )
return false;
subMatId = id;
return true;
}
CNelMaterialProxy CNel3DInterface::getMaterial()
{
NL3D::CDynMaterial *mat = NULL;
if( !currentShape.empty() && ( currentShape.getNumMaterials() > 0 ) )
mat = currentShape.getMaterial( subMatId ).getObjectPtr()->getDynMat();
return CNelMaterialProxy( mat );
}
void CNel3DInterface::getShaderList( std::vector< std::string > &v )
{
shaderManager->getShaderList( v );
}
bool CNel3DInterface::getShaderInfo( const std::string &name, SShaderInfo &info )
{
NL3D::CUsrShaderProgram program;
bool ok = shaderManager->getShader( name, &program );
if( !ok )
return false;
std::string s;
info.name = name;
program.getDescription( s );
info.description = s;
program.getVP( s );
info.vp = s;
program.getFP( s );
info.fp = s;
return true;
}
bool CNel3DInterface::updateShaderInfo( const SShaderInfo &info )
{
NL3D::CUsrShaderProgram program;
program.setName( info.name );
program.setDescription( info.description );
program.setVP( info.vp );
program.setFP( info.fp );
return shaderManager->changeShader( info.name, &program );
}
bool CNel3DInterface::addShader( const SShaderInfo &info )
{
NL3D::CUsrShaderProgram *program = new NL3D::CUsrShaderProgram();
program->setName( info.name );
program->setDescription( info.description );
program->setVP( info.vp );
program->setFP( info.fp );
bool ok = shaderManager->addShader( program );
if( !ok )
{
delete program;
return false;
}
return true;
}
bool CNel3DInterface::removeShader( const std::string &name )
{
return shaderManager->removeShader( name );
}
void CNel3DInterface::loadShaders()
{
NL3D::CUsrShaderLoader loader;
loader.setManager( shaderManager );
loader.loadShaders( "./shaders" );
}
void CNel3DInterface::saveShader( const std::string &name )
{
NL3D::CUsrShaderSaver saver;
saver.setManager( shaderManager );
saver.saveShader( "./shaders", name );
NL3D::CDriverUser *d = dynamic_cast< NL3D::CDriverUser* >( driver );
if( d != NULL )
d->getDriver()->reloadUserShaders();
}
void CNel3DInterface::deleteShader( const std::string &name )
{
NLMISC::CFile::deleteFile( "./shaders/" + name + ".nlshdr" );
}
void CNel3DInterface::initViewPort( unsigned long wnd, unsigned long w, unsigned long h )
{
//driver = NL3D::UDriver::createDriver( 0, false, 0 );
driver = NL3D::UDriver::createDriver( 0, NL3D::UDriver::OpenGl3, 0 );
nlassert( driver != NULL );
driver->setDisplay( (nlWindow)wnd, NL3D::UDriver::CMode( w, h, 32 ) );
scene = driver->createScene( true );
driver->enableFog( true );
driver->setupFog( 5.0f, 15.0f, NLMISC::CRGBA::White );
NL3D::ULight *ld;
/*
// Let's add a directional light!
ld = NL3D::ULight::createLight();
ld->setMode( NL3D::ULight::DirectionalLight );
ld->setDirection( NLMISC::CVector( -100.0f, 100.0f, 100.0f ) );
ld->setAmbiant( NLMISC::CRGBA::CRGBA( 0.1f, 0.1f, 0.1f, 0.1f ) );
ld->setSpecular( NLMISC::CRGBA::White );
ld->setDiffuse( NLMISC::CRGBA::White );
driver->setLight( 0, *ld );
driver->enableLight( 0, true );
delete ld;
*/
// Let's add a point light as well!
ld = NL3D::ULight::createLight();
ld->setMode( NL3D::ULight::PointLight );
ld->setPosition( NLMISC::CVector( 0.0f, 0.0f, 0.0f ) );
ld->setAmbiant( NLMISC::CRGBA::CRGBA( 0.1f, 0.1f, 0.1f, 0.1f ) );
ld->setSpecular( NLMISC::CRGBA::White );
ld->setDiffuse( NLMISC::CRGBA::White );
ld->setConstantAttenuation( 1.0f );
ld->setLinearAttenuation( 0.0f );
ld->setQuadraticAttenuation( 0.0f );
driver->setLight( 0, *ld );
driver->enableLight( 0, true );
delete ld;
ld = NULL;
scene->enableLightingSystem( false );
mouseListener = driver->create3dMouseListener();
mouseListener->setMouseMode( NL3D::U3dMouseListener::nelStyle );
}
void CNel3DInterface::killViewPort()
{
driver->deleteScene( scene );
scene = NULL;
driver->delete3dMouseListener( mouseListener );
mouseListener = NULL;
delete driver;
driver = NULL;
}
void CNel3DInterface::resizeViewPort( unsigned long w, unsigned long h )
{
if( scene != NULL )
{
scene->getCam().setPerspective( 90.0f, w / (float)h, 0.1f, 1000.0f );
}
}
bool CNel3DInterface::addCube()
{
return loadShape( "primitives/cube.shape" );
}
bool CNel3DInterface::addSphere()
{
return loadShape( "primitives/sphere.shape" );
}
bool CNel3DInterface::addCylinder()
{
return loadShape( "primitives/cylinder.shape" );
}
bool CNel3DInterface::addTeaPot()
{
return loadShape( "primitives/teapot.shape" );
}
bool CNel3DInterface::loadShape( const std::string &fileName )
{
NLMISC::CPath::addSearchPath( NLMISC::CFile::getPath( fileName ), false, false );
NL3D::UInstance instance = scene->createInstance( fileName );
if( instance.empty() )
return false;
clearScene();
currentShape = instance;
subMatId = 0;
setupCamera();
return true;
}
void CNel3DInterface::clearScene()
{
if( scene != NULL )
{
if( currentShape.empty() )
return;
scene->deleteInstance( currentShape );
currentShape = NL3D::UInstance();
subMatId = 0;
}
if( driver == NULL )
return;
NLMISC::CRGBA c;
c.R = bgColor[ 0 ];
c.G = bgColor[ 1 ];
c.B = bgColor[ 2 ];
c.A = bgColor[ 3 ];
driver->clearBuffers( c );
driver->swapBuffers();
}
void CNel3DInterface::updateInput()
{
driver->EventServer.pump();
}
void CNel3DInterface::renderScene()
{
if( scene != NULL )
{
scene->getCam().setTransformMode( NL3D::UTransformable::DirectMatrix );
scene->getCam().setMatrix( mouseListener->getViewMatrix() );
NLMISC::CRGBA c;
c.R = bgColor[ 0 ];
c.G = bgColor[ 1 ];
c.B = bgColor[ 2 ];
c.A = bgColor[ 3 ];
driver->clearBuffers( c );
scene->render();
driver->swapBuffers();
}
}
unsigned long CNel3DInterface::getShapeMatCount() const
{
if( currentShape.empty() )
return 0;
return currentShape.getNumMaterials();
}
void CNel3DInterface::getFogSettings( SFogSettings &s )
{
s.enable = driver->fogEnabled();
s.start = driver->getFogStart();
s.end = driver->getFogEnd();
NLMISC::CRGBA c = driver->getFogColor();
s.color[ 0 ] = c.R;
s.color[ 1 ] = c.G;
s.color[ 2 ] = c.B;
s.color[ 3 ] = c.A;
}
void CNel3DInterface::setFogSettings( const SFogSettings &s )
{
driver->enableFog( s.enable );
NLMISC::CRGBA c;
c.R = s.color[ 0 ];
c.G = s.color[ 1 ];
c.B = s.color[ 2 ];
c.A = 255;
driver->setupFog( s.start, s.end, c );
setBGColor( c.R, c.G, c.B, c.A );
}
unsigned char CNel3DInterface::getMaxLights() const
{
return driver->getMaxDriverLights();
}
void CNel3DInterface::getLightInfo( unsigned char light, SLightInfo &info )
{
info.enabled = driver->isLightEnabled( light );
NL3D::ULight *u = driver->getLight( light );
info.ambColor[ 0 ] = u->getAmbiant().R / 255.0f;
info.ambColor[ 1 ] = u->getAmbiant().G / 255.0f;
info.ambColor[ 2 ] = u->getAmbiant().B / 255.0f;
info.ambColor[ 3 ] = u->getAmbiant().A / 255.0f;
info.diffColor[ 0 ] = u->getDiffuse().R / 255.0f;
info.diffColor[ 1 ] = u->getDiffuse().G / 255.0f;
info.diffColor[ 2 ] = u->getDiffuse().B / 255.0f;
info.diffColor[ 3 ] = u->getDiffuse().A / 255.0f;
info.specColor[ 0 ] = u->getSpecular().R / 255.0f;
info.specColor[ 1 ] = u->getSpecular().G / 255.0f;
info.specColor[ 2 ] = u->getSpecular().B / 255.0f;
info.specColor[ 3 ] = u->getSpecular().A / 255.0f;
info.constAttn = u->getConstantAttenuation();
info.linAttn = u->getLinearAttenuation();
info.quadAttn = u->getQuadraticAttenuation();
switch( u->getMode() )
{
case NL3D::ULight::DirectionalLight:
info.type = SLightInfo::Directional;
break;
case NL3D::ULight::PointLight:
info.type = SLightInfo::Point;
break;
case NL3D::ULight::SpotLight:
info.type = SLightInfo::Spot;
break;
}
if( info.type == SLightInfo::Directional )
{
info.posOrDir[ 0 ] = u->getDirection().x;
info.posOrDir[ 1 ] = u->getDirection().y;
info.posOrDir[ 2 ] = u->getDirection().z;
}
else
{
info.posOrDir[ 0 ] = u->getPosition().x;
info.posOrDir[ 1 ] = u->getPosition().y;
info.posOrDir[ 2 ] = u->getPosition().z;
}
delete u;
}
void CNel3DInterface::setLightInfo( unsigned char light, const SLightInfo &info )
{
NL3D::ULight *u = NL3D::ULight::createLight();
NLMISC::CRGBA c;
c.R = info.ambColor[ 0 ] * 255.0f;
c.G = info.ambColor[ 1 ] * 255.0f;
c.B = info.ambColor[ 2 ] * 255.0f;
c.A = 255;
u->setAmbiant( c );
c.R = info.diffColor[ 0 ] * 255.0f;
c.G = info.diffColor[ 1 ] * 255.0f;
c.B = info.diffColor[ 2 ] * 255.0f;
u->setDiffuse( c );
c.R = info.specColor[ 0 ] * 255.0f;
c.G = info.specColor[ 1 ] * 255.0f;
c.B = info.specColor[ 2 ] * 255.0f;
u->setSpecular( c );
switch( info.type )
{
case SLightInfo::Directional:
u->setMode( NL3D::ULight::DirectionalLight );
break;
case SLightInfo::Point:
u->setMode( NL3D::ULight::PointLight );
break;
case SLightInfo::Spot:
u->setMode( NL3D::ULight::SpotLight );
break;
}
if( info.type == SLightInfo::Directional )
u->setDirection( NLMISC::CVector( info.posOrDir[ 0 ], info.posOrDir[ 1 ], info.posOrDir[ 2 ] ) );
else
u->setPosition( NLMISC::CVector( info.posOrDir[ 0 ], info.posOrDir[ 1 ], info.posOrDir[ 2 ] ) );
u->setConstantAttenuation( info.constAttn );
u->setLinearAttenuation( info.linAttn );
u->setQuadraticAttenuation( info.quadAttn );
driver->setLight( light, *u );
driver->enableLight( light, info.enabled );
delete u;
u = NULL;
}
void CNel3DInterface::setupCamera()
{
NLMISC::CAABBox bbox;
currentShape.getShapeAABBox( bbox );
NLMISC::CVector center = bbox.getCenter();
NLMISC::CQuat q( 0.0f, 0.0f, 0.0f, 0.0f );
currentShape.getDefaultRotQuat( q );
NLMISC::CVector max_radius = bbox.getHalfSize();
float radius = std::max( max_radius.x, std::max( max_radius.y, max_radius.z ) );
float distance = radius / tan( 45.0f );
NLMISC::CVector axis = q.getAxis();
if( axis.isNull() || ( axis == NLMISC::CVector::I ) )
axis = NLMISC::CVector::J;
else
if( axis == -NLMISC::CVector::K )
axis = -NLMISC::CVector::J;
NLMISC::CVector eye = center - axis * ( radius + distance );
scene->getCam().lookAt( eye, center );
mouseListener->setHotSpot( center );
mouseListener->setMatrix( scene->getCam().getMatrix() );
}
}

@ -1,331 +0,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/>.
#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,10 +0,0 @@
<plugin-spec>
<library-name>ovqt_plugin_material_editor</library-name>
<name>Material Editor</name>
<version>0.0.1</version>
<vendor>Ryzom Core</vendor>
<description>Material Editor plugin.</description>
<dependencies>
<dependency plugin-name="Core" version="0.8"/>
</dependencies>
</plugin-spec>

@ -1,394 +0,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 "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 +0,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/>.
#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 +0,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 "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 +0,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/>.
#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,147 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RenderPassesWidget</class>
<widget class="QWidget" name="RenderPassesWidget">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>498</width>
<height>297</height>
</rect>
</property>
<property name="windowTitle">
<string>Rendering passes</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="addButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="editButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="upButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Up</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="downButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Down</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="okButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

@ -1,90 +0,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 "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 +0,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/>.
#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,127 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ShaderEditorWidget</class>
<widget class="QDialog" name="ShaderEditorWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>861</width>
<height>735</height>
</rect>
</property>
<property name="windowTitle">
<string>Shader Editor</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="nameLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="nameEdit">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QVBoxLayout" name="descrLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="descriptionEdit"/>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QVBoxLayout" name="vsLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Vertex Shader</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="vsEdit"/>
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QVBoxLayout" name="fsLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Fragment Shader</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="fsEdit"/>
</item>
</layout>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="okButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>468</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

@ -1,220 +0,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 "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 +0,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/>.
#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,116 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ShaderWidget</class>
<widget class="QWidget" name="ShaderWidget">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>502</width>
<height>401</height>
</rect>
</property>
<property name="windowTitle">
<string>Shaders</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Shaders</string>
</property>
</widget>
</item>
<item row="1" column="0" rowspan="4" colspan="2">
<widget class="QListWidget" name="shaderList"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="addButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="removeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="editButton">
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
<item row="4" column="2" rowspan="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>123</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QPlainTextEdit" name="description"/>
</item>
<item row="7" column="0">
<widget class="QPushButton" name="okButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item row="7" column="1" colspan="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>664</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

@ -1,154 +0,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 "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 +0,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/>.
#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

@ -23,7 +23,6 @@
#include "nel/3d/skeleton_shape.h"
#include "nel/3d/vegetable_shape.h"
#include "nel/3d/lod_character_shape.h"
#include "nel/3d/shape_material_serializer.h"
#include "../nel_mesh_lib/export_nel.h"
#include "../nel_mesh_lib/export_appdata.h"
@ -92,10 +91,9 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time)
InfoLog->display("Beg buildShape %s \n", node.GetName());
// Export in mesh format
IShape *pShape = _ExportNel->buildShape(node, time, mapIdPtr, true);
if (InfoLog)
InfoLog->display("End buildShape in %d ms \n", timeGetTime()-t);
// Conversion success ?
if (pShape)
{
@ -138,11 +136,6 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time)
nelExportTerminateProcess();
}
// Export here
ShapeMatSerial sms;
sms.setShape( pShape );
sms.serial( sPath );
// Delete the pointer
nldebug("Delete the pointer");
try

@ -23,7 +23,6 @@
#include "nel/3d/texture_cube.h"
#include "nel/3d/tangent_space_build.h"
#include "nel/3d/meshvp_per_pixel_light.h"
#include "nel/3d/dyn_mat_loader.h"
#include <vector>
#include <string>
@ -278,19 +277,6 @@ void CExportNel::buildAMaterial (NL3D::CMaterial& material, CMaxMaterialInfo& ma
// It is a NeL material ?
if (isClassIdCompatible (mtl, Class_ID(NEL_MTL_A,NEL_MTL_B)))
{
std::string sMaterialFile;
if( CExportNel::getValueByNameUsingParamBlock2( mtl, "sMaterialFile", (ParamType2)TYPE_STRING, &sMaterialFile, time ) )
{
if( !sMaterialFile.empty() )
{
nlinfo( "Using material file %s", sMaterialFile.c_str() );
CDynMatLoader loader;
if( loader.loadFrom( sMaterialFile ) )
material.setDynMat( loader.getDynMat() );
else
nlinfo( "Error loading material file %s", sMaterialFile.c_str() );
}
}
// Get the shader value now
int iShaderType = 0;

@ -349,7 +349,6 @@ plugin material NelMaterial
cSelfIllumColor type:#color
pSelfIllumAmount type:#percent
bUseSelfIllumColor type:#boolean
sMaterialFile type:#string default:""
)
parameters main rollout:NelParams
@ -549,12 +548,6 @@ plugin material NelMaterial
Label lblNlbpB "http://dev.ryzom.com/" align:#center
CheckBox cbTwoSided "2-Sided" checked:false align:#right
group "Material file"
(
edittext mfEdit
button materialButton "browse"
)
group "Standard Lighting"
(
-- Label lblNlbpslA "Diffuse is the color in light, ambient in the dark." align:#right
@ -581,49 +574,6 @@ plugin material NelMaterial
CheckBox cbUseSelfIllumColor "Use Color" checked:false align:#right
)
on materialButton pressed do
(
fname = getOpenFileName caption:"Open material file" types:"Nel material (*.nelmat)"
if fname == undefined then (
if mfEdit.text == "" then
sMaterialFile = ""
)
else
sMaterialFile = fname
mfEdit.text = sMaterialFile
)
on cbTwoSided changed bval do
updateUI false
on cpAmbient changed cval do
updateUI false
on cpDiffuse changed cval do
updateUI false
on spOpacity changed pval do
updateUI false
on cpSpecular changed cval do
updateUI false
on spSpecularLevel changed pval do
updateUI false
on spGlossiness changed pval do
updateUI false
on cpSelfIllumColor changed cval do
updateUI false
on spSelfIllumAmount changed bval do
updateUI false
on cbUseSelfIllumColor changed bval do
updateUI false
Fn updateUI update =
(
if (version >= 14) then
@ -631,7 +581,6 @@ plugin material NelMaterial
if update == true then
(
cbTwoSided.checked = bTwoSided
mfEdit.text = sMaterialFile
cpAmbient.color = cAmbient
cpDiffuse.color = cDiffuse
spOpacity.value = pOpacity
@ -648,7 +597,6 @@ plugin material NelMaterial
else
(
bTwoSided = cbTwoSided.checked
sMaterial = mfEdit.text
cAmbient = cpAmbient.color
cDiffuse = cpDiffuse.color
pOpacity = spOpacity.value
@ -677,6 +625,36 @@ plugin material NelMaterial
)
)
on cbTwoSided changed bval do
updateUI false
on cpAmbient changed cval do
updateUI false
on cpDiffuse changed cval do
updateUI false
on spOpacity changed pval do
updateUI false
on cpSpecular changed cval do
updateUI false
on spSpecularLevel changed pval do
updateUI false
on spGlossiness changed pval do
updateUI false
on cpSelfIllumColor changed cval do
updateUI false
on spSelfIllumAmount changed bval do
updateUI false
on cbUseSelfIllumColor changed bval do
updateUI false
on nelBasicParameters open do
(
updateUI true

Loading…
Cancel
Save