Compare commits
77 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 26587e39db | |||
| 199ef1e26d | |||
| d2a457b1bd | |||
| 36e6b1d5c1 | |||
| bcb3c189a1 | |||
| bbe4e99fe8 | |||
| 1a4cabe097 | |||
| dbd0c9a739 | |||
| 1cf8e7e965 | |||
| 337b896761 | |||
| 2e688ef9aa | |||
| 41731eaa38 | |||
| 784d7d0ae4 | |||
| 3a4c73f77f | |||
| 117511a04f | |||
| a83fdbda5e | |||
| 5349437d28 | |||
| b30fa0b55e | |||
| 95bceba089 | |||
| d9c9622972 | |||
| 0a28896ab6 | |||
| a357df9cd0 | |||
| 2fb3ffb614 | |||
| d7385ec15d | |||
| 076c74488f | |||
| c77d7cffe8 | |||
| 08bbafc909 | |||
| 55021cf19c | |||
| adc7df9de7 | |||
| 1dcb86abe8 | |||
| bfacbc23c6 | |||
| 4bfd4e4f5d | |||
| 69ab09f5b3 | |||
| 7254d3dece | |||
| f5bf52467a | |||
| 588795960d | |||
| e2d54eee41 | |||
| b11b39acbf | |||
| fbe6c7232e | |||
| 7930a229f9 | |||
| bc248d7f24 | |||
| d80435c4df | |||
| ada682cba3 | |||
| 49dac32893 | |||
| e8b10ef4e8 | |||
| 1c37299baf | |||
| d61656fdd4 | |||
| 4081ff7830 | |||
| fec352f37b | |||
| 199fbf25d8 | |||
| 8611f15893 | |||
| 69e7dab720 | |||
| 43daacac9a | |||
| 93ec29f2fd | |||
| e51b4d5750 | |||
| eaa964eca2 | |||
| 000db07d85 | |||
| 14ffb16d79 | |||
| ebda47089d | |||
| 00a81d6e04 | |||
| 9d32f3e7cc | |||
| 1704b40c17 | |||
| 0794fded30 | |||
| 147964cf6a | |||
| 30b56dbfc8 | |||
| 3c1e9e8790 | |||
| 59ddf02887 | |||
| 9384f8f0df | |||
| 327e8bcf2a | |||
| 1a393126f3 | |||
| 7fd9bae8fc | |||
| 8b47da0588 | |||
| 9fd623cf9e | |||
| f37aeb5892 | |||
| cd77324145 | |||
| e5a7ec2ff6 | |||
| 7294508074 |
@@ -1,7 +1,7 @@
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// EgalTech 2013-2013
|
// EgalTech 2013-2023
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// File : DllMain.h Data : 17.02.14 Versione : 1.5b3
|
// File : DllMain.h Data : 30.05.23 Versione : 2.5e5
|
||||||
// Contenuto : Prototipi funzioni per uso locale della DLL.
|
// Contenuto : Prototipi funzioni per uso locale della DLL.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@@ -21,3 +21,4 @@
|
|||||||
ILogger* GetEGrLogger( void) ;
|
ILogger* GetEGrLogger( void) ;
|
||||||
const std::string& GetEGrKey( void) ;
|
const std::string& GetEGrKey( void) ;
|
||||||
bool GetEGrNetHwKey( void) ;
|
bool GetEGrNetHwKey( void) ;
|
||||||
|
bool VerifyKey( int nKeyOpt) ;
|
||||||
|
|||||||
+30
-2
@@ -1,7 +1,7 @@
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// EgalTech 2014-2014
|
// EgalTech 2014-2023
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// File : EGrDllMain.cpp Data : 13.02.14 Versione : 1.5b1
|
// File : EGrDllMain.cpp Data : 30.05.23 Versione : 2.5e
|
||||||
// Contenuto : Inizializzazione della DLL.
|
// Contenuto : Inizializzazione della DLL.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "DllMain.h"
|
#include "DllMain.h"
|
||||||
#include "/EgtDev/Include/EGrDllMain.h"
|
#include "/EgtDev/Include/EGrDllMain.h"
|
||||||
#include "/EgtDev/Include/EGnGetModuleVer.h"
|
#include "/EgtDev/Include/EGnGetModuleVer.h"
|
||||||
|
#include "/EgtDev/Include/EGnGetKeyData.h"
|
||||||
#include "/EgtDev/Include/EgtTrace.h"
|
#include "/EgtDev/Include/EgtTrace.h"
|
||||||
|
|
||||||
//--------------------------- Costanti ----------------------------------------
|
//--------------------------- Costanti ----------------------------------------
|
||||||
@@ -118,3 +119,30 @@ GetEGrNetHwKey( void)
|
|||||||
{
|
{
|
||||||
return s_bNetHwKey ;
|
return s_bNetHwKey ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
VerifyKey( int nKeyOpt)
|
||||||
|
{
|
||||||
|
// Controllo della licenza
|
||||||
|
unsigned int nOpt1, nOpt2 ;
|
||||||
|
int nOptExpDays ;
|
||||||
|
int nRet = GetEGnKeyOptions( KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
|
||||||
|
nOpt1, nOpt2, nOptExpDays) ;
|
||||||
|
if ( ! GetEGrNetHwKey())
|
||||||
|
nRet = GetKeyOptions( GetEGrKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
|
||||||
|
nOpt1, nOpt2, nOptExpDays) ;
|
||||||
|
if ( nRet != KEY_OK) {
|
||||||
|
std::string sErr = "Error on Key (GRC/" + ToString( nRet) + ")" ;
|
||||||
|
LOG_ERROR( GetEGrLogger(), sErr.c_str()) ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
if ( ( nOpt1 & KEYOPT_EGR_BASE) == 0 ||
|
||||||
|
( nKeyOpt != 0 && ( nOpt1 & nKeyOpt) == 0) ||
|
||||||
|
nOptExpDays < GetCurrDay()) {
|
||||||
|
std::string sErr = "Warning on Key (GRC/OPT)" ;
|
||||||
|
LOG_ERROR( GetEGrLogger(), sErr.c_str()) ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|||||||
Binary file not shown.
+5
-2
@@ -22,7 +22,7 @@
|
|||||||
<ProjectGuid>{4EC970B1-B4D9-4088-8A31-B462CF72116E}</ProjectGuid>
|
<ProjectGuid>{4EC970B1-B4D9-4088-8A31-B462CF72116E}</ProjectGuid>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<RootNamespace>EgtGraphics</RootNamespace>
|
<RootNamespace>EgtGraphics</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0.20348.0</WindowsTargetPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
@@ -108,6 +108,7 @@
|
|||||||
<CompileAs>CompileAsCpp</CompileAs>
|
<CompileAs>CompileAsCpp</CompileAs>
|
||||||
<DisableSpecificWarnings>
|
<DisableSpecificWarnings>
|
||||||
</DisableSpecificWarnings>
|
</DisableSpecificWarnings>
|
||||||
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
@@ -170,6 +171,7 @@ copy $(TargetPath) \EgtProg\DllD64</Command>
|
|||||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
@@ -203,7 +205,7 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
|
|||||||
<DisableSpecificWarnings>
|
<DisableSpecificWarnings>
|
||||||
</DisableSpecificWarnings>
|
</DisableSpecificWarnings>
|
||||||
<OmitFramePointers>true</OmitFramePointers>
|
<OmitFramePointers>true</OmitFramePointers>
|
||||||
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||||
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
|
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
|
||||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||||
<CompileAs>CompileAsCpp</CompileAs>
|
<CompileAs>CompileAsCpp</CompileAs>
|
||||||
@@ -261,6 +263,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
|||||||
<ClCompile Include="SceneCamera.cpp" />
|
<ClCompile Include="SceneCamera.cpp" />
|
||||||
<ClCompile Include="SceneGeom.cpp" />
|
<ClCompile Include="SceneGeom.cpp" />
|
||||||
<ClCompile Include="SceneDirect.cpp" />
|
<ClCompile Include="SceneDirect.cpp" />
|
||||||
|
<ClCompile Include="SceneGlobCube.cpp" />
|
||||||
<ClCompile Include="SceneGlobFrame.cpp" />
|
<ClCompile Include="SceneGlobFrame.cpp" />
|
||||||
<ClCompile Include="SceneGrid.cpp" />
|
<ClCompile Include="SceneGrid.cpp" />
|
||||||
<ClCompile Include="SceneImage.cpp" />
|
<ClCompile Include="SceneImage.cpp" />
|
||||||
|
|||||||
@@ -140,6 +140,9 @@
|
|||||||
<ClCompile Include="ImageMgr.cpp">
|
<ClCompile Include="ImageMgr.cpp">
|
||||||
<Filter>File di origine</Filter>
|
<Filter>File di origine</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="SceneGlobCube.cpp">
|
||||||
|
<Filter>File di origine</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="EgtGraphics.rc">
|
<ResourceCompile Include="EgtGraphics.rc">
|
||||||
|
|||||||
+2
-4
@@ -29,10 +29,8 @@ IEgrImageMgr*
|
|||||||
CreateEgrImageMgr( void)
|
CreateEgrImageMgr( void)
|
||||||
{
|
{
|
||||||
// verifico la chiave e le opzioni
|
// verifico la chiave e le opzioni
|
||||||
if ( ! GetEGrNetHwKey()) {
|
if ( ! VerifyKey( 0))
|
||||||
if ( ! TestKeyForEGr( GetEGrKey(), 0, GetEGrLogger()))
|
return nullptr ;
|
||||||
return nullptr ;
|
|
||||||
}
|
|
||||||
// creo l'oggetto
|
// creo l'oggetto
|
||||||
return static_cast<IEgrImageMgr*> ( new(nothrow) ImageMgr) ;
|
return static_cast<IEgrImageMgr*> ( new(nothrow) ImageMgr) ;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -1,7 +1,7 @@
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// EgalTech 2014-2014
|
// EgalTech 2014-2023
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// File : ObjEGrGraphics.h Data : 13.02.14 Versione : 1.5b2
|
// File : ObjEGrGraphics.h Data : 08.07.23 Versione : 2.5g1
|
||||||
// Contenuto : Dichiarazione della classe grafica di un oggetto geometrico.
|
// Contenuto : Dichiarazione della classe grafica di un oggetto geometrico.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@@ -37,6 +37,7 @@ class ObjEGrGraphics : public IObjGraphics
|
|||||||
virtual bool AddMaterial( const Color& colAmb, const Color& colDiff,
|
virtual bool AddMaterial( const Color& colAmb, const Color& colDiff,
|
||||||
const Color& colSpec, float fShin) = 0 ;
|
const Color& colSpec, float fShin) = 0 ;
|
||||||
virtual bool AddBackMaterial( const Color& colAmbDiff) = 0 ;
|
virtual bool AddBackMaterial( const Color& colAmbDiff) = 0 ;
|
||||||
|
virtual bool AddLineStipple( int nFactor, int nPattern) = 0 ;
|
||||||
virtual bool AddPoint( const Point3d& ptP, bool bAux = false) = 0 ;
|
virtual bool AddPoint( const Point3d& ptP, bool bAux = false) = 0 ;
|
||||||
virtual bool AddPoints( const PNTVECTOR& vPnt, bool bAux = false) = 0 ;
|
virtual bool AddPoints( const PNTVECTOR& vPnt, bool bAux = false) = 0 ;
|
||||||
virtual bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) = 0 ;
|
virtual bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) = 0 ;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
//--------------------------- Include ----------------------------------------
|
//--------------------------- Include ----------------------------------------
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "/EgtDev/Include/EGkColor.h"
|
||||||
#include "ObjMultiGraphics.h"
|
#include "ObjMultiGraphics.h"
|
||||||
#include "ObjNewGraphics.h"
|
#include "ObjNewGraphics.h"
|
||||||
#include "ObjOldGraphics.h"
|
#include "ObjOldGraphics.h"
|
||||||
@@ -105,6 +106,15 @@ ObjMultiGraphics::AddBackMaterial( const Color& colAmbDiff)
|
|||||||
return m_vOEGR[m_nCurr]->AddBackMaterial( colAmbDiff) ;
|
return m_vOEGR[m_nCurr]->AddBackMaterial( colAmbDiff) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
ObjMultiGraphics::AddLineStipple( int nFactor, int nPattern)
|
||||||
|
{
|
||||||
|
if ( m_nCurr < 0 || m_nCurr >= int( m_vOEGR.size()))
|
||||||
|
return false ;
|
||||||
|
return m_vOEGR[m_nCurr]->AddLineStipple( nFactor, nPattern) ;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
ObjMultiGraphics::AddPoint( const Point3d& ptP, bool bAux)
|
ObjMultiGraphics::AddPoint( const Point3d& ptP, bool bAux)
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class ObjMultiGraphics : public ObjEGrGraphics
|
|||||||
bool AddMaterial( const Color& colAmb, const Color& colDiff,
|
bool AddMaterial( const Color& colAmb, const Color& colDiff,
|
||||||
const Color& colSpec, float fShin) override ;
|
const Color& colSpec, float fShin) override ;
|
||||||
bool AddBackMaterial( const Color& colAmbDiff) override ;
|
bool AddBackMaterial( const Color& colAmbDiff) override ;
|
||||||
|
bool AddLineStipple( int nFactor, int nPattern) override ;
|
||||||
bool AddPoint( const Point3d& ptP, bool bAux = false) override ;
|
bool AddPoint( const Point3d& ptP, bool bAux = false) override ;
|
||||||
bool AddPoints( const PNTVECTOR& vPnt, bool bAux = false) override ;
|
bool AddPoints( const PNTVECTOR& vPnt, bool bAux = false) override ;
|
||||||
bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) override ;
|
bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) override ;
|
||||||
|
|||||||
+87
-47
@@ -1,7 +1,7 @@
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// EgalTech 2014-2014
|
// EgalTech 2014-2023
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// File : ObjNewGraphics.cpp Data : 23.04.14 Versione : 1.5d5
|
// File : ObjNewGraphics.cpp Data : 08.07.23 Versione : 2.5g1
|
||||||
// Contenuto : Implementazione della classe grafica di un oggetto geometrico.
|
// Contenuto : Implementazione della classe grafica di un oggetto geometrico.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
#include "/EgtDev/Include/EGkPolyLine.h"
|
#include "/EgtDev/Include/EGkPolyLine.h"
|
||||||
#include "/EgtDev/Include/EGkGdbConst.h"
|
#include "/EgtDev/Include/EGkGdbConst.h"
|
||||||
#include "/EgtDev/Include/EGkTriangle3d.h"
|
#include "/EgtDev/Include/EGkTriangle3d.h"
|
||||||
|
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||||
|
|
||||||
//--------------------------- Macro e Costanti -------------------------------
|
//--------------------------- Macro e Costanti -------------------------------
|
||||||
// Dimensioni flag per edge di triangoli
|
// Dimensioni flag per edge di triangoli
|
||||||
@@ -27,6 +27,7 @@ const size_t SIZEFLAG = sizeof( unsigned char) ;
|
|||||||
// Dimensioni record del buffer ( vertice + normale + flag)
|
// Dimensioni record del buffer ( vertice + normale + flag)
|
||||||
const size_t SIZEVNF = ( 2 * SIZEV3F + SIZEFLAG) ;
|
const size_t SIZEVNF = ( 2 * SIZEV3F + SIZEFLAG) ;
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
ObjNewGraphics::~ObjNewGraphics( void)
|
ObjNewGraphics::~ObjNewGraphics( void)
|
||||||
{
|
{
|
||||||
@@ -55,7 +56,7 @@ ObjNewGraphics::Clear( void)
|
|||||||
bool
|
bool
|
||||||
ObjNewGraphics::AddColor( const Color& colC)
|
ObjNewGraphics::AddColor( const Color& colC)
|
||||||
{
|
{
|
||||||
return AddColor( colC.GetRed(), colC.GetGreen(), colC.GetBlue(), colC.GetAlpha()) ;
|
return AddNgaColor( colC.GetRed(), colC.GetGreen(), colC.GetBlue(), colC.GetAlpha()) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -63,21 +64,28 @@ bool
|
|||||||
ObjNewGraphics::AddMaterial( const Color& colAmb, const Color& colDiff,
|
ObjNewGraphics::AddMaterial( const Color& colAmb, const Color& colDiff,
|
||||||
const Color& colSpec, float fShin)
|
const Color& colSpec, float fShin)
|
||||||
{
|
{
|
||||||
return AddMaterial( NgAtom::MAT_A, colAmb.GetRed(), colAmb.GetGreen(),
|
return AddNgaMaterial( NgAtom::MAT_A, colAmb.GetRed(), colAmb.GetGreen(),
|
||||||
colAmb.GetBlue(), colDiff.GetAlpha()) &&
|
colAmb.GetBlue(), colDiff.GetAlpha()) &&
|
||||||
AddMaterial( NgAtom::MAT_D, colDiff.GetRed(), colDiff.GetGreen(),
|
AddNgaMaterial( NgAtom::MAT_D, colDiff.GetRed(), colDiff.GetGreen(),
|
||||||
colDiff.GetBlue(), colDiff.GetAlpha()) &&
|
colDiff.GetBlue(), colDiff.GetAlpha()) &&
|
||||||
AddMaterial( NgAtom::MAT_S, colSpec.GetRed(), colSpec.GetGreen(),
|
AddNgaMaterial( NgAtom::MAT_S, colSpec.GetRed(), colSpec.GetGreen(),
|
||||||
colSpec.GetBlue(), colDiff.GetAlpha()) &&
|
colSpec.GetBlue(), colDiff.GetAlpha()) &&
|
||||||
AddMaterial( NgAtom::MAT_SH, fShin, 0, 0, 0) ;
|
AddNgaMaterial( NgAtom::MAT_SH, fShin, 0, 0, 0) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
ObjNewGraphics::AddBackMaterial( const Color& colAmbDiff)
|
ObjNewGraphics::AddBackMaterial( const Color& colAmbDiff)
|
||||||
{
|
{
|
||||||
return AddMaterial( NgAtom::MAT_B, colAmbDiff.GetRed(), colAmbDiff.GetGreen(),
|
return AddNgaMaterial( NgAtom::MAT_B, colAmbDiff.GetRed(), colAmbDiff.GetGreen(),
|
||||||
colAmbDiff.GetBlue(), colAmbDiff.GetAlpha()) ;
|
colAmbDiff.GetBlue(), colAmbDiff.GetAlpha()) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
ObjNewGraphics::AddLineStipple( int nFactor, int nPattern)
|
||||||
|
{
|
||||||
|
return AddNgaLineStipple( nFactor, nPattern) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -109,7 +117,7 @@ ObjNewGraphics::AddPoint( const Point3d& ptP, bool bAux)
|
|||||||
glEnableClientState( GL_VERTEX_ARRAY) ;
|
glEnableClientState( GL_VERTEX_ARRAY) ;
|
||||||
glBindVertexArray( 0) ;
|
glBindVertexArray( 0) ;
|
||||||
// aggiungo i dati in lista
|
// aggiungo i dati in lista
|
||||||
AddVerts( GL_POINTS, nCount, nVaoId, nVboId, bAux) ;
|
AddNgaVerts( GL_POINTS, nCount, nVaoId, nVboId, bAux) ;
|
||||||
// dichiaro valida la grafica
|
// dichiaro valida la grafica
|
||||||
m_bValid = true ;
|
m_bValid = true ;
|
||||||
|
|
||||||
@@ -148,7 +156,7 @@ ObjNewGraphics::AddPoints( const PNTVECTOR& vPnt, bool bAux)
|
|||||||
glEnableClientState( GL_VERTEX_ARRAY) ;
|
glEnableClientState( GL_VERTEX_ARRAY) ;
|
||||||
glBindVertexArray( 0) ;
|
glBindVertexArray( 0) ;
|
||||||
// aggiungo i dati in lista
|
// aggiungo i dati in lista
|
||||||
AddVerts( GL_POINTS, nCount, nVaoId, nVboId, bAux) ;
|
AddNgaVerts( GL_POINTS, nCount, nVaoId, nVboId, bAux) ;
|
||||||
// dichiaro valida la grafica
|
// dichiaro valida la grafica
|
||||||
m_bValid = true ;
|
m_bValid = true ;
|
||||||
|
|
||||||
@@ -187,7 +195,7 @@ ObjNewGraphics::AddLines( const PNTVECTOR& vPnt, bool bAux)
|
|||||||
glEnableClientState( GL_VERTEX_ARRAY) ;
|
glEnableClientState( GL_VERTEX_ARRAY) ;
|
||||||
glBindVertexArray( 0) ;
|
glBindVertexArray( 0) ;
|
||||||
// aggiungo i dati in lista
|
// aggiungo i dati in lista
|
||||||
AddVerts( GL_LINES, nCount, nVaoId, nVboId, bAux) ;
|
AddNgaVerts( GL_LINES, nCount, nVaoId, nVboId, bAux) ;
|
||||||
// dichiaro valida la grafica
|
// dichiaro valida la grafica
|
||||||
m_bValid = true ;
|
m_bValid = true ;
|
||||||
|
|
||||||
@@ -228,7 +236,7 @@ ObjNewGraphics::AddPolyLine( const PolyLine& PL, bool bAux)
|
|||||||
glEnableClientState( GL_VERTEX_ARRAY) ;
|
glEnableClientState( GL_VERTEX_ARRAY) ;
|
||||||
glBindVertexArray( 0) ;
|
glBindVertexArray( 0) ;
|
||||||
// aggiungo i dati in lista
|
// aggiungo i dati in lista
|
||||||
AddVerts( GL_LINE_STRIP, nCount, nVaoId, nVboId, bAux) ;
|
AddNgaVerts( GL_LINE_STRIP, nCount, nVaoId, nVboId, bAux) ;
|
||||||
// dichiaro valida la grafica
|
// dichiaro valida la grafica
|
||||||
m_bValid = true ;
|
m_bValid = true ;
|
||||||
|
|
||||||
@@ -261,7 +269,7 @@ ObjNewGraphics::StartTriangles( int nNum, bool bAux)
|
|||||||
// NumTria * 3 * dimensione( vertice+normale+flag)
|
// NumTria * 3 * dimensione( vertice+normale+flag)
|
||||||
glBufferData( GL_ARRAY_BUFFER, nNum * 3 * SIZEVNF, NULL, GL_STATIC_DRAW) ;
|
glBufferData( GL_ARRAY_BUFFER, nNum * 3 * SIZEVNF, NULL, GL_STATIC_DRAW) ;
|
||||||
// aggiungo i dati in lista
|
// aggiungo i dati in lista
|
||||||
AddVerts( GL_TRIANGLES, 0, nVaoId, nVboId, bAux) ;
|
AddNgaVerts( GL_TRIANGLES, 0, nVaoId, nVboId, bAux) ;
|
||||||
// dichiaro modo triangoli
|
// dichiaro modo triangoli
|
||||||
m_nCurrMode = GL_TRIANGLES ;
|
m_nCurrMode = GL_TRIANGLES ;
|
||||||
return true ;
|
return true ;
|
||||||
@@ -329,8 +337,8 @@ ObjNewGraphics::EndTriangles( void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
static float*
|
static const float*
|
||||||
AdjustColor( float fCol[4], bool bDark)
|
AdjustColor( const float fCol[4], bool bDark)
|
||||||
{
|
{
|
||||||
if ( ! bDark) {
|
if ( ! bDark) {
|
||||||
return fCol ;
|
return fCol ;
|
||||||
@@ -399,42 +407,58 @@ ObjNewGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bSurf, int nAlph
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ciclo di disegno
|
// ciclo di disegno
|
||||||
for ( auto iIter = m_ngaVect.begin() ; iIter != m_ngaVect.end() ; ++ iIter) {
|
bool bLineStipple = false ;
|
||||||
switch ( iIter->m_nType) {
|
for ( const auto& Nga : m_ngaVect) {
|
||||||
|
switch ( Nga.m_nType) {
|
||||||
case NgAtom::VERTS :
|
case NgAtom::VERTS :
|
||||||
if ( iIter->m_nCount > 0 && iIter->m_nVaoId != 0) {
|
if ( Nga.m_nCount > 0 && Nga.m_nVaoId != 0) {
|
||||||
glBindVertexArray( iIter->m_nVaoId) ;
|
glBindVertexArray( Nga.m_nVaoId) ;
|
||||||
glDrawArrays( iIter->m_nMode, 0, iIter->m_nCount) ;
|
glDrawArrays( Nga.m_nMode, 0, Nga.m_nCount) ;
|
||||||
glBindVertexArray( 0) ;
|
glBindVertexArray( 0) ;
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
case NgAtom::VERTS_A :
|
case NgAtom::VERTS_A :
|
||||||
if ( bShowAux && iIter->m_nCount > 0 && iIter->m_nVaoId != 0) {
|
if ( bShowAux && Nga.m_nCount > 0 && Nga.m_nVaoId != 0) {
|
||||||
glBindVertexArray( iIter->m_nVaoId) ;
|
glBindVertexArray( Nga.m_nVaoId) ;
|
||||||
glDrawArrays( iIter->m_nMode, 0, iIter->m_nCount) ;
|
glDrawArrays( Nga.m_nMode, 0, Nga.m_nCount) ;
|
||||||
glBindVertexArray( 0) ;
|
glBindVertexArray( 0) ;
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
case NgAtom::COLOR :
|
case NgAtom::COLOR :
|
||||||
glColor4fv( ( bStdCol ? AdjustColor( iIter->m_fCol, bDark) : fSelMarkCol)) ;
|
glColor4fv( ( bStdCol ? AdjustColor( Nga.m_fCol, bDark) : fSelMarkCol)) ;
|
||||||
break ;
|
break ;
|
||||||
case NgAtom::MAT_A :
|
case NgAtom::MAT_A :
|
||||||
glMaterialfv( GL_FRONT, GL_AMBIENT, ( bStdCol ? iIter->m_fCol : fSelMarkCol)) ;
|
glMaterialfv( GL_FRONT, GL_AMBIENT, ( bStdCol ? Nga.m_fCol : fSelMarkCol)) ;
|
||||||
break ;
|
break ;
|
||||||
case NgAtom::MAT_D :
|
case NgAtom::MAT_D :
|
||||||
glMaterialfv( GL_FRONT, GL_DIFFUSE, ( bStdCol ? iIter->m_fCol : fSelMarkCol)) ;
|
glMaterialfv( GL_FRONT, GL_DIFFUSE, ( bStdCol ? Nga.m_fCol : fSelMarkCol)) ;
|
||||||
break ;
|
break ;
|
||||||
case NgAtom::MAT_S :
|
case NgAtom::MAT_S :
|
||||||
glMaterialfv( GL_FRONT, GL_SPECULAR, ( bStdCol ? iIter->m_fCol : fSelMarkCol)) ;
|
glMaterialfv( GL_FRONT, GL_SPECULAR, ( bStdCol ? Nga.m_fCol : fSelMarkCol)) ;
|
||||||
break ;
|
break ;
|
||||||
case NgAtom::MAT_SH :
|
case NgAtom::MAT_SH :
|
||||||
glMaterialf( GL_FRONT, GL_SHININESS, iIter->m_fCol[0]) ;
|
glMaterialf( GL_FRONT, GL_SHININESS, Nga.m_fCol[0]) ;
|
||||||
break ;
|
break ;
|
||||||
case NgAtom::MAT_B :
|
case NgAtom::MAT_B :
|
||||||
glMaterialfv( GL_BACK, GL_AMBIENT_AND_DIFFUSE, ( bStdCol ? iIter->m_fCol : fSelMarkBackCol)) ;
|
glMaterialfv( GL_BACK, GL_AMBIENT_AND_DIFFUSE, ( bStdCol ? Nga.m_fCol : fSelMarkBackCol)) ;
|
||||||
|
break ;
|
||||||
|
case NgAtom::LINE_STIPPLE :
|
||||||
|
if ( Nga.m_nMode > 0) {
|
||||||
|
bLineStipple = true ;
|
||||||
|
glLineStipple( Clamp( Nga.m_nFactor, 1, 256), Clamp( Nga.m_nPattern, 0, 65535)) ;
|
||||||
|
glEnable( GL_LINE_STIPPLE) ;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bLineStipple = false ;
|
||||||
|
glDisable( GL_LINE_STIPPLE) ;
|
||||||
|
}
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( bLineStipple) {
|
||||||
|
bLineStipple = false ;
|
||||||
|
glDisable( GL_LINE_STIPPLE) ;
|
||||||
|
}
|
||||||
|
|
||||||
// se marcato e non superficie in shading, disegno halo
|
// se marcato e non superficie in shading, disegno halo
|
||||||
if ( nMark == GDB_MK_ON && ! bSurfSha) {
|
if ( nMark == GDB_MK_ON && ! bSurfSha) {
|
||||||
@@ -450,25 +474,41 @@ ObjNewGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bSurf, int nAlph
|
|||||||
glColor4f( colMark.GetRed(), colMark.GetGreen(), colMark.GetBlue(), colMark.GetAlpha()) ;
|
glColor4f( colMark.GetRed(), colMark.GetGreen(), colMark.GetBlue(), colMark.GetAlpha()) ;
|
||||||
|
|
||||||
// ciclo di disegno
|
// ciclo di disegno
|
||||||
for ( auto iIter = m_ngaVect.begin() ; iIter != m_ngaVect.end() ; ++ iIter) {
|
bool bLineStipple = false ;
|
||||||
switch ( iIter->m_nType) {
|
for ( const auto& Nga : m_ngaVect) {
|
||||||
|
switch ( Nga.m_nType) {
|
||||||
case NgAtom::VERTS :
|
case NgAtom::VERTS :
|
||||||
if ( iIter->m_nCount > 0 && iIter->m_nVaoId != 0) {
|
if ( Nga.m_nCount > 0 && Nga.m_nVaoId != 0) {
|
||||||
glBindVertexArray( iIter->m_nVaoId) ;
|
glBindVertexArray( Nga.m_nVaoId) ;
|
||||||
glDrawArrays( iIter->m_nMode, 0, iIter->m_nCount) ;
|
glDrawArrays( Nga.m_nMode, 0, Nga.m_nCount) ;
|
||||||
glBindVertexArray( 0) ;
|
glBindVertexArray( 0) ;
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
case NgAtom::VERTS_A :
|
case NgAtom::VERTS_A :
|
||||||
if ( bShowAux && iIter->m_nCount > 0 && iIter->m_nVaoId != 0) {
|
if ( bShowAux && Nga.m_nCount > 0 && Nga.m_nVaoId != 0) {
|
||||||
glBindVertexArray( iIter->m_nVaoId) ;
|
glBindVertexArray( Nga.m_nVaoId) ;
|
||||||
glDrawArrays( iIter->m_nMode, 0, iIter->m_nCount) ;
|
glDrawArrays( Nga.m_nMode, 0, Nga.m_nCount) ;
|
||||||
glBindVertexArray( 0) ;
|
glBindVertexArray( 0) ;
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
// non si impostano i colori, si usa quello di marcatura
|
// non si impostano i colori, si usa quello di marcatura
|
||||||
|
case NgAtom::LINE_STIPPLE :
|
||||||
|
if ( Nga.m_nMode > 0) {
|
||||||
|
bLineStipple = true ;
|
||||||
|
glLineStipple( Clamp( Nga.m_nFactor, 1, 256), Clamp( Nga.m_nPattern, 0, 65535)) ;
|
||||||
|
glEnable( GL_LINE_STIPPLE) ;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bLineStipple = false ;
|
||||||
|
glDisable( GL_LINE_STIPPLE) ;
|
||||||
|
}
|
||||||
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( bLineStipple) {
|
||||||
|
bLineStipple = false ;
|
||||||
|
glDisable( GL_LINE_STIPPLE) ;
|
||||||
|
}
|
||||||
// ripristino test di depth
|
// ripristino test di depth
|
||||||
glDepthFunc( GL_LEQUAL) ;
|
glDepthFunc( GL_LEQUAL) ;
|
||||||
}
|
}
|
||||||
@@ -490,13 +530,13 @@ ObjNewGraphics::DeleteVaoVbo( void)
|
|||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// ciclo di cancellazione VAO/VBO
|
// ciclo di cancellazione VAO/VBO
|
||||||
for ( auto iIter = m_ngaVect.begin() ; iIter != m_ngaVect.end() ; ++ iIter) {
|
for ( auto& Nga : m_ngaVect) {
|
||||||
if ( iIter->m_nType == NgAtom::VERTS && iIter->m_nCount > 0) {
|
if ( Nga.m_nType == NgAtom::VERTS && Nga.m_nCount > 0) {
|
||||||
glBindBuffer( GL_ARRAY_BUFFER, 0) ;
|
glBindBuffer( GL_ARRAY_BUFFER, 0) ;
|
||||||
glDeleteBuffers( 1, &iIter->m_nVboId) ;
|
glDeleteBuffers( 1, &Nga.m_nVboId) ;
|
||||||
glBindVertexArray( 0) ;
|
glBindVertexArray( 0) ;
|
||||||
glDeleteVertexArrays( 1, &iIter->m_nVaoId) ;
|
glDeleteVertexArrays( 1, &Nga.m_nVaoId) ;
|
||||||
iIter->m_nCount = 0 ;
|
Nga.m_nCount = 0 ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+17
-4
@@ -24,7 +24,7 @@ class NgAtom {
|
|||||||
|
|
||||||
public :
|
public :
|
||||||
enum GrType { NONE = 0, VERTS = 1, VERTS_A = 2, COLOR = 3,
|
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} ;
|
MAT_A = 4, MAT_D = 5, MAT_S = 6, MAT_SH = 7, MAT_B = 8, LINE_STIPPLE = 9} ;
|
||||||
|
|
||||||
public :
|
public :
|
||||||
GrType m_nType ;
|
GrType m_nType ;
|
||||||
@@ -42,6 +42,10 @@ class NgAtom {
|
|||||||
float m_fAlpha ;
|
float m_fAlpha ;
|
||||||
} ;
|
} ;
|
||||||
float m_fCol[4] ;
|
float m_fCol[4] ;
|
||||||
|
struct {
|
||||||
|
int m_nFactor ;
|
||||||
|
int m_nPattern ;
|
||||||
|
} ;
|
||||||
} ;
|
} ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
@@ -70,6 +74,7 @@ class ObjNewGraphics : public ObjEGrGraphics
|
|||||||
bool AddMaterial( const Color& colAmb, const Color& colDiff,
|
bool AddMaterial( const Color& colAmb, const Color& colDiff,
|
||||||
const Color& colSpec, float fShin) override ;
|
const Color& colSpec, float fShin) override ;
|
||||||
bool AddBackMaterial( const Color& colAmbDiff) override ;
|
bool AddBackMaterial( const Color& colAmbDiff) override ;
|
||||||
|
bool AddLineStipple( int nFactor, int nPattern) override ;
|
||||||
bool AddPoint( const Point3d& ptP, bool bAux = false) override ;
|
bool AddPoint( const Point3d& ptP, bool bAux = false) override ;
|
||||||
bool AddPoints( const PNTVECTOR& vPnt, bool bAux = false) override ;
|
bool AddPoints( const PNTVECTOR& vPnt, bool bAux = false) override ;
|
||||||
bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) override ;
|
bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) override ;
|
||||||
@@ -78,6 +83,8 @@ class ObjNewGraphics : public ObjEGrGraphics
|
|||||||
bool AddTriangle( const Triangle3d& Tria, const TriFlags3d& TFlags, const TriNormals3d& TNrms) override ;
|
bool AddTriangle( const Triangle3d& Tria, const TriFlags3d& TFlags, const TriNormals3d& TNrms) override ;
|
||||||
bool EndTriangles( void) override ;
|
bool EndTriangles( void) override ;
|
||||||
bool Draw( int nStat, int nMark, bool bSurfSha, bool bSurf, int nAlpha, bool bShowAux) override ;
|
bool Draw( int nStat, int nMark, bool bSurfSha, bool bSurf, int nAlpha, bool bShowAux) override ;
|
||||||
|
|
||||||
|
|
||||||
bool GetLocalBBox( BBox3d& b3Loc) const override
|
bool GetLocalBBox( BBox3d& b3Loc) const override
|
||||||
{ b3Loc = m_b3Loc ; return ! m_b3Loc.IsEmpty() ; }
|
{ b3Loc = m_b3Loc ; return ! m_b3Loc.IsEmpty() ; }
|
||||||
|
|
||||||
@@ -90,22 +97,28 @@ class ObjNewGraphics : public ObjEGrGraphics
|
|||||||
{ try { m_ngaVect.push_back( nga) ; }
|
{ try { m_ngaVect.push_back( nga) ; }
|
||||||
catch(...) { return false ; }
|
catch(...) { return false ; }
|
||||||
return true ; }
|
return true ; }
|
||||||
bool AddVerts( int nMode, int nCount, unsigned int nVaoId, unsigned int nVboId, bool bAux = false)
|
bool AddNgaVerts( int nMode, int nCount, unsigned int nVaoId, unsigned int nVboId, bool bAux = false)
|
||||||
{ NgAtom nga ;
|
{ NgAtom nga ;
|
||||||
nga.m_nType = ( bAux ? NgAtom::VERTS_A : NgAtom::VERTS) ;
|
nga.m_nType = ( bAux ? NgAtom::VERTS_A : NgAtom::VERTS) ;
|
||||||
nga.m_nMode = nMode ; nga.m_nCount = nCount ;
|
nga.m_nMode = nMode ; nga.m_nCount = nCount ;
|
||||||
nga.m_nVaoId = nVaoId ; nga.m_nVboId = nVboId ;
|
nga.m_nVaoId = nVaoId ; nga.m_nVboId = nVboId ;
|
||||||
return AddNgAtom( nga) ; }
|
return AddNgAtom( nga) ; }
|
||||||
bool AddColor( float fRed, float fGreen, float fBlue, float fAlpha = 1)
|
bool AddNgaColor( float fRed, float fGreen, float fBlue, float fAlpha = 1)
|
||||||
{ NgAtom nga ;
|
{ NgAtom nga ;
|
||||||
nga.m_nType = NgAtom::COLOR ;
|
nga.m_nType = NgAtom::COLOR ;
|
||||||
nga.m_fRed = fRed ; nga.m_fGreen = fGreen ; nga.m_fBlue = fBlue ; nga.m_fAlpha = fAlpha ;
|
nga.m_fRed = fRed ; nga.m_fGreen = fGreen ; nga.m_fBlue = fBlue ; nga.m_fAlpha = fAlpha ;
|
||||||
return AddNgAtom( nga) ; }
|
return AddNgAtom( nga) ; }
|
||||||
bool AddMaterial( NgAtom::GrType nMat, float fRed, float fGreen, float fBlue, float fAlpha = 1)
|
bool AddNgaMaterial( NgAtom::GrType nMat, float fRed, float fGreen, float fBlue, float fAlpha = 1)
|
||||||
{ NgAtom nga ;
|
{ NgAtom nga ;
|
||||||
nga.m_nType = nMat ;
|
nga.m_nType = nMat ;
|
||||||
nga.m_fRed = fRed ; nga.m_fGreen = fGreen ; nga.m_fBlue = fBlue ; nga.m_fAlpha = fAlpha ;
|
nga.m_fRed = fRed ; nga.m_fGreen = fGreen ; nga.m_fBlue = fBlue ; nga.m_fAlpha = fAlpha ;
|
||||||
return AddNgAtom( nga) ; }
|
return AddNgAtom( nga) ; }
|
||||||
|
bool AddNgaLineStipple( int nFactor, int nPattern)
|
||||||
|
{ NgAtom nga ;
|
||||||
|
nga.m_nType = NgAtom::LINE_STIPPLE ;
|
||||||
|
nga.m_nFactor = nFactor ;
|
||||||
|
nga.m_nPattern = nPattern ;
|
||||||
|
return AddNgAtom( nga) ; }
|
||||||
|
|
||||||
private :
|
private :
|
||||||
Scene* m_pScene ; // puntatore alla scena
|
Scene* m_pScene ; // puntatore alla scena
|
||||||
|
|||||||
+91
-51
@@ -1,7 +1,7 @@
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// EgalTech 2014-2014
|
// EgalTech 2014-2023
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// File : ObjOldGraphics.cpp Data : 23.04.14 Versione : 1.5d5
|
// File : ObjOldGraphics.cpp Data : 08.07.23 Versione : 2.5g1
|
||||||
// Contenuto : Implementazione della classe grafica di un oggetto geometrico.
|
// Contenuto : Implementazione della classe grafica di un oggetto geometrico.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@@ -19,8 +19,9 @@
|
|||||||
#include "/EgtDev/Include/EGkPolyLine.h"
|
#include "/EgtDev/Include/EGkPolyLine.h"
|
||||||
#include "/EgtDev/Include/EGkGdbConst.h"
|
#include "/EgtDev/Include/EGkGdbConst.h"
|
||||||
#include "/EgtDev/Include/EGkTriangle3d.h"
|
#include "/EgtDev/Include/EGkTriangle3d.h"
|
||||||
|
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//--------------------------- Macro e Costanti -------------------------------
|
||||||
const int VECT_HEAP = 20 ;
|
const int VECT_HEAP = 20 ;
|
||||||
|
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ ObjOldGraphics::Clear( void)
|
|||||||
bool
|
bool
|
||||||
ObjOldGraphics::AddColor( const Color& colC)
|
ObjOldGraphics::AddColor( const Color& colC)
|
||||||
{
|
{
|
||||||
return AddColor( colC.GetRed(), colC.GetGreen(), colC.GetBlue(), colC.GetAlpha()) ;
|
return AddOgaColor( colC.GetRed(), colC.GetGreen(), colC.GetBlue(), colC.GetAlpha()) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -59,21 +60,28 @@ bool
|
|||||||
ObjOldGraphics::AddMaterial( const Color& colAmb, const Color& colDiff,
|
ObjOldGraphics::AddMaterial( const Color& colAmb, const Color& colDiff,
|
||||||
const Color& colSpec, float fShin)
|
const Color& colSpec, float fShin)
|
||||||
{
|
{
|
||||||
return AddMaterial( OgAtom::MAT_A, colAmb.GetRed(), colAmb.GetGreen(),
|
return AddOgaMaterial( OgAtom::MAT_A, colAmb.GetRed(), colAmb.GetGreen(),
|
||||||
colAmb.GetBlue(), colDiff.GetAlpha()) &&
|
colAmb.GetBlue(), colDiff.GetAlpha()) &&
|
||||||
AddMaterial( OgAtom::MAT_D, colDiff.GetRed(), colDiff.GetGreen(),
|
AddOgaMaterial( OgAtom::MAT_D, colDiff.GetRed(), colDiff.GetGreen(),
|
||||||
colDiff.GetBlue(), colDiff.GetAlpha()) &&
|
colDiff.GetBlue(), colDiff.GetAlpha()) &&
|
||||||
AddMaterial( OgAtom::MAT_S, colSpec.GetRed(), colSpec.GetGreen(),
|
AddOgaMaterial( OgAtom::MAT_S, colSpec.GetRed(), colSpec.GetGreen(),
|
||||||
colSpec.GetBlue(), colDiff.GetAlpha()) &&
|
colSpec.GetBlue(), colDiff.GetAlpha()) &&
|
||||||
AddMaterial( OgAtom::MAT_SH, fShin, 0, 0, 0) ;
|
AddOgaMaterial( OgAtom::MAT_SH, fShin, 0, 0, 0) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
ObjOldGraphics::AddBackMaterial( const Color& colAmbDiff)
|
ObjOldGraphics::AddBackMaterial( const Color& colAmbDiff)
|
||||||
{
|
{
|
||||||
return AddMaterial( OgAtom::MAT_B, colAmbDiff.GetRed(), colAmbDiff.GetGreen(),
|
return AddOgaMaterial( OgAtom::MAT_B, colAmbDiff.GetRed(), colAmbDiff.GetGreen(),
|
||||||
colAmbDiff.GetBlue(), colAmbDiff.GetAlpha()) ;
|
colAmbDiff.GetBlue(), colAmbDiff.GetAlpha()) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
ObjOldGraphics::AddLineStipple( int nFactor, int nPattern)
|
||||||
|
{
|
||||||
|
return AddOgaLineStipple( nFactor, nPattern) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -84,13 +92,13 @@ ObjOldGraphics::AddPoint( const Point3d& ptP, bool bAux)
|
|||||||
if ( m_nCurrMode != GL_NONE)
|
if ( m_nCurrMode != GL_NONE)
|
||||||
return false ;
|
return false ;
|
||||||
// start
|
// start
|
||||||
AddStart( GL_POINTS, bAux) ;
|
AddOgaStart( GL_POINTS, bAux) ;
|
||||||
// inserisco il nuovo vertice
|
// inserisco il nuovo vertice
|
||||||
AddVert3f( ptP) ;
|
AddOgaVert3f( ptP) ;
|
||||||
// aggiorno bbox
|
// aggiorno bbox
|
||||||
m_b3Loc.Add( ptP) ;
|
m_b3Loc.Add( ptP) ;
|
||||||
// fine
|
// fine
|
||||||
AddEnd() ;
|
AddOgaEnd() ;
|
||||||
// dichiaro valida la grafica
|
// dichiaro valida la grafica
|
||||||
m_bValid = true ;
|
m_bValid = true ;
|
||||||
|
|
||||||
@@ -105,14 +113,14 @@ ObjOldGraphics::AddPoints( const PNTVECTOR& vPnt, bool bAux)
|
|||||||
if ( m_nCurrMode != GL_NONE)
|
if ( m_nCurrMode != GL_NONE)
|
||||||
return false ;
|
return false ;
|
||||||
// start
|
// start
|
||||||
AddStart( GL_POINTS, bAux) ;
|
AddOgaStart( GL_POINTS, bAux) ;
|
||||||
// inserisco i vertici + aggiorno bbox
|
// inserisco i vertici + aggiorno bbox
|
||||||
for ( int i = 0 ; i < int( vPnt.size()) ; ++ i) {
|
for ( int i = 0 ; i < int( vPnt.size()) ; ++ i) {
|
||||||
AddVert3f( vPnt[i]) ;
|
AddOgaVert3f( vPnt[i]) ;
|
||||||
m_b3Loc.Add( vPnt[i]) ;
|
m_b3Loc.Add( vPnt[i]) ;
|
||||||
}
|
}
|
||||||
// fine
|
// fine
|
||||||
AddEnd() ;
|
AddOgaEnd() ;
|
||||||
// dichiaro valida la grafica
|
// dichiaro valida la grafica
|
||||||
m_bValid = true ;
|
m_bValid = true ;
|
||||||
|
|
||||||
@@ -129,14 +137,14 @@ ObjOldGraphics::AddLines( const PNTVECTOR& vPnt, bool bAux)
|
|||||||
// riservo memoria per vettore
|
// riservo memoria per vettore
|
||||||
m_ogaVect.reserve( VECT_HEAP + vPnt.size()) ;
|
m_ogaVect.reserve( VECT_HEAP + vPnt.size()) ;
|
||||||
// start
|
// start
|
||||||
AddStart( GL_LINES, bAux) ;
|
AddOgaStart( GL_LINES, bAux) ;
|
||||||
// inserisco i vertici + aggiorno bbox
|
// inserisco i vertici + aggiorno bbox
|
||||||
for ( int i = 0 ; i < int( vPnt.size()) ; ++ i) {
|
for ( int i = 0 ; i < int( vPnt.size()) ; ++ i) {
|
||||||
AddVert3f( vPnt[i]) ;
|
AddOgaVert3f( vPnt[i]) ;
|
||||||
m_b3Loc.Add( vPnt[i]) ;
|
m_b3Loc.Add( vPnt[i]) ;
|
||||||
}
|
}
|
||||||
// fine
|
// fine
|
||||||
AddEnd() ;
|
AddOgaEnd() ;
|
||||||
// dichiaro valida la grafica
|
// dichiaro valida la grafica
|
||||||
m_bValid = true ;
|
m_bValid = true ;
|
||||||
|
|
||||||
@@ -153,15 +161,15 @@ ObjOldGraphics::AddPolyLine( const PolyLine& PL, bool bAux)
|
|||||||
// riservo memoria per vettore
|
// riservo memoria per vettore
|
||||||
m_ogaVect.reserve( VECT_HEAP + PL.GetPointNbr()) ;
|
m_ogaVect.reserve( VECT_HEAP + PL.GetPointNbr()) ;
|
||||||
// start
|
// start
|
||||||
AddStart( GL_LINE_STRIP, bAux) ;
|
AddOgaStart( GL_LINE_STRIP, bAux) ;
|
||||||
// inserisco i nuovi vertici + aggiorno bbox
|
// inserisco i nuovi vertici + aggiorno bbox
|
||||||
Point3d ptP ;
|
Point3d ptP ;
|
||||||
for ( bool bFound = PL.GetFirstPoint( ptP) ; bFound ; bFound = PL.GetNextPoint( ptP)) {
|
for ( bool bFound = PL.GetFirstPoint( ptP) ; bFound ; bFound = PL.GetNextPoint( ptP)) {
|
||||||
AddVert3f( ptP) ;
|
AddOgaVert3f( ptP) ;
|
||||||
m_b3Loc.Add( ptP) ;
|
m_b3Loc.Add( ptP) ;
|
||||||
}
|
}
|
||||||
// fine
|
// fine
|
||||||
AddEnd() ;
|
AddOgaEnd() ;
|
||||||
// dichiaro valida la grafica
|
// dichiaro valida la grafica
|
||||||
m_bValid = true ;
|
m_bValid = true ;
|
||||||
|
|
||||||
@@ -178,7 +186,7 @@ ObjOldGraphics::StartTriangles( int nNum, bool bAux)
|
|||||||
// riservo memoria per vettore
|
// riservo memoria per vettore
|
||||||
m_ogaVect.reserve( VECT_HEAP + 3 * nNum) ;
|
m_ogaVect.reserve( VECT_HEAP + 3 * nNum) ;
|
||||||
// inizio emissione triangoli
|
// inizio emissione triangoli
|
||||||
AddStart( GL_TRIANGLES, bAux) ;
|
AddOgaStart( GL_TRIANGLES, bAux) ;
|
||||||
m_nCurrMode = GL_TRIANGLES ;
|
m_nCurrMode = GL_TRIANGLES ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
@@ -192,9 +200,9 @@ ObjOldGraphics::AddTriangle( const Triangle3d& Tria, const TriFlags3d& TFlags, c
|
|||||||
return false ;
|
return false ;
|
||||||
// emetto i flag, le normali e i vertici del triangolo + aggiorno bbox
|
// emetto i flag, le normali e i vertici del triangolo + aggiorno bbox
|
||||||
for ( int i = 0 ; i < 3 ; ++ i) {
|
for ( int i = 0 ; i < 3 ; ++ i) {
|
||||||
AddBndFlag( TFlags.bFlag[i]) ;
|
AddOgaBndFlag( TFlags.bFlag[i]) ;
|
||||||
AddNormal3f( TNrms.vtN[i]) ;
|
AddOgaNormal3f( TNrms.vtN[i]) ;
|
||||||
AddVert3f( Tria.GetP( i)) ;
|
AddOgaVert3f( Tria.GetP( i)) ;
|
||||||
m_b3Loc.Add( Tria.GetP( i)) ;
|
m_b3Loc.Add( Tria.GetP( i)) ;
|
||||||
}
|
}
|
||||||
return true ;
|
return true ;
|
||||||
@@ -208,7 +216,7 @@ ObjOldGraphics::EndTriangles( void)
|
|||||||
if ( m_nCurrMode != GL_TRIANGLES)
|
if ( m_nCurrMode != GL_TRIANGLES)
|
||||||
return false ;
|
return false ;
|
||||||
// termino il modo triangoli
|
// termino il modo triangoli
|
||||||
AddEnd() ;
|
AddOgaEnd() ;
|
||||||
m_nCurrMode = GL_NONE ;
|
m_nCurrMode = GL_NONE ;
|
||||||
// dichiaro valida la grafica
|
// dichiaro valida la grafica
|
||||||
m_bValid = true ;
|
m_bValid = true ;
|
||||||
@@ -217,8 +225,8 @@ ObjOldGraphics::EndTriangles( void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
static float*
|
static const float*
|
||||||
AdjustColor( float fCol[4], bool bDark)
|
AdjustColor( const float fCol[4], bool bDark)
|
||||||
{
|
{
|
||||||
if ( ! bDark) {
|
if ( ! bDark) {
|
||||||
return fCol ;
|
return fCol ;
|
||||||
@@ -285,15 +293,16 @@ ObjOldGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bSurf, int nAlph
|
|||||||
|
|
||||||
// ciclo di disegno
|
// ciclo di disegno
|
||||||
bool bStartA = false ;
|
bool bStartA = false ;
|
||||||
for ( auto iIter = m_ogaVect.begin() ; iIter != m_ogaVect.end() ; ++ iIter) {
|
bool bLineStipple = false ;
|
||||||
switch ( iIter->m_nType) {
|
for ( const auto& Oga : m_ogaVect) {
|
||||||
|
switch ( Oga.m_nType) {
|
||||||
case OgAtom::START :
|
case OgAtom::START :
|
||||||
glBegin( iIter->m_nMode) ;
|
glBegin( Oga.m_nMode) ;
|
||||||
bStartA = false ;
|
bStartA = false ;
|
||||||
break ;
|
break ;
|
||||||
case OgAtom::START_A :
|
case OgAtom::START_A :
|
||||||
if ( bShowAux)
|
if ( bShowAux)
|
||||||
glBegin( iIter->m_nMode) ;
|
glBegin( Oga.m_nMode) ;
|
||||||
bStartA = true ;
|
bStartA = true ;
|
||||||
break ;
|
break ;
|
||||||
case OgAtom::END :
|
case OgAtom::END :
|
||||||
@@ -303,36 +312,51 @@ ObjOldGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bSurf, int nAlph
|
|||||||
break ;
|
break ;
|
||||||
case OgAtom::VERT :
|
case OgAtom::VERT :
|
||||||
if ( ! bStartA || bShowAux)
|
if ( ! bStartA || bShowAux)
|
||||||
glVertex3fv( iIter->m_fVal) ;
|
glVertex3fv( Oga.m_fVal) ;
|
||||||
break ;
|
break ;
|
||||||
case OgAtom::BND_FLAG :
|
case OgAtom::BND_FLAG :
|
||||||
if ( ! bStartA || bShowAux)
|
if ( ! bStartA || bShowAux)
|
||||||
glEdgeFlag( iIter->m_nFlag) ;
|
glEdgeFlag( Oga.m_nFlag) ;
|
||||||
break ;
|
break ;
|
||||||
case OgAtom::NORMAL :
|
case OgAtom::NORMAL :
|
||||||
if ( ! bStartA || bShowAux)
|
if ( ! bStartA || bShowAux)
|
||||||
glNormal3fv( iIter->m_fVal) ;
|
glNormal3fv( Oga.m_fVal) ;
|
||||||
break ;
|
break ;
|
||||||
case OgAtom::COLOR :
|
case OgAtom::COLOR :
|
||||||
glColor4fv( ( bStdCol ? AdjustColor( iIter->m_fVal, bDark) : fSelMarkCol)) ;
|
glColor4fv( ( bStdCol ? AdjustColor( Oga.m_fVal, bDark) : fSelMarkCol)) ;
|
||||||
break ;
|
break ;
|
||||||
case OgAtom::MAT_A :
|
case OgAtom::MAT_A :
|
||||||
glMaterialfv( GL_FRONT, GL_AMBIENT, ( bStdCol ? iIter->m_fVal : fSelMarkCol)) ;
|
glMaterialfv( GL_FRONT, GL_AMBIENT, ( bStdCol ? Oga.m_fVal : fSelMarkCol)) ;
|
||||||
break ;
|
break ;
|
||||||
case OgAtom::MAT_D :
|
case OgAtom::MAT_D :
|
||||||
glMaterialfv( GL_FRONT, GL_DIFFUSE, ( bStdCol ? iIter->m_fVal : fSelMarkCol)) ;
|
glMaterialfv( GL_FRONT, GL_DIFFUSE, ( bStdCol ? Oga.m_fVal : fSelMarkCol)) ;
|
||||||
break ;
|
break ;
|
||||||
case OgAtom::MAT_S :
|
case OgAtom::MAT_S :
|
||||||
glMaterialfv( GL_FRONT, GL_SPECULAR, ( bStdCol ? iIter->m_fVal : fSelMarkCol)) ;
|
glMaterialfv( GL_FRONT, GL_SPECULAR, ( bStdCol ? Oga.m_fVal : fSelMarkCol)) ;
|
||||||
break ;
|
break ;
|
||||||
case OgAtom::MAT_SH :
|
case OgAtom::MAT_SH :
|
||||||
glMaterialf( GL_FRONT, GL_SHININESS, iIter->m_fVal[0]) ;
|
glMaterialf( GL_FRONT, GL_SHININESS, Oga.m_fVal[0]) ;
|
||||||
break ;
|
break ;
|
||||||
case OgAtom::MAT_B :
|
case OgAtom::MAT_B :
|
||||||
glMaterialfv( GL_BACK, GL_AMBIENT_AND_DIFFUSE, ( bStdCol ? iIter->m_fVal : fSelMarkBackCol)) ;
|
glMaterialfv( GL_BACK, GL_AMBIENT_AND_DIFFUSE, ( bStdCol ? Oga.m_fVal : fSelMarkBackCol)) ;
|
||||||
|
break ;
|
||||||
|
case OgAtom::LINE_STIPPLE :
|
||||||
|
if ( Oga.m_nMode > 0) {
|
||||||
|
bLineStipple = true ;
|
||||||
|
glLineStipple( Clamp( Oga.m_nFactor, 1, 256), Clamp( Oga.m_nPattern, 0, 65535)) ;
|
||||||
|
glEnable( GL_LINE_STIPPLE) ;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bLineStipple = false ;
|
||||||
|
glDisable( GL_LINE_STIPPLE) ;
|
||||||
|
}
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( bLineStipple) {
|
||||||
|
bLineStipple = false ;
|
||||||
|
glDisable( GL_LINE_STIPPLE) ;
|
||||||
|
}
|
||||||
|
|
||||||
// se marcato e non superficie in shading, disegno halo
|
// se marcato e non superficie in shading, disegno halo
|
||||||
if ( nMark == GDB_MK_ON && ! bSurfSha) {
|
if ( nMark == GDB_MK_ON && ! bSurfSha) {
|
||||||
@@ -349,15 +373,16 @@ ObjOldGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bSurf, int nAlph
|
|||||||
|
|
||||||
// ciclo di disegno
|
// ciclo di disegno
|
||||||
bool bStartA = false ;
|
bool bStartA = false ;
|
||||||
for ( auto iIter = m_ogaVect.begin() ; iIter != m_ogaVect.end() ; ++ iIter) {
|
bool bLineStipple = false ;
|
||||||
switch ( iIter->m_nType) {
|
for ( const auto& Oga : m_ogaVect) {
|
||||||
|
switch ( Oga.m_nType) {
|
||||||
case OgAtom::START :
|
case OgAtom::START :
|
||||||
glBegin( iIter->m_nMode) ;
|
glBegin( Oga.m_nMode) ;
|
||||||
bStartA = false ;
|
bStartA = false ;
|
||||||
break ;
|
break ;
|
||||||
case OgAtom::START_A :
|
case OgAtom::START_A :
|
||||||
if ( bShowAux)
|
if ( bShowAux)
|
||||||
glBegin( iIter->m_nMode) ;
|
glBegin( Oga.m_nMode) ;
|
||||||
bStartA = true ;
|
bStartA = true ;
|
||||||
break ;
|
break ;
|
||||||
case OgAtom::END :
|
case OgAtom::END :
|
||||||
@@ -367,16 +392,31 @@ ObjOldGraphics::Draw( int nStat, int nMark, bool bSurfSha, bool bSurf, int nAlph
|
|||||||
break ;
|
break ;
|
||||||
case OgAtom::VERT :
|
case OgAtom::VERT :
|
||||||
if ( ! bStartA || bShowAux)
|
if ( ! bStartA || bShowAux)
|
||||||
glVertex3fv( iIter->m_fVal) ;
|
glVertex3fv( Oga.m_fVal) ;
|
||||||
break ;
|
break ;
|
||||||
case OgAtom::BND_FLAG :
|
case OgAtom::BND_FLAG :
|
||||||
if ( ! bStartA || bShowAux)
|
if ( ! bStartA || bShowAux)
|
||||||
glEdgeFlag( iIter->m_nFlag) ;
|
glEdgeFlag( Oga.m_nFlag) ;
|
||||||
break ;
|
break ;
|
||||||
// non si imposta la normale sono solo curve
|
// non si imposta la normale sono solo curve
|
||||||
// non si impostano i colori, si usa quello di marcatura
|
// non si impostano i colori, si usa quello di marcatura
|
||||||
|
case OgAtom::LINE_STIPPLE :
|
||||||
|
if ( Oga.m_nMode > 0) {
|
||||||
|
bLineStipple = true ;
|
||||||
|
glLineStipple( Clamp( Oga.m_nFactor, 1, 256), Clamp( Oga.m_nPattern, 0, 65535)) ;
|
||||||
|
glEnable( GL_LINE_STIPPLE) ;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bLineStipple = false ;
|
||||||
|
glDisable( GL_LINE_STIPPLE) ;
|
||||||
|
}
|
||||||
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( bLineStipple) {
|
||||||
|
bLineStipple = false ;
|
||||||
|
glDisable( GL_LINE_STIPPLE) ;
|
||||||
|
}
|
||||||
// ripristino test di depth
|
// ripristino test di depth
|
||||||
glDepthFunc( GL_LEQUAL) ;
|
glDepthFunc( GL_LEQUAL) ;
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-10
@@ -1,7 +1,7 @@
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// EgalTech 2014-2014
|
// EgalTech 2014-2023
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// File : ObjOldGraphics.h Data : 13.02.14 Versione : 1.5b1
|
// File : ObjOldGraphics.h Data : 08.07.23 Versione : 2.5g1
|
||||||
// Contenuto : Dichiarazione della classe grafica di un oggetto geometrico.
|
// Contenuto : Dichiarazione della classe grafica di un oggetto geometrico.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@@ -27,7 +27,7 @@ class OgAtom {
|
|||||||
|
|
||||||
public :
|
public :
|
||||||
enum GrType { NONE = 0, START = 1, START_A = 2, END = 3, VERT = 4, BND_FLAG = 5, NORMAL = 6,
|
enum GrType { NONE = 0, START = 1, START_A = 2, END = 3, VERT = 4, BND_FLAG = 5, NORMAL = 6,
|
||||||
COLOR = 7, MAT_A = 8, MAT_D = 9, MAT_S = 10, MAT_SH = 11, MAT_B = 12} ;
|
COLOR = 7, MAT_A = 8, MAT_D = 9, MAT_S = 10, MAT_SH = 11, MAT_B = 12, LINE_STIPPLE = 13} ;
|
||||||
|
|
||||||
public :
|
public :
|
||||||
GrType m_nType ;
|
GrType m_nType ;
|
||||||
@@ -47,6 +47,10 @@ class OgAtom {
|
|||||||
float m_fAlpha ;
|
float m_fAlpha ;
|
||||||
} ;
|
} ;
|
||||||
float m_fVal[4] ;
|
float m_fVal[4] ;
|
||||||
|
struct {
|
||||||
|
int m_nFactor ;
|
||||||
|
int m_nPattern ;
|
||||||
|
} ;
|
||||||
} ;
|
} ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
@@ -75,6 +79,7 @@ class ObjOldGraphics : public ObjEGrGraphics
|
|||||||
bool AddMaterial( const Color& colAmb, const Color& colDiff,
|
bool AddMaterial( const Color& colAmb, const Color& colDiff,
|
||||||
const Color& colSpec, float fShin) override ;
|
const Color& colSpec, float fShin) override ;
|
||||||
bool AddBackMaterial( const Color& colAmbDiff) override ;
|
bool AddBackMaterial( const Color& colAmbDiff) override ;
|
||||||
|
bool AddLineStipple( int nFactor, int nPattern) override ;
|
||||||
bool AddPoint( const Point3d& ptP, bool bAux = false) override ;
|
bool AddPoint( const Point3d& ptP, bool bAux = false) override ;
|
||||||
bool AddPoints( const PNTVECTOR& vPnt, bool bAux = false) override ;
|
bool AddPoints( const PNTVECTOR& vPnt, bool bAux = false) override ;
|
||||||
bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) override ;
|
bool AddLines( const PNTVECTOR& vPnt, bool bAux = false) override ;
|
||||||
@@ -83,6 +88,7 @@ class ObjOldGraphics : public ObjEGrGraphics
|
|||||||
bool AddTriangle( const Triangle3d& Tria, const TriFlags3d& TFlags, const TriNormals3d& TNrms) override ;
|
bool AddTriangle( const Triangle3d& Tria, const TriFlags3d& TFlags, const TriNormals3d& TNrms) override ;
|
||||||
bool EndTriangles( void) override ;
|
bool EndTriangles( void) override ;
|
||||||
bool Draw( int nStat, int nMark, bool bSurfSha, bool bSurf, int nAlpha, bool bShowAux) override ;
|
bool Draw( int nStat, int nMark, bool bSurfSha, bool bSurf, int nAlpha, bool bShowAux) override ;
|
||||||
|
|
||||||
bool GetLocalBBox( BBox3d& b3Loc) const override
|
bool GetLocalBBox( BBox3d& b3Loc) const override
|
||||||
{ b3Loc = m_b3Loc ; return ! m_b3Loc.IsEmpty() ; }
|
{ b3Loc = m_b3Loc ; return ! m_b3Loc.IsEmpty() ; }
|
||||||
|
|
||||||
@@ -94,40 +100,46 @@ class ObjOldGraphics : public ObjEGrGraphics
|
|||||||
{ try { m_ogaVect.push_back( oga) ; }
|
{ try { m_ogaVect.push_back( oga) ; }
|
||||||
catch(...) { return false ; }
|
catch(...) { return false ; }
|
||||||
return true ; }
|
return true ; }
|
||||||
bool AddStart( int nMode, bool bAux = false)
|
bool AddOgaStart( int nMode, bool bAux = false)
|
||||||
{ OgAtom oga ;
|
{ OgAtom oga ;
|
||||||
oga.m_nType = ( bAux ? OgAtom::START_A : OgAtom::START) ;
|
oga.m_nType = ( bAux ? OgAtom::START_A : OgAtom::START) ;
|
||||||
oga.m_nMode = nMode ;
|
oga.m_nMode = nMode ;
|
||||||
return AddOgAtom( oga) ; }
|
return AddOgAtom( oga) ; }
|
||||||
bool AddEnd( void)
|
bool AddOgaEnd( void)
|
||||||
{ OgAtom oga ;
|
{ OgAtom oga ;
|
||||||
oga.m_nType = OgAtom::END ;
|
oga.m_nType = OgAtom::END ;
|
||||||
return AddOgAtom( oga) ; }
|
return AddOgAtom( oga) ; }
|
||||||
bool AddVert3f( const Point3d& ptP)
|
bool AddOgaVert3f( const Point3d& ptP)
|
||||||
{ OgAtom oga ;
|
{ OgAtom oga ;
|
||||||
oga.m_nType = OgAtom::VERT ;
|
oga.m_nType = OgAtom::VERT ;
|
||||||
oga.m_fX = float( ptP.x) ; oga.m_fY = float( ptP.y) ; oga.m_fZ = float( ptP.z) ;
|
oga.m_fX = float( ptP.x) ; oga.m_fY = float( ptP.y) ; oga.m_fZ = float( ptP.z) ;
|
||||||
return AddOgAtom( oga) ; }
|
return AddOgAtom( oga) ; }
|
||||||
bool AddBndFlag( bool bFlag)
|
bool AddOgaBndFlag( bool bFlag)
|
||||||
{ OgAtom oga ;
|
{ OgAtom oga ;
|
||||||
oga.m_nType = OgAtom::BND_FLAG ;
|
oga.m_nType = OgAtom::BND_FLAG ;
|
||||||
oga.m_nFlag = ( bFlag ? TRUE : FALSE) ;
|
oga.m_nFlag = ( bFlag ? TRUE : FALSE) ;
|
||||||
return AddOgAtom( oga) ; }
|
return AddOgAtom( oga) ; }
|
||||||
bool AddNormal3f( const Vector3d& vtN)
|
bool AddOgaNormal3f( const Vector3d& vtN)
|
||||||
{ OgAtom oga ;
|
{ OgAtom oga ;
|
||||||
oga.m_nType = OgAtom::NORMAL ;
|
oga.m_nType = OgAtom::NORMAL ;
|
||||||
oga.m_fX = float( vtN.x) ; oga.m_fY = float( vtN.y) ; oga.m_fZ = float( vtN.z) ;
|
oga.m_fX = float( vtN.x) ; oga.m_fY = float( vtN.y) ; oga.m_fZ = float( vtN.z) ;
|
||||||
return AddOgAtom( oga) ; }
|
return AddOgAtom( oga) ; }
|
||||||
bool AddColor( float fRed, float fGreen, float fBlue, float fAlpha = 1)
|
bool AddOgaColor( float fRed, float fGreen, float fBlue, float fAlpha = 1)
|
||||||
{ OgAtom oga ;
|
{ OgAtom oga ;
|
||||||
oga.m_nType = OgAtom::COLOR ;
|
oga.m_nType = OgAtom::COLOR ;
|
||||||
oga.m_fRed = fRed ; oga.m_fGreen = fGreen ; oga.m_fBlue = fBlue ; oga.m_fAlpha = fAlpha ;
|
oga.m_fRed = fRed ; oga.m_fGreen = fGreen ; oga.m_fBlue = fBlue ; oga.m_fAlpha = fAlpha ;
|
||||||
return AddOgAtom( oga) ; }
|
return AddOgAtom( oga) ; }
|
||||||
bool AddMaterial( OgAtom::GrType nMat, float fRed, float fGreen, float fBlue, float fAlpha = 1)
|
bool AddOgaMaterial( OgAtom::GrType nMat, float fRed, float fGreen, float fBlue, float fAlpha = 1)
|
||||||
{ OgAtom nga ;
|
{ OgAtom nga ;
|
||||||
nga.m_nType = nMat ;
|
nga.m_nType = nMat ;
|
||||||
nga.m_fRed = fRed ; nga.m_fGreen = fGreen ; nga.m_fBlue = fBlue ; nga.m_fAlpha = fAlpha ;
|
nga.m_fRed = fRed ; nga.m_fGreen = fGreen ; nga.m_fBlue = fBlue ; nga.m_fAlpha = fAlpha ;
|
||||||
return AddOgAtom( nga) ; }
|
return AddOgAtom( nga) ; }
|
||||||
|
bool AddOgaLineStipple( int nFactor, int nPattern)
|
||||||
|
{ OgAtom oga ;
|
||||||
|
oga.m_nType = OgAtom::LINE_STIPPLE ;
|
||||||
|
oga.m_nFactor = nFactor ;
|
||||||
|
oga.m_nPattern = nPattern ;
|
||||||
|
return AddOgAtom( oga) ; }
|
||||||
|
|
||||||
private :
|
private :
|
||||||
Scene* m_pScene ; // puntatore alla scena
|
Scene* m_pScene ; // puntatore alla scena
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// EgalTech 2014-2020
|
// EgalTech 2014-2024
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// File : Scene.h Data : 02.01.20 Versione : 2.2a1
|
// File : Scene.h Data : 16.02.24 Versione : 2.6b4
|
||||||
// Contenuto : Dichiarazione della classe gestione scena.
|
// Contenuto : Dichiarazione della classe gestione scena.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Modifiche : 29.01.14 DS Creazione modulo.
|
// Modifiche : 29.01.14 DS Creazione modulo.
|
||||||
|
// 16.02.24 DS Aggiunte Set/Get CameraDirOrizzOffset.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -89,11 +90,15 @@ class Scene : public IEGrScene
|
|||||||
void Destroy( void) override ;
|
void Destroy( void) override ;
|
||||||
// Camera
|
// Camera
|
||||||
bool SetCenter( const Point3d& ptCenter) override ;
|
bool SetCenter( const Point3d& ptCenter) override ;
|
||||||
|
bool SetCameraDirOrizzOffset( int nRightStepOffset = 0) override
|
||||||
|
{ m_nOrizzOffsCamera = nRightStepOffset ; return true ; }
|
||||||
bool SetCamera( double dAngVertDeg, double dAngOrizzDeg, double dDist) override ;
|
bool SetCamera( double dAngVertDeg, double dAngOrizzDeg, double dDist) override ;
|
||||||
bool SetCamera( int nDir, double dDist = 0) override ;
|
bool SetCamera( int nDir, double dDist = 0) override ;
|
||||||
const Point3d& GetCenter( void) const override
|
const Point3d& GetCenter( void) const override
|
||||||
{ return m_ptCenter ; }
|
{ return m_ptCenter ; }
|
||||||
Point3d GetProjectedCenter( void) const override ;
|
Point3d GetProjectedCenter( void) const override ;
|
||||||
|
int GetCameraDirOrizzOffset( void) const override
|
||||||
|
{ return m_nOrizzOffsCamera ; }
|
||||||
void GetCamera( double* pdAngVertDeg, double* pdAngOrizzDeg, double* pdDist = nullptr) const override ;
|
void GetCamera( double* pdAngVertDeg, double* pdAngOrizzDeg, double* pdDist = nullptr) const override ;
|
||||||
int GetCameraDir( void) const override ;
|
int GetCameraDir( void) const override ;
|
||||||
const Vector3d& GetCameraUp( void) const override
|
const Vector3d& GetCameraUp( void) const override
|
||||||
@@ -106,6 +111,10 @@ class Scene : public IEGrScene
|
|||||||
bool ZoomChange( double dCoeff) override ;
|
bool ZoomChange( double dCoeff) override ;
|
||||||
bool ZoomOnPoint( const Point3d& ptWin, double dCoeff) override ;
|
bool ZoomOnPoint( const Point3d& ptWin, double dCoeff) override ;
|
||||||
bool ZoomWin( const Point3d& ptWin1, const Point3d& ptWin2) override ;
|
bool ZoomWin( const Point3d& ptWin1, const Point3d& ptWin2) override ;
|
||||||
|
bool RotateCameraWithCube() ;
|
||||||
|
bool RotateCameraWithBlockedAngle( Vector3d vDirS, Vector3d vDirE, double dDist, int nAdaptSpeed,
|
||||||
|
int nBlockedAngle, double dTheta_orig, double dPhi_orig,
|
||||||
|
double& dTheta_new, double& dPhi_new) ;
|
||||||
void GetOrthoCamParam( double* pdWidth, double* pdHeight, double* pdNear, double* pdFar) const override ;
|
void GetOrthoCamParam( double* pdWidth, double* pdHeight, double* pdNear, double* pdFar) const override ;
|
||||||
// ShowMode
|
// ShowMode
|
||||||
bool SetShowMode( int nShowMode) override
|
bool SetShowMode( int nShowMode) override
|
||||||
@@ -133,6 +142,12 @@ class Scene : public IEGrScene
|
|||||||
{ m_nShowText = nMode ; }
|
{ m_nShowText = nMode ; }
|
||||||
int GetShowText( void) const override
|
int GetShowText( void) const override
|
||||||
{ return m_nShowText ; }
|
{ return m_nShowText ; }
|
||||||
|
// Colors
|
||||||
|
void SetSceneColors( Color cColX, Color cColY, Color cColZ, Color cColXm, Color cColYm, Color cColZm,
|
||||||
|
Color cColEdge, Color cColCorner) override
|
||||||
|
{ m_cColX = cColX ; m_cColY = cColY ; m_cColZ = cColZ ;
|
||||||
|
m_cColXm = cColXm ; m_cColYm = cColYm ; m_cColZm = cColZm ;
|
||||||
|
m_cColEdge = cColEdge ; m_cColCorner = cColCorner ; }
|
||||||
// Geometry
|
// Geometry
|
||||||
bool SetExtension( const BBox3d& b3Ext) override ;
|
bool SetExtension( const BBox3d& b3Ext) override ;
|
||||||
bool UpdateExtension( void) override ;
|
bool UpdateExtension( void) override ;
|
||||||
@@ -142,11 +157,22 @@ class Scene : public IEGrScene
|
|||||||
// Grid
|
// Grid
|
||||||
bool SetGridShow( bool bShowGrid, bool bShowFrame) override ;
|
bool SetGridShow( bool bShowGrid, bool bShowFrame) override ;
|
||||||
bool SetGridGeo( double dSnapStep, int nMinLineSstep, int nMajLineSstep, int nExtSstep) override ;
|
bool SetGridGeo( double dSnapStep, int nMinLineSstep, int nMajLineSstep, int nExtSstep) override ;
|
||||||
|
bool SetGridGeoAdv( double dSnapStep, int nMinLineSstep, int nMajLineSstep,
|
||||||
|
double dXmin, double dXmax, double dYmin, double dYmax) override ;
|
||||||
bool SetGridColor( Color colMinLine, Color colMajLine) override ;
|
bool SetGridColor( Color colMinLine, Color colMajLine) override ;
|
||||||
void GetGridParam( double& dSnapStep, int& nExtStep) const override ;
|
void GetGridParam( double& dSnapStep, int& nExtStep) const override ;
|
||||||
bool GetShowGrid() override ;
|
bool GetShowGrid() override ;
|
||||||
// Glob Frame
|
// Axis Frame
|
||||||
bool SetGlobFrameShow( bool bShow) override ;
|
bool SetGlobFrameShow( bool bShow) override ;
|
||||||
|
bool SetGlobFrameParameters( int nPosFlag, double dDistX, double dDistY,
|
||||||
|
double dLenLine, double dWidthLine) override ;
|
||||||
|
// Glob Cube
|
||||||
|
bool DrawCube( bool bSurf) override ;
|
||||||
|
bool CreateFlatPart( ISurfTriMesh* pSrf) override ;
|
||||||
|
bool CreateEdgePart( ISurfTriMesh* pSrf) override ;
|
||||||
|
bool CreateCornerPart( ISurfTriMesh* pSrf) override ;
|
||||||
|
bool GetAngleByCubeFace( int nFaceId, double& dTheta, double& dPhi) ;
|
||||||
|
bool SetGlobCubeParameters( int nPosFlag, double dDistX, double dDistY, double dLenEdge) override ;
|
||||||
// Direct
|
// Direct
|
||||||
bool SetGeoLineAttribs( Color GLcol) override ;
|
bool SetGeoLineAttribs( Color GLcol) override ;
|
||||||
bool SetGeoLine( const Point3d& ptP1, const Point3d& ptP2) override ;
|
bool SetGeoLine( const Point3d& ptP1, const Point3d& ptP2) override ;
|
||||||
@@ -204,26 +230,26 @@ class Scene : public IEGrScene
|
|||||||
int GetOpenGLver( void)
|
int GetOpenGLver( void)
|
||||||
{ return m_nOglVer ; }
|
{ return m_nOglVer ; }
|
||||||
// PointSize - LineWidth
|
// PointSize - LineWidth
|
||||||
double GetPointSize( void)
|
double GetPointSize( void) const
|
||||||
{ return m_dPointSize ; }
|
{ return m_dPointSize ; }
|
||||||
double GetSelPointSize( void)
|
double GetSelPointSize( void) const
|
||||||
{ return m_dSelPointSize ; }
|
{ return m_dSelPointSize ; }
|
||||||
double GetMarkPointSize( void)
|
double GetMarkPointSize( void) const
|
||||||
{ return m_dMarkPointSize ; }
|
{ return m_dMarkPointSize ; }
|
||||||
double GetLineWidth( void)
|
double GetLineWidth( void) const
|
||||||
{ return m_dLineWidth ; }
|
{ return m_dLineWidth ; }
|
||||||
double GetSelLineWidth( void)
|
double GetSelLineWidth( void) const
|
||||||
{ return m_dSelLineWidth ; }
|
{ return m_dSelLineWidth ; }
|
||||||
double GetMarkLineWidth( void)
|
double GetMarkLineWidth( void) const
|
||||||
{ return m_dMarkLineWidth ; }
|
{ return m_dMarkLineWidth ; }
|
||||||
double GetGridLineWidth( void)
|
double GetGridLineWidth( void) const
|
||||||
{ return m_dGridLineWidth ; }
|
{ return m_dGridLineWidth ; }
|
||||||
double GetFrameLineWidth( void)
|
double GetFrameLineWidth( void) const
|
||||||
{ return m_dFrameLineWidth ; }
|
{ return m_dFrameLineWidth ; }
|
||||||
// Geometry
|
// Geometry
|
||||||
Color GetMark( void)
|
Color GetMark( void) const
|
||||||
{ return m_colMark ; }
|
{ return m_colMark ; }
|
||||||
Color GetSelSurf( void)
|
Color GetSelSurf( void) const
|
||||||
{ return m_colSelSurf ; }
|
{ return m_colSelSurf ; }
|
||||||
|
|
||||||
private :
|
private :
|
||||||
@@ -237,8 +263,8 @@ class Scene : public IEGrScene
|
|||||||
bool Background( void) ;
|
bool Background( void) ;
|
||||||
bool Prepare( void) ;
|
bool Prepare( void) ;
|
||||||
// Camera
|
// Camera
|
||||||
bool VerifyCamera( void) ;
|
bool VerifyCamera( bool bUseOrizzOffsCamera = false) ;
|
||||||
bool CalcDirUp( void) ;
|
bool CalcDirUp( bool bUseOrizzOffsCamera = false) ;
|
||||||
bool CalcCameraFrame( Frame3d& frView) ;
|
bool CalcCameraFrame( Frame3d& frView) ;
|
||||||
// Geometry
|
// Geometry
|
||||||
bool DrawGroup( int nId, int nPass, const MdStMkCol& siParent) ;
|
bool DrawGroup( int nId, int nPass, const MdStMkCol& siParent) ;
|
||||||
@@ -253,8 +279,11 @@ class Scene : public IEGrScene
|
|||||||
static Frame3d frGrid ;
|
static Frame3d frGrid ;
|
||||||
return frGrid ; }
|
return frGrid ; }
|
||||||
bool DrawGrid( void) ;
|
bool DrawGrid( void) ;
|
||||||
|
bool DrawRectangularGrid( void) ;
|
||||||
// Glob Frame
|
// Glob Frame
|
||||||
bool DrawGlobFrame( void) ;
|
bool DrawGlobFrame( void) ;
|
||||||
|
// Glob Cube
|
||||||
|
bool DrawGlobCube( bool bSurf) ;
|
||||||
// Direct
|
// Direct
|
||||||
bool DrawDirect( void) ;
|
bool DrawDirect( void) ;
|
||||||
bool DrawGeoLine( void) ;
|
bool DrawGeoLine( void) ;
|
||||||
@@ -286,10 +315,20 @@ class Scene : public IEGrScene
|
|||||||
HDC m_hDC ; // Device Context
|
HDC m_hDC ; // Device Context
|
||||||
HGLRC m_hRC ; // OpenGL Rendering Context
|
HGLRC m_hRC ; // OpenGL Rendering Context
|
||||||
int m_nOglVer ; // OpenGL Version
|
int m_nOglVer ; // OpenGL Version
|
||||||
bool m_bNewWay ; // flag che indica nuova modalità (OpenGL 3.0 in poi)
|
bool m_bNewWay ; // flag che indica nuova modalità (OpenGL 3.0 in poi)
|
||||||
|
// Colors
|
||||||
|
Color m_cColX ; // colore asse x
|
||||||
|
Color m_cColXm ; // colore asse -x
|
||||||
|
Color m_cColY ; // colore asse y
|
||||||
|
Color m_cColYm ; // colore asse -y
|
||||||
|
Color m_cColZ ; // colore asse z
|
||||||
|
Color m_cColZm ; // colore asse -z
|
||||||
|
Color m_cColEdge ; // colore per Edge ( per cubetto)
|
||||||
|
Color m_cColCorner ; // colore per Corner ( per cubetto)
|
||||||
// Camera
|
// Camera
|
||||||
Point3d m_ptCenter ; // centro verso cui è rivolta la camera
|
Point3d m_ptCenter ; // centro verso cui è rivolta la camera
|
||||||
Vector3d m_vtDirCamera ; // versore direzione dal centro alla camera
|
Vector3d m_vtDirCamera ; // versore direzione dal centro alla camera
|
||||||
|
int m_nOrizzOffsCamera ; // offset orizzontale viste camera in multipli di 90deg
|
||||||
double m_dDistCamera ; // distanza dal centro alla camera
|
double m_dDistCamera ; // distanza dal centro alla camera
|
||||||
Vector3d m_vtUp ; // versore direzione Su della camera
|
Vector3d m_vtUp ; // versore direzione Su della camera
|
||||||
bool m_bUpOk ; // flag per stato aggiornamento di Up
|
bool m_bUpOk ; // flag per stato aggiornamento di Up
|
||||||
@@ -304,7 +343,7 @@ class Scene : public IEGrScene
|
|||||||
int m_nShowMode ; // modo di visualizzazione (wireframe, hiddenline, shading)
|
int m_nShowMode ; // modo di visualizzazione (wireframe, hiddenline, shading)
|
||||||
bool m_bShowCurveDirection ; // flag di visualizzazione direzione curve
|
bool m_bShowCurveDirection ; // flag di visualizzazione direzione curve
|
||||||
bool m_bShowTriaAdvanced ; // flag per abilitare la visualizzazione avanzata dei triangoli
|
bool m_bShowTriaAdvanced ; // flag per abilitare la visualizzazione avanzata dei triangoli
|
||||||
int m_nShowZmap ; // modo visualizzazione Zmap (+1=surf, +2=spilloni, +4=normali, +8=più colori)
|
int m_nShowZmap ; // modo visualizzazione Zmap (+1=surf, +2=spilloni, +4=normali, +8=più colori)
|
||||||
int m_nShowText ; // modo visualizzazione scritte (1=solo contorni, 2=con riempimento)
|
int m_nShowText ; // modo visualizzazione scritte (1=solo contorni, 2=con riempimento)
|
||||||
// PointSize - LineWidth
|
// PointSize - LineWidth
|
||||||
double m_dPointSize ; // dimensione punti
|
double m_dPointSize ; // dimensione punti
|
||||||
@@ -329,9 +368,9 @@ class Scene : public IEGrScene
|
|||||||
SelRec m_nSelBuff[DIM_SEL_BUF] ; // buffer per selezione con OpenGL
|
SelRec m_nSelBuff[DIM_SEL_BUF] ; // buffer per selezione con OpenGL
|
||||||
// Snap
|
// Snap
|
||||||
// lo snap a oggetti usa la select, quindi anche per esso valgono m_nObjFilterForSelect e m_Unsel
|
// lo snap a oggetti usa la select, quindi anche per esso valgono m_nObjFilterForSelect e m_Unsel
|
||||||
int m_nLastSnapId ; // Id dell'entità generatrice dell'ultimo punto snap
|
int m_nLastSnapId ; // Id dell'entit� generatrice dell'ultimo punto snap
|
||||||
Point3d m_ptLastSnapPnt ; // ultimo punto di snap
|
Point3d m_ptLastSnapPnt ; // ultimo punto di snap
|
||||||
bool m_bLastSnapDirOk ; // flag validità direzione associata a ultimo punto snap
|
bool m_bLastSnapDirOk ; // flag validità direzione associata a ultimo punto snap
|
||||||
Vector3d m_vtLastSnapDir ; // direzione associata a ultimo punto snap
|
Vector3d m_vtLastSnapDir ; // direzione associata a ultimo punto snap
|
||||||
// Geometry
|
// Geometry
|
||||||
IGeomDB* m_pGeomDB ; // puntatore al DB geometrico
|
IGeomDB* m_pGeomDB ; // puntatore al DB geometrico
|
||||||
@@ -355,11 +394,29 @@ class Scene : public IEGrScene
|
|||||||
int m_nMinLineSstep ; // interasse tra due linee minori come numero di passi di snap
|
int m_nMinLineSstep ; // interasse tra due linee minori come numero di passi di snap
|
||||||
int m_nMajLineSstep ; // interasse tra due linee maggiori come numero di passi di snap
|
int m_nMajLineSstep ; // interasse tra due linee maggiori come numero di passi di snap
|
||||||
int m_nExtSstep ; // estensione della griglia come numero di passi di snap
|
int m_nExtSstep ; // estensione della griglia come numero di passi di snap
|
||||||
|
double m_dGridMinX ; // minima estensione in X della griglia
|
||||||
|
double m_dGridMaxX ; // massima estensione in X della griglia
|
||||||
|
double m_dGridMinY ; // minima estensione in Y della griglia
|
||||||
|
double m_dGridMaxY ; // massima estensione in Y della griglia
|
||||||
Color m_colMinLine ; // colore delle linee minori
|
Color m_colMinLine ; // colore delle linee minori
|
||||||
Color m_colMajLine ; // colore delle linee maggiori
|
Color m_colMajLine ; // colore delle linee maggiori
|
||||||
// Glob Frame
|
// Axis Frame
|
||||||
bool m_bShowGlobFrame ; // flag di visualizzazione del riferimento globale
|
bool m_bShowGlobFrame ; // flag di visualizzazione del riferimento globale
|
||||||
// Direct
|
int m_nAxisFrame_Flag ; // flag per quadrante di visualizzazione del frame
|
||||||
|
double m_dFrame_DistX ; // X del Centro del frame sullo schermo
|
||||||
|
double m_dFrame_DistY ; // Y del Centro del frame sullo schetrmo
|
||||||
|
double m_dFrameLineL ; // lunghezza delle linee del frame
|
||||||
|
double m_dFrameLineW ; // spessore delle linee del frame
|
||||||
|
// Glob Cube
|
||||||
|
ISURFTMPOVECTOR m_vStm_Cube ; // vettore contenente le superificie del cubo ( 26 in totale)
|
||||||
|
bool m_bShowGlobCube ; // flag di visualizzazione del cubetto
|
||||||
|
Point3d m_ptOrigCube ; // centro del cubo in cordinate globali
|
||||||
|
int m_nCube_Flag ; // flag per posizione negli angoli del cubetto
|
||||||
|
double m_dCubeEdge ; // lunghezza del lato del cubo
|
||||||
|
double m_dCubeX ; // X del Centro del cubo sullo schermo
|
||||||
|
double m_dCubeY ; // Y del Centro del cubo sullo schermo
|
||||||
|
int m_nStartFaceId ; // nuovo id iniziale utilizzato per assegnare un id univoco e non in uso alle facce del cubo
|
||||||
|
// Direct
|
||||||
Color m_colorGL ; // colore per GeoLine
|
Color m_colorGL ; // colore per GeoLine
|
||||||
bool m_bGeoLine ; // flag esistenza linea diretta in finestra
|
bool m_bGeoLine ; // flag esistenza linea diretta in finestra
|
||||||
Point3d m_ptGeoLineP1 ; // primo estremo della linea diretta
|
Point3d m_ptGeoLineP1 ; // primo estremo della linea diretta
|
||||||
|
|||||||
+53
-19
@@ -32,16 +32,13 @@ static const double MIN_EXTENSION = 250 ;
|
|||||||
static const double MIN_W_H = 0.01 ;
|
static const double MIN_W_H = 0.01 ;
|
||||||
static const double MIN_ZCLIP_EXT = 25000 ;
|
static const double MIN_ZCLIP_EXT = 25000 ;
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
IEGrScene*
|
IEGrScene*
|
||||||
CreateEGrScene( void)
|
CreateEGrScene( void)
|
||||||
{
|
{
|
||||||
// verifico la chiave e le opzioni
|
// verifico la chiave e le opzioni
|
||||||
if ( ! GetEGrNetHwKey()) {
|
if ( ! VerifyKey( 0))
|
||||||
if ( ! TestKeyForEGr( GetEGrKey(), 0, GetEGrLogger()))
|
return nullptr ;
|
||||||
return nullptr ;
|
|
||||||
}
|
|
||||||
// creo l'oggetto
|
// creo l'oggetto
|
||||||
return static_cast<IEGrScene*> ( new(nothrow) Scene) ;
|
return static_cast<IEGrScene*> ( new(nothrow) Scene) ;
|
||||||
}
|
}
|
||||||
@@ -54,8 +51,18 @@ Scene::Scene( void)
|
|||||||
m_hRC = nullptr ;
|
m_hRC = nullptr ;
|
||||||
m_nOglVer = 0 ;
|
m_nOglVer = 0 ;
|
||||||
m_bNewWay = false ;
|
m_bNewWay = false ;
|
||||||
|
// Colors
|
||||||
|
m_cColX = Color( 255, 0, 0, 1) ;
|
||||||
|
m_cColXm = Color( 167, 27, 11, 1) ;
|
||||||
|
m_cColY = Color( 0, 255, 0, 1) ;
|
||||||
|
m_cColYm = Color( 36, 163, 25, 1) ;
|
||||||
|
m_cColZ = Color( 0, 0, 255, 1) ;
|
||||||
|
m_cColZm = Color( 36, 17, 120, 1) ;
|
||||||
|
m_cColEdge = Color( 200, 200, 200, 1) ;
|
||||||
|
m_cColCorner = Color( 200, 200, 200, 1) ;
|
||||||
// Camera e viewport
|
// Camera e viewport
|
||||||
m_ptCenter = ORIG ;
|
m_ptCenter = ORIG ;
|
||||||
|
m_nOrizzOffsCamera = 0 ;
|
||||||
SetCamera( 0, 0, 0) ;
|
SetCamera( 0, 0, 0) ;
|
||||||
m_nViewportW = 0 ;
|
m_nViewportW = 0 ;
|
||||||
m_nViewportH = 0 ;
|
m_nViewportH = 0 ;
|
||||||
@@ -64,7 +71,7 @@ Scene::Scene( void)
|
|||||||
// Sfondo
|
// Sfondo
|
||||||
m_colBackTop.Set( 176, 176, 176) ;
|
m_colBackTop.Set( 176, 176, 176) ;
|
||||||
m_colBackBottom.Set( 176, 176, 176) ;
|
m_colBackBottom.Set( 176, 176, 176) ;
|
||||||
// Modalità di visualizzazione
|
// Modalit� di visualizzazione
|
||||||
m_nShowMode = SM_WIREFRAME ;
|
m_nShowMode = SM_WIREFRAME ;
|
||||||
m_bShowCurveDirection = false ;
|
m_bShowCurveDirection = false ;
|
||||||
m_bShowTriaAdvanced = true ;
|
m_bShowTriaAdvanced = true ;
|
||||||
@@ -100,10 +107,14 @@ Scene::Scene( void)
|
|||||||
// Grid
|
// Grid
|
||||||
m_bShowGrid = false ;
|
m_bShowGrid = false ;
|
||||||
m_bShowFrame = false ;
|
m_bShowFrame = false ;
|
||||||
m_dSnapStep = 1 ;
|
m_dSnapStep = 10 ;
|
||||||
m_nMinLineSstep = 10 ;
|
m_nMinLineSstep = 1 ;
|
||||||
m_nMajLineSstep = 100 ;
|
m_nMajLineSstep = 10 ;
|
||||||
m_nExtSstep = 500 ;
|
m_nExtSstep = 100 ;
|
||||||
|
m_dGridMinX = -INFINITO ;
|
||||||
|
m_dGridMaxX = INFINITO ;
|
||||||
|
m_dGridMinY = -INFINITO ;
|
||||||
|
m_dGridMaxY = INFINITO ;
|
||||||
m_colMinLine.Set( 160, 160, 160) ;
|
m_colMinLine.Set( 160, 160, 160) ;
|
||||||
m_colMajLine.Set( 160, 160, 160) ;
|
m_colMajLine.Set( 160, 160, 160) ;
|
||||||
// Global Frame
|
// Global Frame
|
||||||
@@ -135,7 +146,7 @@ Scene::Init( IGeomDB* pGeomDB)
|
|||||||
bool
|
bool
|
||||||
Scene::CreateContext( HDC hDC, int nDriver, bool b2Buff, int nColorBits, int nDepthBits)
|
Scene::CreateContext( HDC hDC, int nDriver, bool b2Buff, int nColorBits, int nDepthBits)
|
||||||
{
|
{
|
||||||
// verifico validità Device Context
|
// verifico validit� Device Context
|
||||||
if ( hDC == nullptr)
|
if ( hDC == nullptr)
|
||||||
return false ;
|
return false ;
|
||||||
m_hDC = hDC ;
|
m_hDC = hDC ;
|
||||||
@@ -212,7 +223,7 @@ Scene::CreateContext( HDC hDC, int nDriver, bool b2Buff, int nColorBits, int nDe
|
|||||||
LOG_INFO( GetEGrLogger(), "WGL_ARB_create_context missing !")
|
LOG_INFO( GetEGrLogger(), "WGL_ARB_create_context missing !")
|
||||||
}
|
}
|
||||||
|
|
||||||
// verifico validità Rendering Context
|
// verifico validit� Rendering Context
|
||||||
if ( m_hRC == nullptr)
|
if ( m_hRC == nullptr)
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
@@ -223,7 +234,7 @@ Scene::CreateContext( HDC hDC, int nDriver, bool b2Buff, int nColorBits, int nDe
|
|||||||
if ( GlewInitResult != GLEW_OK)
|
if ( GlewInitResult != GLEW_OK)
|
||||||
LOG_INFO( GetEGrLogger(), "GLEW is not initialized !")
|
LOG_INFO( GetEGrLogger(), "GLEW is not initialized !")
|
||||||
|
|
||||||
// verifico se posso lavorare in modalità nuova
|
// verifico se posso lavorare in modalit� nuova
|
||||||
m_bNewWay = ( nDriver == OD_NEW && glewIsSupported( "GL_VERSION_3_0") == 1) ;
|
m_bNewWay = ( nDriver == OD_NEW && glewIsSupported( "GL_VERSION_3_0") == 1) ;
|
||||||
if ( ! m_bNewWay)
|
if ( ! m_bNewWay)
|
||||||
LOG_INFO( GetEGrLogger(), "OpenGL old way rendering !")
|
LOG_INFO( GetEGrLogger(), "OpenGL old way rendering !")
|
||||||
@@ -285,11 +296,11 @@ Scene::ChooseGenPixelFormat( int nPfd, bool b2Buff, int nColorBits, int nDepthBi
|
|||||||
bool
|
bool
|
||||||
Scene::MakeCurrent( void) const
|
Scene::MakeCurrent( void) const
|
||||||
{
|
{
|
||||||
// se RC della scena non è definito, errore
|
// se RC della scena non � definito, errore
|
||||||
if ( m_hRC == nullptr)
|
if ( m_hRC == nullptr)
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// se RC della scena è quello corrente, ok
|
// se RC della scena � quello corrente, ok
|
||||||
HGLRC hRC = wglGetCurrentContext() ;
|
HGLRC hRC = wglGetCurrentContext() ;
|
||||||
if ( m_hRC == hRC)
|
if ( m_hRC == hRC)
|
||||||
return true ;
|
return true ;
|
||||||
@@ -416,7 +427,7 @@ Scene::SetExtension( const BBox3d& b3Ext)
|
|||||||
bool
|
bool
|
||||||
Scene::CalcExtView( void)
|
Scene::CalcExtView( void)
|
||||||
{
|
{
|
||||||
// verifico se il calcolo è necessario
|
// verifico se il calcolo � necessario
|
||||||
if ( m_bExtViewOk && m_bUpOk)
|
if ( m_bExtViewOk && m_bUpOk)
|
||||||
return true ;
|
return true ;
|
||||||
// calcolo direzione camera Up
|
// calcolo direzione camera Up
|
||||||
@@ -514,6 +525,7 @@ Scene::CalcClippingPlanesFromExtView( void)
|
|||||||
double dExtent = max( ( EXP_COEFF * vtExtent.z), MIN_ZCLIP_EXT) ;
|
double dExtent = max( ( EXP_COEFF * vtExtent.z), MIN_ZCLIP_EXT) ;
|
||||||
m_dZNear = - ( ptCenter.z + dExtent) ;
|
m_dZNear = - ( ptCenter.z + dExtent) ;
|
||||||
m_dZFar = - ( ptCenter.z - dExtent) ;
|
m_dZFar = - ( ptCenter.z - dExtent) ;
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -728,12 +740,12 @@ Scene::MyDraw( bool bSwapBF)
|
|||||||
if ( m_pGeomDB != nullptr)
|
if ( m_pGeomDB != nullptr)
|
||||||
m_pGeomDB->GetDefaultMaterial( m_colDef) ;
|
m_pGeomDB->GetDefaultMaterial( m_colDef) ;
|
||||||
|
|
||||||
// impostazioni dipendenti dalla modalità di visualizzazione
|
// impostazioni dipendenti dalla modalit� di visualizzazione
|
||||||
switch ( m_nShowMode) {
|
switch ( m_nShowMode) {
|
||||||
case SM_WIREFRAME :
|
case SM_WIREFRAME :
|
||||||
// disabilito illuminazione
|
// disabilito illuminazione
|
||||||
glDisable( GL_LIGHTING) ;
|
glDisable( GL_LIGHTING) ;
|
||||||
// disegno griglia senza illuminazione (già impostato)
|
// disegno griglia senza illuminazione (gi� impostato)
|
||||||
DrawGrid() ;
|
DrawGrid() ;
|
||||||
// imposto dati standard per punti e linee
|
// imposto dati standard per punti e linee
|
||||||
glPointSize( (float) GetPointSize()) ;
|
glPointSize( (float) GetPointSize()) ;
|
||||||
@@ -746,7 +758,7 @@ Scene::MyDraw( bool bSwapBF)
|
|||||||
case SM_HIDDENLINE :
|
case SM_HIDDENLINE :
|
||||||
// disabilito illuminazione
|
// disabilito illuminazione
|
||||||
glDisable( GL_LIGHTING) ;
|
glDisable( GL_LIGHTING) ;
|
||||||
// disegno griglia senza illuminazione (già impostato)
|
// disegno griglia senza illuminazione (gi� impostato)
|
||||||
DrawGrid() ;
|
DrawGrid() ;
|
||||||
// imposto dati standard per punti e linee
|
// imposto dati standard per punti e linee
|
||||||
glPointSize( (float) GetPointSize()) ;
|
glPointSize( (float) GetPointSize()) ;
|
||||||
@@ -832,6 +844,10 @@ Scene::MyDraw( bool bSwapBF)
|
|||||||
glDisable( GL_DEPTH_TEST) ;
|
glDisable( GL_DEPTH_TEST) ;
|
||||||
glDisable( GL_LIGHTING) ;
|
glDisable( GL_LIGHTING) ;
|
||||||
|
|
||||||
|
// da togliere e richiamare esternamente...
|
||||||
|
SetGlobCubeParameters( 1, 60, 60, 75) ;
|
||||||
|
SetGlobFrameParameters( 3, 40, 40, 25, 2) ;
|
||||||
|
|
||||||
// disegno riferimento globale
|
// disegno riferimento globale
|
||||||
DrawGlobFrame() ;
|
DrawGlobFrame() ;
|
||||||
|
|
||||||
@@ -839,6 +855,24 @@ Scene::MyDraw( bool bSwapBF)
|
|||||||
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL) ;
|
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL) ;
|
||||||
DrawDirect() ;
|
DrawDirect() ;
|
||||||
|
|
||||||
|
|
||||||
|
// disegno il cubetto
|
||||||
|
glDisable( GL_LIGHTING) ;
|
||||||
|
glEnable( GL_DEPTH_TEST) ;
|
||||||
|
glEnable( GL_POLYGON_OFFSET_FILL) ;
|
||||||
|
glFrontFace( GL_CCW) ;
|
||||||
|
glCullFace( GL_BACK) ;
|
||||||
|
glEnable( GL_CULL_FACE) ;
|
||||||
|
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL) ;
|
||||||
|
glPolygonOffset( 0.5, 0.5) ;
|
||||||
|
DrawGlobCube( true) ; // superifici
|
||||||
|
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE) ;
|
||||||
|
glLineWidth( 1) ;
|
||||||
|
DrawGlobCube( false) ; // linee
|
||||||
|
glLineWidth( GetLineWidth()) ;
|
||||||
|
glDisable( GL_CULL_FACE) ;
|
||||||
|
glDisable( GL_DEPTH_TEST) ;
|
||||||
|
|
||||||
// aggiorno
|
// aggiorno
|
||||||
glFlush() ;
|
glFlush() ;
|
||||||
|
|
||||||
|
|||||||
+51
-25
@@ -24,6 +24,11 @@ using namespace std ;
|
|||||||
static const double MIN_DIST_CAMERA = 10 ;
|
static const double MIN_DIST_CAMERA = 10 ;
|
||||||
static const double STD_DIST_CAMERA = 1000 ;
|
static const double STD_DIST_CAMERA = 1000 ;
|
||||||
|
|
||||||
|
static const double MIN_HALF_WIDTH_STD = 0.7 ;
|
||||||
|
static const double MAX_HALF_WIDTH_STD = 180000 ;
|
||||||
|
static const double MIN_HALF_HEIGHT_STD = 0.5 ;
|
||||||
|
static const double MAX_HALF_HEIGHT_STD = 140000 ;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
Scene::SetCenter( const Point3d& ptCenter)
|
Scene::SetCenter( const Point3d& ptCenter)
|
||||||
@@ -83,16 +88,16 @@ Scene::SetCamera( int nDir, double dDist)
|
|||||||
m_vtDirCamera.Set( 0, 0, -1) ;
|
m_vtDirCamera.Set( 0, 0, -1) ;
|
||||||
break ;
|
break ;
|
||||||
case CT_ISO_SW :
|
case CT_ISO_SW :
|
||||||
m_vtDirCamera.Set( - SQRT1_3, - SQRT1_3, SQRT1_3) ;
|
m_vtDirCamera.Set( -SQRT1_3, -SQRT1_3, SQRT1_3) ;
|
||||||
break ;
|
break ;
|
||||||
case CT_ISO_SE :
|
case CT_ISO_SE :
|
||||||
m_vtDirCamera.Set( SQRT1_3, - SQRT1_3, SQRT1_3) ;
|
m_vtDirCamera.Set( SQRT1_3, -SQRT1_3, SQRT1_3) ;
|
||||||
break ;
|
break ;
|
||||||
case CT_ISO_NE :
|
case CT_ISO_NE :
|
||||||
m_vtDirCamera.Set( SQRT1_3, SQRT1_3, SQRT1_3) ;
|
m_vtDirCamera.Set( SQRT1_3, SQRT1_3, SQRT1_3) ;
|
||||||
break ;
|
break ;
|
||||||
case CT_ISO_NW :
|
case CT_ISO_NW :
|
||||||
m_vtDirCamera.Set( - SQRT1_3, SQRT1_3, SQRT1_3) ;
|
m_vtDirCamera.Set( -SQRT1_3, SQRT1_3, SQRT1_3) ;
|
||||||
break ;
|
break ;
|
||||||
case CT_CPLANE :
|
case CT_CPLANE :
|
||||||
m_vtDirCamera = GetGridFrame().VersZ() ;
|
m_vtDirCamera = GetGridFrame().VersZ() ;
|
||||||
@@ -101,14 +106,15 @@ Scene::SetCamera( int nDir, double dDist)
|
|||||||
return false ;
|
return false ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
if ( nDir != CT_CPLANE)
|
||||||
|
m_vtDirCamera.Rotate( Z_AX, m_nOrizzOffsCamera * ANG_RIGHT) ;
|
||||||
m_dDistCamera = dDist ;
|
m_dDistCamera = dDist ;
|
||||||
|
return VerifyCamera( nDir != CT_CPLANE) ;
|
||||||
return VerifyCamera() ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
Scene::VerifyCamera( void)
|
Scene::VerifyCamera( bool bUseOrizzOffsCamera)
|
||||||
{
|
{
|
||||||
// verifico il versore
|
// verifico il versore
|
||||||
if ( ! m_vtDirCamera.Normalize())
|
if ( ! m_vtDirCamera.Normalize())
|
||||||
@@ -118,12 +124,16 @@ Scene::VerifyCamera( void)
|
|||||||
m_dDistCamera = STD_DIST_CAMERA ;
|
m_dDistCamera = STD_DIST_CAMERA ;
|
||||||
else
|
else
|
||||||
m_dDistCamera = max( m_dDistCamera, MIN_DIST_CAMERA) ;
|
m_dDistCamera = max( m_dDistCamera, MIN_DIST_CAMERA) ;
|
||||||
// invalido Up e ExtView
|
// ricalcolo direzione Up
|
||||||
m_bUpOk = false ;
|
m_bUpOk = false ;
|
||||||
|
if ( ! CalcDirUp( bUseOrizzOffsCamera))
|
||||||
|
return false ;
|
||||||
|
// ricalcolo ExtView
|
||||||
m_bExtViewOk = false ;
|
m_bExtViewOk = false ;
|
||||||
|
if ( ! CalcExtView())
|
||||||
|
return false ;
|
||||||
// calcolo nuovi dati di Z clipping
|
// calcolo nuovi dati di Z clipping
|
||||||
CalcClippingPlanesFromExtView() ;
|
return CalcClippingPlanesFromExtView() ;
|
||||||
return true ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -157,25 +167,27 @@ Scene::GetCamera( double* pdAngVertDeg, double* pdAngOrizzDeg, double* pdDist) c
|
|||||||
int
|
int
|
||||||
Scene::GetCameraDir( void) const
|
Scene::GetCameraDir( void) const
|
||||||
{
|
{
|
||||||
if ( m_vtDirCamera.IsZplus())
|
Vector3d vtDir = m_vtDirCamera ;
|
||||||
|
vtDir.Rotate( Z_AX, - m_nOrizzOffsCamera * ANG_RIGHT) ;
|
||||||
|
if ( vtDir.IsZplus())
|
||||||
return CT_TOP ;
|
return CT_TOP ;
|
||||||
else if ( m_vtDirCamera.IsYminus())
|
else if ( vtDir.IsYminus())
|
||||||
return CT_FRONT ;
|
return CT_FRONT ;
|
||||||
else if ( m_vtDirCamera.IsXplus())
|
else if ( vtDir.IsXplus())
|
||||||
return CT_RIGHT ;
|
return CT_RIGHT ;
|
||||||
else if ( m_vtDirCamera.IsYplus())
|
else if ( vtDir.IsYplus())
|
||||||
return CT_BACK ;
|
return CT_BACK ;
|
||||||
else if ( m_vtDirCamera.IsXminus())
|
else if ( vtDir.IsXminus())
|
||||||
return CT_LEFT ;
|
return CT_LEFT ;
|
||||||
else if ( m_vtDirCamera.IsZminus())
|
else if ( vtDir.IsZminus())
|
||||||
return CT_BOTTOM ;
|
return CT_BOTTOM ;
|
||||||
else if ( AreSameVectorApprox( m_vtDirCamera, Vector3d( - SQRT1_3, - SQRT1_3, SQRT1_3)))
|
else if ( AreSameVectorApprox( vtDir, Vector3d( - SQRT1_3, - SQRT1_3, SQRT1_3)))
|
||||||
return CT_ISO_SW ;
|
return CT_ISO_SW ;
|
||||||
else if ( AreSameVectorApprox( m_vtDirCamera, Vector3d( SQRT1_3, - SQRT1_3, SQRT1_3)))
|
else if ( AreSameVectorApprox( vtDir, Vector3d( SQRT1_3, - SQRT1_3, SQRT1_3)))
|
||||||
return CT_ISO_SE ;
|
return CT_ISO_SE ;
|
||||||
else if ( AreSameVectorApprox( m_vtDirCamera, Vector3d( SQRT1_3, SQRT1_3, SQRT1_3)))
|
else if ( AreSameVectorApprox( vtDir, Vector3d( SQRT1_3, SQRT1_3, SQRT1_3)))
|
||||||
return CT_ISO_NE ;
|
return CT_ISO_NE ;
|
||||||
else if ( AreSameVectorApprox( m_vtDirCamera, Vector3d( - SQRT1_3, SQRT1_3, SQRT1_3)))
|
else if ( AreSameVectorApprox( vtDir, Vector3d( - SQRT1_3, SQRT1_3, SQRT1_3)))
|
||||||
return CT_ISO_NW ;
|
return CT_ISO_NW ;
|
||||||
else
|
else
|
||||||
return CT_NONE ;
|
return CT_NONE ;
|
||||||
@@ -194,7 +206,7 @@ Scene::GetProjectedCenter( void) const
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
Scene::CalcDirUp( void)
|
Scene::CalcDirUp( bool bUseOrizzOffsCamera)
|
||||||
{
|
{
|
||||||
// verifico se il calcolo è necessario
|
// verifico se il calcolo è necessario
|
||||||
if ( m_bUpOk)
|
if ( m_bUpOk)
|
||||||
@@ -203,10 +215,9 @@ Scene::CalcDirUp( void)
|
|||||||
// ( m_vtDirCamera è opposta alla direzione in cui si guarda)
|
// ( m_vtDirCamera è opposta alla direzione in cui si guarda)
|
||||||
Vector3d vtPerpXY = m_vtDirCamera ^ Z_AX ;
|
Vector3d vtPerpXY = m_vtDirCamera ^ Z_AX ;
|
||||||
if ( ! vtPerpXY.Normalize()) {
|
if ( ! vtPerpXY.Normalize()) {
|
||||||
if ( m_vtDirCamera.z < 0)
|
vtPerpXY = -X_AX ;
|
||||||
vtPerpXY = X_AX ;
|
if ( bUseOrizzOffsCamera)
|
||||||
else
|
vtPerpXY.Rotate( Z_AX, m_nOrizzOffsCamera * ANG_RIGHT) ;
|
||||||
vtPerpXY = - X_AX ;
|
|
||||||
}
|
}
|
||||||
// direzione Up
|
// direzione Up
|
||||||
m_vtUp = vtPerpXY ^ m_vtDirCamera ;
|
m_vtUp = vtPerpXY ^ m_vtDirCamera ;
|
||||||
@@ -362,7 +373,6 @@ Scene::ZoomChange( double dCoeff)
|
|||||||
dCoeff = MIN_COEFF ;
|
dCoeff = MIN_COEFF ;
|
||||||
else if ( dCoeff > MAX_COEFF)
|
else if ( dCoeff > MAX_COEFF)
|
||||||
dCoeff = MAX_COEFF ;
|
dCoeff = MAX_COEFF ;
|
||||||
// cambio le dimensioni di zoom
|
|
||||||
m_dHalfWidth *= dCoeff ;
|
m_dHalfWidth *= dCoeff ;
|
||||||
m_dHalfHeight *= dCoeff ;
|
m_dHalfHeight *= dCoeff ;
|
||||||
|
|
||||||
@@ -373,6 +383,22 @@ Scene::ZoomChange( double dCoeff)
|
|||||||
bool
|
bool
|
||||||
Scene::ZoomOnPoint( const Point3d& ptWin, double dCoeff)
|
Scene::ZoomOnPoint( const Point3d& ptWin, double dCoeff)
|
||||||
{
|
{
|
||||||
|
// recupero la matrice viewport
|
||||||
|
GLint Viewport[4] ;
|
||||||
|
glGetIntegerv( GL_VIEWPORT, Viewport) ;
|
||||||
|
|
||||||
|
// range valori delle Viewport
|
||||||
|
double dLimInfHW = MIN_HALF_WIDTH_STD * Viewport[2] / 1152.0 ;
|
||||||
|
double dLimInfHH = MIN_HALF_HEIGHT_STD * Viewport[3] / 928.0 ;
|
||||||
|
double dLimSupHW = MAX_HALF_WIDTH_STD * Viewport[2] / 1152.0 ;
|
||||||
|
double dLimSupHH = MAX_HALF_WIDTH_STD * Viewport[3] / 928.0 ;
|
||||||
|
|
||||||
|
// controllo se i parametri di Zoom minimo e massimo sono rispettati, altrimenti esco
|
||||||
|
if ( m_dHalfWidth * dCoeff > dLimSupHW || m_dHalfHeight * dCoeff > dLimSupHH)
|
||||||
|
return true ;
|
||||||
|
if ( m_dHalfWidth * dCoeff < dLimInfHW || m_dHalfHeight * dCoeff < dLimInfHH)
|
||||||
|
return true ;
|
||||||
|
|
||||||
// porto il punto in coordinate mondo
|
// porto il punto in coordinate mondo
|
||||||
Point3d ptView( ptWin.x, ptWin.y, GetProjectedCenter().z) ;
|
Point3d ptView( ptWin.x, ptWin.y, GetProjectedCenter().z) ;
|
||||||
Point3d ptWorld ;
|
Point3d ptWorld ;
|
||||||
|
|||||||
+25
-16
@@ -276,6 +276,9 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
|
|||||||
// calcolo la grafica
|
// calcolo la grafica
|
||||||
pGraphics->Clear() ;
|
pGraphics->Clear() ;
|
||||||
pGraphics->AddColor( siObj.colObj) ;
|
pGraphics->AddColor( siObj.colObj) ;
|
||||||
|
int nFactor, nPattern ;
|
||||||
|
if ( iIter.GetStipple( nFactor, nPattern) && nFactor != 0)
|
||||||
|
pGraphics->AddLineStipple( nFactor, nPattern) ;
|
||||||
PolyLine PL ;
|
PolyLine PL ;
|
||||||
if ( pVector->GetDrawWithArrowHead( 0.1, 10, PL))
|
if ( pVector->GetDrawWithArrowHead( 0.1, 10, PL))
|
||||||
pGraphics->AddPolyLine(PL) ;
|
pGraphics->AddPolyLine(PL) ;
|
||||||
@@ -291,6 +294,9 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
|
|||||||
// calcolo la grafica
|
// calcolo la grafica
|
||||||
pGraphics->Clear() ;
|
pGraphics->Clear() ;
|
||||||
pGraphics->AddColor( siObj.colObj) ;
|
pGraphics->AddColor( siObj.colObj) ;
|
||||||
|
int nFactor, nPattern ;
|
||||||
|
if ( iIter.GetStipple( nFactor, nPattern) && nFactor != 0)
|
||||||
|
pGraphics->AddLineStipple( nFactor, nPattern) ;
|
||||||
pGraphics->AddPoint( pPoint->GetPoint()) ;
|
pGraphics->AddPoint( pPoint->GetPoint()) ;
|
||||||
}
|
}
|
||||||
// se riferimento
|
// se riferimento
|
||||||
@@ -301,7 +307,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
|
|||||||
return false ;
|
return false ;
|
||||||
// aggiorno la grafica (colori speciali)
|
// aggiorno la grafica (colori speciali)
|
||||||
PolyLine plX, plY, plZ ;
|
PolyLine plX, plY, plZ ;
|
||||||
pFrame->GetDrawWithArrowHeads( 10, 0.1, plX, plY, plZ) ;
|
pFrame->GetDrawWithArrowHeads( 40, 0.1, plX, plY, plZ) ;
|
||||||
pGraphics->Clear() ;
|
pGraphics->Clear() ;
|
||||||
pGraphics->AddColor( RED) ;
|
pGraphics->AddColor( RED) ;
|
||||||
pGraphics->AddPolyLine( plX) ;
|
pGraphics->AddPolyLine( plX) ;
|
||||||
@@ -321,6 +327,9 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
|
|||||||
pCurve->ApproxWithLines( EPS_SMALL, ANG_TOL_GRAPH_DEG, ICurve::APL_SPECIAL, PL) ;
|
pCurve->ApproxWithLines( EPS_SMALL, ANG_TOL_GRAPH_DEG, ICurve::APL_SPECIAL, PL) ;
|
||||||
pGraphics->Clear() ;
|
pGraphics->Clear() ;
|
||||||
pGraphics->AddColor( siObj.colObj) ;
|
pGraphics->AddColor( siObj.colObj) ;
|
||||||
|
int nFactor, nPattern ;
|
||||||
|
if ( iIter.GetStipple( nFactor, nPattern) && nFactor != 0)
|
||||||
|
pGraphics->AddLineStipple( nFactor, nPattern) ;
|
||||||
pGraphics->AddPolyLine( PL) ;
|
pGraphics->AddPolyLine( PL) ;
|
||||||
// eventuali segni ausiliari (mark, frecce, ...)
|
// eventuali segni ausiliari (mark, frecce, ...)
|
||||||
Vector3d vtRef ;
|
Vector3d vtRef ;
|
||||||
@@ -456,6 +465,8 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
|
|||||||
int nCount = 0 ;
|
int nCount = 0 ;
|
||||||
// numero di colori
|
// numero di colori
|
||||||
const int ZMAP_COL = 2 ;
|
const int ZMAP_COL = 2 ;
|
||||||
|
// indicazione se tridexel
|
||||||
|
bool bIsTriDexel = pZmap->IsTriDexel() ;
|
||||||
// se triangoli da disegnare
|
// se triangoli da disegnare
|
||||||
if ( ( m_nShowZmap & ZSM_SURF) != 0) {
|
if ( ( m_nShowZmap & ZSM_SURF) != 0) {
|
||||||
// definizione materiali
|
// definizione materiali
|
||||||
@@ -515,7 +526,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
|
|||||||
for ( const auto& Tria : vTria) {
|
for ( const auto& Tria : vTria) {
|
||||||
if ( ( j == 0 && Tria.GetGrade() != 0) || ( j == 1 && Tria.GetGrade() == 0))
|
if ( ( j == 0 && Tria.GetGrade() != 0) || ( j == 1 && Tria.GetGrade() == 0))
|
||||||
continue ;
|
continue ;
|
||||||
if ( m_bShowTriaAdvanced)
|
if ( m_bShowTriaAdvanced && bIsTriDexel)
|
||||||
pGraphics->AddTriangle( Tria, Tria.GetTriFlags(), Tria.GetTriNormals()) ;
|
pGraphics->AddTriangle( Tria, Tria.GetTriFlags(), Tria.GetTriNormals()) ;
|
||||||
else
|
else
|
||||||
pGraphics->AddTriangle( Tria, TriFlags3d(), TriNormals3d( Tria.GetN())) ;
|
pGraphics->AddTriangle( Tria, TriFlags3d(), TriNormals3d( Tria.GetN())) ;
|
||||||
@@ -637,7 +648,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
|
|||||||
POLYLINELIST lstPL ;
|
POLYLINELIST lstPL ;
|
||||||
if ( pUserObj->GetDrawPolyLines( lstPL)) {
|
if ( pUserObj->GetDrawPolyLines( lstPL)) {
|
||||||
for ( const auto& PL : lstPL)
|
for ( const auto& PL : lstPL)
|
||||||
pGraphics->AddPolyLine( PL, true) ;
|
pGraphics->AddPolyLine( PL, ( PL.GetTempProp() == 0)) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -725,17 +736,15 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
|
|||||||
Frame3d frTxr ;
|
Frame3d frTxr ;
|
||||||
iIter.GetTextureFrame( frTxr) ;
|
iIter.GetTextureFrame( frTxr) ;
|
||||||
// creo piano per la S
|
// creo piano per la S
|
||||||
GLfloat PlaneS[4] ;
|
GLfloat PlaneS[4] { GLfloat( frTxr.VersX().x / dTextDimS),
|
||||||
PlaneS[0] = GLfloat( frTxr.VersX().x / dTextDimS) ;
|
GLfloat( frTxr.VersX().y / dTextDimS),
|
||||||
PlaneS[1] = GLfloat( frTxr.VersX().y / dTextDimS) ;
|
GLfloat( frTxr.VersX().z / dTextDimS),
|
||||||
PlaneS[2] = GLfloat( frTxr.VersX().z / dTextDimS) ;
|
GLfloat( -frTxr.VersX() * ( frTxr.Orig() - ORIG) / dTextDimS)} ;
|
||||||
PlaneS[3] = GLfloat( - frTxr.VersX() * ( frTxr.Orig() - ORIG) / dTextDimS) ;
|
|
||||||
// creo piano per la T
|
// creo piano per la T
|
||||||
GLfloat PlaneT[4] ;
|
GLfloat PlaneT[4] { GLfloat( frTxr.VersY().x / dTextDimT),
|
||||||
PlaneT[0] = GLfloat( frTxr.VersY().x / dTextDimT) ;
|
GLfloat( frTxr.VersY().y / dTextDimT),
|
||||||
PlaneT[1] = GLfloat( frTxr.VersY().y / dTextDimT) ;
|
GLfloat( frTxr.VersY().z / dTextDimT),
|
||||||
PlaneT[2] = GLfloat( frTxr.VersY().z / dTextDimT) ;
|
GLfloat( -frTxr.VersY() * ( frTxr.Orig() - ORIG) / dTextDimT)} ;
|
||||||
PlaneT[3] = GLfloat( - frTxr.VersY() * ( frTxr.Orig() - ORIG) / dTextDimT) ;
|
|
||||||
// setto generazione automatica coordinate S e T per texture
|
// setto generazione automatica coordinate S e T per texture
|
||||||
glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR) ;
|
glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR) ;
|
||||||
glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR) ;
|
glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR) ;
|
||||||
@@ -965,18 +974,18 @@ static bool
|
|||||||
CalcCurveConnectingLines( const PolyLine& plCrv, const Vector3d& vtTh, bool bDense, PNTVECTOR& vPnt)
|
CalcCurveConnectingLines( const PolyLine& plCrv, const Vector3d& vtTh, bool bDense, PNTVECTOR& vPnt)
|
||||||
{
|
{
|
||||||
// assegno coefficiente
|
// assegno coefficiente
|
||||||
double dDelta = ( bDense ? 0.25 : 1) ;
|
double dDelta = ( bDense ? 0.25 : 0.5) ;
|
||||||
// ciclo per creare i segmenti di raccordo
|
// ciclo per creare i segmenti di raccordo
|
||||||
double dU, dUprev = - dDelta ;
|
double dU, dUprev = - dDelta ;
|
||||||
vPnt.reserve( 5) ;
|
vPnt.reserve( 5) ;
|
||||||
for ( bool bFound = plCrv.GetFirstU( dU) ; bFound ; bFound = plCrv.GetNextU( dU)) {
|
for ( bool bFound = plCrv.GetFirstU( dU) ; bFound ; bFound = plCrv.GetNextU( dU)) {
|
||||||
if ( ( dU - dUprev) > dDelta - EPS_PARAM) {
|
if ( ( dU - dUprev) > dDelta - EPS_PARAM || fmod( dU, 1.) < EPS_PARAM) {
|
||||||
Point3d ptP ;
|
Point3d ptP ;
|
||||||
plCrv.GetCurrPoint( ptP) ;
|
plCrv.GetCurrPoint( ptP) ;
|
||||||
vPnt.push_back( ptP) ;
|
vPnt.push_back( ptP) ;
|
||||||
ptP += vtTh ;
|
ptP += vtTh ;
|
||||||
vPnt.push_back( ptP) ;
|
vPnt.push_back( ptP) ;
|
||||||
dUprev += dDelta ;
|
dUprev = dU ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true ;
|
return true ;
|
||||||
|
|||||||
@@ -0,0 +1,770 @@
|
|||||||
|
//----------------------------------------------------------------------------
|
||||||
|
// EgalTech 2022
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
// File : SceneGlobCube.cpp Data : 10.10.22 Versione : 1
|
||||||
|
// Contenuto : Implementazione gestione e disegno Cubetto per viste.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Modifiche : 11.10.22 DS Creazione modulo.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//--------------------------- Include ----------------------------------------
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "Scene.h"
|
||||||
|
#include "EGrUtils.h"
|
||||||
|
#include "ObjOldGraphics.h"
|
||||||
|
#include "ObjNewGraphics.h"
|
||||||
|
#include "ObjMultiGraphics.h"
|
||||||
|
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||||
|
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||||
|
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||||
|
#include "/EgtDev/Include/EGkObjGraphics.h"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace std ;
|
||||||
|
|
||||||
|
// posizione X e Y dello schermo
|
||||||
|
const double MIN_EDGE_SIZE = 20 ;
|
||||||
|
const double MAX_EDGE_SIZE = 200.0 ;
|
||||||
|
|
||||||
|
// colore render dei bordi delle superifici del cubo
|
||||||
|
const Color CUBE_LINES( 0, 0, 0, 1) ;
|
||||||
|
|
||||||
|
// angolo di tolleranza per rotazioni con vettori quasi paralleli
|
||||||
|
const double ANG_ROT_TOLL = 5 ;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
Scene::CreateFlatPart( ISurfTriMesh* pSrf)
|
||||||
|
{
|
||||||
|
|
||||||
|
// vertici
|
||||||
|
pSrf->AddVertex( Point3d( 0.33 * m_dCubeEdge, 0.33 * m_dCubeEdge, 0)),
|
||||||
|
pSrf->AddVertex( Point3d( - 0.33 * m_dCubeEdge, 0.33 * m_dCubeEdge, 0)) ;
|
||||||
|
pSrf->AddVertex( Point3d( - 0.33 * m_dCubeEdge, - 0.33 * m_dCubeEdge, 0)) ;
|
||||||
|
pSrf->AddVertex( Point3d( 0.33 * m_dCubeEdge, - 0.33 * m_dCubeEdge, 0)) ;
|
||||||
|
|
||||||
|
// triangoli
|
||||||
|
int nNewInd_0[3] = { 0, 1, 2} ;
|
||||||
|
pSrf->AddTriangle( nNewInd_0) ;
|
||||||
|
int nNewInd_1[3] = { 0, 2, 3} ;
|
||||||
|
pSrf->AddTriangle( nNewInd_1) ;
|
||||||
|
|
||||||
|
// verifico
|
||||||
|
pSrf->DoCompacting() ;
|
||||||
|
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
Scene::CreateEdgePart( ISurfTriMesh* pSrf)
|
||||||
|
{
|
||||||
|
// vertici
|
||||||
|
pSrf->AddVertex( Point3d( 0.33 * m_dCubeEdge, - 0.085 * m_dCubeEdge, 0)) ;
|
||||||
|
pSrf->AddVertex( Point3d( - 0.33 * m_dCubeEdge, - 0.085 * m_dCubeEdge, 0)) ;
|
||||||
|
pSrf->AddVertex( Point3d( - 0.33 * m_dCubeEdge, 0, - 0.085 * m_dCubeEdge)) ;
|
||||||
|
pSrf->AddVertex( Point3d( 0.33 * m_dCubeEdge, 0, - 0.085 * m_dCubeEdge)) ;
|
||||||
|
pSrf->AddVertex( Point3d( - 0.33 * m_dCubeEdge, 0.085 * m_dCubeEdge, - 0.17 * m_dCubeEdge)) ;
|
||||||
|
pSrf->AddVertex( Point3d( 0.33 * m_dCubeEdge, 0.085 * m_dCubeEdge, - 0.17 * m_dCubeEdge)) ;
|
||||||
|
|
||||||
|
// triangoli
|
||||||
|
int nNewInd_0[3] = { 2, 1 ,0} ;
|
||||||
|
pSrf->AddTriangle( nNewInd_0) ;
|
||||||
|
int nNewInd_1[3] = { 3, 2, 0} ;
|
||||||
|
pSrf->AddTriangle( nNewInd_1) ;
|
||||||
|
int nNewInd_2[3] = { 2, 5, 4} ;
|
||||||
|
pSrf->AddTriangle( nNewInd_2) ;
|
||||||
|
int nNewInd_3[3] = { 2, 3, 5} ;
|
||||||
|
pSrf->AddTriangle( nNewInd_3) ;
|
||||||
|
|
||||||
|
// verifico
|
||||||
|
pSrf->DoCompacting() ;
|
||||||
|
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
Scene::CreateCornerPart( ISurfTriMesh* pSrf)
|
||||||
|
{
|
||||||
|
// vertici
|
||||||
|
pSrf->AddVertex( Point3d( - 0.085 * m_dCubeEdge, 0.085 * m_dCubeEdge, -0.17 * m_dCubeEdge)) ;
|
||||||
|
pSrf->AddVertex( Point3d( - 0.085 * m_dCubeEdge, - 0.085 * m_dCubeEdge, 0)) ;
|
||||||
|
pSrf->AddVertex( Point3d( 0.085 * m_dCubeEdge, - 0.085 * m_dCubeEdge, - 0.17 * m_dCubeEdge)) ;
|
||||||
|
|
||||||
|
// triangoli
|
||||||
|
int nNewInd_0[3] = { 0, 1, 2} ;
|
||||||
|
pSrf->AddTriangle( nNewInd_0) ;
|
||||||
|
|
||||||
|
// verifico
|
||||||
|
pSrf->DoCompacting() ;
|
||||||
|
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
static ObjEGrGraphics*
|
||||||
|
CreateObjEGrGraphics( int nCount, bool bNewWay)
|
||||||
|
{
|
||||||
|
if ( nCount > 1)
|
||||||
|
return ( new( nothrow) ObjMultiGraphics( nCount, bNewWay)) ;
|
||||||
|
else if ( bNewWay)
|
||||||
|
return ( new( nothrow) ObjNewGraphics) ;
|
||||||
|
else
|
||||||
|
return ( new( nothrow) ObjOldGraphics) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
Scene::DrawCube( bool bSurf)
|
||||||
|
{
|
||||||
|
|
||||||
|
// recupero la matrice viewport
|
||||||
|
GLint Viewport[4] ;
|
||||||
|
glGetIntegerv( GL_VIEWPORT, Viewport) ;
|
||||||
|
|
||||||
|
// se il vettore delle superifici č vuoto, allora lo creo
|
||||||
|
if ( m_vStm_Cube.empty()) {
|
||||||
|
// Z+ -> 1 -> TOP
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_Zp( CreateSurfTriMesh()) ;
|
||||||
|
CreateFlatPart( pStm_Zp) ;
|
||||||
|
pStm_Zp->Translate( Vector3d( 0, 0, 0.5 * m_dCubeEdge)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_Zp)) ;
|
||||||
|
|
||||||
|
// Z- -> 2 -> BOTTOM
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_Zm( CreateSurfTriMesh()) ;
|
||||||
|
CreateFlatPart( pStm_Zm) ;
|
||||||
|
pStm_Zm->Rotate( ORIG, Y_AX, 180) ;
|
||||||
|
pStm_Zm->Translate( Vector3d( 0, 0, - 0.5 * m_dCubeEdge)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_Zm)) ;
|
||||||
|
|
||||||
|
// X+ -> 3 -> RIGHT
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_Xp( CreateSurfTriMesh()) ;
|
||||||
|
CreateFlatPart( pStm_Xp) ;
|
||||||
|
pStm_Xp->Rotate( ORIG, Y_AX, 180) ;
|
||||||
|
pStm_Xp->Rotate( ORIG, -Y_AX, 90) ;
|
||||||
|
pStm_Xp->Translate( Vector3d( 0.5 * m_dCubeEdge, 0, 0)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_Xp)) ;
|
||||||
|
|
||||||
|
// X- -> 4 -> LEFT
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_Xm( CreateSurfTriMesh()) ;
|
||||||
|
CreateFlatPart( pStm_Xm) ;
|
||||||
|
pStm_Xm->Rotate( ORIG, -Y_AX, 90) ;
|
||||||
|
pStm_Xm->Translate( Vector3d( -0.5 * m_dCubeEdge, 0, 0)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_Xm)) ;
|
||||||
|
|
||||||
|
// Y+ -> 5 -> FRONT
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_Yp( CreateSurfTriMesh()) ;
|
||||||
|
CreateFlatPart( pStm_Yp) ;
|
||||||
|
pStm_Yp->Rotate( ORIG, -X_AX, 90) ;
|
||||||
|
pStm_Yp->Translate( Vector3d( 0, 0.5 * m_dCubeEdge, 0)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_Yp)) ;
|
||||||
|
|
||||||
|
// Y- -> 6 -> BACK
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_Ym( CreateSurfTriMesh()) ;
|
||||||
|
CreateFlatPart( pStm_Ym) ;
|
||||||
|
pStm_Ym->Rotate( ORIG, Y_AX, 180) ;
|
||||||
|
pStm_Ym->Rotate( ORIG, -X_AX, 90) ;
|
||||||
|
pStm_Ym->Translate( Vector3d( 0, -0.5 * m_dCubeEdge, 0)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_Ym)) ;
|
||||||
|
|
||||||
|
// Z+X+ -> 7 -> TOP-RIGHT
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_ZpXp( CreateSurfTriMesh()) ;
|
||||||
|
CreateEdgePart( pStm_ZpXp) ;
|
||||||
|
pStm_ZpXp->Rotate( ORIG, -Z_AX, 90) ;
|
||||||
|
pStm_ZpXp->Translate( Vector3d(( 0.5 - 0.085) * m_dCubeEdge , 0, 0.5 * m_dCubeEdge)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_ZpXp)) ;
|
||||||
|
|
||||||
|
// Z+X- -> 8 -> TOP-LEFT
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_ZpXm( CreateSurfTriMesh()) ;
|
||||||
|
CreateEdgePart( pStm_ZpXm) ;
|
||||||
|
pStm_ZpXm->Rotate( ORIG, Z_AX, 90) ;
|
||||||
|
pStm_ZpXm->Translate( Vector3d(( - 0.5 + 0.085) * m_dCubeEdge, 0, 0.5 * m_dCubeEdge));
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_ZpXm)) ;
|
||||||
|
|
||||||
|
// Z-X+ -> 9 -> BOTTOM-RIGHT
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_ZmXp( CreateSurfTriMesh()) ;
|
||||||
|
CreateEdgePart( pStm_ZmXp) ;
|
||||||
|
pStm_ZmXp->Rotate( ORIG, -Z_AX, 90) ;
|
||||||
|
pStm_ZmXp->Rotate( ORIG, Y_AX, 90) ;
|
||||||
|
pStm_ZmXp->Translate( Vector3d( 0.5 * m_dCubeEdge, 0,( - 0.5 + 0.085) * m_dCubeEdge)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_ZmXp)) ;
|
||||||
|
|
||||||
|
// Z-X- -> 10 -> BOTTOM-LEFT
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_ZmXm( CreateSurfTriMesh()) ;
|
||||||
|
CreateEdgePart( pStm_ZmXm) ;
|
||||||
|
pStm_ZmXm->Rotate( ORIG, Z_AX, 90) ;
|
||||||
|
pStm_ZmXm->Rotate( ORIG, -Y_AX, 90) ;
|
||||||
|
pStm_ZmXm->Translate( Vector3d( - 0.5 * m_dCubeEdge, 0, ( - 0.5 + 0.085) * m_dCubeEdge)) ;;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_ZmXm)) ;
|
||||||
|
|
||||||
|
// Z+Y+ -> 11 -> TOP-FRONT
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_ZpYp( CreateSurfTriMesh()) ;
|
||||||
|
CreateEdgePart( pStm_ZpYp) ;
|
||||||
|
pStm_ZpYp->Translate( Vector3d( 0, ( 0.5 - 0.085) * m_dCubeEdge, 0.5 * m_dCubeEdge)) ;
|
||||||
|
pStm_ZpYp->SetTempProp( 5, 0) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_ZpYp)) ;
|
||||||
|
|
||||||
|
// Z+Y- -> 12 -> TOP-BACK
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_ZpYm( CreateSurfTriMesh()) ;
|
||||||
|
CreateEdgePart( pStm_ZpYm) ;
|
||||||
|
pStm_ZpYm->Rotate( ORIG, -Z_AX, 180) ;
|
||||||
|
pStm_ZpYm->Translate( Vector3d( 0, ( - 0.5 + 0.085) * m_dCubeEdge, 0.5 * m_dCubeEdge)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_ZpYm)) ;
|
||||||
|
|
||||||
|
// Z-Y+ -> 13 -> BOTTOM-FRONT
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_ZmYp( CreateSurfTriMesh()) ;
|
||||||
|
CreateEdgePart( pStm_ZmYp) ;
|
||||||
|
pStm_ZmYp->Rotate( ORIG, -X_AX, 90) ;
|
||||||
|
pStm_ZmYp->Translate( Vector3d( 0, ( 0.5) * m_dCubeEdge ,
|
||||||
|
( - 0.5 + 0.085) * m_dCubeEdge)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_ZmYp)) ;
|
||||||
|
|
||||||
|
// Z-Y- -> 14 -> BOTTOM-BACK
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_ZmYm( CreateSurfTriMesh()) ;
|
||||||
|
CreateEdgePart( pStm_ZmYm) ;
|
||||||
|
pStm_ZmYm->Rotate( ORIG, -Z_AX, 180) ;
|
||||||
|
pStm_ZmYm->Rotate( ORIG, X_AX, 90) ;
|
||||||
|
pStm_ZmYm->Translate( Vector3d( 0, - 0.5 * m_dCubeEdge, ( - 0.5 + 0.085) * m_dCubeEdge )) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_ZmYm)) ;
|
||||||
|
|
||||||
|
// X+Y+ -> 15 -> RIGHT-FRONT
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_XpYp( CreateSurfTriMesh()) ;
|
||||||
|
CreateEdgePart( pStm_XpYp) ;
|
||||||
|
pStm_XpYp->Rotate( ORIG, Y_AX, 90) ;
|
||||||
|
pStm_XpYp->Translate( Vector3d( 0.5 * m_dCubeEdge,( 0.5 - 0.085) * m_dCubeEdge, 0)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_XpYp)) ;
|
||||||
|
|
||||||
|
// X-Y+ -> 16 -> LEFT-FRONT
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_XmYp( CreateSurfTriMesh()) ;
|
||||||
|
CreateEdgePart( pStm_XmYp) ;
|
||||||
|
pStm_XmYp->Rotate( ORIG, -Y_AX, 90) ;
|
||||||
|
pStm_XmYp->Translate( Vector3d( - 0.5 * m_dCubeEdge, ( 0.5 - 0.085) * m_dCubeEdge, 0)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_XmYp)) ;
|
||||||
|
|
||||||
|
// X+Y- -> 17 -> RIGHT-BACK
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_XpYm( CreateSurfTriMesh()) ;
|
||||||
|
CreateEdgePart( pStm_XpYm) ;
|
||||||
|
pStm_XpYm->Rotate( ORIG, -Y_AX, 90) ;
|
||||||
|
pStm_XpYm->Rotate( ORIG, Z_AX, 180) ;
|
||||||
|
pStm_XpYm->Translate( Vector3d( 0.5 * m_dCubeEdge, ( - 0.5 + 0.085) * m_dCubeEdge , 0)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_XpYm)) ;
|
||||||
|
|
||||||
|
// X-Y- -> 18 -> LEFT-BACK
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_XmYm( CreateSurfTriMesh()) ;
|
||||||
|
CreateEdgePart( pStm_XmYm) ;
|
||||||
|
pStm_XmYm->Rotate( ORIG, Y_AX, 90) ;
|
||||||
|
pStm_XmYm->Rotate( ORIG, Z_AX, 180) ;
|
||||||
|
pStm_XmYm->Translate( Vector3d( - 0.5 * m_dCubeEdge,- ( 0.5 - 0.085) * m_dCubeEdge, 0)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_XmYm)) ;
|
||||||
|
|
||||||
|
// Z+X+Y+ -> 19 -> TOP-RIGHT-FRONT
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_XpYpZp( CreateSurfTriMesh()) ;
|
||||||
|
CreateCornerPart( pStm_XpYpZp ) ;
|
||||||
|
pStm_XpYpZp->Translate( Vector3d(( 0.5 - 0.085) * m_dCubeEdge, ( 0.5 - 0.085) * m_dCubeEdge, 0.5 * m_dCubeEdge)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_XpYpZp)) ;
|
||||||
|
|
||||||
|
// Z+X-Y+ -> 20 -> TOP-LEFT-FRONT
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_XmYpZp( CreateSurfTriMesh()) ;
|
||||||
|
CreateCornerPart( pStm_XmYpZp) ;
|
||||||
|
pStm_XmYpZp->Rotate( ORIG, Z_AX, 90) ;
|
||||||
|
pStm_XmYpZp->Translate( Vector3d(( - 0.5 + 0.085) * m_dCubeEdge,( 0.5 - 0.085) * m_dCubeEdge,0.5 * m_dCubeEdge)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_XmYpZp)) ;
|
||||||
|
|
||||||
|
// Z+X+Y- -> 21 -> TOP-RIGHT-BACK
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_XpYmZp( CreateSurfTriMesh()) ;
|
||||||
|
CreateCornerPart( pStm_XpYmZp) ;
|
||||||
|
pStm_XpYmZp->Rotate( ORIG, -Z_AX, 90) ;
|
||||||
|
pStm_XpYmZp->Translate( Vector3d(( + 0.5 - 0.085) * m_dCubeEdge, ( - 0.5 + 0.085) * m_dCubeEdge,0.5 * m_dCubeEdge)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_XpYmZp)) ;
|
||||||
|
|
||||||
|
// Z+X-Y- -> 22 -> TOP-LEFT-BACK
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_XmYmZp( CreateSurfTriMesh()) ;
|
||||||
|
CreateCornerPart( pStm_XmYmZp) ;
|
||||||
|
pStm_XmYmZp->Rotate( ORIG, Z_AX, 180) ;
|
||||||
|
pStm_XmYmZp->Translate( Vector3d(( - 0.5 + 0.085) * m_dCubeEdge, ( - 0.5 + 0.085) * m_dCubeEdge, 0.5 * m_dCubeEdge)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_XmYmZp)) ;
|
||||||
|
|
||||||
|
// Z-X+Y+ -> 23 -> BOTTOM-RIGHT-FRONT
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_XpYpZm( CreateSurfTriMesh()) ;
|
||||||
|
CreateCornerPart( pStm_XpYpZm) ;
|
||||||
|
pStm_XpYpZm->Rotate( ORIG, X_AX, 180) ;
|
||||||
|
pStm_XpYpZm->Rotate( ORIG, Z_AX, 90) ;
|
||||||
|
pStm_XpYpZm->Translate( Vector3d(( 0.5 - 0.085) * m_dCubeEdge, ( 0.5 - 0.085) * m_dCubeEdge, - 0.5 * m_dCubeEdge)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_XpYpZm)) ;
|
||||||
|
|
||||||
|
// Z-X-Y+ -> 24 -> BOTTOM-LEFT-FRONT
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_XmYpZm( CreateSurfTriMesh()) ;
|
||||||
|
CreateCornerPart( pStm_XmYpZm) ;
|
||||||
|
pStm_XmYpZm->Rotate(ORIG, -X_AX, 90) ;
|
||||||
|
pStm_XmYpZm->Rotate( ORIG, Z_AX, 90) ;
|
||||||
|
pStm_XmYpZm->Translate( Vector3d( - 0.5 * m_dCubeEdge, ( 0.5 - 0.085) * m_dCubeEdge,( - 0.5 + 0.085) * m_dCubeEdge)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_XmYpZm)) ;
|
||||||
|
|
||||||
|
// Z-X+Y- -> 25 -> BOTTOM-RIGHT-BACK
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_XpYmZm( CreateSurfTriMesh()) ;
|
||||||
|
CreateCornerPart( pStm_XpYmZm) ;
|
||||||
|
pStm_XpYmZm->Rotate( ORIG, X_AX, 180) ;
|
||||||
|
pStm_XpYmZm->Translate( Vector3d(( + 0.5 - 0.085) * m_dCubeEdge, ( - 0.5 + 0.085) * m_dCubeEdge, - 0.5 * m_dCubeEdge)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_XpYmZm)) ;
|
||||||
|
|
||||||
|
// Z-X-Y- -> 26 -> BOTTOM-LEFT-BACK
|
||||||
|
PtrOwner<ISurfTriMesh> pStm_XmYmZm( CreateSurfTriMesh()) ;
|
||||||
|
CreateCornerPart( pStm_XmYmZm) ;
|
||||||
|
pStm_XmYmZm->Rotate( ORIG, X_AX, 180) ;
|
||||||
|
pStm_XmYmZm->Rotate( ORIG, -Z_AX, 90) ;
|
||||||
|
pStm_XmYmZm->Translate( Vector3d(( - 0.5 + 0.085) * m_dCubeEdge, ( - 0.5 + 0.085) * m_dCubeEdge, - 0.5 * m_dCubeEdge)) ;
|
||||||
|
m_vStm_Cube.emplace_back( Release( pStm_XmYmZm)) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// creo un vettore di Graphics, uno per ogni superificie del cubetto
|
||||||
|
vector<PtrOwner<ObjEGrGraphics>> vGraphics ;
|
||||||
|
for ( int i = 0 ; i < 26 ; ++ i) {
|
||||||
|
PtrOwner<ObjEGrGraphics> pNewGraphics( CreateObjEGrGraphics( 0, false)) ;
|
||||||
|
vGraphics.emplace_back( Release( pNewGraphics)) ;
|
||||||
|
vGraphics[i]->SetScene( this) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// render delle superifici del cubo ( superfici o Linee a seconda del Flag)
|
||||||
|
for ( int s = 0 ; s < 26 ; ++ s) {
|
||||||
|
|
||||||
|
// recupero la superificie corrente del cubo da visualizzare
|
||||||
|
PtrOwner<ISurfTriMesh> pStmCurr( CloneSurfTriMesh( m_vStm_Cube[s])) ;
|
||||||
|
if ( IsNull( pStmCurr))
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
// scalo la superificie a seconda della viewport corrente ( per Zoom)
|
||||||
|
pStmCurr->Scale( GLOB_FRM, ( 2 * m_dHalfWidth) / Viewport[2], ( 2 * m_dHalfWidth) / Viewport[2],
|
||||||
|
( 2 * m_dHalfWidth) / Viewport[2]) ;
|
||||||
|
// sposto la superificie nel sistema di riferimento relativo alla telecamera ( per Pan)
|
||||||
|
pStmCurr->Translate(( m_ptOrigCube - ORIG)) ;
|
||||||
|
|
||||||
|
// definisco colori per i vertici e colore per le linee
|
||||||
|
Color cCol_Vertex ;
|
||||||
|
Color cCol_Line = CUBE_LINES ;
|
||||||
|
|
||||||
|
switch ( s) {
|
||||||
|
case 0 :
|
||||||
|
cCol_Vertex = m_cColZ ; break ;
|
||||||
|
case 1 :
|
||||||
|
cCol_Vertex = m_cColZm ; break ;
|
||||||
|
case 2 :
|
||||||
|
cCol_Vertex = m_cColX ; break ;
|
||||||
|
case 3 :
|
||||||
|
cCol_Vertex = m_cColXm ; break ;
|
||||||
|
case 4 :
|
||||||
|
cCol_Vertex = m_cColY ; break ;
|
||||||
|
case 5 :
|
||||||
|
cCol_Vertex = m_cColYm ; break ;
|
||||||
|
break ;
|
||||||
|
case 6 : case 7 : case 8 : case 9 : case 10 : case 11 :
|
||||||
|
case 12 : case 13 : case 14 : case 15 : case 16 : case 17 :
|
||||||
|
cCol_Vertex = m_cColEdge ; break ;
|
||||||
|
case 18 : case 19 : case 20 : case 21: case 22: case 23 : case 24 : case 25 :
|
||||||
|
cCol_Vertex = m_cColCorner ; break ;
|
||||||
|
default :
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
vGraphics[s]->AddColor( bSurf ? cCol_Vertex : CUBE_LINES) ;
|
||||||
|
int nTria = pStmCurr->GetTriangleCount() ;
|
||||||
|
vGraphics[s]->StartTriangles( nTria) ;
|
||||||
|
Triangle3dEx Tria ;
|
||||||
|
int nId = pStmCurr->GetFirstTriangle( Tria) ;
|
||||||
|
while ( nId != SVT_NULL) {
|
||||||
|
// edge solo se boundary e normali ai vertici smussate
|
||||||
|
vGraphics[s]->AddTriangle( Tria, Tria.GetTriFlags(), Tria.GetTriNormals()) ;
|
||||||
|
nId = pStmCurr->GetNextTriangle( nId, Tria) ;
|
||||||
|
}
|
||||||
|
vGraphics[s]->EndTriangles() ;
|
||||||
|
// assegno un id temporaneo alla superificie caricata ( modalita wireFrame, come nella Select)
|
||||||
|
if ( ! bSurf)
|
||||||
|
glLoadName( m_nStartFaceId + s + 1) ;
|
||||||
|
vGraphics[s]->Draw( GDB_ST_ON, GDB_MK_OFF, true, true, 80, false) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
Scene::DrawGlobCube( bool bSurf)
|
||||||
|
{
|
||||||
|
// se non devo disegnare il cubetto, esco
|
||||||
|
if ( ! m_bShowGlobCube)
|
||||||
|
return true ;
|
||||||
|
|
||||||
|
// recupero il primo Id libero ( e aggiungo 1000)
|
||||||
|
m_nStartFaceId = m_pGeomDB->GetNewId() + 1000 ;
|
||||||
|
|
||||||
|
// recupero la matrice viewport
|
||||||
|
GLint Viewport[4] ;
|
||||||
|
glGetIntegerv( GL_VIEWPORT, Viewport) ;
|
||||||
|
|
||||||
|
// imposto il riferimento
|
||||||
|
glPushMatrix() ;
|
||||||
|
|
||||||
|
// se sono in selezione il cubo lo lascio nella posizione precedente ( cambio di viewport => cambio centro del cubo)
|
||||||
|
Point3d ptOrig ;
|
||||||
|
if ( m_bSelect)
|
||||||
|
ptOrig = m_ptOrigCube ;
|
||||||
|
else {
|
||||||
|
UnProject( Point3d( m_dCubeX, m_dCubeY, 0.25), ptOrig) ; // posizione Z del cubo sempre 0.25 dallo schermo
|
||||||
|
m_ptOrigCube = ptOrig ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// creo il cubo
|
||||||
|
if ( ! DrawCube( bSurf))
|
||||||
|
return true ;
|
||||||
|
|
||||||
|
// tolgo lo stack dei nomi in modalitŕ selezione
|
||||||
|
if ( m_bSelect)
|
||||||
|
glLoadName( 0) ;
|
||||||
|
|
||||||
|
// ripristino lo stack delle matrici
|
||||||
|
glPopMatrix() ;
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
Scene::RotateCameraWithCube()
|
||||||
|
{
|
||||||
|
// controllo se il cubetto č abilitato e ho almeno un Id dalla selezione nel buffer
|
||||||
|
if ( ! m_bShowGlobCube || m_nSelNbr == 0)
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
// controllo che la selezione non sia avvenuta mediante Drag
|
||||||
|
if ( m_nSelW != 13 || m_nSelH != 13)
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
// se ho piů di un elemento trovato, do prioritŕ alla superificie con piů facce
|
||||||
|
int nId = 0 ;
|
||||||
|
int nFace = 1 ;
|
||||||
|
bool bSelStm_Cube = false ;
|
||||||
|
|
||||||
|
for ( int i = 0 ; i < m_nSelNbr ; ++ i) {
|
||||||
|
// recupero l'Id corrente
|
||||||
|
int nCurrId = m_nSelBuff[i].nId ;
|
||||||
|
// controllo che l'Id appartenga ad una superificie del cubetto
|
||||||
|
if ( nCurrId <= m_nStartFaceId || nCurrId > m_nStartFaceId + 26)
|
||||||
|
continue ;
|
||||||
|
|
||||||
|
bSelStm_Cube = true ;
|
||||||
|
int nCurrFace = 1 ;
|
||||||
|
if ( nCurrId - m_nStartFaceId > 6 && nCurrId - m_nStartFaceId <= 18) // se superificie Edge
|
||||||
|
nCurrFace = 2 ;
|
||||||
|
else if ( nCurrId - m_nStartFaceId > 18) // se superificie Corner
|
||||||
|
nCurrFace = 3 ;
|
||||||
|
|
||||||
|
nFace = max( nFace, nCurrFace) ;
|
||||||
|
if ( nFace == 1 || nFace == nCurrFace)
|
||||||
|
nId = nCurrId ;
|
||||||
|
}
|
||||||
|
if ( ! bSelStm_Cube)
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
// ottengo la faccia del cubo selezionato ( valore tra 1 e 26)
|
||||||
|
int nCubeface = nId - m_nStartFaceId ;
|
||||||
|
|
||||||
|
// prendo i parametri della telecamera
|
||||||
|
double dTheta, dPhi, dDist ;
|
||||||
|
GetCamera( &dPhi, &dTheta, &dDist) ;
|
||||||
|
double dPhi_orig = dPhi ;
|
||||||
|
double dTheta_orig = dTheta ;
|
||||||
|
|
||||||
|
// flag per numero di Step fatti e valore forzato di Theta per Z+ e Z-
|
||||||
|
bool bHasTwoStep = false ;
|
||||||
|
double dTheta_Forced = 0.0 ;
|
||||||
|
|
||||||
|
// imposto i nuovi angoli theta e phi mantenendo la distanza
|
||||||
|
if ( GetAngleByCubeFace( nCubeface, dTheta, dPhi)) {
|
||||||
|
// ricavo il vettore iniziale della telecamera
|
||||||
|
Vector3d v_q1 = m_vtDirCamera ;
|
||||||
|
// ricavo il vettore finale della telecamera
|
||||||
|
Vector3d v_q2 = FromSpherical( 1 , dPhi, dTheta) ;
|
||||||
|
// flag per rotazione necessaria o superflua
|
||||||
|
bool bDoRotation = true ;
|
||||||
|
// nuovi angoli nel caso di doppie rotazioni
|
||||||
|
double dTheta_new ; double dPhi_new ;
|
||||||
|
|
||||||
|
// controllo se voglio mettere la vista in Z+ o Z-
|
||||||
|
if ( AreSameOrOppositeVectorApprox( v_q2, Z_AX)) {
|
||||||
|
// controllo se sono giŕ in posizione questa posizione ( Z+ o Z-)
|
||||||
|
if ( AreSameVectorApprox( v_q1, v_q2)) {
|
||||||
|
// se sono giŕ orientato in maniera corretta non faccio nulla, altrimenti...
|
||||||
|
if ( abs( dTheta_orig - ( ANG_RIGHT - ANG_STRAIGHT)) > EPS_ANG_SMALL) {
|
||||||
|
Vector3d v_q1S = FromSpherical( 1, 90, dTheta_orig) ;
|
||||||
|
// ... ruoto la telecamera solo lungo theta
|
||||||
|
RotateCameraWithBlockedAngle( v_q1S, -Y_AX, dDist, true, 1, dTheta_orig, dPhi_orig, dTheta_new, dPhi_new) ;
|
||||||
|
}
|
||||||
|
bDoRotation = false ;
|
||||||
|
}
|
||||||
|
// se non sono in posizione Z+ o Z- e devo andare in una di queste due, allora...
|
||||||
|
else if ( ! (( v_q2.IsZplus() || v_q2.IsZminus()) &&
|
||||||
|
( abs( dTheta_orig - ( ANG_STRAIGHT + ANG_RIGHT)) < EPS_SMALL && v_q1.y < 0))) {
|
||||||
|
// controllo se sono nel caso limite della faccia quasi opposta
|
||||||
|
bool bForceCoeff = false ;
|
||||||
|
if ( abs( dTheta_orig - ( ANG_RIGHT)) < EPS_ANG_SMALL)
|
||||||
|
v_q1.Rotate( Z_AX, 5) ;
|
||||||
|
bHasTwoStep = true ;
|
||||||
|
// ... ruoto la telecamera solo lungo theta
|
||||||
|
RotateCameraWithBlockedAngle( v_q1, - Y_AX, 1, true, 1, dTheta_orig, dPhi_orig, dTheta_new, dPhi_new) ;
|
||||||
|
dTheta_Forced = ANG_RIGHT + ANG_STRAIGHT ;
|
||||||
|
v_q1 = FromSpherical( 1, dPhi_orig, dTheta_Forced) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// controllo se sono in posizione Z+ o Z- e devo sistemare la vista in un'altra posizione
|
||||||
|
else if ( AreSameOrOppositeVectorApprox( v_q1, Z_AX)) {
|
||||||
|
// ho giŕ controllato di non aver v_q1 e v_q2 paralleli...
|
||||||
|
double dTheta_S, dPhi_S , dLenS_ ;
|
||||||
|
v_q2.ToSpherical( &dLenS_, &dPhi_S, &dTheta_S) ;
|
||||||
|
|
||||||
|
if ( abs( dTheta_orig - dTheta_S) > EPS_SMALL) {
|
||||||
|
Vector3d v_q1S = FromSpherical( 1, 90, dTheta_orig) ;
|
||||||
|
|
||||||
|
// controllo nel caso di angoli opposti ( o quasi)
|
||||||
|
bool bForceCoeff = false ;
|
||||||
|
if ( abs( dTheta_S - ANG_RIGHT ) < EPS_ANG_SMALL) {
|
||||||
|
v_q1S.Rotate( Z_AX, dTheta_S - ANG_RIGHT >= 0 ? ANG_ROT_TOLL : -ANG_ROT_TOLL) ;
|
||||||
|
bForceCoeff = true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ... ruoto la telecamera solo lungo theta
|
||||||
|
RotateCameraWithBlockedAngle( v_q1S, v_q2, dDist, bForceCoeff ? 2 : 1, 1, dTheta_orig, dPhi_orig,
|
||||||
|
dTheta_new, dPhi_new) ;
|
||||||
|
|
||||||
|
dTheta_Forced = dTheta_new ;
|
||||||
|
v_q1 = FromSpherical( 1, dPhi_orig, dTheta_Forced) ;
|
||||||
|
bHasTwoStep = true ;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bHasTwoStep = true ;
|
||||||
|
dTheta_Forced = ANG_RIGHT + ANG_STRAIGHT ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// se devo ruotare ... animazione mediante Slerp con parametro u tra 0 e 1
|
||||||
|
if ( bDoRotation)
|
||||||
|
RotateCameraWithBlockedAngle( v_q1, v_q2, dDist, true, bHasTwoStep ? 2 : 0, dTheta_Forced, dPhi_orig,
|
||||||
|
dTheta_new, dPhi_new) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// refresh finale per sicurezza
|
||||||
|
RedrawWindow() ;
|
||||||
|
// annullo il numero di elementi selezionati
|
||||||
|
m_nSelNbr = 0 ;
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
Scene::RotateCameraWithBlockedAngle( Vector3d vDirS, Vector3d vDirE, double dDist, int nAdaptSpeed,
|
||||||
|
int nBlockedAngle, double dTheta_orig, double dPhi_orig,
|
||||||
|
double& dTheta_new, double& dPhi_new)
|
||||||
|
{
|
||||||
|
// controllo dei parametri
|
||||||
|
if ( vDirS.IsSmall() || vDirE.IsSmall() || dDist < EPS_SMALL)
|
||||||
|
return false ;
|
||||||
|
if ( nBlockedAngle < 0 || nBlockedAngle > 2)
|
||||||
|
nBlockedAngle = 0 ;
|
||||||
|
vDirS.Normalize() ;
|
||||||
|
vDirE.Normalize() ;
|
||||||
|
|
||||||
|
// angolo per interpolazione sferica
|
||||||
|
double dAng = acos( vDirS * vDirE) ;
|
||||||
|
|
||||||
|
// imposto la velocitŕ di rotazione a seconda dell'angolo da percorrere... ( se richisto, altrimenti 1)
|
||||||
|
int nCoeff = 1 ;
|
||||||
|
if (( nAdaptSpeed == 1 && dAng * RADTODEG > ANG_RIGHT * ( 2.0 / 3.0) - 50 * EPS_ANG_SMALL) || nAdaptSpeed == 2)
|
||||||
|
nCoeff = 2 ;
|
||||||
|
double dThetaSs, dPhiSs, dLenSs, dThetaEs, dPhiEs, dLenEs ;
|
||||||
|
vDirS.ToSpherical( &dLenSs, &dPhiSs, &dThetaSs) ;
|
||||||
|
vDirE.ToSpherical( &dLenEs, &dPhiEs, &dThetaEs) ;
|
||||||
|
if (( abs ( abs( dThetaEs - dThetaSs) - ANG_STRAIGHT)) < 3 * ANG_ROT_TOLL + 5 * EPS_ANG_SMALL)
|
||||||
|
nCoeff = 4 ;
|
||||||
|
|
||||||
|
// ricavo i parametri per l'interpolazione sferica
|
||||||
|
for ( int u = 0 ; u <= 10 * nCoeff && abs( dAng) > EPS_SMALL ; ++ u) {
|
||||||
|
double du = u ;
|
||||||
|
if ( nCoeff == 2) du = 0.5 * u ;
|
||||||
|
if ( nCoeff == 4) du = 0.25 * u ;
|
||||||
|
Vector3d vSlerp = (( sin( 1 - 0.1 * du) * dAng) / sin( dAng)) * vDirS +
|
||||||
|
( sin( 0.1 * du * dAng) / sin( dAng)) * vDirE ;
|
||||||
|
double dTheta_u ,dPhi_u ,dLen ;
|
||||||
|
vSlerp.ToSpherical( &dLen, &dPhi_u, &dTheta_u) ;
|
||||||
|
if ( abs( u - 10 * nCoeff) < EPS_SMALL &&
|
||||||
|
( abs( dPhi_u) < EPS_ANG_SMALL || abs( dPhi_u - ANG_STRAIGHT) < EPS_ANG_SMALL))
|
||||||
|
dTheta_u = ANG_STRAIGHT + ANG_RIGHT ;
|
||||||
|
SetCamera( nBlockedAngle == 1 ? dPhi_orig : dPhi_u,
|
||||||
|
nBlockedAngle == 2 ? dTheta_orig : dTheta_u, dDist) ;
|
||||||
|
RedrawWindow() ;
|
||||||
|
dTheta_new = dTheta_u ;
|
||||||
|
dPhi_new = dPhi_u ;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
Scene::GetAngleByCubeFace( int nFaceId, double &dTheta, double &dPhi)
|
||||||
|
{
|
||||||
|
switch ( nFaceId)
|
||||||
|
{
|
||||||
|
case 1 : // TOP
|
||||||
|
dPhi = 0 ; dTheta = 270 ;
|
||||||
|
break ;
|
||||||
|
case 2 : // BOTTOM
|
||||||
|
dPhi = 180 ; dTheta = 270 ;
|
||||||
|
break ;
|
||||||
|
case 3 : // RIGHT
|
||||||
|
dPhi = 90 ; dTheta = 0 ;
|
||||||
|
break ;
|
||||||
|
case 4 : // LEFT
|
||||||
|
dPhi = 90 ; dTheta = 180 ;
|
||||||
|
break ;
|
||||||
|
case 5 : // FRONT
|
||||||
|
dPhi = 90 ; dTheta = 90 ;
|
||||||
|
break ;
|
||||||
|
case 6 : // BACK
|
||||||
|
dPhi = 90 ; dTheta = 270 ;
|
||||||
|
break ;
|
||||||
|
case 7 : // TOP-RIGHT
|
||||||
|
dPhi = 45 ; dTheta = 0 ;
|
||||||
|
break ;
|
||||||
|
case 8 : // TOP-LEFT
|
||||||
|
dPhi = 45 ; dTheta = 180 ;
|
||||||
|
break ;
|
||||||
|
case 9 : // BOTTOM-RIGHT
|
||||||
|
dPhi = 225 ; dTheta = 180 ;
|
||||||
|
break ;
|
||||||
|
case 10 : // BOTTOM-LEFT
|
||||||
|
dPhi = 225 ; dTheta = 0 ;
|
||||||
|
break ;
|
||||||
|
case 11 : // TOP-FRONT
|
||||||
|
dPhi = 45 ; dTheta = 90 ;
|
||||||
|
break ;
|
||||||
|
case 12 : // TOP-BACK
|
||||||
|
dPhi = 45 ; dTheta = 270 ;
|
||||||
|
break ;
|
||||||
|
case 13 : // BOTTOM-FRONT
|
||||||
|
dPhi = 225 ; dTheta = 270 ;
|
||||||
|
break ;
|
||||||
|
case 14 : // BOTTOM-BACK
|
||||||
|
dPhi = 225 ; dTheta = 90 ;
|
||||||
|
break ;
|
||||||
|
case 15 : // RIGHT-FRONT
|
||||||
|
dPhi = 90 ; dTheta = 45 ;
|
||||||
|
break ;
|
||||||
|
case 16 : // LEFT-FRONT
|
||||||
|
dPhi = 90 ; dTheta = 135 ;
|
||||||
|
break ;
|
||||||
|
case 17 : // RIGHT-BACK
|
||||||
|
dPhi = 90 ; dTheta = 315 ;
|
||||||
|
break ;
|
||||||
|
case 18 : // LEFT-BACK
|
||||||
|
dPhi = 90 ; dTheta = 225 ;
|
||||||
|
break ;
|
||||||
|
case 19 : // TOP-RIGHT-FRONT
|
||||||
|
dPhi = 45 ; dTheta = 45 ;
|
||||||
|
break ;
|
||||||
|
case 20 : // TOP-LEFT-FRONT
|
||||||
|
dPhi = 45 ; dTheta = 135 ;
|
||||||
|
break ;
|
||||||
|
case 21 : // TOP-RIGHT-BACK
|
||||||
|
dPhi = 45 ; dTheta = 315 ;
|
||||||
|
break ;
|
||||||
|
case 22 : // TOP-LEFT-BACK
|
||||||
|
dPhi = 45 ; dTheta = 225 ;
|
||||||
|
break ;
|
||||||
|
case 23 : // BOTTOM-RIGHT-FRONT
|
||||||
|
dPhi = 135 ; dTheta = 45 ;
|
||||||
|
break ;
|
||||||
|
case 24 : // BOTTOM-LEFT-FRONT
|
||||||
|
dPhi = 135 ; dTheta = 135 ;
|
||||||
|
break ;
|
||||||
|
case 25 : // BOTTOM-RIGHT-BACK
|
||||||
|
dPhi = 135 ; dTheta = 315 ;
|
||||||
|
break ;
|
||||||
|
case 26: // BOTTOM-LEFT-BACK
|
||||||
|
dPhi = 135 ; dTheta = 215 ;
|
||||||
|
break ;
|
||||||
|
default :
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
Scene::SetGlobCubeParameters( int nPosFlag, double dDistX, double dDistY, double dLenEdge)
|
||||||
|
{
|
||||||
|
// controllo ammissibilitŕ dei parametri
|
||||||
|
if ( nPosFlag < 0 || nPosFlag > 4 ||
|
||||||
|
dDistX < 0 || dDistY < 0 ||
|
||||||
|
dLenEdge < MIN_EDGE_SIZE || dLenEdge > MAX_EDGE_SIZE )
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
// se visualizzazione del cubo non ammessa, esco
|
||||||
|
if ( nPosFlag == 0) {
|
||||||
|
m_bShowGlobCube = false ;
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// imposto il flag di scelta dell'angolo del cubetto
|
||||||
|
m_nCube_Flag = nPosFlag ;
|
||||||
|
|
||||||
|
// recupero la matrice viewport
|
||||||
|
GLint Viewport[4] ;
|
||||||
|
glGetIntegerv( GL_VIEWPORT, Viewport) ;
|
||||||
|
|
||||||
|
// imposto le coordinate del centro del cubo ( X e Y coordinate in ViewPort)
|
||||||
|
double dCoordX = 0 ;
|
||||||
|
double dCoordY = 0 ;
|
||||||
|
switch ( m_nCube_Flag)
|
||||||
|
{
|
||||||
|
case 1 : // cubo in alto a destra
|
||||||
|
dCoordX = Viewport[2] - dDistX ;
|
||||||
|
dCoordY = dDistY ;
|
||||||
|
break ;
|
||||||
|
case 2 : // cubo in alto a sinistra
|
||||||
|
dCoordX = dDistX ;
|
||||||
|
dCoordY = dDistY ;
|
||||||
|
break ;
|
||||||
|
case 3 : // cubo in basso a sinistra
|
||||||
|
dCoordX = dDistX ;
|
||||||
|
dCoordY = Viewport[3] - dDistY ;
|
||||||
|
break ;
|
||||||
|
case 4 : // cubo in basso a destra
|
||||||
|
dCoordX = Viewport[2] - dDistX ;
|
||||||
|
dCoordY = Viewport[3] - dDistY ;
|
||||||
|
break ;
|
||||||
|
default :
|
||||||
|
return false ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// controllo che il cubo stia nella Viewport verticale con l'ingombro del suo lato
|
||||||
|
if ( dCoordX <= sqrt( 3) * dLenEdge * 0.5 * sqrt( 2) * 0.5 + 3 ||
|
||||||
|
dCoordX >= Viewport[2] - sqrt( 3) * dLenEdge * 0.5 * sqrt( 2) / 2 - 3)
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
// controllo che il cubo stia nella Viewport orizzontale con l'ingombro del suo lato
|
||||||
|
if ( dCoordY <= Viewport[1] + sqrt( 3) * dLenEdge * 0.5 * sqrt( 2) * 0.5 + 3 ||
|
||||||
|
dCoordY >= Viewport[3] - sqrt( 3) * dLenEdge * 0.5 * sqrt( 2) * 0.5 - 3)
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
// imposto le variabili membro
|
||||||
|
m_dCubeX = dCoordX ;
|
||||||
|
m_dCubeY = dCoordY ;
|
||||||
|
m_dCubeEdge = dLenEdge ;
|
||||||
|
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
+248
-20
@@ -15,10 +15,69 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "Scene.h"
|
#include "Scene.h"
|
||||||
#include "EGrUtils.h"
|
#include "EGrUtils.h"
|
||||||
|
#include "/EgtDev/Include/EGkStmStandard.h"
|
||||||
|
#include "ObjOldGraphics.h"
|
||||||
|
#include "ObjNewGraphics.h"
|
||||||
|
#include "ObjMultiGraphics.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace std ;
|
using namespace std ;
|
||||||
|
|
||||||
|
// posizione X e Y dello schermo
|
||||||
|
const int POSITION_FLAG = 3 ;
|
||||||
|
const double DIST_X = 40 ;
|
||||||
|
const double DIST_Y = 40 ;
|
||||||
|
|
||||||
|
// dimensione lunghezza delle linee
|
||||||
|
const double LINE_LEN = 25 ;
|
||||||
|
const double MIN_LINE_LEN = 20.0 ;
|
||||||
|
const double MAX_LINE_LEN = 100.0 ;
|
||||||
|
|
||||||
|
// dimensione spessore delle linee
|
||||||
|
const double LINE_WIDTH = 2 ;
|
||||||
|
|
||||||
|
// colore origine del Frame
|
||||||
|
const Color FRAME_ORIG( 0, 0, 0, 1) ;
|
||||||
|
|
||||||
|
// flag creazione coni per assi e vettore delle tre rispettive superifici
|
||||||
|
static bool bConeCreated = false ;
|
||||||
|
ISURFTMPOVECTOR vStmCones ;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool CreateCone( double dConeRad, double dConeLen, double dLen) {
|
||||||
|
|
||||||
|
vStmCones.clear() ;
|
||||||
|
|
||||||
|
PtrOwner<ISurfTriMesh> pStmConeX( GetSurfTriMeshCone( dConeRad, dConeLen, 10)) ;
|
||||||
|
pStmConeX->Rotate( ORIG, Y_AX, ANG_RIGHT) ;
|
||||||
|
pStmConeX->Translate( Vector3d( 1, 0, 0) * dLen) ;
|
||||||
|
vStmCones.emplace_back( Release( pStmConeX)) ;
|
||||||
|
|
||||||
|
PtrOwner<ISurfTriMesh> pStmConeY( GetSurfTriMeshCone( dConeRad, dConeLen, 10)) ;
|
||||||
|
pStmConeY->Rotate( ORIG, -X_AX, ANG_RIGHT) ;
|
||||||
|
pStmConeY->Translate( Vector3d( 0, 1, 0) * dLen) ;
|
||||||
|
vStmCones.emplace_back( Release( pStmConeY)) ;
|
||||||
|
|
||||||
|
PtrOwner<ISurfTriMesh> pStmConeZ( GetSurfTriMeshCone( dConeRad, dConeLen, 10)) ;
|
||||||
|
pStmConeZ->Translate( Vector3d( 0, 0, 1) * dLen) ;
|
||||||
|
vStmCones.emplace_back( Release( pStmConeZ)) ;
|
||||||
|
|
||||||
|
bConeCreated = true ;
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
static ObjEGrGraphics*
|
||||||
|
CreateObjEGrGraphics( int nCount, bool bNewWay)
|
||||||
|
{
|
||||||
|
if ( nCount > 1)
|
||||||
|
return ( new( nothrow) ObjMultiGraphics( nCount, bNewWay)) ;
|
||||||
|
else if ( bNewWay)
|
||||||
|
return ( new( nothrow) ObjNewGraphics) ;
|
||||||
|
else
|
||||||
|
return ( new( nothrow) ObjOldGraphics) ;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
Scene::SetGlobFrameShow( bool bShow)
|
Scene::SetGlobFrameShow( bool bShow)
|
||||||
@@ -27,6 +86,76 @@ Scene::SetGlobFrameShow( bool bShow)
|
|||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
Scene::SetGlobFrameParameters( int nPosFlag, double dDistX, double dDistY,
|
||||||
|
double dLenLine, double dWidthLine)
|
||||||
|
{
|
||||||
|
// controllo ammissibilità dei parametri
|
||||||
|
if ( nPosFlag < 0 || nPosFlag > 4 ||
|
||||||
|
dDistX < 0 || dDistY < 0 ||
|
||||||
|
dLenLine < MIN_LINE_LEN || dLenLine > MAX_LINE_LEN ||
|
||||||
|
dWidthLine < 1.0)
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
// se visualizzazione del frame non ammessa, esco
|
||||||
|
if ( nPosFlag == 0) {
|
||||||
|
m_bShowGlobFrame = false ;
|
||||||
|
bConeCreated = false ;
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// setto il flag di scelta per l'angolo di visualizzazione del Frame
|
||||||
|
m_nAxisFrame_Flag = nPosFlag ;
|
||||||
|
|
||||||
|
// recupero la matrice viewport
|
||||||
|
GLint Viewport[4] ;
|
||||||
|
glGetIntegerv( GL_VIEWPORT, Viewport) ;
|
||||||
|
|
||||||
|
// imposto le coordinate del centro del Frame ( X e Y coordinate in ViewPort)
|
||||||
|
double dCoordX = 0 ;
|
||||||
|
double dCoordY = 0 ;
|
||||||
|
switch ( m_nAxisFrame_Flag)
|
||||||
|
{
|
||||||
|
case 1 : // frame in alto a destra
|
||||||
|
dCoordX = Viewport[2] - dDistX ;
|
||||||
|
dCoordY = dDistY ;
|
||||||
|
break ;
|
||||||
|
case 2 : // frame in alto a sinistra
|
||||||
|
dCoordX = dDistX ;
|
||||||
|
dCoordY = dDistY ;
|
||||||
|
break ;
|
||||||
|
case 3 : // frame in basso a sinistra
|
||||||
|
dCoordX = dDistX ;
|
||||||
|
dCoordY = Viewport[3] - dDistY ;
|
||||||
|
break ;
|
||||||
|
case 4 : // frame in basso a destra
|
||||||
|
dCoordX = Viewport[2] - dDistX ;
|
||||||
|
dCoordY = Viewport[3] - dDistY ;
|
||||||
|
break ;
|
||||||
|
default :
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// controllo che il frame stia nella Viewport verticale con l'ingombro dei suoi versori
|
||||||
|
if ( dCoordX <= dLenLine * 0.5 * sqrt( 2) + 3 ||
|
||||||
|
dCoordX >= Viewport[2] - sqrt( 2) * dLenLine * 0.5 - 3)
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
// controllo che il frame stia nella Viewport orizzontale con l'ingombro dei suoi versori
|
||||||
|
if ( dCoordY <= Viewport[1] + sqrt( 2) * dLenLine * 0.5 + 3 ||
|
||||||
|
dCoordY >= Viewport[3] - sqrt( 2) * dLenLine * 0.5 - 3)
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
// imposto le variabili membro
|
||||||
|
m_dFrame_DistX = dCoordX ;
|
||||||
|
m_dFrame_DistY = dCoordY ;
|
||||||
|
m_dFrameLineL = dLenLine ;
|
||||||
|
m_dFrameLineW = dWidthLine ;
|
||||||
|
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
Scene::DrawGlobFrame( void)
|
Scene::DrawGlobFrame( void)
|
||||||
@@ -42,38 +171,137 @@ Scene::DrawGlobFrame( void)
|
|||||||
// imposto il riferimento
|
// imposto il riferimento
|
||||||
glPushMatrix() ;
|
glPushMatrix() ;
|
||||||
|
|
||||||
// origine del riferimento globale
|
// imposto l'origine del sistema di riferimento nelle coordinate della ViewPort
|
||||||
const double DIST_BORDER = 30 ;
|
|
||||||
const double POS_Z = 0.5 ;
|
|
||||||
Point3d ptOrig ;
|
Point3d ptOrig ;
|
||||||
UnProject( Point3d( DIST_BORDER, Viewport[3] - DIST_BORDER, POS_Z), ptOrig) ;
|
const double POS_Z = 0.25 ;
|
||||||
|
UnProject( Point3d( m_dFrame_DistX, m_dFrame_DistY, POS_Z), ptOrig) ;
|
||||||
|
|
||||||
// lunghezza degli assi
|
// abilito Ztest per rendering delle linee e dei punti
|
||||||
const double LEN_AX = DIST_BORDER - 2 ;
|
glEnable( GL_DEPTH_TEST) ;
|
||||||
double dLen = LEN_AX * ( 2 * m_dHalfWidth) / Viewport[2] ;
|
|
||||||
|
|
||||||
// disegno degli assi
|
// controllo gli angoli correnti della telecamera per decidere il rendering delle linee ( continue o stripped)
|
||||||
glLineWidth( (float) GetFrameLineWidth()) ;
|
double dTheta, dPhi, dDist ;
|
||||||
|
GetCamera( &dPhi, &dTheta, &dDist) ;
|
||||||
|
bool bStripped_X = false ;
|
||||||
|
bool bStripped_Y = false ;
|
||||||
|
bool bStripped_Z = false ;
|
||||||
|
if ( abs( dPhi) > ANG_RIGHT)
|
||||||
|
bStripped_Z = true ;
|
||||||
|
if ( abs( dTheta) > ANG_RIGHT && abs( dTheta) < ANG_RIGHT + ANG_STRAIGHT)
|
||||||
|
bStripped_X = true ;
|
||||||
|
if ( abs( dTheta) > ANG_STRAIGHT)
|
||||||
|
bStripped_Y = true ;
|
||||||
|
|
||||||
|
// scalo la lunghezza degli assi
|
||||||
|
double dLen = m_dFrameLineL * ( 2 * m_dHalfWidth) / Viewport[2] ;
|
||||||
|
double dOrigOff = 0.875 * m_dFrameLineW * ( 2 * m_dHalfWidth) / Viewport[2] ;
|
||||||
|
double dConeRad = m_dFrameLineW * 1.0 ;
|
||||||
|
double dConeLen = 0.4 * m_dFrameLineL ;
|
||||||
|
|
||||||
|
// imposto la dimensione degli assi
|
||||||
|
glLineWidth(( float) m_dFrameLineW) ;
|
||||||
|
|
||||||
|
// asse X
|
||||||
|
if ( bStripped_X)
|
||||||
|
glEnable( GL_LINE_STIPPLE) ;
|
||||||
|
else
|
||||||
|
glEnable( GL_LINES) ;
|
||||||
glBegin( GL_LINES) ;
|
glBegin( GL_LINES) ;
|
||||||
// asse X+
|
glColor3f( m_cColX.GetRed(), m_cColX.GetGreen(), m_cColX.GetBlue()) ;
|
||||||
glColor3f( 1, 0, 0) ;
|
glVertex3f( float( ptOrig.x + dOrigOff), float( ptOrig.y), float( ptOrig.z)) ;
|
||||||
glVertex3f( float( ptOrig.x), float( ptOrig.y), float( ptOrig.z)) ;
|
|
||||||
glVertex3f( float( ptOrig.x + dLen), float( ptOrig.y), float( ptOrig.z)) ;
|
glVertex3f( float( ptOrig.x + dLen), float( ptOrig.y), float( ptOrig.z)) ;
|
||||||
// asse Y+
|
glEnd() ;
|
||||||
glColor3f( 0, 1, 0) ;
|
if ( bStripped_X)
|
||||||
glVertex3f( float( ptOrig.x), float( ptOrig.y), float( ptOrig.z)) ;
|
glDisable( GL_LINE_STIPPLE) ;
|
||||||
|
|
||||||
|
// asse Y
|
||||||
|
if ( bStripped_Y)
|
||||||
|
glEnable( GL_LINE_STIPPLE) ;
|
||||||
|
else
|
||||||
|
glEnable( GL_LINES) ;
|
||||||
|
glBegin( GL_LINES) ;
|
||||||
|
glColor3f( m_cColY.GetRed(), m_cColY.GetGreen(), m_cColY.GetBlue()) ;
|
||||||
|
glVertex3f( float( ptOrig.x), float( ptOrig.y + dOrigOff), float( ptOrig.z)) ;
|
||||||
glVertex3f( float( ptOrig.x), float( ptOrig.y + dLen), float( ptOrig.z)) ;
|
glVertex3f( float( ptOrig.x), float( ptOrig.y + dLen), float( ptOrig.z)) ;
|
||||||
// asse Z+
|
glEnd() ;
|
||||||
glColor3f( 0, 0, 1) ;
|
if ( bStripped_Y)
|
||||||
glVertex3f( float( ptOrig.x), float( ptOrig.y), float( ptOrig.z)) ;
|
glDisable( GL_LINE_STIPPLE) ;
|
||||||
|
|
||||||
|
// asse Z
|
||||||
|
if ( bStripped_Z)
|
||||||
|
glEnable( GL_LINE_STIPPLE) ;
|
||||||
|
else
|
||||||
|
glEnable( GL_LINES) ;
|
||||||
|
glBegin( GL_LINES) ;
|
||||||
|
glColor3f( m_cColZ.GetRed(), m_cColZ.GetGreen(), m_cColZ.GetBlue()) ;
|
||||||
|
glVertex3f( float( ptOrig.x), float( ptOrig.y), float( ptOrig.z + dOrigOff)) ;
|
||||||
glVertex3f( float( ptOrig.x), float( ptOrig.y), float( ptOrig.z + dLen)) ;
|
glVertex3f( float( ptOrig.x), float( ptOrig.y), float( ptOrig.z + dLen)) ;
|
||||||
glEnd() ;
|
glEnd() ;
|
||||||
|
if ( bStripped_Z)
|
||||||
|
glDisable( GL_LINE_STIPPLE) ;
|
||||||
|
|
||||||
// ripristino spessore linee
|
// TEST PUNTI !
|
||||||
glLineWidth( (float) GetLineWidth()) ;
|
glEnable( GL_POINT_SMOOTH ) ;
|
||||||
|
glPointSize(( float) 2.5 * m_dFrameLineW) ;
|
||||||
|
glBegin( GL_POINTS) ;
|
||||||
|
glColor3f( FRAME_ORIG.GetRed(), FRAME_ORIG.GetGreen(), FRAME_ORIG.GetBlue()) ;
|
||||||
|
glVertex3f( float( ptOrig.x), float( ptOrig.y), float( ptOrig.z)) ;
|
||||||
|
glEnd() ;
|
||||||
|
glPointSize(( float) GetPointSize()) ;
|
||||||
|
glDisable( GL_POINT_SMOOTH) ;
|
||||||
|
|
||||||
|
// disegno i tre coni ( se precedentemente non già creati)
|
||||||
|
if ( ! bConeCreated)
|
||||||
|
CreateCone( dConeRad, dConeLen, m_dFrameLineL) ;
|
||||||
|
|
||||||
|
// creo un vettore di Graphics, uno per ogni cono del frame
|
||||||
|
vector<PtrOwner<ObjEGrGraphics>> vGraphics ;
|
||||||
|
for ( int i = 0 ; i < 3 ; ++ i) {
|
||||||
|
PtrOwner<ObjEGrGraphics> pNewGraphics( CreateObjEGrGraphics( 0, false)) ;
|
||||||
|
vGraphics.emplace_back( Release( pNewGraphics)) ;
|
||||||
|
vGraphics[i]->SetScene( this) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( int s = 0 ; s < 3 ; ++ s) {
|
||||||
|
// recupero la superificie corrente del cubo da visualizzare
|
||||||
|
PtrOwner<ISurfTriMesh> pStmCurr_Cone( CloneSurfTriMesh( vStmCones[s])) ;
|
||||||
|
if ( IsNull( pStmCurr_Cone))
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
// scalo la superificie a seconda della viewport corrente ( per Zoom)
|
||||||
|
pStmCurr_Cone->Scale( GLOB_FRM, ( 2 * m_dHalfWidth) / Viewport[2], ( 2 * m_dHalfWidth) / Viewport[2],
|
||||||
|
( 2 * m_dHalfWidth) / Viewport[2]) ;
|
||||||
|
// sposto la superificie nel sistema di riferimento relativo alla telecamera ( per Pan)
|
||||||
|
pStmCurr_Cone->Translate(( ptOrig - ORIG)) ;
|
||||||
|
|
||||||
|
Color cCurrColor ;
|
||||||
|
if ( s == 0) cCurrColor = m_cColX ;
|
||||||
|
if ( s == 1) cCurrColor = m_cColY ;
|
||||||
|
if ( s == 2) cCurrColor = m_cColZ ;
|
||||||
|
vGraphics[s]->AddColor( cCurrColor) ;
|
||||||
|
int nTria = pStmCurr_Cone->GetTriangleCount() ;
|
||||||
|
vGraphics[s]->StartTriangles( nTria) ;
|
||||||
|
Triangle3dEx Tria ;
|
||||||
|
int nId = pStmCurr_Cone->GetFirstTriangle( Tria) ;
|
||||||
|
while ( nId != SVT_NULL) {
|
||||||
|
// edge solo se boundary e normali ai vertici smussate
|
||||||
|
vGraphics[s]->AddTriangle( Tria, Tria.GetTriFlags(), Tria.GetTriNormals()) ;
|
||||||
|
nId = pStmCurr_Cone->GetNextTriangle( nId, Tria) ;
|
||||||
|
}
|
||||||
|
vGraphics[s]->EndTriangles() ;
|
||||||
|
// assegno un id temporaneo alla superificie caricata ( modalita wireFrame, come nella Select)
|
||||||
|
vGraphics[s]->Draw( GDB_ST_ON, GDB_MK_OFF, true, true, 80, false) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// torno a spessore della linee impostato in precedenza
|
||||||
|
glLineWidth((float) GetLineWidth()) ;
|
||||||
|
|
||||||
|
glDisable( GL_DEPTH_TEST) ;
|
||||||
|
|
||||||
// ripristino lo stack delle matrici
|
// ripristino lo stack delle matrici
|
||||||
glPopMatrix() ;
|
glPopMatrix() ;
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+120
-53
@@ -20,6 +20,9 @@
|
|||||||
|
|
||||||
using namespace std ;
|
using namespace std ;
|
||||||
|
|
||||||
|
//--------------------------- Constants --------------------------------------
|
||||||
|
const double MIN_SNAP_STEP = 0.1 ;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
Scene::SetGridShow( bool bShowGrid, bool bShowFrame)
|
Scene::SetGridShow( bool bShowGrid, bool bShowFrame)
|
||||||
@@ -33,11 +36,41 @@ Scene::SetGridShow( bool bShowGrid, bool bShowFrame)
|
|||||||
bool
|
bool
|
||||||
Scene::SetGridGeo( double dSnapStep, int nMinLineSstep, int nMajLineSstep, int nExtSstep)
|
Scene::SetGridGeo( double dSnapStep, int nMinLineSstep, int nMajLineSstep, int nExtSstep)
|
||||||
{
|
{
|
||||||
const double MIN_SNAP_STEP = 0.1 ;
|
if ( dSnapStep > 0)
|
||||||
m_dSnapStep = max( abs( dSnapStep), MIN_SNAP_STEP) ;
|
m_dSnapStep = max( dSnapStep, MIN_SNAP_STEP) ;
|
||||||
m_nMinLineSstep = abs( nMinLineSstep) ;
|
if ( nMinLineSstep > 0)
|
||||||
m_nMajLineSstep = max( abs( nMajLineSstep), m_nMinLineSstep) ;
|
m_nMinLineSstep = nMinLineSstep ;
|
||||||
|
if ( nMajLineSstep > 0)
|
||||||
|
m_nMajLineSstep = max( nMajLineSstep, m_nMinLineSstep) ;
|
||||||
m_nExtSstep = max( abs( nExtSstep), m_nMajLineSstep) ;
|
m_nExtSstep = max( abs( nExtSstep), m_nMajLineSstep) ;
|
||||||
|
m_dGridMinX = -INFINITO ;
|
||||||
|
m_dGridMaxX = INFINITO ;
|
||||||
|
m_dGridMinY = -INFINITO ;
|
||||||
|
m_dGridMaxY = INFINITO ;
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
Scene::SetGridGeoAdv( double dSnapStep, int nMinLineSstep, int nMajLineSstep,
|
||||||
|
double dXmin, double dXmax, double dYmin, double dYmax)
|
||||||
|
{
|
||||||
|
if ( dSnapStep > 0)
|
||||||
|
m_dSnapStep = max( dSnapStep, MIN_SNAP_STEP) ;
|
||||||
|
if ( nMinLineSstep > 0)
|
||||||
|
m_nMinLineSstep = nMinLineSstep ;
|
||||||
|
if ( nMajLineSstep > 0)
|
||||||
|
m_nMajLineSstep = max( nMajLineSstep, m_nMinLineSstep) ;
|
||||||
|
if ( dXmin > dXmax)
|
||||||
|
swap( dXmin, dXmax) ;
|
||||||
|
if ( dYmin > dYmax)
|
||||||
|
swap( dYmin, dYmax) ;
|
||||||
|
int nExtSstep = int( ceil( max( max( abs( dXmin), abs( dYmin)), max( abs( dXmax), abs( dYmax))) / m_dSnapStep)) ;
|
||||||
|
m_nExtSstep = max( abs( nExtSstep), m_nMajLineSstep) ;
|
||||||
|
m_dGridMinX = dXmin ;
|
||||||
|
m_dGridMaxX = dXmax ;
|
||||||
|
m_dGridMinY = dYmin ;
|
||||||
|
m_dGridMaxY = dYmax ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,6 +122,10 @@ Scene::DrawGrid( void)
|
|||||||
|
|
||||||
// semi-estensione della griglia
|
// semi-estensione della griglia
|
||||||
float dExt = float( m_nExtSstep * m_dSnapStep) ;
|
float dExt = float( m_nExtSstep * m_dSnapStep) ;
|
||||||
|
float dExtMinX = max( float( m_dGridMinX), -dExt) ;
|
||||||
|
float dExtMaxX = min( float( m_dGridMaxX), dExt) ;
|
||||||
|
float dExtMinY = max( float( m_dGridMinY), -dExt) ;
|
||||||
|
float dExtMaxY = min( float( m_dGridMaxY), dExt) ;
|
||||||
// abbassamento in Z per evitare sovrapposizioni con geometria
|
// abbassamento in Z per evitare sovrapposizioni con geometria
|
||||||
const float Z_DOWN = float( - 0.01) ;
|
const float Z_DOWN = float( - 0.01) ;
|
||||||
|
|
||||||
@@ -105,18 +142,26 @@ Scene::DrawGrid( void)
|
|||||||
// se non si sovrappongono alle maggiori
|
// se non si sovrappongono alle maggiori
|
||||||
if ( ( i % m_nMajLineSstep) != 0) {
|
if ( ( i % m_nMajLineSstep) != 0) {
|
||||||
float dPos = float( i * m_dSnapStep) ;
|
float dPos = float( i * m_dSnapStep) ;
|
||||||
// X +
|
// X +
|
||||||
glVertex3f( dPos, - dExt, Z_DOWN) ;
|
if ( dPos >= dExtMinX && dPos <= dExtMaxX) {
|
||||||
glVertex3f( dPos, dExt, Z_DOWN) ;
|
glVertex3f( dPos, dExtMinY, Z_DOWN) ;
|
||||||
// X -
|
glVertex3f( dPos, dExtMaxY, Z_DOWN) ;
|
||||||
glVertex3f( - dPos, - dExt, Z_DOWN) ;
|
}
|
||||||
glVertex3f( - dPos, dExt, Z_DOWN) ;
|
// X -
|
||||||
// Y +
|
if ( -dPos >= dExtMinX && -dPos <= dExtMaxX) {
|
||||||
glVertex3f( - dExt, dPos, Z_DOWN) ;
|
glVertex3f( -dPos, dExtMinY, Z_DOWN) ;
|
||||||
glVertex3f( dExt, dPos, Z_DOWN) ;
|
glVertex3f( -dPos, dExtMaxY, Z_DOWN) ;
|
||||||
// Y -
|
}
|
||||||
glVertex3f( - dExt, - dPos, Z_DOWN) ;
|
// Y +
|
||||||
glVertex3f( dExt, - dPos, Z_DOWN) ;
|
if ( dPos >= dExtMinY && dPos <= dExtMaxY) {
|
||||||
|
glVertex3f( dExtMinX, dPos, Z_DOWN) ;
|
||||||
|
glVertex3f( dExtMaxX, dPos, Z_DOWN) ;
|
||||||
|
}
|
||||||
|
// Y -
|
||||||
|
if ( -dPos >= dExtMinY && -dPos <= dExtMaxY) {
|
||||||
|
glVertex3f( dExtMinX, -dPos, Z_DOWN) ;
|
||||||
|
glVertex3f( dExtMaxX, -dPos, Z_DOWN) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glEnd() ;
|
glEnd() ;
|
||||||
@@ -129,50 +174,68 @@ Scene::DrawGrid( void)
|
|||||||
glColor3f( m_colMajLine.GetRed(), m_colMajLine.GetGreen(), m_colMajLine.GetBlue()) ;
|
glColor3f( m_colMajLine.GetRed(), m_colMajLine.GetGreen(), m_colMajLine.GetBlue()) ;
|
||||||
for ( int i = min( nCoeff * m_nMajLineSstep, m_nExtSstep) ; i <= m_nExtSstep ; i += nCoeff * m_nMajLineSstep) {
|
for ( int i = min( nCoeff * m_nMajLineSstep, m_nExtSstep) ; i <= m_nExtSstep ; i += nCoeff * m_nMajLineSstep) {
|
||||||
float dPos = float( i * m_dSnapStep) ;
|
float dPos = float( i * m_dSnapStep) ;
|
||||||
// X +
|
// X +
|
||||||
glVertex3f( dPos, - dExt, Z_DOWN) ;
|
if ( dPos >= dExtMinX && dPos <= dExtMaxX) {
|
||||||
glVertex3f( dPos, dExt, Z_DOWN) ;
|
glVertex3f( dPos, dExtMinY, Z_DOWN) ;
|
||||||
// X -
|
glVertex3f( dPos, dExtMaxY, Z_DOWN) ;
|
||||||
glVertex3f( - dPos, - dExt, Z_DOWN) ;
|
}
|
||||||
glVertex3f( - dPos, dExt, Z_DOWN) ;
|
// X -
|
||||||
// Y +
|
if ( -dPos >= dExtMinX && -dPos <= dExtMaxX) {
|
||||||
glVertex3f( - dExt, dPos, Z_DOWN) ;
|
glVertex3f( -dPos, dExtMinY, Z_DOWN) ;
|
||||||
glVertex3f( dExt, dPos, Z_DOWN) ;
|
glVertex3f( -dPos, dExtMaxY, Z_DOWN) ;
|
||||||
// Y -
|
}
|
||||||
glVertex3f( - dExt, - dPos, Z_DOWN) ;
|
// Y +
|
||||||
glVertex3f( dExt, - dPos, Z_DOWN) ;
|
if ( dPos >= dExtMinY && dPos <= dExtMaxY) {
|
||||||
|
glVertex3f( dExtMinX, dPos, Z_DOWN) ;
|
||||||
|
glVertex3f( dExtMaxX, dPos, Z_DOWN) ;
|
||||||
|
}
|
||||||
|
// Y -
|
||||||
|
if ( -dPos >= dExtMinY && -dPos <= dExtMaxY) {
|
||||||
|
glVertex3f( dExtMinX, -dPos, Z_DOWN) ;
|
||||||
|
glVertex3f( dExtMaxX, -dPos, Z_DOWN) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
glEnd() ;
|
glEnd() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// se richiesto, disegno assi del frame
|
// se richiesto, disegno assi del frame
|
||||||
if ( m_bShowFrame) {
|
if ( m_bShowFrame) {
|
||||||
// calcolo lunghezza asse Z
|
// calcolo lunghezza asse Z
|
||||||
GLint Viewport[4] ;
|
GLint Viewport[4] ;
|
||||||
glGetIntegerv(GL_VIEWPORT, Viewport) ;
|
glGetIntegerv(GL_VIEWPORT, Viewport) ;
|
||||||
const double LEN_AX = 28 ;
|
const double LEN_AX = 28 ;
|
||||||
double dLenZ = LEN_AX * ( 2 * m_dHalfWidth) / Viewport[2] ;
|
double dLenZ = LEN_AX * ( 2 * m_dHalfWidth) / Viewport[2] ;
|
||||||
float fLenZ = float( min( m_dSnapStep, dLenZ)) ;
|
float fLenZ = float( min( m_dSnapStep, dLenZ)) ;
|
||||||
glBegin( GL_LINES) ;
|
glBegin( GL_LINES) ;
|
||||||
// asse X+
|
// asse X+
|
||||||
glColor3f( 0.8f, 0, 0) ;
|
if ( 0 >= dExtMinY && 0 <= dExtMaxY && 0 >= dExtMinY) {
|
||||||
glVertex3f( 0, 0, Z_DOWN) ;
|
glColor3f( 0.8f, 0, 0) ;
|
||||||
glVertex3f( dExt, 0, Z_DOWN) ;
|
glVertex3f( max( 0.0f, dExtMinX), 0, Z_DOWN) ;
|
||||||
// asse Y+
|
glVertex3f( dExtMaxX, 0, Z_DOWN) ;
|
||||||
glColor3f( 0, 0.8f, 0) ;
|
}
|
||||||
glVertex3f( 0, 0, Z_DOWN) ;
|
// asse Y+
|
||||||
glVertex3f( 0, dExt, Z_DOWN) ;
|
if ( 0 >= dExtMinX && 0 <= dExtMaxX && 0 <= dExtMaxY) {
|
||||||
// asse Z+
|
glColor3f( 0, 0.8f, 0) ;
|
||||||
glColor3f( 0, 0, 0.8f) ;
|
glVertex3f( 0, max( 0.0f, dExtMinY), Z_DOWN) ;
|
||||||
glVertex3f( 0, 0, Z_DOWN) ;
|
glVertex3f( 0, dExtMaxY, Z_DOWN) ;
|
||||||
glVertex3f( 0, 0, fLenZ) ;
|
}
|
||||||
// se richiesta griglia, assi X- e Y-
|
// asse Z+
|
||||||
|
if ( 0 >= dExtMinX && 0 <= dExtMaxX && 0 >= dExtMinY && 0 <= dExtMaxY) {
|
||||||
|
glColor3f( 0, 0, 0.8f) ;
|
||||||
|
glVertex3f( 0, 0, Z_DOWN) ;
|
||||||
|
glVertex3f( 0, 0, fLenZ) ;
|
||||||
|
}
|
||||||
|
// se richiesta griglia, assi X- e Y-
|
||||||
if ( m_bShowGrid) {
|
if ( m_bShowGrid) {
|
||||||
glColor3f( m_colMajLine.GetRed(), m_colMajLine.GetGreen(), m_colMajLine.GetBlue()) ;
|
glColor3f( m_colMajLine.GetRed(), m_colMajLine.GetGreen(), m_colMajLine.GetBlue()) ;
|
||||||
glVertex3f( 0, 0, Z_DOWN) ;
|
if ( 0 >= dExtMinY && 0 <= dExtMaxY && 0 >= dExtMinX) {
|
||||||
glVertex3f( -dExt, 0, Z_DOWN) ;
|
glVertex3f( min( 0.0f, dExtMaxX), 0, Z_DOWN) ;
|
||||||
glVertex3f( 0, 0, Z_DOWN) ;
|
glVertex3f( dExtMinX, 0, Z_DOWN) ;
|
||||||
glVertex3f( 0, -dExt, Z_DOWN) ;
|
}
|
||||||
|
if ( 0 >= dExtMinX && 0 <= dExtMaxX && 0 >= dExtMinY) {
|
||||||
|
glVertex3f( 0, min( 0.0f, dExtMaxY), Z_DOWN) ;
|
||||||
|
glVertex3f( 0, dExtMinY, Z_DOWN) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
glEnd() ;
|
glEnd() ;
|
||||||
}
|
}
|
||||||
@@ -180,12 +243,16 @@ Scene::DrawGrid( void)
|
|||||||
else if ( m_bShowGrid) {
|
else if ( m_bShowGrid) {
|
||||||
glBegin( GL_LINES) ;
|
glBegin( GL_LINES) ;
|
||||||
glColor3f( m_colMajLine.GetRed(), m_colMajLine.GetGreen(), m_colMajLine.GetBlue()) ;
|
glColor3f( m_colMajLine.GetRed(), m_colMajLine.GetGreen(), m_colMajLine.GetBlue()) ;
|
||||||
// asse X
|
// asse X
|
||||||
glVertex3f( - dExt, 0, Z_DOWN) ;
|
if ( 0 >= dExtMinY && 0 <= dExtMaxY) {
|
||||||
glVertex3f( dExt, 0, Z_DOWN) ;
|
glVertex3f( dExtMinX, 0, Z_DOWN) ;
|
||||||
// asse Y
|
glVertex3f( dExtMaxX, 0, Z_DOWN) ;
|
||||||
glVertex3f( 0, - dExt, Z_DOWN) ;
|
}
|
||||||
glVertex3f( 0, dExt, Z_DOWN) ;
|
// asse Y
|
||||||
|
if ( 0 >= dExtMinX && 0 <= dExtMaxX) {
|
||||||
|
glVertex3f( 0, dExtMinY, Z_DOWN) ;
|
||||||
|
glVertex3f( 0, dExtMaxY, Z_DOWN) ;
|
||||||
|
}
|
||||||
glEnd() ;
|
glEnd() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,4 +278,4 @@ bool
|
|||||||
Scene::GetShowGrid()
|
Scene::GetShowGrid()
|
||||||
{
|
{
|
||||||
return m_bShowGrid ;
|
return m_bShowGrid ;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,6 +95,12 @@ Scene::Select( const Point3d& ptSelCenter, int nW, int nH, int& nSel)
|
|||||||
// non imposto glPolygonMode secondo il tipo di rendering perchè ignorato in selezione
|
// non imposto glPolygonMode secondo il tipo di rendering perchè ignorato in selezione
|
||||||
// disegno le geometrie del DB in una sola passata
|
// disegno le geometrie del DB in una sola passata
|
||||||
DrawGroup( GDB_ID_ROOT, 1, MdStMkCol( GDB_MD_STD, GDB_ST_ON, GDB_MK_OFF, m_colDef)) ;
|
DrawGroup( GDB_ID_ROOT, 1, MdStMkCol( GDB_MD_STD, GDB_ST_ON, GDB_MK_OFF, m_colDef)) ;
|
||||||
|
// disegno il cubetto
|
||||||
|
glEnable( GL_CULL_FACE) ;
|
||||||
|
glCullFace( GL_BACK) ;
|
||||||
|
glFrontFace( GL_CCW) ;
|
||||||
|
DrawGlobCube( false) ;
|
||||||
|
glDisable( GL_CULL_FACE) ;
|
||||||
|
|
||||||
// pulisco stack nomi
|
// pulisco stack nomi
|
||||||
glPopName() ;
|
glPopName() ;
|
||||||
@@ -109,6 +115,10 @@ Scene::Select( const Point3d& ptSelCenter, int nW, int nH, int& nSel)
|
|||||||
// riordino il buffer di selezione secondo la Zdepth minima crescente
|
// riordino il buffer di selezione secondo la Zdepth minima crescente
|
||||||
qsort( m_nSelBuff, m_nSelNbr, sizeof( SelRec), CompareSelRec) ;
|
qsort( m_nSelBuff, m_nSelNbr, sizeof( SelRec), CompareSelRec) ;
|
||||||
|
|
||||||
|
// controllo se ho selezionato una superficie sul cubetto
|
||||||
|
if ( RotateCameraWithCube())
|
||||||
|
m_nSelNbr = 0 ;
|
||||||
|
|
||||||
nSel = m_nSelNbr ;
|
nSel = m_nSelNbr ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -32,6 +32,7 @@
|
|||||||
#include "/EgtDev/Include/EGkIntersCurves.h"
|
#include "/EgtDev/Include/EGkIntersCurves.h"
|
||||||
#include "/EgtDev/Include/EGkIntersLinePlane.h"
|
#include "/EgtDev/Include/EGkIntersLinePlane.h"
|
||||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||||
|
#include "/EgtDev/Include/EGkIntersLineVolZmap.h"
|
||||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
@@ -969,7 +970,7 @@ Scene::FindVolZmapSnapPoint( int nSnap, const Point3d& ptWin, int nId, const Fra
|
|||||||
|
|
||||||
// cerco i triangoli intersecati dalla linea di mira
|
// cerco i triangoli intersecati dalla linea di mira
|
||||||
ILZIVECTOR vInfo ;
|
ILZIVECTOR vInfo ;
|
||||||
if ( ! pVzm->GetLineIntersection( ptMir, vtDir, vInfo))
|
if ( ! IntersLineVolZmap( ptMir, vtDir, *pVzm, vInfo))
|
||||||
return false ;
|
return false ;
|
||||||
// se non trovato alcunchè, cerco le linee che partono dagli angoli del rettangolo di mira
|
// se non trovato alcunchè, cerco le linee che partono dagli angoli del rettangolo di mira
|
||||||
Vector3d vtWinD( -1, -1, 0) ;
|
Vector3d vtWinD( -1, -1, 0) ;
|
||||||
@@ -984,7 +985,7 @@ Scene::FindVolZmapSnapPoint( int nSnap, const Point3d& ptWin, int nId, const Fra
|
|||||||
ptMir2.ToLoc( frEnt) ;
|
ptMir2.ToLoc( frEnt) ;
|
||||||
ptMir2 -= vtDir * 2 * dBlRad ;
|
ptMir2 -= vtDir * 2 * dBlRad ;
|
||||||
// interseco con la superficie
|
// interseco con la superficie
|
||||||
if ( ! pVzm->GetLineIntersection( ptMir2, vtDir, vInfo))
|
if ( ! IntersLineVolZmap( ptMir2, vtDir, *pVzm, vInfo))
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
if ( vInfo.size() == 0)
|
if ( vInfo.size() == 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user