EgtGraphics 1.5b2 :
- aggiunta gestione ObjNewGraphics e ObjOldGraphics.
This commit is contained in:
Binary file not shown.
+10
-1
@@ -188,15 +188,24 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\Include\EGkGdbIterator.h" />
|
||||
<ClInclude Include="..\Include\EgkObjGraphics.h" />
|
||||
<ClInclude Include="..\Include\EGkPolyLine.h" />
|
||||
<ClInclude Include="..\Include\EGrDllMain.h" />
|
||||
<ClInclude Include="..\Include\EGrScene.h" />
|
||||
<ClInclude Include="EGrGraphObjs.h" />
|
||||
<ClInclude Include="GraphObjs.h" />
|
||||
<ClInclude Include="ObjEGrGraphics.h" />
|
||||
<ClInclude Include="ObjNewGraphics.h" />
|
||||
<ClInclude Include="ObjOldGraphics.h" />
|
||||
<ClInclude Include="OpenGL.h" />
|
||||
<ClInclude Include="Scene.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="EGrDllMain.cpp" />
|
||||
<ClCompile Include="ObjNewGraphics.cpp" />
|
||||
<ClCompile Include="ObjOldGraphics.cpp" />
|
||||
<ClCompile Include="SceneBasic.cpp" />
|
||||
<ClCompile Include="SceneCamera.cpp" />
|
||||
<ClCompile Include="SceneGeom.cpp" />
|
||||
|
||||
@@ -30,7 +30,28 @@
|
||||
<ClInclude Include="..\Include\EGrScene.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="EGrGraphObjs.h">
|
||||
<ClInclude Include="GraphObjs.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="OpenGL.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EgkObjGraphics.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkGdbIterator.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ObjOldGraphics.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ObjNewGraphics.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkPolyLine.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ObjEGrGraphics.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
@@ -50,6 +71,12 @@
|
||||
<ClCompile Include="SceneGeom.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ObjOldGraphics.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ObjNewGraphics.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtGraphics.rc">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : EGrGraphObjs.h Data : 06.02.14 Versione : 1.5b4
|
||||
// File : GraphObjs.h Data : 06.02.14 Versione : 1.5b4
|
||||
// Contenuto : Oggetti grafici e loro raccolte.
|
||||
//
|
||||
//
|
||||
@@ -0,0 +1,38 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : ObjEGrGraphics.h Data : 13.02.14 Versione : 1.5b2
|
||||
// Contenuto : Dichiarazione della classe grafica di un oggetto geometrico.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 13.02.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "GraphObjs.h"
|
||||
#include "/EgtDev/Include/EgkObjGraphics.h"
|
||||
#include "/EgtDev/Include/EgkGeoObj.h"
|
||||
#include "/EgtDev/Include/EGkPolyLine.h"
|
||||
|
||||
class Scene ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class ObjEGrGraphics : public IObjGraphics
|
||||
{
|
||||
public :
|
||||
virtual bool IsValid( void) = 0 ;
|
||||
virtual void SetScene( Scene* pScene) = 0 ;
|
||||
virtual Scene* GetScene( void) = 0 ;
|
||||
virtual bool AddPolyLine( const PolyLine& PL) = 0 ;
|
||||
virtual bool Draw( void) = 0 ;
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline const ObjEGrGraphics* GetObjEGrGraphics( const IGeoObj* pGObj)
|
||||
{ return (dynamic_cast<const ObjEGrGraphics*>(pGObj->GetObjGraphics())) ; }
|
||||
inline ObjEGrGraphics* GetObjEGrGraphics( IGeoObj* pGObj)
|
||||
{ return (dynamic_cast<ObjEGrGraphics*>(pGObj->GetObjGraphics())) ; }
|
||||
@@ -0,0 +1,107 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : ObjNewGraphics.cpp Data : 10.02.14 Versione : 1.5b1
|
||||
// Contenuto : Implementazione della classe grafica di un oggetto geometrico.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 10.02.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "ObjNewGraphics.h"
|
||||
#include "Scene.h"
|
||||
|
||||
#define glewGetContext() (( m_pScene != nullptr) ? m_pScene->glewGetContext() : nullptr)
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ObjNewGraphics::~ObjNewGraphics( void)
|
||||
{
|
||||
// cancello eventuali vecchi vertici
|
||||
DeleteVaoVbo() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
ObjNewGraphics::Invalidate( void)
|
||||
{
|
||||
m_bValid = false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjNewGraphics::AddPolyLine( const PolyLine& PL)
|
||||
{
|
||||
if ( m_pScene == nullptr || ! m_pScene->MakeCurrent())
|
||||
return false ;
|
||||
|
||||
// cancello eventuali vecchi vertici
|
||||
DeleteVaoVbo() ;
|
||||
// imposto il nuovo stato
|
||||
m_bValid = true ;
|
||||
m_nMode = GL_LINE_STRIP ;
|
||||
// inserisco i nuovi vertici
|
||||
glGenVertexArrays( 1, &m_nVaoId) ;
|
||||
if ( m_nVaoId == 0)
|
||||
return false ;
|
||||
glBindVertexArray( m_nVaoId) ;
|
||||
glGenBuffers( 1, &m_nVboId) ;
|
||||
glBindBuffer( GL_ARRAY_BUFFER, m_nVboId) ;
|
||||
glBufferData( GL_ARRAY_BUFFER, PL.GetPointNbr() * SIZEV3F, NULL, GL_STATIC_DRAW) ;
|
||||
Point3d ptP ;
|
||||
Vert3f v3V ;
|
||||
m_nCount = 0 ;
|
||||
for ( bool bFound = PL.GetFirstPoint( ptP) ; bFound ; bFound = PL.GetNextPoint( ptP)) {
|
||||
v3V.Set( ptP.x, ptP.y, ptP.z) ;
|
||||
glBufferSubData( GL_ARRAY_BUFFER, m_nCount * SIZEV3F, SIZEV3F, &v3V) ;
|
||||
++ m_nCount ;
|
||||
}
|
||||
glVertexAttribPointer( (GLuint)0, 3, GL_FLOAT, GL_FALSE, 0, 0) ;
|
||||
glEnableVertexAttribArray( 0) ;
|
||||
glBindVertexArray( 0) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjNewGraphics::Draw( void)
|
||||
{
|
||||
if ( m_pScene == nullptr || ! m_pScene->MakeCurrent())
|
||||
return false ;
|
||||
|
||||
// se vuoto non faccio alcunché
|
||||
if ( m_nCount == 0)
|
||||
return true ;
|
||||
|
||||
if ( m_nVaoId != 0) {
|
||||
glBindVertexArray( m_nVaoId) ;
|
||||
glDrawArrays( m_nMode, 0, m_nCount) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjNewGraphics::DeleteVaoVbo( void)
|
||||
{
|
||||
if ( m_pScene == nullptr || ! m_pScene->MakeCurrent())
|
||||
return false ;
|
||||
|
||||
// cancellazione VAO/VBO
|
||||
if ( m_nCount > 0) {
|
||||
glBindBuffer( GL_ARRAY_BUFFER, 0) ;
|
||||
glDeleteBuffers( 1, &m_nVboId) ;
|
||||
glBindVertexArray( 0) ;
|
||||
glDeleteVertexArrays( 1, &m_nVaoId) ;
|
||||
m_nCount = 0 ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// 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"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class ObjNewGraphics : public ObjEGrGraphics
|
||||
{
|
||||
public :
|
||||
ObjNewGraphics( void) : m_pScene( nullptr), m_bValid( false), m_nMode( 0), m_nCount( 0) {}
|
||||
virtual ~ObjNewGraphics( void) ;
|
||||
virtual void Invalidate( void) ;
|
||||
|
||||
public :
|
||||
virtual bool IsValid( void)
|
||||
{ return m_bValid ; }
|
||||
virtual void SetScene( Scene* pScene)
|
||||
{ m_pScene = pScene ; }
|
||||
virtual Scene* GetScene( void)
|
||||
{ return m_pScene ; }
|
||||
virtual bool AddPolyLine( const PolyLine& PL) ;
|
||||
virtual bool Draw( void) ;
|
||||
|
||||
private :
|
||||
bool DeleteVaoVbo( void) ;
|
||||
|
||||
private :
|
||||
Scene* m_pScene ; // puntatore alla scena
|
||||
bool m_bValid ; // flag
|
||||
int m_nMode ; // modo di utilizzo dei vertici
|
||||
int m_nCount ; // numero di vertici nel VBO
|
||||
unsigned int m_nVaoId ; // Id del VAO
|
||||
unsigned int m_nVboId ; // Id del VBO
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
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())) ; }
|
||||
@@ -0,0 +1,66 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : ObjOldGraphics.cpp Data : 10.02.14 Versione : 1.5b1
|
||||
// Contenuto : Implementazione della classe grafica di un oggetto geometrico.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 10.02.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "ObjOldGraphics.h"
|
||||
#include "OpenGL.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ObjOldGraphics::~ObjOldGraphics( void)
|
||||
{
|
||||
m_v3fList.clear() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
ObjOldGraphics::Invalidate( void)
|
||||
{
|
||||
m_bValid = false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjOldGraphics::AddPolyLine( const PolyLine& PL)
|
||||
{
|
||||
// cancello eventuali vecchi vertici
|
||||
m_v3fList.clear() ;
|
||||
// imposto il nuovo stato
|
||||
m_bValid = true ;
|
||||
m_nMode = GL_LINE_STRIP ;
|
||||
// inserisco i nuovi vertici
|
||||
Point3d ptP ;
|
||||
for ( bool bFound = PL.GetFirstPoint( ptP) ; bFound ; bFound = PL.GetNextPoint( ptP))
|
||||
m_v3fList.push_back( Vert3f( (float)ptP.x, (float)ptP.y, (float)ptP.z)) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ObjOldGraphics::Draw( void)
|
||||
{
|
||||
// se vuoto non faccio alcunché
|
||||
if ( m_v3fList.size() == 0)
|
||||
return true ;
|
||||
|
||||
// ciclo di disegno
|
||||
glBegin( m_nMode) ;
|
||||
V3FLIST::iterator iIter ;
|
||||
for ( iIter = m_v3fList.begin() ; iIter != m_v3fList.end() ; ++ iIter) {
|
||||
glVertex3f( iIter->x, iIter->y, iIter->z) ;
|
||||
}
|
||||
glEnd() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : ObjOldGraphics.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"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class ObjOldGraphics : public ObjEGrGraphics
|
||||
{
|
||||
public :
|
||||
ObjOldGraphics( void) : m_pScene( nullptr), m_bValid( false), m_nMode( 0) {}
|
||||
virtual ~ObjOldGraphics( void) ;
|
||||
virtual void Invalidate( void) ;
|
||||
|
||||
public :
|
||||
virtual bool IsValid( void)
|
||||
{ return m_bValid ; }
|
||||
virtual void SetScene( Scene* pScene)
|
||||
{ m_pScene = pScene ; }
|
||||
virtual Scene* GetScene( void)
|
||||
{ return m_pScene ; }
|
||||
virtual bool AddPolyLine( const PolyLine& PL) ;
|
||||
virtual bool Draw( void) ;
|
||||
|
||||
private :
|
||||
Scene* m_pScene ; // puntatore alla scena
|
||||
bool m_bValid ; // flag
|
||||
int m_nMode ; // modo di utilizzo dei vertici
|
||||
V3FLIST m_v3fList ; // lista di vertici
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
inline const ObjOldGraphics* GetObjOldGraphics( const IGeoObj* pGObj)
|
||||
{ return (dynamic_cast<const ObjOldGraphics*>(pGObj->GetObjGraphics())) ; }
|
||||
inline ObjOldGraphics* GetObjOldGraphics( IGeoObj* pGObj)
|
||||
{ return (dynamic_cast<ObjOldGraphics*>(pGObj->GetObjGraphics())) ; }
|
||||
@@ -0,0 +1,18 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : OpenGL.h Data : 14.02.14 Versione : 1.5b2
|
||||
// Contenuto : Include per OpenGL.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 14.02.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#define GLEW_MX
|
||||
#include "/EgtDev/Extern/GLEW/Include/glew.h"
|
||||
#include "/EgtDev/Extern/GLEW/Include/wglew.h"
|
||||
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : EGrScene.h Data : 03.02.14 Versione : 1.5b1
|
||||
// File : Scene.h Data : 03.02.14 Versione : 1.5b1
|
||||
// Contenuto : Dichiarazione della classe gestione scena.
|
||||
//
|
||||
//
|
||||
@@ -15,10 +15,9 @@
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
#include "/EgtDev/Include/EGrScene.h"
|
||||
#include "EGrGraphObjs.h"
|
||||
#define GLEW_MX
|
||||
#include "/EgtDev/Extern/GLEW/Include/glew.h"
|
||||
#include "/EgtDev/Extern/GLEW/Include/wglew.h"
|
||||
#include "OpenGL.h"
|
||||
|
||||
class IGeoObj ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class Scene : public IEGrScene
|
||||
@@ -40,7 +39,7 @@ class Scene : public IEGrScene
|
||||
virtual bool Project( const Point3d& ptWorld, Point3d& ptView) ;
|
||||
virtual bool UnProject( const Point3d& ptView, Point3d& ptWorld) ;
|
||||
virtual void Destroy( void) ;
|
||||
// Camera
|
||||
// Camera
|
||||
virtual bool SetCenter( const Point3d& ptCenter) ;
|
||||
virtual bool SetCamera( double dAngVertDeg, double dAngOrizzDeg, double dDist) ;
|
||||
virtual bool SetCamera( int nDir, double dDist = 0) ;
|
||||
@@ -54,17 +53,19 @@ class Scene : public IEGrScene
|
||||
virtual bool ZoomAll( void) ;
|
||||
virtual bool ZoomChange( double dCoeff) ;
|
||||
virtual bool ZoomOnPoint( const Point3d& ptWin, double dCoeff) ;
|
||||
// Geometry
|
||||
virtual bool UpdateExtension( void) ;
|
||||
|
||||
public :
|
||||
// Basic
|
||||
Scene( void) ;
|
||||
bool MakeCurrent( void) ;
|
||||
GLEWContext* glewGetContext( void)
|
||||
{ return &m_glewc ; }
|
||||
|
||||
private :
|
||||
// Basic
|
||||
int ChooseGenPixelFormat( int nPfd, bool b2Buff, int nColorBits, int nDepthBits) ;
|
||||
bool MakeCurrent( void) ;
|
||||
GLEWContext* glewGetContext( void)
|
||||
{ return &m_glewc ; }
|
||||
WGLEWContext* wglewGetContext( void)
|
||||
{ return &m_wglewc ; }
|
||||
bool CalcExtView( void) ;
|
||||
@@ -75,6 +76,8 @@ class Scene : public IEGrScene
|
||||
bool CalcDirUp( void) ;
|
||||
// Geometry
|
||||
bool DrawGroup( int nId) ;
|
||||
bool DrawGeoObj( IGeoObj* pGeoObj) ;
|
||||
bool DeleteObjGraphicsGroup( int nId) ;
|
||||
|
||||
private :
|
||||
IGeomDB* m_pGeomDB ;
|
||||
@@ -94,7 +97,7 @@ class Scene : public IEGrScene
|
||||
int m_nViewportW ; // larghezza della finestra
|
||||
int m_nViewportH ; // altezza della finestra
|
||||
|
||||
BBox3d m_b3ExtWorld ; // estensione della geometria
|
||||
BBox3d m_b3ExtWorld ; // estensione della geometria nel riferimento globale (mondo)
|
||||
BBox3d m_b3ExtView ; // estensione nel riferimento di vista
|
||||
bool m_bExtViewOk ; // flag per stato aggiornamento di EView
|
||||
double m_dHalfWidth ;
|
||||
|
||||
+7
-5
@@ -23,6 +23,7 @@ using namespace std ;
|
||||
|
||||
//--------------------------- Constants --------------------------------------
|
||||
static const double MIN_EXTENSION = 50 ;
|
||||
static const double MIN_ZCLIP_EXT = 5000 ;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -420,8 +421,8 @@ Scene::CalcClippingPlanesFromExtView( void)
|
||||
if ( ! m_b3ExtView.GetCenterExtent( ptCenter, vtExtent))
|
||||
return false ;
|
||||
// ricavo la posizione dei piani di clipping sull'asse Z di vista
|
||||
const double EXP_COEFF = 1.05 ;
|
||||
double dExtent = __max( ( EXP_COEFF * vtExtent.z), MIN_EXTENSION) ;
|
||||
const double EXP_COEFF = 1.1 ;
|
||||
double dExtent = __max( ( EXP_COEFF * vtExtent.z), MIN_ZCLIP_EXT) ;
|
||||
m_dZNear = - ( ptCenter.z + dExtent) ;
|
||||
m_dZFar = - ( ptCenter.z - dExtent) ;
|
||||
return true ;
|
||||
@@ -496,9 +497,6 @@ Scene::Prepare( void)
|
||||
bool
|
||||
Scene::Draw( void)
|
||||
{
|
||||
// provvisorio
|
||||
SetExtension( BBox3d( -1000, -1000, -1000, 1000, 1000, 1000)) ;
|
||||
|
||||
// imposto
|
||||
if ( ! Prepare())
|
||||
return false ;
|
||||
@@ -581,6 +579,10 @@ Scene::UnProject( const Point3d& ptView, Point3d& ptWorld)
|
||||
void
|
||||
Scene::Destroy( void)
|
||||
{
|
||||
// cancellazione eventuali ObjEgrGraphics attaccati a oggetti geometrici
|
||||
DeleteObjGraphicsGroup( GDB_ID_ROOT) ;
|
||||
|
||||
// cancellazione rendering context
|
||||
wglMakeCurrent( nullptr, nullptr) ;
|
||||
if ( m_hRC != nullptr) {
|
||||
wglDeleteContext( m_hRC) ;
|
||||
|
||||
@@ -245,6 +245,9 @@ Scene::RotateCamera( const Point3d& ptWinOld, const Point3d& ptWinNew)
|
||||
bool
|
||||
Scene::ZoomAll( void)
|
||||
{
|
||||
// aggiorno l'ingombro
|
||||
UpdateExtension() ;
|
||||
|
||||
// traslo il centro di vista nel centro del box
|
||||
Point3d ptExtCent ;
|
||||
if ( ! m_b3ExtWorld.GetCenter( ptExtCent))
|
||||
|
||||
+107
-14
@@ -14,6 +14,8 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "Scene.h"
|
||||
#include "ObjOldGraphics.h"
|
||||
#include "ObjNewGraphics.h"
|
||||
#include "/EgtDev/Include/EgtILogger.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGkFrame3d.h"
|
||||
@@ -54,6 +56,26 @@ FrameToOpenGlMatrix( const Frame3d& frFrame, double Matrix[OGLMAT_DIM])
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ObjEGrGraphics*
|
||||
CreateObjEGrGraphics( bool bNewWay)
|
||||
{
|
||||
if ( bNewWay)
|
||||
return ( new ObjNewGraphics) ;
|
||||
else
|
||||
return ( new ObjOldGraphics) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::UpdateExtension( void)
|
||||
{
|
||||
BBox3d b3Ext ;
|
||||
if ( ! m_pGeomDB->GetLocalBBox( GDB_ID_ROOT, b3Ext))
|
||||
return false ;
|
||||
return SetExtension( b3Ext) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::DrawGroup( int nId)
|
||||
@@ -62,7 +84,7 @@ Scene::DrawGroup( int nId)
|
||||
Frame3d frFrame ;
|
||||
if ( ! m_pGeomDB->GetGroupFrame( nId, frFrame))
|
||||
return false ;
|
||||
// se non è identità, lo imposto nello stack delle matrici MODELVIEW di OpenGL
|
||||
// se non è identità, lo aggiungo sullo stack delle matrici MODELVIEW di OpenGL
|
||||
bool bMatrix = ( frFrame.GetType() != Frame3d::TOP || ! frFrame.Orig().IsSmall()) ;
|
||||
if ( bMatrix) {
|
||||
glPushMatrix() ;
|
||||
@@ -78,26 +100,25 @@ Scene::DrawGroup( int nId)
|
||||
pIter->SetGDB( m_pGeomDB) ;
|
||||
bool bNext = pIter->GoToFirstInGroup( nId) ;
|
||||
while ( bNext) {
|
||||
// leggo il tipo di nodo
|
||||
int nGdbType = pIter->GetGdbType() ;
|
||||
// se oggetto geometrico
|
||||
if ( nGdbType == GDB_GEO) {
|
||||
const ICurve* pCurve ;
|
||||
// se curva, la emetto
|
||||
if ( ( pCurve = GetCurve( pIter->GetGeoObj())) != nullptr) {
|
||||
bool bFound ;
|
||||
PolyLine PL ;
|
||||
Point3d ptP ;
|
||||
pCurve->ApproxWithLines( 0.1, 5, PL) ;
|
||||
glBegin( GL_LINE_STRIP) ;
|
||||
for ( bFound = PL.GetFirstPoint( ptP) ; bFound ; bFound = PL.GetNextPoint( ptP)) {
|
||||
glVertex3f( (GLfloat)ptP.x, (GLfloat)ptP.y, (GLfloat)ptP.z) ;
|
||||
}
|
||||
glEnd() ;
|
||||
}
|
||||
// lo recupero
|
||||
IGeoObj* pGeoObj = pIter->GetGeoObj() ;
|
||||
if ( pGeoObj == nullptr)
|
||||
return false ;
|
||||
// lo disegno
|
||||
if ( ! DrawGeoObj( pGeoObj))
|
||||
return false ;
|
||||
}
|
||||
// se gruppo
|
||||
else if ( nGdbType == GDB_GROUP) {
|
||||
// lo disegno
|
||||
if ( ! DrawGroup( pIter->GetId()))
|
||||
return false ;
|
||||
}
|
||||
// passo al successivo
|
||||
bNext = pIter->GoToNext() ;
|
||||
}
|
||||
// se necessario, ripristino lo stack delle matrici
|
||||
@@ -106,3 +127,75 @@ Scene::DrawGroup( int nId)
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::DrawGeoObj( IGeoObj* pGeoObj)
|
||||
{
|
||||
// se non esiste grafica associata, la creo
|
||||
if ( pGeoObj->GetObjGraphics() == nullptr) {
|
||||
ObjEGrGraphics* pGraphics = CreateObjEGrGraphics( m_bNewWay) ;
|
||||
if ( pGraphics == nullptr)
|
||||
return false ;
|
||||
pGraphics->SetScene( this) ;
|
||||
pGeoObj->SetObjGraphics( pGraphics) ;
|
||||
}
|
||||
// leggo il tipo di oggetto geometrico
|
||||
int nGeoType = pGeoObj->GetType() ;
|
||||
// se curva
|
||||
if ( ( nGeoType & GEO_CURVE) != 0) {
|
||||
// recupero la curva
|
||||
const ICurve* pCurve = GetCurve( pGeoObj) ;
|
||||
if ( pCurve == nullptr)
|
||||
return false ;
|
||||
// se la grafica associata non è valida la ricalcolo
|
||||
ObjEGrGraphics* pGraphics = GetObjEGrGraphics( pGeoObj) ;
|
||||
if ( ! pGraphics->IsValid()) {
|
||||
PolyLine PL ;
|
||||
pCurve->ApproxWithLines( 0.1, 5, PL) ;
|
||||
pGraphics->AddPolyLine( PL) ;
|
||||
}
|
||||
// visualizzo la grafica associata
|
||||
pGraphics->Draw() ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::DeleteObjGraphicsGroup( int nId)
|
||||
{
|
||||
// creo un iteratore
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator()) ;
|
||||
if ( ! ::IsValid( pIter))
|
||||
return false ;
|
||||
// scandisco il gruppo
|
||||
pIter->SetGDB( m_pGeomDB) ;
|
||||
bool bNext = pIter->GoToFirstInGroup( nId) ;
|
||||
while ( bNext) {
|
||||
// leggo il tipo di nodo
|
||||
int nGdbType = pIter->GetGdbType() ;
|
||||
// se oggetto geometrico
|
||||
if ( nGdbType == GDB_GEO) {
|
||||
// lo recupero
|
||||
IGeoObj* pGeoObj = pIter->GetGeoObj() ;
|
||||
if ( pGeoObj == nullptr)
|
||||
return false ;
|
||||
// ne cancello l'eventuale parte grafica
|
||||
ObjEGrGraphics* pGraph = GetObjEGrGraphics( pGeoObj) ;
|
||||
if ( pGraph != nullptr && pGraph->GetScene() == this)
|
||||
pGeoObj->SetObjGraphics( nullptr) ;
|
||||
}
|
||||
// se gruppo
|
||||
else if ( nGdbType == GDB_GROUP) {
|
||||
// ripeto sugli oggetti dello stesso
|
||||
if ( ! DeleteObjGraphicsGroup( pIter->GetId()))
|
||||
return false ;
|
||||
}
|
||||
// passo al successivo
|
||||
bNext = pIter->GoToNext() ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user