8f53f1959d
- prevista grafica ausiliaria per curve, visualizzabile da flag.
118 lines
4.6 KiB
C++
118 lines
4.6 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2014-2014
|
|
//----------------------------------------------------------------------------
|
|
// File : ObjNewGraphics.h Data : 13.02.14 Versione : 1.5b1
|
|
// Contenuto : Dichiarazione della classe grafica di un oggetto geometrico.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 13.02.14 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include "ObjEGrGraphics.h"
|
|
#include <list>
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
// Definizione di NgAtom
|
|
class NgAtom {
|
|
public :
|
|
NgAtom( void) : m_nType( NONE), m_nMode( 0), m_nCount( 0), m_nVaoId( 0), m_nVboId( 0) {}
|
|
|
|
public :
|
|
enum GrType { NONE = 0, VERTS = 1, VERTS_A = 2, COLOR = 3,
|
|
MAT_A = 4, MAT_D = 5, MAT_S = 6, MAT_SH = 7, MAT_B = 8} ;
|
|
|
|
public :
|
|
GrType m_nType ;
|
|
union {
|
|
struct {
|
|
int m_nMode ;
|
|
int m_nCount ;
|
|
unsigned int m_nVaoId ;
|
|
unsigned int m_nVboId ;
|
|
} ;
|
|
struct {
|
|
float m_fRed ;
|
|
float m_fGreen ;
|
|
float m_fBlue ;
|
|
float m_fAlpha ;
|
|
} ;
|
|
float m_fCol[4] ;
|
|
} ;
|
|
} ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
// Lista di NgAtom
|
|
typedef std::list<NgAtom> NGALIST ;
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
class ObjNewGraphics : public ObjEGrGraphics
|
|
{
|
|
public : // IObjGraphics
|
|
virtual ~ObjNewGraphics( void) ;
|
|
virtual void Reset( void) ;
|
|
|
|
public : // ObjEGrGraphics
|
|
virtual bool IsValid( void)
|
|
{ return m_bValid ; }
|
|
virtual void SetScene( Scene* pScene)
|
|
{ m_pScene = pScene ; }
|
|
virtual Scene* GetScene( void)
|
|
{ return m_pScene ; }
|
|
virtual void Clear( void) ;
|
|
virtual bool AddColor( const Color& colC) ;
|
|
virtual bool AddMaterial( const Color& colAmb, const Color& colDiff,
|
|
const Color& colSpec, float fShin) ;
|
|
virtual bool AddBackMaterial( const Color& colAmbDiff) ;
|
|
virtual bool AddPoint( const Point3d& ptP, bool bAux = false) ;
|
|
virtual bool AddPolyLine( const PolyLine& PL, bool bAux = false) ;
|
|
virtual bool StartTriangles( int nNum, bool bAux = false) ;
|
|
virtual bool AddTriangle( const Triangle3d& Tria, const TriNormals3d& TNrms) ;
|
|
virtual bool EndTriangles( void) ;
|
|
virtual bool Draw( int nStat, int nMark, bool bShowAux) ;
|
|
|
|
public :
|
|
ObjNewGraphics( void) : m_pScene( nullptr), m_bValid( false) {}
|
|
|
|
private :
|
|
bool DeleteVaoVbo( void) ;
|
|
bool AddNgAtom( const NgAtom& nga)
|
|
{ try { m_ngaList.push_back( nga) ; }
|
|
catch(...) { return false ; }
|
|
return true ; }
|
|
bool AddVerts( int nMode, int nCount, unsigned int nVaoId, unsigned int nVboId, bool bAux = false)
|
|
{ NgAtom nga ;
|
|
nga.m_nType = ( bAux ? NgAtom::VERTS_A : NgAtom::VERTS) ;
|
|
nga.m_nMode = nMode ; nga.m_nCount = nCount ;
|
|
nga.m_nVaoId = nVaoId ; nga.m_nVboId = nVboId ;
|
|
return AddNgAtom( nga) ; }
|
|
bool AddColor( float fRed, float fGreen, float fBlue, float fAlpha = 1)
|
|
{ NgAtom nga ;
|
|
nga.m_nType = NgAtom::COLOR ;
|
|
nga.m_fRed = fRed ; nga.m_fGreen = fGreen ; nga.m_fBlue = fBlue ; nga.m_fAlpha = fAlpha ;
|
|
return AddNgAtom( nga) ; }
|
|
bool AddMaterial( NgAtom::GrType nMat, float fRed, float fGreen, float fBlue, float fAlpha = 1)
|
|
{ NgAtom nga ;
|
|
nga.m_nType = nMat ;
|
|
nga.m_fRed = fRed ; nga.m_fGreen = fGreen ; nga.m_fBlue = fBlue ; nga.m_fAlpha = fAlpha ;
|
|
return AddNgAtom( nga) ; }
|
|
|
|
private :
|
|
Scene* m_pScene ; // puntatore alla scena
|
|
bool m_bValid ; // flag
|
|
int m_nCurrMode ; // modo corrente
|
|
NGALIST m_ngaList ; // liste di atomi per nuova grafica
|
|
} ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
inline const ObjNewGraphics* GetObjNewGraphics( const IGeoObj* pGObj)
|
|
{ return (dynamic_cast<const ObjNewGraphics*>(pGObj->GetObjGraphics())) ; }
|
|
inline ObjNewGraphics* GetObjNewGraphics( IGeoObj* pGObj)
|
|
{ return (dynamic_cast<ObjNewGraphics*>(pGObj->GetObjGraphics())) ; }
|