Added skeleton for CDynMaterial. This class will be the new material.
--HG-- branch : gsoc2013-dfighterhg/feature/gsoc2013-dfighter
parent
40c95e82ff
commit
32071d9053
@ -0,0 +1,66 @@
|
||||
// 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 <string>
|
||||
#include <vector>
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
|
||||
struct CDynMaterialProp
|
||||
{
|
||||
enum EPropertyType
|
||||
{
|
||||
Color,
|
||||
Vector4,
|
||||
Float,
|
||||
Double,
|
||||
Int,
|
||||
Uint,
|
||||
Matrix4,
|
||||
Texture
|
||||
};
|
||||
|
||||
std::string prop;
|
||||
std::string label;
|
||||
uint8 type;
|
||||
std::string value;
|
||||
};
|
||||
|
||||
class CDynMaterial : public NLMISC::IStreamable
|
||||
{
|
||||
public:
|
||||
CDynMaterial();
|
||||
~CDynMaterial();
|
||||
void serial( NLMISC::IStream &f );
|
||||
|
||||
void addProperty( const CDynMaterialProp &prop );
|
||||
void removeProperty( const std::string &name );
|
||||
void changeProperty( const std::string &name, const CDynMaterialProp &prop );
|
||||
|
||||
private:
|
||||
std::vector< CDynMaterialProp > properties;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -0,0 +1,95 @@
|
||||
// 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
|
||||
{
|
||||
CDynMaterial::CDynMaterial()
|
||||
{
|
||||
}
|
||||
|
||||
CDynMaterial::~CDynMaterial()
|
||||
{
|
||||
}
|
||||
|
||||
void CDynMaterial::serial( NLMISC::IStream &f )
|
||||
{
|
||||
int version = f.serialVersion( 1 );
|
||||
|
||||
std::vector< CDynMaterialProp >::const_iterator itr = properties.begin();
|
||||
while( itr != properties.end() )
|
||||
{
|
||||
f.serial( std::string( itr->prop ) );
|
||||
f.serial( std::string( itr->label ) );
|
||||
f.serial( uint8( itr->type ) );
|
||||
f.serial( std::string( itr->value ) );
|
||||
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
void CDynMaterial::addProperty( const CDynMaterialProp &prop )
|
||||
{
|
||||
std::vector< CDynMaterialProp >::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 CDynMaterial::removeProperty( const std::string &name )
|
||||
{
|
||||
std::vector< CDynMaterialProp >::iterator itr = properties.begin();
|
||||
while( itr != properties.end() )
|
||||
{
|
||||
if( itr->prop == name )
|
||||
break;
|
||||
++itr;
|
||||
}
|
||||
if( itr == properties.end() )
|
||||
return;
|
||||
|
||||
properties.erase( itr );
|
||||
}
|
||||
|
||||
void CDynMaterial::changeProperty( const std::string &name, const CDynMaterialProp &prop )
|
||||
{
|
||||
std::vector< CDynMaterialProp >::iterator itr = properties.begin();
|
||||
while( itr != properties.end() )
|
||||
{
|
||||
if( itr->prop == name )
|
||||
break;
|
||||
++itr;
|
||||
}
|
||||
if( itr == properties.end() )
|
||||
return;
|
||||
|
||||
itr->prop = prop.prop;
|
||||
itr->label = prop.label;
|
||||
itr->type = prop.type;
|
||||
itr->value = prop.value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue