Open PaperOpt
OpenPaperOpt/FiberMaterial.h
Go to the documentation of this file.
00001 #ifndef FIBERMATERIAL_H
00002 #define FIBERMATERIAL_H
00003 
00004 
00005 #include "utilities.h"
00006 #include "RndRay.h"
00007 #include "RndVolume.h"
00008 #include "WavePacket.h"
00009 #include "DistributionHenyeyGreenstein.h"
00010 
00011 namespace p3d{
00012 
00018 #define FIB_MATERIAL_STATE_INITED   1
00019 #define FIB_MATERIAL_STATE_RSCAT    2
00020 #define FIB_MATERIAL_STATE_DSCAT    4
00021 
00022         class FiberMaterial {
00023 
00024         public:
00025 
00026                 FiberMaterial();
00038                 void SetParameters(double sigmaScat=0.0f,double sigmaAbs=0.0003f,double n=1.55f,double microR=0.2f,
00039                         double assymetry=0,int zuse_diffuse_scat=0,int use_random_polar_scat=1);
00040 
00041                 int  IsInited() {return mState&1;}
00042 
00051                 int TracePacket(WavePacket* wp,RndVolume* rVol,int threadNo);
00052 
00053         private:
00054 
00059                 double GetRandomPathLength() {return -log(GenerateRandom())/mSigma_tot;}
00060                 int    IsHitScattered()      {return GenerateRandom()>mPAbs;}
00061                 V3 <double>     ScatterDirection(const V3<double>& dir,const V3 <double> & pol,V3 <double> & new_pol);
00068                 double GetLambertTheta() {return acos(1.0-2.0*GenerateRandom())/2.0;}
00069 
00087                 int SurfaceScatter(int toFiber,V3 <double>* newDir,V3 <double>* newPol,const V3 <double>& dir,
00088                         const V3 <double>& pol,const V3 <double> & nrm,const V3 <double> & fnrm,double lambda,int threadNo,
00089                         int secCall=0);
00090 
00091 
00092         private:
00093 
00094                 int   mState;       //Bit 0: Inited. 
00095                                                         //Bit 1: 0-Acreo material, 1-Random polar after scatter from internal
00096 
00097                 //Material description
00098                 double mSigma_scat;  //Scattering coefficient, 1/um
00099                 double mSigma_abs;   //Absorbtion coefficient, 1/um
00100                 double mSigma_tot;
00101                 double mPAbs;        //[0..pabs]->abs, [pabs..1]->scatter
00102                 double mFiberN,mFiberNInv;
00103                 double mMicroR;      //Micro roughness, um
00104         };
00105 }
00106 #endif