740392c456
- aggiunte funzioni per gestire dati per textures su oggetti - aggiornato formato Nge per salvare questi dati.
112 lines
3.3 KiB
C++
112 lines
3.3 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : TextureData.cpp Data : 04.10.15 Versione : 1.6j1
|
|
// Contenuto : Implementazione della classe TextureData.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 04.10.15 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "TextureData.h"
|
|
#include "NgeWriter.h"
|
|
#include "NgeReader.h"
|
|
#include "GeomDB.h"
|
|
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
|
#include "/EgtDev/Include/EGkUiUnits.h"
|
|
#include "/EgtDev/Include/EgnStringKeyVal.h"
|
|
|
|
using namespace std ;
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
TextureData::Dump( const GeomDB& GDB, string& sOut, bool bMM, const char* szNewLine) const
|
|
{
|
|
// nome della texture
|
|
sOut += "Texture Name=" ;
|
|
sOut += m_sTxrName ;
|
|
sOut += szNewLine ;
|
|
// riferimento della texture
|
|
sOut += "O(" + ToString( GetInUiUnits( m_frTxrRef.Orig(), bMM)) + ")" + szNewLine ;
|
|
sOut += "VX(" + ToString( m_frTxrRef.VersX()) + ")" + szNewLine ;
|
|
sOut += "VY(" + ToString( m_frTxrRef.VersY()) + ")" + szNewLine ;
|
|
sOut += "VZ(" + ToString( m_frTxrRef.VersZ()) + ")" + szNewLine ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
TextureData::Save( NgeWriter& ngeOut) const
|
|
{
|
|
// flag presenza dati di texture
|
|
if ( ! ngeOut.WriteKey( NGE_T))
|
|
return false ;
|
|
// nome della texture
|
|
if ( ! ngeOut.WriteString( m_sTxrName, ",", false))
|
|
return false ;
|
|
// spazio per un flag intero
|
|
if ( ! ngeOut.WriteInt( 0, ";", true))
|
|
return false ;
|
|
// riferimento della texture
|
|
if ( ! ngeOut.WriteFrame( m_frTxrRef, ";", true))
|
|
return false ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
TextureData::Load( NgeReader& ngeIn)
|
|
{
|
|
// nome della texture
|
|
if ( ! ngeIn.ReadString( m_sTxrName, ",", false))
|
|
return false ;
|
|
// spazio per un flag intero
|
|
int nFlag ;
|
|
if ( ! ngeIn.ReadInt( nFlag, ";", true))
|
|
return false ;
|
|
// riferimento della texture
|
|
if ( ! ngeIn.ReadFrame( m_frTxrRef, ";", true))
|
|
return false ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
TextureData::SetName( const string& sTxrName)
|
|
{
|
|
m_sTxrName = sTxrName ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
TextureData::SetFrame( const Frame3d& frTxrRef)
|
|
{
|
|
if ( ! frTxrRef.IsValid())
|
|
return false ;
|
|
m_frTxrRef = frTxrRef ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
TextureData::GetName( string& sTxrName) const
|
|
{
|
|
sTxrName = m_sTxrName ;
|
|
return ( ! m_sTxrName.empty()) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
TextureData::GetFrame( Frame3d& frTxrRef) const
|
|
{
|
|
frTxrRef = m_frTxrRef ;
|
|
return m_frTxrRef.IsValid() ;
|
|
}
|