Using the PhotonMap Class

[ LiB ]

Using the PhotonMap Class

Take a look at the final PhotonMap class. This final class includes all the changes you've been developing throughout this chapter. The files photon.h and photon.cpp contain the photon structure, the photon list structure, and the photon map class. The PhotonMap class has all the methods covered in this chapter.

 #ifndef _C_PHOTON_H #define _C_PHOTON_H #include <math.h> // how much memory to allocate per call #define PHOTON_REALLOC_JUMP            1000 // 1.0000000000 is used for the local coordinate system #define TINY (1.0e-10) // the photon structure typedef struct {    color3 tPower;    cVector3 tDirection;    cVector3 tPosition; } photon_t; // the photon list structure used in finding the closest photons at x typedef struct {    photon_t tPhoton;    float dDistance; } photonlist_t; // the photon map class class PhotonMap { public:    long        lNumGlobalPhotons; // number of photons in photon map    photon_t * pGlobalPhoton; // the photon map as an array    long       lMaxPhotonPerObject; // max photons per object to shoot    long       lMaxPhotonNeighbors; // max closest neighbors at hit point     long      nAbsorbed;  // number of absorbed photons    long      nRefracted; // number of refracted/transmitted photons    long      nSpecularReflected; // number of mirror reflected photons    long      nDiffuseReflected;  // number of diffused reflected photons public:         //constructor used to allocate and set up NULL pointers     PhotonMap();     // set method for the max photons per object     // and max neighbors to return at x     void SetupPhotonMapping(long max_photons, int max_friends);     // add a photon to the photon map (array)     void AddToPhotonList(photon_t **, long *, photon_t);     // calculate the X and Y axes vectors of local coordinate system     void MakeXY( cVector3 *vX, cVector3 *vY, cVector3 V );     // gather nearest photons at X and save them to passed array as param1     long GetNearestPhotons(photonlist_t [], long, cVector3); }; 

[ LiB ]


Focus On Photon Mapping
Focus On Photon Mapping (Premier Press Game Development)
ISBN: 1592000088
EAN: 2147483647
Year: 2005
Pages: 128
Authors: Marlon John

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net