Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

SurfelGPFrameBuffer.h

Go to the documentation of this file.
00001 //
00002 // Title:   SurfelGPFrameBuffer.h
00003 // Created: Mon Sep 23 15:07:02 2002
00004 // Authors: Oliver Knoll, Mark Pauly, Matthias Zwicker
00005 //
00006 // Copyright (c) 2001, 2002, Computer Graphics Lab, ETH Zurich
00007 //
00008 // This file is part of the Pointshop3D system.
00009 // See http://www.pointshop3d.com/ for more information.
00010 //
00011 // This program is free software; you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License as
00013 // published by the Free Software Foundation; either version 2 of
00014 // the License, or (at your option) any later version.
00015 //
00016 // This program is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 // GNU General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU General Public
00022 // License along with this program; if not, write to the Free
00023 // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00024 // MA 02111-1307, USA.
00025 //
00026 // Contact info@pointshop3d.com if any conditions of this
00027 // licensing are not clear to you.
00028 //
00029 
00030 #ifndef __SURFELGPFRAMEBUFFER_H_
00031 #define __SURFELGPFRAMEBUFFER_H_
00032 
00033 #include <qarray.h>
00034 #include <qvector.h>
00035 #include <qimage.h>
00036 #include <qsize.h>
00037 #include <qthread.h>
00038 
00039 #include "../../../Core/Interfaces/src/FrameBufferInterface.h"
00040 #include "../../../Core/Interfaces/src/RendererInterface.h"
00041 #include "../../../Core/DataStructures/src/SurfelCollection.h"
00042 #include "../../../Core/Scene/src/Scene.h"
00043 #include "../../../DataTypes/src/Vector3D.h"
00044 #include "../../../DataTypes/src/Vector2D.h"
00045 
00046 #include "SurfelPipeline_SurfSplat/Srf.h"
00047 
00054 class SurfelGPFrameBuffer : public FrameBufferInterface {
00055 
00056 public:
00057 
00066         SurfelGPFrameBuffer (const QSize size = QSize (0, 0));
00067         virtual ~SurfelGPFrameBuffer();
00068 
00075         void setSurfelContext(SrfContext *srf);
00076 
00077         // ******************************
00078         // interface FrameBufferInterface
00079         // ******************************
00080 
00081         RENDERER_API void setAttributes (const int attriubtes);
00082         RENDERER_API int getAttributes() const;
00083         RENDERER_API void setValid (const bool valid);
00084         RENDERER_API bool isValid() const;
00085         RENDERER_API void setSize (const QSize newBufferSize);
00086         RENDERER_API QSize getSize() const;
00087 
00088         RENDERER_API void setColor (const int x, const int y, const QRgb newPixelColor);
00089         RENDERER_API QRgb getColor (const int x, const int y) const;
00090         RENDERER_API const QImage *getImage() const;
00091         RENDERER_API void clearImage (const QRgb clearColor);
00092 
00093         RENDERER_API void addWeight (const int x, const int y, const float pixelWeightIncrement);
00094         RENDERER_API void setWeight (const int x, const int y, const float newPixelweight);
00095         RENDERER_API float getWeight (const int x, const int y) const;
00096         RENDERER_API void setDepth (const int x, const int y, const float z);
00097         RENDERER_API float getDepth (const int x, const int y) const;
00098         RENDERER_API void setNormal (const int x, const int y, const Vector3D newNormal);
00099         RENDERER_API void setNormal (const int x, const int y, const float nx, const float ny, const float nz);
00100         RENDERER_API Vector3D getNormal (const int x, const int y) const;
00101         RENDERER_API SurfelInterface* getSurfel(const int x, const int y);
00102         RENDERER_API void addVisibleSurfel (const int x, const int y, SurfelInterface *visibleSurfel);
00103         RENDERER_API void getVisibleSurfels (const int x, const int y,  const QArray<SurfelInterface *> **visibleSurfels, uint *nofVisible) const;
00104 
00105         RENDERER_API void resetPosition (const int x, const int y);
00106         RENDERER_API bool isPixelCovered (const int x, const int y) const;
00107         RENDERER_API bool allPixelsCovered ();
00108         
00109         RENDERER_API Object* getObjectAtPixel (const int x, const int y) const;
00110         RENDERER_API void setObjectAtPixel (const int x, const int y, Object *object);
00111 
00112         RENDERER_API int getNofSplatInfoEntries() const;
00113         RENDERER_API const QArray<SurfelInterface *>& getSurfelsInViewFrustum() const;
00114         RENDERER_API const QArray<MyDataTypes::TextureCoordinate>& getTextureCoordinatesInViewFrustum() const;
00115         RENDERER_API const QArray<MyDataTypes::Splat>& getSplatsInViewFrustum() const;
00116         RENDERER_API void setSplatInfo (SurfelInterface *surfel, const float x, const float y, const float z, const float a, const float b_2, const float c, const int bbox[4]);
00117 
00118         RENDERER_API QImage *getZImage() const; 
00119         RENDERER_API float getMaxZValue() const;        
00120         RENDERER_API float getMinZValue() const;        
00121 
00122         RENDERER_API QList<SurfelInterface> *getAllVisibleSurfels ();
00123         RENDERER_API void markAllSurfels ();
00124 
00125 private:
00126 
00127         typedef struct bufferEntry {
00128                 uint                      nofVisible;      // number of visible surfels
00129                 QArray<SurfelInterface *> *visibleSurfels; // the visible surfels
00130                 Object                    *object;         // the object belonging to the last surfel rendered to this pixel
00131         } BufferEntry;
00132 
00133         BufferEntry             *buffer;            // the per pixel data which holds pointers to visible surfels
00134 
00135         QSize                   size;               // the size of the buffer in pixels
00136         int                                             height_1;                       // size.height()-1
00137         int                                             height;                         // size.height()
00138         int                                             width;                          // size.width()
00139 
00140         SrfZBufItem*                    srfFrameBuffer;         // direct access to internal frame buffer of the surfel renderer
00141                                                                                                 // this buffer stores pixel weights, z values, and normals
00142 
00143         int                     attributes;                     // attributes that are written to the frame buffer during rendering
00144         QImage                  *image;             // contains the rendered image      
00145         
00146         bool                    valid;              // true, if the buffer is filled with valid data
00147                                 
00148 
00149         QArray<SurfelInterface*> surfels;           // array storing the rendered surfels
00150         QArray<MyDataTypes::TextureCoordinate>  texCoords;
00151         QArray<MyDataTypes::Splat>              splats;           // array storing splats rendered to the frame buffer
00152 
00153         uint                                    nSplats;                        // number of splats currently stored in the splats array
00154 
00155         // initializes all buffer entries
00156         void initBuffer();
00157 
00158         // resets all buffer entries - buffer must already be initialized
00159         // with 'initBuffer'
00160         void resetBuffer();
00161 
00162         // removes the current 'buffer', releasing all resources
00163         void removeBuffer();
00164 
00165 
00166 
00167 };
00168 
00169 #endif  // __SURFELGPFRAMEBUFFER_H_
00170 
00171 // Some Emacs-Hints -- please don't remove:
00172 //
00173 //  Local Variables:
00174 //  mode:C++
00175 //  tab-width:4
00176 //  End:

Generated on Mon Sep 30 15:50:42 2002 for PointShop by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002