osg::DisplayFilterForeground::DisplayFilterGroup Class Reference

#include <OSGDisplayFilterForeground.h>

List of all members.

Public Member Functions

 DisplayFilterGroup (bool readback, std::vector< ViewportPtr > &ports)
virtual ~DisplayFilterGroup ()
TextureChunkPtr getTexture (void)
GeometryPtr getGeometry (void)
ChunkMaterialPtr getMaterial (void)
ComponentTransformPtr getTransform (void)
TextureTransformChunkPtr getTextureTransform (void)
void createGrid (UInt32 width, UInt32 height)

Protected Attributes

ViewportPtr _vp
NodePtr _root
TextureChunkPtr _texture
GeometryPtr _geometry
ChunkMaterialPtr _material
ComponentTransformPtr _transform
BackgroundPtr _background
TextureTransformChunkPtr _textureTransform


Detailed Description

Definition at line 72 of file OSGDisplayFilterForeground.h.


Constructor & Destructor Documentation

osg::DisplayFilterForeground::DisplayFilterGroup::DisplayFilterGroup ( bool  readback,
std::vector< ViewportPtr > &  ports 
)

A DisplayFilter group contains a background, that can be a texture readback backgound, a transformation node and a geometry with a ChunkMaterial attached to it. The idea is that several filters can share the same group to avoid a texture readback for each filter. For example Color correction and distortion correction can share the same group as the first manipulates only the texture and the second modifies the geometry.

Definition at line 292 of file OSGDisplayFilterForeground.cpp.

References _geometry, _material, _root, _texture, _textureTransform, _transform, _vp, osg::addRefCP(), osg::beginEditCP(), osg::TextureTransformChunkBase::create(), osg::TextureGrabBackgroundBase::create(), osg::TextureChunkBase::create(), osg::ImageBase::create(), osg::PassiveBackgroundBase::create(), osg::MatrixCameraBase::create(), osg::Node::create(), osg::ChunkMaterialBase::create(), osg::ComponentTransformBase::create(), osg::GeometryBase::create(), osg::ViewportBase::create(), createGrid(), osg::endEditCP(), GL_CLAMP_TO_EDGE, osg::TransformationMatrix< ValueTypeT >::identity(), osg::MatrixOrthogonal(), and osg::TransformationMatrix< ValueTypeT >::setIdentity().

00295 {
00296     // create one or two viewports
00297     _vp = Viewport::create();
00298     _geometry = Geometry::create();
00299     _transform = ComponentTransform::create();
00300     _material = ChunkMaterial::create();
00301     _root = Node::create();
00302     NodePtr node = Node::create();
00303     MatrixCameraPtr cam = MatrixCamera::create();
00304     beginEditCP(node);
00305     beginEditCP(_vp);
00306     beginEditCP(_root);
00307     beginEditCP(_geometry);
00308     beginEditCP(_material);
00309     beginEditCP(_transform);
00310 
00311     createGrid(2,2);
00312 
00313     addRefCP(_vp);
00314     addRefCP(_root);
00315 
00316     ports.push_back(_vp);
00317 
00318     // camera
00319     cam->setNear(-1);
00320     cam->setFar ( 1);
00321     cam->setModelviewMatrix(Matrix::identity());
00322     cam->setProjectionMatrix(Matrix::identity());   
00323 
00324     Matrix proj;
00325     proj.setIdentity();
00326     MatrixOrthogonal(proj,0,1,0,1,-1,1);
00327     cam->setProjectionMatrix(proj);   
00328 
00329     // creat tree
00330     node->setCore(_geometry);
00331     _root->setCore(_transform);
00332     _root->addChild(node);
00333     _geometry->setMaterial(_material);
00334 
00335     _vp->setRoot(_root);
00336     _vp->setCamera(cam);
00337 
00338     if(!readback)
00339     {
00340         // no readback, create black solid backgrounds
00341         PassiveBackgroundPtr back = PassiveBackground::create();
00342         _vp->setBackground(back);
00343     }
00344     else
00345     {
00346         // image
00347         ImagePtr img = Image::create();
00348         beginEditCP(img);
00349         img->set(GL_RGB,1,1);
00350         endEditCP(img);
00351         // texture chunk
00352         _texture = TextureChunk::create();    
00353         beginEditCP(_texture);
00354         _texture->setImage(img);
00355         _texture->setWrapS(GL_CLAMP_TO_EDGE);
00356         _texture->setWrapT(GL_CLAMP_TO_EDGE);
00357         _texture->setMinFilter(GL_LINEAR);
00358         _texture->setMagFilter(GL_LINEAR);
00359         _texture->setScale(false);
00360         _texture->setEnvMode(GL_REPLACE);
00361         _texture->setNPOTMatrixScale(true);
00362         _texture->setScale(false);
00363         endEditCP(_texture);
00364         // texture grep background
00365         TextureGrabBackgroundPtr back = TextureGrabBackground::create();
00366         beginEditCP(back);
00367         back->setTexture(_texture);
00368         back->setColor(Color3f(0,0,0));
00369         endEditCP(back);
00370         _vp->setBackground(back);
00371 
00372         _material->addChunk(_texture);
00373     }
00374 
00375     // add texture transform chunk
00376     _textureTransform = TextureTransformChunk::create();
00377     _material->addChunk(_textureTransform);
00378 
00379     endEditCP(_vp);
00380     endEditCP(node);
00381     endEditCP(_root);
00382     endEditCP(_geometry);
00383     endEditCP(_material);
00384     endEditCP(_transform);
00385 }

