Include :
- modifiche per materiali.
This commit is contained in:
+6
-1
@@ -51,6 +51,10 @@ class Color
|
||||
m_Col[GREEN] = (( dGreen < 0) ? 0 : (( dGreen > 1) ? MAX_RGB : int( dGreen * MAX_RGB))) ;
|
||||
m_Col[BLUE] = (( dBlue < 0) ? 0 : (( dBlue > 1) ? MAX_RGB : int( dBlue * MAX_RGB))) ;
|
||||
m_Col[ALPHA] = (( dAlpha < 0) ? 0 : (( dAlpha > 1) ? MAX_ALPHA : int( dAlpha * MAX_ALPHA))) ; }
|
||||
void SetAlpha( int nAlpha)
|
||||
{ m_Col[ALPHA] = (( nAlpha < 0) ? 0 : (( nAlpha > MAX_ALPHA) ? MAX_ALPHA : nAlpha)) ; }
|
||||
void SetAlpha( double dAlpha)
|
||||
{ m_Col[ALPHA] = (( dAlpha < 0) ? 0 : (( dAlpha > 1) ? MAX_ALPHA : int( dAlpha * MAX_ALPHA))) ; }
|
||||
int GetIntRed( void) const
|
||||
{ return m_Col[RED] ; }
|
||||
int GetIntGreen( void) const
|
||||
@@ -105,4 +109,5 @@ const Color BROWN( 150, 75, 0) ;
|
||||
//----------------------------------------------------------------------------
|
||||
EGK_EXPORT bool GetStdColor( const std::string& sName, Color& cCol) ;
|
||||
EGK_EXPORT bool GetNameOfStdColor( Color cCol, std::string& sName) ;
|
||||
EGK_EXPORT Color GetOppositeColor( Color cCol) ;
|
||||
EGK_EXPORT Color GetOppositeColor( Color cCol) ;
|
||||
EGK_EXPORT Color GetSurfBackColor( Color cCol) ;
|
||||
|
||||
@@ -47,6 +47,7 @@ enum GdbMark { GDB_MK_OFF = 0,
|
||||
enum GdbMaterial { GDB_MT_COLOR = -1,
|
||||
GDB_MT_PARENT = 0} ;
|
||||
// valori positivi indicano indici nella lista dei materiali (1 based)
|
||||
const int GDB_MT_NULL = GDB_MT_PARENT ;
|
||||
|
||||
//----------------- Costanti flag di BBox --------------------------------------
|
||||
enum BBoxFlag { BBF_NONE = 0,
|
||||
|
||||
@@ -68,10 +68,13 @@ class __declspec( novtable) IGdbIterator
|
||||
virtual bool GetMark( int& nMark) const = 0 ;
|
||||
virtual bool GetCalcMark( int& nMark) const = 0 ;
|
||||
virtual bool SetMaterial( int nMat) = 0 ;
|
||||
virtual bool SetMaterial( int nMat, const std::string& sMatName) = 0 ;
|
||||
virtual bool SetMaterial( Color cCol) = 0 ;
|
||||
virtual bool GetMaterial( int& nMat) const = 0 ;
|
||||
virtual bool GetMaterial( Material& mMat) const = 0 ;
|
||||
virtual bool GetMaterial( Color& cCol) const = 0 ;
|
||||
virtual bool GetCalcMaterial( int& nMat) const = 0 ;
|
||||
virtual bool GetCalcMaterial( Material& mMat) const = 0 ;
|
||||
virtual bool GetCalcMaterial( Color& cCol) const = 0 ;
|
||||
virtual bool SetName( const std::string& sName) = 0 ;
|
||||
virtual bool GetName( std::string& sName) const = 0 ;
|
||||
|
||||
+17
-4
@@ -1,13 +1,13 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2013
|
||||
// EgalTech 2013-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : EGkGeomDB.h Data : 24.11.13 Versione : 1.3a1
|
||||
// File : EGkGeomDB.h Data : 26.04.14 Versione : 1.5d7
|
||||
// Contenuto : Dichiarazione della interfaccia IGeomDB.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 24.11.13 DS Creazione modulo.
|
||||
//
|
||||
// 26.04.14 DS Agg. gestione libreria materiali.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "/EgtDev/Include/EGkGdbConst.h"
|
||||
#include "/EgtDev/Include/EGkGeoFrame3d.h"
|
||||
#include "/EgtDev/Include/EGkGeoObj.h"
|
||||
#include "/EgtDev/Include/EGkColor.h"
|
||||
#include "/EgtDev/Include/EGkMaterial.h"
|
||||
#include "/EgtDev/Include/EGtILogger.h"
|
||||
#include <string>
|
||||
|
||||
@@ -102,10 +102,13 @@ class __declspec( novtable) IGeomDB
|
||||
virtual bool SetDefaultMaterial( Color cCol) = 0 ;
|
||||
virtual bool GetDefaultMaterial( Color& cCol) const = 0 ;
|
||||
virtual bool SetMaterial( int nId, int nMat) = 0 ;
|
||||
virtual bool SetMaterial( int nId, const std::string& sMatName) = 0 ;
|
||||
virtual bool SetMaterial( int nId, Color cCol) = 0 ;
|
||||
virtual bool GetMaterial( int nId, int& nMat) const = 0 ;
|
||||
virtual bool GetMaterial( int nId, Material& mMat) const = 0 ;
|
||||
virtual bool GetMaterial( int nId, Color& cCol) const = 0 ;
|
||||
virtual bool GetCalcMaterial( int nId, int& nMat) const = 0 ;
|
||||
virtual bool GetCalcMaterial( int nId, Material& mMat) const = 0 ;
|
||||
virtual bool GetCalcMaterial( int nId, Color& cCol) const = 0 ;
|
||||
virtual bool SetName( int nId, const std::string& sName) = 0 ;
|
||||
virtual bool GetName( int nId, std::string& sName) const = 0 ;
|
||||
@@ -113,6 +116,16 @@ class __declspec( novtable) IGeomDB
|
||||
virtual bool SetInfo( int nId, const std::string& sKey, const std::string& sInfo) = 0 ;
|
||||
virtual bool GetInfo( int nId, const std::string& sKey, std::string& sInfo) const = 0 ;
|
||||
virtual bool RemoveInfo( int nId, const std::string& sKey) = 0 ;
|
||||
// material library
|
||||
virtual int AddMaterial( const std::string& sName, const Material& matM) = 0 ;
|
||||
virtual int FindMaterial( const std::string& sName) const = 0 ;
|
||||
virtual bool EraseMaterial( int nMat, bool& bInUse) = 0 ;
|
||||
virtual bool GetMaterialData( int nMat, Material& matM) const = 0 ;
|
||||
virtual bool GetMaterialName( int nMat, std::string& sName) const = 0 ;
|
||||
virtual bool ExistsMaterial( int nMat) const = 0 ;
|
||||
virtual bool IsCustomMaterial( int nMat, bool& bCustom) const = 0 ;
|
||||
virtual bool ModifyMaterialData( int nMat, const Material& matM) = 0 ;
|
||||
virtual bool ModifyMaterialName( int nMat, const std::string& sName) = 0 ;
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : EGkMaterial.h Data : 23.04.14 Versione : 1.5d7
|
||||
// Contenuto : Implementazione della classe Material.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 23.04.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EGkColor.h"
|
||||
|
||||
//----------------------- Macro per import/export ----------------------------
|
||||
#undef EGK_EXPORT
|
||||
#if defined( I_AM_EGK) // da definirsi solo nella DLL
|
||||
#define EGK_EXPORT __declspec( dllexport)
|
||||
#else
|
||||
#define EGK_EXPORT __declspec( dllimport)
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
const int MAX_SHIN = 128 ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class Material
|
||||
{
|
||||
public :
|
||||
Material( void) : m_colAmb( Color()), m_colDiff( Color()), m_colSpec( Color()), m_fShin( 64)
|
||||
{}
|
||||
Material( Color colAmb, Color colDiff, Color colSpec, double dShin)
|
||||
{ Set( colAmb, colDiff, colSpec, dShin) ; }
|
||||
Material( Color colC)
|
||||
{ Set( colC) ; }
|
||||
void Set( void)
|
||||
{ m_colAmb = Color() ; m_colDiff = Color() ; m_colSpec = Color() ; }
|
||||
void Set( Color colAmb, Color colDiff, Color colSpec, double dShin)
|
||||
{ m_colAmb = colAmb ; m_colDiff = colDiff ; m_colSpec = colSpec ; AdjustAlpha() ;
|
||||
m_fShin = float( dShin) ; AdjustShin() ; }
|
||||
void Set( Color colC)
|
||||
{ m_colAmb = colC ; m_colDiff = colC ; m_colSpec = Color( 192, 192, 192) ; AdjustAlpha() ;
|
||||
m_fShin = 64 ; }
|
||||
void SetAmbient( Color colAmb)
|
||||
{ m_colAmb = colAmb ; AdjustAlpha() ; }
|
||||
void SetDiffuse( Color colDiff)
|
||||
{ m_colDiff = colDiff ; AdjustAlpha() ; }
|
||||
void SetSpecular( Color colSpec)
|
||||
{ m_colSpec = colSpec ; AdjustAlpha() ; }
|
||||
void SetAlpha( int nAlpha)
|
||||
{ m_colDiff.SetAlpha( nAlpha) ; AdjustAlpha() ; }
|
||||
void SetAlpha( double dAlpha)
|
||||
{ m_colDiff.SetAlpha( dAlpha) ; AdjustAlpha() ; }
|
||||
void SetShininess( int nShin)
|
||||
{ m_fShin = float( nShin) ; AdjustShin() ; }
|
||||
void SetShininess( double dShin)
|
||||
{ m_fShin = float( dShin) ; AdjustShin() ; }
|
||||
Color GetAmbient( void) const
|
||||
{ return m_colAmb ; }
|
||||
Color GetDiffuse( void) const
|
||||
{ return m_colDiff ; }
|
||||
Color GetSpecular( void) const
|
||||
{ return m_colSpec ; }
|
||||
float GetAlpha( void) const
|
||||
{ return m_colDiff.GetAlpha() ; }
|
||||
float GetShininess( void) const
|
||||
{ return m_fShin ; }
|
||||
bool operator == ( const Material& other) const
|
||||
{ return ( m_colAmb == other.m_colAmb &&
|
||||
m_colDiff == other.m_colDiff &&
|
||||
m_colSpec == other.m_colSpec) ; }
|
||||
|
||||
private :
|
||||
void AdjustAlpha( void)
|
||||
{ m_colAmb.SetAlpha( m_colDiff.GetAlpha()) ; m_colSpec.SetAlpha( m_colDiff.GetAlpha()) ; }
|
||||
void AdjustShin( void)
|
||||
{ m_fShin = (( m_fShin < 0) ? 0 : (( m_fShin > MAX_SHIN) ? MAX_SHIN : m_fShin)) ; }
|
||||
|
||||
private :
|
||||
Color m_colAmb ; // solo RGB
|
||||
Color m_colDiff ; // RGBA ( alpha del materiale)
|
||||
Color m_colSpec ; // solo RGB
|
||||
float m_fShin ; // lucentezza (scala 0-128)
|
||||
} ;
|
||||
@@ -60,6 +60,13 @@ ToLower( std::string& sString)
|
||||
{ std::transform( sString.begin(), sString.end(), sString.begin(), ::tolower) ;
|
||||
return sString ; }
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline bool
|
||||
IsValidName( const std::string& sName)
|
||||
{ if ( sName.empty())
|
||||
return false ;
|
||||
return ( sName.find_first_of( "\\/:*?\"<>|", 0) == std::string::npos) ; }
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline bool
|
||||
FromString( const std::string& sVal, int& nVal)
|
||||
|
||||
Reference in New Issue
Block a user