#include <OSGTextureBackground.h>
Inheritance diagram for osg::TextureBackground:

Definition at line 55 of file OSGTextureBackground.h.
|
|
Reimplemented from osg::TextureBackgroundBase. Definition at line 59 of file OSGTextureBackground.h. |
|
|
Reimplemented from osg::BackgroundBase. Definition at line 96 of file OSGTextureBackgroundBase.h. |
|
|
Reimplemented from osg::AttachmentContainer. Definition at line 98 of file OSGTextureBackgroundBase.h. 00099 { 00100 ColorFieldId = Inherited::NextFieldId, 00101 TextureFieldId = ColorFieldId + 1, 00102 TexCoordsFieldId = TextureFieldId + 1, 00103 RadialDistortionFieldId = TexCoordsFieldId + 1, 00104 CenterOfDistortionFieldId = RadialDistortionFieldId + 1, 00105 HorFieldId = CenterOfDistortionFieldId + 1, 00106 VertFieldId = HorFieldId + 1, 00107 NextFieldId = VertFieldId + 1 00108 };
|
|
|
Definition at line 88 of file OSGTextureBackground.cpp. 00088 : 00089 Inherited() 00090 { 00091 }
|
|
|
Definition at line 93 of file OSGTextureBackground.cpp. 00093 : 00094 Inherited(source) 00095 { 00096 }
|
|
|
Definition at line 98 of file OSGTextureBackground.cpp.
|
|
||||||||||||
|
Implements osg::Background. Definition at line 181 of file OSGTextureBackground.cpp. References _indexArray, _textureCoordArray, _vertexCoordArray, osg::Eps, osg::TextureBackgroundBase::getColor(), osg::TextureBackgroundBase::getHor(), osg::TextureBackgroundBase::getRadialDistortion(), osg::MField< FieldTypeT, fieldNameSpace >::getSize(), osg::TextureBackgroundBase::getTexCoords(), osg::TextureBackgroundBase::getTexture(), osg::TextureBackgroundBase::getVert(), GLboolean, osg::NullFC, osg::osgabs(), and updateGrid(). 00182 { 00183 TextureChunkPtr tex = getTexture(); 00184 if(tex == NullFC) 00185 { 00186 glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 00187 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00188 return; 00189 } 00190 GLboolean light = glIsEnabled(GL_LIGHTING); 00191 if (light == GL_TRUE) 00192 glDisable(GL_LIGHTING); 00193 00194 GLint fill[2]; 00195 glGetIntegerv(GL_POLYGON_MODE, fill); 00196 #if 1 00197 // original mode 00198 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 00199 #else 00200 // for testing the grid 00201 glColor3f(1.0f, 1.0f, 1.0f); 00202 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 00203 #endif 00204 glClear(GL_DEPTH_BUFFER_BIT); 00205 00206 GLboolean depth = glIsEnabled(GL_DEPTH_TEST); 00207 glDisable(GL_DEPTH_TEST); 00208 00209 GLint depthFunc; 00210 glGetIntegerv(GL_DEPTH_FUNC, &depthFunc); 00211 glDepthFunc(GL_ALWAYS); 00212 00213 glDepthMask(GL_FALSE); 00214 00215 glMatrixMode(GL_MODELVIEW); 00216 glPushMatrix(); 00217 glLoadIdentity(); 00218 00219 glMatrixMode(GL_PROJECTION); 00220 glPushMatrix(); 00221 00222 glLoadIdentity(); 00223 glOrtho(0, 1, 0, 1, 0, 1); 00224 00225 glColor4fv(getColor().getValuesRGBA()); 00226 00227 tex->activate(action); 00228 00229 if(tex->isTransparent()) 00230 { 00231 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 00232 glEnable(GL_BLEND); 00233 } 00234 if(osgabs(getRadialDistortion())<Eps) 00235 { 00236 if(getTexCoords().getSize() < 4) 00237 { 00238 // set some default texture coordinates. 00239 glBegin(GL_QUADS); 00240 glTexCoord2f(0.0f, 0.0f); 00241 glVertex3f(0.0f, 0.0f, 0.0f); 00242 glTexCoord2f(1.0f, 0.0f); 00243 glVertex3f(1.0f, 0.0f, 0.0f); 00244 glTexCoord2f(1.0f, 1.0f); 00245 glVertex3f(1.0f, 1.0f, 0.0f); 00246 glTexCoord2f(0.0f, 1.0f); 00247 glVertex3f(0.0f, 1.0f, 0.0f); 00248 glEnd(); 00249 } 00250 else 00251 { 00252 glBegin(GL_QUADS); 00253 glTexCoord2f(getTexCoords()[0].getValues()[0], 00254 getTexCoords()[0].getValues()[1]); 00255 glVertex3f(0.0f, 0.0f, 0.0f); 00256 glTexCoord2f(getTexCoords()[1].getValues()[0], 00257 getTexCoords()[1].getValues()[1]); 00258 glVertex3f(1.0f, 0.0f, 0.0f); 00259 glTexCoord2f(getTexCoords()[2].getValues()[0], 00260 getTexCoords()[2].getValues()[1]); 00261 glVertex3f(1.0f, 1.0f, 0.0f); 00262 glTexCoord2f(getTexCoords()[3].getValues()[0], 00263 getTexCoords()[3].getValues()[1]); 00264 glVertex3f(0.0f, 1.0f, 0.0f); 00265 glEnd(); 00266 } 00267 } 00268 else // map texture to distortion grid 00269 { 00270 updateGrid(); 00271 Int16 xxmax=getHor()+2,yymax=getVert()+2; 00272 00273 UInt32 gridCoords=xxmax*yymax; 00274 int indexArraySize=xxmax*((getVert()+1)*2); 00275 00276 if(_vertexCoordArray.size()==gridCoords && 00277 _textureCoordArray.size()==gridCoords && 00278 _indexArray.size()==indexArraySize) 00279 { 00280 // clear background, because possibly the distortion grid could not cover th whole window 00281 glClearColor(.5f, 0.5f, 0.5f, 1.0f); 00282 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00283 std::vector<UInt32>::iterator i; 00284 UInt32 yMax=getVert()+1; 00285 for(UInt32 y=0;y<yMax;y++) 00286 { 00287 glBegin(GL_TRIANGLE_STRIP); 00288 std::vector<UInt32>::iterator begin=_indexArray.begin()+(y*2*xxmax); 00289 std::vector<UInt32>::iterator end=begin+2*xxmax; 00290 for(std::vector<UInt32>::iterator i=begin;i!=end;i++) 00291 { 00292 glTexCoord2fv(_textureCoordArray[*i].getValues()); 00293 glVertex2fv(_vertexCoordArray[*i].getValues()); 00294 00295 } 00296 glEnd(); 00297 } 00298 } 00299 } 00300 if(tex->isTransparent()) 00301 { 00302 glDisable(GL_BLEND); 00303 } 00304 00305 tex->deactivate(action); 00306 00307 glClear(GL_DEPTH_BUFFER_BIT); 00308 00309 glPopMatrix(); 00310 glMatrixMode(GL_MODELVIEW); 00311 glPopMatrix(); 00312 00313 glDepthMask(GL_TRUE); 00314 if(depth) 00315 glEnable(GL_DEPTH_TEST); 00316 glDepthFunc(depthFunc); 00317 00318 glPolygonMode(GL_FRONT, fill[0]); 00319 glPolygonMode(GL_BACK , fill[1]); 00320 if(light) 00321 glEnable(GL_LIGHTING); 00322 glColor3f(1.0f, 1.0f, 1.0f); 00323 }
|
|
||||||||||||
|
Reimplemented from osg::Background. Definition at line 107 of file OSGTextureBackground.cpp. References osg::Background::changed(). 00108 { 00109 Inherited::changed(whichField, origin); 00110 00111 // all updates are handled in updateGrid() 00112 }
|
|
||||||||||||
|
Reimplemented from osg::Background. Definition at line 326 of file OSGTextureBackground.cpp. References SLOG. 00328 { 00329 SLOG << "Dump TextureBackground NI" << std::endl; 00330 }
|
|
|
Definition at line 115 of file OSGTextureBackground.cpp. References _centerOfDistortion, _hor, _indexArray, _radialDistortion, _textureCoordArray, _vert, _vertexCoordArray, osg::TextureBackgroundBase::getCenterOfDistortion(), osg::TextureBackgroundBase::getHor(), osg::TextureBackgroundBase::getRadialDistortion(), osg::TextureBackgroundBase::getVert(), osg::VecStorage2< ValueTypeT >::x(), and osg::VecStorage2< ValueTypeT >::y(). Referenced by clear(). 00116 { 00117 bool gridChanged=( (getHor() != _hor) || 00118 (getVert() != _vert) ); 00119 00120 if(gridChanged) 00121 { 00122 //resize grid 00123 UInt32 gridCoords=(getHor()+2)*(getVert()+2); 00124 _textureCoordArray.resize(gridCoords); 00125 _vertexCoordArray.resize(gridCoords); 00126 00127 int indexArraySize=(getHor()+2)*((getVert()+1)*2); 00128 _indexArray.resize(indexArraySize); 00129 00130 _hor = getHor(); 00131 _vert = getVert(); 00132 } 00133 00134 if(gridChanged || _radialDistortion != getRadialDistortion() || 00135 _centerOfDistortion != getCenterOfDistortion() 00136 ) 00137 { 00138 _radialDistortion = getRadialDistortion(); 00139 _centerOfDistortion = getCenterOfDistortion(); 00140 00141 // calculate grid coordinates and triangle strip indices 00142 float xStep=1.0/float(getHor()+1); 00143 float yStep=1.0/float(getVert()+1); 00144 std::vector<Vec2f>::iterator texCoord=_textureCoordArray.begin(); 00145 std::vector<Vec2f>::iterator vertexCoord=_vertexCoordArray.begin(); 00146 std::vector<UInt32>::iterator index=_indexArray.begin(); 00147 UInt32 coord0(0),coord1(0); 00148 GLfloat x,y; 00149 Int16 xx,yy; 00150 Int16 xxmax=getHor()+2,yymax=getVert()+2; 00151 for(yy=0,y=0.0f;yy<yymax;yy++,y+=yStep) 00152 { 00153 if(yy>0) 00154 { 00155 coord1=yy*xxmax; 00156 coord0=coord1-xxmax; 00157 *index++=coord1++; 00158 *index++=coord0++; 00159 } 00160 float dy=y-getCenterOfDistortion().y(); 00161 float dy2=dy*dy; 00162 for(xx=0,x=0.0f;xx<xxmax;xx++,x+=xStep) 00163 { 00164 *texCoord++=Vec2f(x,y); 00165 float dx=(x-getCenterOfDistortion().x()); 00166 float dx2=dx*dx; 00167 float dist2=dx2+dy2; 00168 float deltaX=dx*getRadialDistortion()*dist2; 00169 float deltaY=dy*getRadialDistortion()*dist2; 00170 *vertexCoord++=Vec2f(x+deltaX,y+deltaY); 00171 if(yy>0&&xx>0) 00172 { 00173 *index++=coord1++; 00174 *index++=coord0++; 00175 } 00176 } 00177 } 00178 } 00179 }
|
|
|
Reimplemented from osg::Background. Definition at line 73 of file OSGTextureBackground.cpp.
|
|
|
|
|
|
Reimplemented from osg::BackgroundBase. Definition at line 58 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_type. Referenced by osg::TextureBackgroundBase::create(). 00059 { 00060 return _type; 00061 }
|
|
|
Reimplemented from osg::BackgroundBase. Definition at line 65 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_type, and osg::TypeBase::getId(). 00066 { 00067 return _type.getId(); 00068 }
|
|
|
Reimplemented from osg::BackgroundBase. Definition at line 172 of file OSGTextureBackgroundBase.cpp. References osg::TextureBackgroundBase::_type. 00173 { 00174 return _type; 00175 }
|
|
|
Reimplemented from osg::BackgroundBase. Definition at line 177 of file OSGTextureBackgroundBase.cpp. References osg::TextureBackgroundBase::_type. 00178 { 00179 return _type; 00180 }
|
|
|
Reimplemented from osg::BackgroundBase. Definition at line 192 of file OSGTextureBackgroundBase.cpp. 00193 { 00194 return sizeof(TextureBackground); 00195 }
|
|
|
Definition at line 101 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_sfColor. 00102 { 00103 return &_sfColor; 00104 }
|
|
|
Definition at line 108 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_sfTexture. 00109 { 00110 return &_sfTexture; 00111 }
|
|
|
Definition at line 115 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_mfTexCoords. 00116 { 00117 return &_mfTexCoords; 00118 }
|
|
|
Definition at line 122 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_sfRadialDistortion. 00123 { 00124 return &_sfRadialDistortion; 00125 }
|
|
|
Definition at line 129 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_sfCenterOfDistortion. 00130 { 00131 return &_sfCenterOfDistortion; 00132 }
|
|
|
Definition at line 136 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_sfHor. 00137 { 00138 return &_sfHor; 00139 }
|
|
|
Definition at line 143 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_sfVert. 00144 { 00145 return &_sfVert; 00146 }
|
|
|
Definition at line 151 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_sfColor, and osg::SField< FieldTypeT, fieldNameSpace >::getValue(). Referenced by clear(). 00152 { 00153 return _sfColor.getValue(); 00154 }
|
|
|
Definition at line 158 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_sfColor, and osg::SField< FieldTypeT, fieldNameSpace >::getValue(). 00159 { 00160 return _sfColor.getValue(); 00161 }
|
|
|
Definition at line 172 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_sfTexture, and osg::SField< FieldTypeT, fieldNameSpace >::getValue(). Referenced by clear(). 00173 { 00174 return _sfTexture.getValue(); 00175 }
|
|
|
Definition at line 179 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_sfTexture, and osg::SField< FieldTypeT, fieldNameSpace >::getValue(). 00180 { 00181 return _sfTexture.getValue(); 00182 }
|
|
|
Definition at line 193 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_sfRadialDistortion, and osg::SField< FieldTypeT, fieldNameSpace >::getValue(). Referenced by clear(), and updateGrid(). 00194 { 00195 return _sfRadialDistortion.getValue(); 00196 }
|
|
|
Definition at line 200 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_sfRadialDistortion, and osg::SField< FieldTypeT, fieldNameSpace >::getValue(). 00201 { 00202 return _sfRadialDistortion.getValue(); 00203 }
|
|
|
Definition at line 214 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_sfCenterOfDistortion, and osg::SField< FieldTypeT, fieldNameSpace >::getValue(). Referenced by updateGrid(). 00215 { 00216 return _sfCenterOfDistortion.getValue(); 00217 }
|
|
|
Definition at line 221 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_sfCenterOfDistortion, and osg::SField< FieldTypeT, fieldNameSpace >::getValue(). 00222 { 00223 return _sfCenterOfDistortion.getValue(); 00224 }
|
|
|
Definition at line 235 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_sfHor, and osg::SField< FieldTypeT, fieldNameSpace >::getValue(). Referenced by clear(), and updateGrid(). 00236 { 00237 return _sfHor.getValue(); 00238 }
|
|
|
Definition at line 242 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_sfHor, and osg::SField< FieldTypeT, fieldNameSpace >::getValue(). 00243 { 00244 return _sfHor.getValue(); 00245 }
|
|
|
Definition at line 256 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_sfVert, and osg::SField< FieldTypeT, fieldNameSpace >::getValue(). Referenced by clear(), and updateGrid(). 00257 { 00258 return _sfVert.getValue(); 00259 }
|
|
|
Definition at line 263 of file OSGTextureBackgroundBase.inl. References osg::TextureBackgroundBase::_sfVert, and osg::SField< FieldTypeT, fieldNameSpace >::getValue(). 00264 { 00265 return _sfVert.getValue(); 00266 }
|
|