The 3dsmax exporter will now use the material file specified in the Nel material.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 12 years ago
parent f94960dffe
commit 0c64261e22

@ -0,0 +1,45 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef DYN_MAT_LOADER_H
#define DYN_MAT_LOADER_H
#include <string>
namespace NL3D
{
class CDynMaterial;
class CDynMatLoader
{
public:
CDynMatLoader();
~CDynMatLoader();
bool loadFrom( const std::string &fileName );
CDynMaterial* getDynMat() const{ return mat; }
private:
CDynMaterial *mat;
};
}
#endif

@ -81,6 +81,8 @@ namespace NL3D
public:
CDynMaterial();
~CDynMaterial();
CDynMaterial& operator=( const CDynMaterial &other );
void reconstruct();
void clear();
void serial( NLMISC::IStream &f );

@ -262,7 +262,7 @@ public:
*/
CMaterial();
/// see operator=.
CMaterial(const CMaterial &mat) : CRefCount() {_Touched= 0;_Flags=0; operator=(mat);}
CMaterial(const CMaterial &mat);
/// dtor.
~CMaterial();
/// Do not copy DrvInfos, copy all infos and set IDRV_TOUCHED_ALL.
@ -701,6 +701,7 @@ private:
public:
CDynMaterial* getDynMat() const{ return dynMat; }
void setDynMat( CDynMaterial *newDynMat ){ dynMat = newDynMat; }
/// Create the dynamic material from the current material parameters
void createDynMat();

@ -146,6 +146,8 @@ SOURCE_GROUP(Driver FILES
../../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

@ -0,0 +1,61 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nel/3d/dyn_mat_loader.h"
#include "nel/3d/dynamic_material.h"
#include "nel/misc/file.h"
#include "nel/misc/i_xml.h"
namespace NL3D
{
CDynMatLoader::CDynMatLoader()
{
mat = NULL;
}
CDynMatLoader::~CDynMatLoader()
{
mat = NULL;
}
bool CDynMatLoader::loadFrom( const std::string &fileName )
{
NLMISC::CIFile ifile;
if( !ifile.open( fileName, true ) )
{
nlinfo( "Error opening file %s", fileName.c_str() );
return false;
}
NLMISC::CIXml xml;
if( !xml.init( ifile ) )
{
ifile.close();
nlinfo( "Error initializing XML stream for file %s", fileName.c_str() );
return false;
}
mat = new CDynMaterial();
mat->serial( xml );
ifile.close();
return true;
}
}

@ -158,6 +158,25 @@ namespace NL3D
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();
@ -201,6 +220,7 @@ namespace NL3D
}
else
{
clear();
uint32 n;
f.xmlPush( "count" );
f.serial( n );

@ -53,6 +53,15 @@ CMaterial::CMaterial()
dynMat = NULL;
}
CMaterial::CMaterial( const CMaterial &mat ) :
CRefCount()
{
_Touched= 0;
_Flags=0;
dynMat = NULL;
operator=(mat);
}
// ***************************************************************************
void CMaterial::initUnlit()
{
@ -123,7 +132,13 @@ CMaterial &CMaterial::operator=(const CMaterial &mat)
// All states of material is modified.
_Touched= IDRV_TOUCHED_ALL;
dynMat = NULL;
if( mat.dynMat != NULL )
{
if( dynMat == NULL )
dynMat = new CDynMaterial();
*dynMat = *mat.dynMat;
}
return *this;
}
@ -178,8 +193,6 @@ void CMaterial::serial(NLMISC::IStream &f)
- base version.
*/
dynMat = NULL;
sint ver= f.serialVersion(9);
// For the version <=1:
nlassert(IDRV_MAT_MAXTEXTURES==4);

@ -58,8 +58,13 @@ namespace NL3D
for( int i = 0; i < n; i++ )
{
CMaterial &m = mb->getMaterial( i );
m.createDynMat();
CDynMaterial *dm = m.getDynMat();
if( dm == NULL )
{
m.createDynMat();
dm = m.getDynMat();
}
fname = path + "_";
fname += char( '0' + i );
fname += ".nelmat";

@ -22,6 +22,7 @@
#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>
@ -276,6 +277,19 @@ 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;

Loading…
Cancel
Save