EgtGraphics :
- migliorata gestione textures.
This commit is contained in:
+28
-32
@@ -416,46 +416,42 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
|
||||
|
||||
// eventuale texture
|
||||
string sTxtName ;
|
||||
if ( iIter.GetInfo( "!TXT", sTxtName)) {
|
||||
|
||||
Frame3d frRef ;
|
||||
iIter.GetGlobFrame( frRef) ;
|
||||
if ( iIter.GetInfo( "!TNA", sTxtName)) {
|
||||
|
||||
// rendo corrente la texture
|
||||
GLuint texName ;
|
||||
double dTextDimS = 400 ;
|
||||
double dTextDimT = 200 ;
|
||||
m_TextMgr.GetTextureData( sTxtName, texName, dTextDimS, dTextDimT) ;
|
||||
double dTextDimS ;
|
||||
double dTextDimT ;
|
||||
if ( m_TextMgr.GetTextureData( sTxtName, texName, dTextDimS, dTextDimT)) {
|
||||
glEnable( GL_TEXTURE_2D) ;
|
||||
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE) ;
|
||||
glBindTexture( GL_TEXTURE_2D, texName) ;
|
||||
}
|
||||
|
||||
glEnable( GL_TEXTURE_2D) ;
|
||||
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE) ;
|
||||
glBindTexture( GL_TEXTURE_2D, texName) ;
|
||||
|
||||
GLfloat PlaneS[4] ;
|
||||
GLfloat PlaneT[4] ;
|
||||
Point3d ptOri(-4009.4378,-2415.5604,0) ;
|
||||
ptOri.ToLoc( frRef) ;
|
||||
Vector3d vtX = X_AX ;
|
||||
vtX.ToLoc( frRef) ;
|
||||
//vtX.Rotate( Z_AX, 30) ;
|
||||
Vector3d vtY = Y_AX ;
|
||||
vtY.ToLoc( frRef) ;
|
||||
//vtY.Rotate( Z_AX, 30) ;
|
||||
// recupero il riferimento dell' oggetto
|
||||
//Frame3d frRef ;
|
||||
//iIter.GetGlobFrame( frRef) ;
|
||||
// recupero il riferimento della texture
|
||||
Frame3d frTxt ;
|
||||
iIter.GetInfo( "!TFR", frTxt) ;
|
||||
//frTxt.ToLoc( frRef) ;
|
||||
// creo piano per la S
|
||||
PlaneS[0] = GLfloat( vtX.x / dTextDimS) ;
|
||||
PlaneS[1] = GLfloat( vtX.y / dTextDimS) ;
|
||||
PlaneS[2] = GLfloat( vtX.z / dTextDimS) ;
|
||||
PlaneS[3] = GLfloat( - vtX * ( ptOri - ORIG) / dTextDimS) ;
|
||||
GLfloat PlaneS[4] ;
|
||||
PlaneS[0] = GLfloat( frTxt.VersX().x / dTextDimS) ;
|
||||
PlaneS[1] = GLfloat( frTxt.VersX().y / dTextDimS) ;
|
||||
PlaneS[2] = GLfloat( frTxt.VersX().z / dTextDimS) ;
|
||||
PlaneS[3] = GLfloat( - frTxt.VersX() * ( frTxt.Orig() - ORIG) / dTextDimS) ;
|
||||
// creo piano per la T
|
||||
PlaneT[0] = GLfloat( vtY.x / dTextDimT) ;
|
||||
PlaneT[1] = GLfloat( vtY.y / dTextDimT) ;
|
||||
PlaneT[2] = GLfloat( vtY.z / dTextDimT) ;
|
||||
PlaneT[3] = GLfloat( - vtY * ( ptOri - ORIG) / dTextDimT) ;
|
||||
// setto generazione texture automatica
|
||||
GLfloat PlaneT[4] ;
|
||||
PlaneT[0] = GLfloat( frTxt.VersY().x / dTextDimT) ;
|
||||
PlaneT[1] = GLfloat( frTxt.VersY().y / dTextDimT) ;
|
||||
PlaneT[2] = GLfloat( frTxt.VersY().z / dTextDimT) ;
|
||||
PlaneT[3] = GLfloat( - frTxt.VersY() * ( frTxt.Orig() - ORIG) / dTextDimT) ;
|
||||
// setto generazione automatica coordinate S e T per texture
|
||||
glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR) ;
|
||||
glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR) ;
|
||||
glTexGenfv( GL_S, GL_OBJECT_PLANE, PlaneS) ;
|
||||
glTexGenfv( GL_T, GL_OBJECT_PLANE, PlaneT) ;
|
||||
|
||||
glEnable( GL_TEXTURE_GEN_S) ;
|
||||
glEnable( GL_TEXTURE_GEN_T) ;
|
||||
}
|
||||
@@ -463,7 +459,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
|
||||
// eseguo visualizzazione
|
||||
bool bOk = pGraphics->Draw( siObj.nStat, siObj.nMark, bSurfSha, nAlpha, bShowAux) ;
|
||||
|
||||
// !!! per textures !!!
|
||||
// disabilito textures
|
||||
glDisable( GL_TEXTURE_GEN_S) ;
|
||||
glDisable( GL_TEXTURE_GEN_T) ;
|
||||
glDisable( GL_TEXTURE_2D) ;
|
||||
|
||||
Reference in New Issue
Block a user