arbeit
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

VolRenAlgBase.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------
00002 //
00003 //   Joe Kniss
00004 //     9-20-02
00005 //                   ________    ____   ___ 
00006 //                  |        \  /    | /  /
00007 //                  +---+     \/     |/  /
00008 //                  +--+|  |\    /|     < 
00009 //                  |  ||  | \  / |  |\  \ 
00010 //                  |      |  \/  |  | \  \ 
00011 //                   \_____|      |__|  \__\
00012 //                       Copyright  2002 
00013 //                      Joe Michael Kniss
00014 //                   <<< jmk@cs.utah.edu >>>
00015 //               "All Your Base are Belong to Us"
00016 //-------------------------------------------------------------------------
00017 
00018 
00019 //VolRenAlgBase.h
00020 
00021 /// Rendering strategy for "VolRen" classes...
00022 ///Base interface for volume rendering algorithms, works in 
00023 ///conjunction with VolRenBase.  Also, implements a 
00024 /// simple slice via-lines view
00025 
00026 #ifndef __VOLREN_ALG_BASE_DOT_H
00027 #define __VOLREN_ALG_BASE_DOT_H
00028 
00029 #include <mathGutz.h>
00030 #include <textureGlift.h>
00031 #include <stateGlift.h>
00032 #include <volume/VolSamples.h>
00033 #include <volume/Volytope.h>
00034 #include <iostream>
00035 #include <graphicsGutz.h>
00036 #include "VolShader.h"
00037 
00038 class VolRenAlgBase : public glift::StateGLI
00039 {
00040 public:
00041    VolRenAlgBase()
00042       :_dataTex( glift::VecTexP_empty ),
00043       _normTex( glift::VecTexP_empty ),
00044       _etcTex(  glift::VecTexP_empty ),
00045       _currentAxis( gutz::vec3f_z ),
00046       _lightOn(false),
00047       _curVSamp(0),
00048       _blend(true),
00049       _curShader(new VolShader())
00050    {}
00051 
00052    ~VolRenAlgBase(){}
00053 
00054    //////////////////////////////////////////////////////////////////
00055    /// Set shader, a user policy
00056    virtual void       setShader(VolShader *vs);
00057    VolShader         *getShader();
00058 
00059    ///////////////////////////////////////////////////////////////////
00060    /// Blending, defaults to true
00061    virtual void         blend(bool onoff) {_blend = onoff; updateShader();}
00062 
00063    ///////////////////////////////////////////////////////////////////
00064    /// Set Slice Axis. set by the "VolRen" class
00065    ///   Provided in eye space, this is needed to tell if you are 
00066    ///   slicing front-to-back or back-to-front, so you can set
00067    ///   the blend equations appropriately, recall that if:
00068    ///   sliceAxis.dot(vec3f_neg_z) is greater than 0 then you are
00069    ///   slicing front to back.  The light view should always be
00070    ///   front-to-back
00071    virtual void        setSliceAxis(gutz::vec3f sliceAxis);
00072 
00073    ///////////////////////////////////////////////////////////////////
00074    /// Set/get Volytope, set by "VolRen" class
00075    /// Which volytope are you currently rendering, needed to get
00076    ///   access to textures,  this class binds the textures associated
00077    ///   with the current volytope being rendered.  
00078    virtual void        setVolytope(VolytopeSP vt);
00079    virtual VolytopeSP  getVolytope()                {return _curVoly;}
00080 
00081    ///////////////////////////////////////////////////////////////////
00082    /// Set geometry to be rendered. Set by "VolRen" class
00083    virtual void        setGeom(VolSamples *vs);
00084    virtual VolSamples *getGeom()                    {return _curVSamp;}
00085 
00086    ///////////////////////////////////////////////////////////////////
00087    /// Core Draw Function. Called by "VolRen" class
00088    ///   you get the range of elements from the vertex/tcoord data
00089    ///   the number of triangles and the index array
00090    virtual void drawTris(VolSamples *vs);
00091 
00092    ///////////////////////////////////////////////////////////////////
00093    /// Pbuffer management
00094 
00095    ///////////////////////////////////////////////////////////////////
00096    /// Light management
00097    virtual gutz::LightVec getLightVec()                    {return _ltv;}
00098    virtual void           setLightVec(gutz::LightVec &ltv) {_ltv = ltv;}
00099    virtual void           enableLight(bool on)             {_lightOn = on;}
00100    virtual void           enableLTHA(bool on)              {_ltha = on;}
00101 
00102    virtual void init(){};
00103 
00104 protected:
00105 
00106    virtual void bindDef();
00107    virtual void releaseDef();
00108 
00109    virtual void bindTex();
00110    virtual void releaseTex();
00111 
00112    /// call if something changes that the shader should know about
00113    virtual void updateShader();
00114 
00115    // for reference, a VecTexP is a std::vector<glift::SingleTex*>
00116    glift::VecTexP  _dataTex, _normTex, _etcTex;
00117 
00118    gutz::vec3f  _currentAxis;
00119 
00120    bool _lightOn, _ltha;
00121 
00122    gutz::LightVec   _ltv;
00123 
00124    VolytopeSP   _curVoly;
00125 
00126    VolSamplesSP _curVSamp;
00127 
00128    bool        _blend;
00129 
00130    VolShaderSP _curShader;
00131 
00132 private:
00133 };
00134 
00135 typedef gutz::SmartPtr<VolRenAlgBase> VolRenAlgBaseSP;
00136 
00137 ///////////////////////////////////////////////////////////////////
00138 /// Texture Vectors.
00139 ///   since these are set for you, 
00140 ///   there may be no need to over-ride this function
00141 //virtual void setTexData(const glift::VecTexP   &dataTex, 
00142 //                        const glift::VecTexP   &normTex, 
00143 //                                              const glift::VecTexP   &etcTex)
00144 //      {_dataTex = dataTex; _normTex = normTex; _etcTex = etcTex;}
00145 
00146 #endif
00147 

Send questions, comments, and bug reports to:
jmk