Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGBrick.h

Go to the documentation of this file.
00001 #ifndef _OSGBRICK_H_
00002 #define _OSGBRICK_H_
00003 
00004 #ifdef __sgi
00005 #pragma once
00006 #endif
00007 
00008 #include <OSGConfig.h>
00009 
00010 #include <OSGSystemDef.h>
00011 
00012 #include <vector>
00013 
00014 #include <OSGVector.h>
00015 #include <OSGChunkMaterial.h>
00016 #include <OSGTextureChunk.h>
00017 #include <OSGImage.h>
00018 
00019 #include "OSGDVRShader.h"
00020 #include "OSGDVRClipper.h"
00021 #include "OSGTextureManager.h"
00022 
00023 OSG_BEGIN_NAMESPACE
00024 
00025 
00026 // Forward declarations
00027 class Brick;
00028 class DVRVolume;
00029 
00030 
00031 struct BrickSet 
00032 {
00033     // Orientation values must be fix for they are used for indexing
00034 
00035     enum Orientation 
00036     {
00037         XY    = 0,
00038         XZ    = 1,
00039         YZ    = 2,
00040         UNDEF = 3   // especially for 3D textures
00041     };
00042 
00043     Brick       *m_pBricks;
00044     int          m_nNumBricks;
00045     Orientation  m_nOrientation;
00046   
00047     BrickSet(void);
00048 
00049     ~BrickSet(void);
00050   
00051 
00053     Brick *sortBricks3D(const Matrix &modelMat, 
00054                         const Vec3f  &eyePoint   );
00055     Brick *sortBricks2D(      bool    backToFront);
00056 
00057 
00059     void buildBrickTextures (ChunkMaterialPtr            &material, 
00060                              TextureSet                  &textures,
00061                              TextureManager::TextureMode  mode            );
00062 
00064     void reloadBrickTextures(DrawActionBase              *action, 
00065                              UInt32                       texStage        );
00066 
00068     void clearBrickTextures (ChunkMaterialPtr            &material        );
00069     
00071     void buildBricks3D      (DVRVolume                   *volume, 
00072                              Vec3f                        brickSubdivision, 
00073                              Int32                        overlap = 1,
00074                              Orientation                  ori     = UNDEF );
00075   
00077     void buildBricks2D      (DVRVolume                   *volume, 
00078                              Orientation                  ori             );
00079 
00080 
00082     static TextureChunkPtr makeTexture(UInt32   internalFormat, 
00083                                        UInt32   externalFormat, 
00084                                        ImagePtr image         );
00085 };
00086 
00087 
00088 class Brick 
00089 {
00090   public:
00091 
00093     Brick *getNext(void);
00094     
00096     void init(Int32  minVoxX, Int32  minVoxY, Int32  minVoxZ,
00097               Int32  resX,    Int32  resY,    Int32  resZ,
00098               Real32 xMin,    Real32 yMin,    Real32 zMin,
00099               Real32 xMax,    Real32 yMax,    Real32 zMax,
00100 
00101               Int32                 overlap = 1,
00102               BrickSet::Orientation ori     = BrickSet::UNDEF);
00103 
00105     void activateTexture  (DrawActionBase *action             );
00106     void changeFromTexture(DrawActionBase *action, Brick * old);
00107     void deactivateTexture(DrawActionBase *action             );
00108 
00110     void renderSlices(DVRVolume                   *volume, 
00111                       DrawActionBase              *action,
00112                       DVRShaderPtr                 shader,  
00113                       DVRClipper                  *clipper,
00114                       TextureManager::TextureMode  mode);
00115 
00117     void renderBrick(void);
00118 
00120     void vertToTex(Real32 *vx, Real32 *vy, Real32 *vz,
00121                    Real32 *tx, Real32 *ty, Real32 *tz);
00122     void vertToTex(Vec3f  &vert, 
00123                    Vec3f  &tex                       );
00124       
00125   private:
00126 
00127     Vec3f                  vertex[8];
00128     Line                   edges[12];
00129     TextureChunkPtr       *texture;
00130     UInt32                *texStage;
00131     Int32                  numTextures;
00132     Vec3f                  center;
00133     Real32                 radius;
00134     Vec3f                  texTranslate;
00135     Vec3f                  texScale;
00136     Int32                  voxSize[3];    // Voxelspace size of the brick
00137     Int32                  minVox[3];
00138     Vec3f                  m_lowerLeft;   // Geometrical size of the brick
00139     Vec3f                  m_upperRight;
00140     BrickSet::Orientation  m_ori;
00141 
00142     // temporary values
00143     Real32                 distance;
00144     Brick                 *prev;
00145     Brick                 *next;
00146 
00147     DVRSlice               slice;
00148     DVRRenderSlice         clippedSlice;
00149 
00151     void render3DSlices     (      DVRVolume      *volume, 
00152                                    DrawActionBase *action,
00153                                    DVRShaderPtr    shader, 
00154                                    DVRClipper     *clipper,
00155                              const Vec3f          &sliceDir);
00156 
00157     void render2DSlices     (      DVRVolume      *volume, 
00158                                    DrawActionBase *action, 
00159                                    DVRShaderPtr    shader, 
00160                                    DVRClipper     *clipper,
00161                              const Vec3f          &sliceDir);
00162 
00163     void render2DMultiSlices(      DVRVolume      *volume,
00164                                    DrawActionBase *action,
00165                                    DVRShaderPtr    shader,
00166                                    DVRClipper     *clipper,
00167                                    bool            btf,
00168                              const Vec3f          &sliceDir);
00169     
00170     void render2DSliceXY    (      DVRVolume      *volume, 
00171                                    DrawActionBase *action, 
00172                                    DVRShaderPtr    shader,   
00173                                    DVRClipper     *clipper,
00174                              const Vec3f          &sliceDir,
00175                              const Real32         &zCoord  );
00176     
00177     void render2DSliceXZ    (      DVRVolume      *volume, 
00178                                    DrawActionBase *action, 
00179                                    DVRShaderPtr    shader,   
00180                                    DVRClipper     *clipper,
00181                              const Vec3f          &sliceDir,
00182                              const Real32         &yCoord  );
00183     
00184     void render2DSliceYZ    (      DVRVolume      *volume, 
00185                                    DrawActionBase *action, 
00186                                    DVRShaderPtr    shader,   
00187                                    DVRClipper     *clipper,
00188                              const Vec3f          &sliceDir,
00189                              const Real32         &xCoord  );
00190 
00191     friend class BrickSet;
00192 };
00193 
00194 OSG_END_NAMESPACE
00195 
00196 #include "OSGBrick.inl"
00197 #endif

Generated on Thu Aug 25 04:01:26 2005 for OpenSG by  doxygen 1.4.3