osg::DisplayFilterForeground::DisplayFilterGroup::~DisplayFilterGroup (  )  [virtual]

Definition at line 387 of file OSGDisplayFilterForeground.cpp.

References _root, _vp, and osg::subRefCP().

00388 {
00389     subRefCP(_vp);
00390     subRefCP(_root);
00391 }


Member Function Documentation

TextureChunkPtr osg::DisplayFilterForeground::DisplayFilterGroup::getTexture ( void   ) 

Definition at line 393 of file OSGDisplayFilterForeground.cpp.

References _texture.

00394 {
00395     return _texture;
00396 }

GeometryPtr osg::DisplayFilterForeground::DisplayFilterGroup::getGeometry ( void   ) 

Definition at line 398 of file OSGDisplayFilterForeground.cpp.

References _geometry.

Referenced by osg::DistortionDisplayFilter::createFilter().

00399 {
00400     return _geometry;
00401 }

ChunkMaterialPtr osg::DisplayFilterForeground::DisplayFilterGroup::getMaterial ( void   ) 

Definition at line 403 of file OSGDisplayFilterForeground.cpp.

References _material.

Referenced by osg::ColorDisplayFilter::createFilter().

00404 {
00405     return _material;
00406 }

ComponentTransformPtr osg::DisplayFilterForeground::DisplayFilterGroup::getTransform ( void   ) 

Definition at line 408 of file OSGDisplayFilterForeground.cpp.

References _transform.

Referenced by osg::ResolutionDisplayFilter::createFilter().

00409 {
00410     return _transform;
00411 }

TextureTransformChunkPtr osg::DisplayFilterForeground::DisplayFilterGroup::getTextureTransform ( void   ) 

Definition at line 413 of file OSGDisplayFilterForeground.cpp.

References _textureTransform.

00414 {
00415     return _textureTransform;
00416 }

void osg::DisplayFilterForeground::DisplayFilterGroup::createGrid ( UInt32  width,
UInt32  height 
)

Definition at line 418 of file OSGDisplayFilterForeground.cpp.

References _geometry, osg::beginEditCP(), osg::GeoProperty< GeoPropertyDesc >::create(), and osg::endEditCP().

Referenced by osg::DistortionDisplayFilter::createFilter(), and DisplayFilterGroup().

00419 {
00420     GeoPTypesUI8Ptr   types = GeoPTypesUI8::create();
00421     GeoPLengthsPtr    lens = GeoPLengthsUI32::create();    
00422     GeoIndicesUI32Ptr index = GeoIndicesUI32::create();   
00423     GeoPositions3fPtr pos = GeoPositions3f::create();
00424     GeoTexCoords2fPtr texcoords = GeoTexCoords2f::create();
00425 
00426     if(width<2)
00427         width = 2;
00428     if(height<2)
00429         height = 2;
00430 
00431     beginEditCP(pos);
00432     beginEditCP(texcoords);
00433     beginEditCP(lens);
00434     beginEditCP(index);
00435 
00436     UInt16 x,y;
00437     Real32 xstep,ystep;
00438     xstep=1.0 / (width-1);
00439     ystep=1.0 / (height-1);
00440 
00441     for(y = 0; y < height; y++)
00442     {
00443         for(x = 0; x < width; x++)
00444         {
00445             pos->push_back(Pnt3f(x*xstep,y*ystep,0));
00446             texcoords->push_back(Vec2f(x*xstep, y*ystep));
00447         }
00448     }
00449 
00450     for(y = 0; y < (height-1); y++)
00451     {
00452         types->push_back(GL_TRIANGLE_STRIP);
00453         lens->push_back(2 * width);
00454         
00455         for(x = 0; x < width; x++)
00456         {
00457             index->push_back((y + 1) * width + x);
00458             index->push_back( y      * width + x);
00459         }
00460     }
00461 
00462     beginEditCP(_geometry);
00463     _geometry->setPositions(pos);
00464     _geometry->setTypes(types);
00465     _geometry->setTexCoords(texcoords);
00466     _geometry->setLengths(lens);
00467     _geometry->setIndices(index);
00468     endEditCP(_geometry);
00469 
00470     endEditCP(pos);
00471     endEditCP(texcoords);
00472     endEditCP(lens);
00473     endEditCP(index);
00474 }


Member Data Documentation

Definition at line 83 of file OSGDisplayFilterForeground.h.

Referenced by DisplayFilterGroup(), and ~DisplayFilterGroup().

Definition at line 84 of file OSGDisplayFilterForeground.h.

Referenced by DisplayFilterGroup(), and ~DisplayFilterGroup().

Definition at line 85 of file OSGDisplayFilterForeground.h.

Referenced by DisplayFilterGroup(), and getTexture().

Definition at line 86 of file OSGDisplayFilterForeground.h.

Referenced by createGrid(), DisplayFilterGroup(), and getGeometry().

Definition at line 87 of file OSGDisplayFilterForeground.h.

Referenced by DisplayFilterGroup(), and getMaterial().

Definition at line 88 of file OSGDisplayFilterForeground.h.

Referenced by DisplayFilterGroup(), and getTransform().

Definition at line 89 of file OSGDisplayFilterForeground.h.

Definition at line 90 of file OSGDisplayFilterForeground.h.

Referenced by DisplayFilterGroup(), and getTextureTransform().


The documentation for this class was generated from the following files:

Generated on Mon Mar 17 11:21:08 2008 for OpenSG by  doxygen 1.5.5