7b1b6e8ad8
- aggiunta gestione normali diverse sui triangoli.
110 lines
3.9 KiB
C++
110 lines
3.9 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 NewGrAtom
|
|
class NewGrAtom {
|
|
public :
|
|
NewGrAtom( void) : m_nType( NONE), m_nMode( 0), m_nCount( 0), m_nVaoId( 0), m_nVboId( 0) {}
|
|
|
|
public :
|
|
enum GrType { NONE = 0, VERTS = 1, COLOR = 2} ;
|
|
|
|
public :
|
|
GrType m_nType ;
|
|
union {
|
|
int m_nMode ;
|
|
float m_fRed ;
|
|
} ;
|
|
union {
|
|
int m_nCount ;
|
|
float m_fGreen ;
|
|
} ;
|
|
union {
|
|
unsigned int m_nVaoId ;
|
|
float m_fBlue ;
|
|
} ;
|
|
union {
|
|
unsigned int m_nVboId ;
|
|
float m_fAlpha ;
|
|
} ;
|
|
} ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
// Lista di NewGrAtom
|
|
typedef std::list<NewGrAtom> 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 AddPoint( const Point3d& ptP) ;
|
|
virtual bool AddPolyLine( const PolyLine& PL) ;
|
|
virtual bool StartTriangles( int nNum) ;
|
|
virtual bool AddTriangle( const Triangle3d& Tria, const TriNormals3d& TNrms) ;
|
|
virtual bool EndTriangles( void) ;
|
|
virtual bool Draw( int nStat, int nMark) ;
|
|
|
|
public :
|
|
ObjNewGraphics( void) : m_pScene( nullptr), m_bValid( false) {}
|
|
|
|
private :
|
|
bool DeleteVaoVbo( void) ;
|
|
bool AddNewGrAtom( const NewGrAtom& nga)
|
|
{ try { m_ngaList.push_back( nga) ; }
|
|
catch(...) { return false ; }
|
|
return true ; }
|
|
bool AddVerts( int nMode, int nCount, unsigned int nVaoId, unsigned int nVboId)
|
|
{ NewGrAtom nga ;
|
|
nga.m_nType = NewGrAtom::VERTS ;
|
|
nga.m_nMode = nMode ; nga.m_nCount = nCount ;
|
|
nga.m_nVaoId = nVaoId ; nga.m_nVboId = nVboId ;
|
|
return AddNewGrAtom( nga) ; }
|
|
bool AddColor( float fRed, float fGreen, float fBlue, float fAlpha = 1)
|
|
{ NewGrAtom nga ;
|
|
nga.m_nType = NewGrAtom::COLOR ;
|
|
nga.m_fRed = fRed ; nga.m_fGreen = fGreen ; nga.m_fBlue = fBlue ; nga.m_fAlpha = fAlpha ;
|
|
return AddNewGrAtom( nga) ; }
|
|
|
|
private :
|
|
Scene* m_pScene ; // puntatore alla scena
|
|
bool m_bValid ; // flag
|
|
int m_nCurrMode ; // modo corrente
|
|
NGALIST m_ngaList ; // lista 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())) ; }
|