photonmap.h

Go to the documentation of this file.
00001 /*                     P H O T O N M A P . H
00002  * BRL-CAD
00003  *
00004  * Copyright (c) 2002-2006 United States Government as represented by
00005  * the U.S. Army Research Laboratory.
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public License
00009  * as published by the Free Software Foundation; either version 2.1 of
00010  * the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this file; see the file named COPYING for more
00019  * information.
00020  */
00021 /** @addtogroup librt */
00022 /*@{*/
00023 /** @file photonmap.h
00024  *                      P H O T O N M A P. H
00025  *@brief
00026  *  Declarations related to Photon Mapping
00027  *
00028  * @author Justin Shumaker
00029  *
00030  *  @par Source
00031  *      Bldg 238
00032  *@n    The U. S. Army Research Laboratory
00033  *@n    Aberdeen Proving Ground, Maryland  21005-5066
00034  *
00035  *  @(#)$Header:
00036  */
00037 
00038 #include "common.h"
00039 
00040 #ifdef HAVE_STRING_H     /* OPTIONAL, for strcmp() etc. */
00041 #  include <string.h>
00042 #else
00043 #  include <strings.h>
00044 #endif
00045 #include <stdio.h>
00046 #include <stdlib.h>
00047 #include <math.h>
00048 #include "machine.h"
00049 #include "bu.h"
00050 #include "vmath.h"
00051 #include "bn.h"
00052 #include "db.h"
00053 #include "nmg.h"
00054 #include "raytrace.h"
00055 #include "optical.h"
00056 #include "plastic.h"
00057 #include "light.h"
00058 
00059 
00060 #define PM_MAPS         4
00061 
00062 #define PM_GLOBAL       0
00063 #define PM_CAUSTIC      1
00064 #define PM_SHADOW       2       /* Current not used */
00065 #define PM_IMPORTANCE   3
00066 
00067 #define PM_SEM          RT_SEM_LAST-1
00068 #define PM_SEM_INIT     RT_SEM_LAST
00069 
00070 /**
00071  *  Photon Map Data Structure
00072  */
00073 struct Photon {
00074   int                   Axis;           /**< @brief Splitting Plane */
00075   point_t               Pos;            /**< @brief Photon Position */
00076   vect_t                Dir;            /**< @brief Photon Direction */
00077   vect_t                Normal;         /**< @brief Normal at Intersection */
00078   vect_t                Power;          /**< @brief Photon Power */
00079   vect_t                Irrad;          /**< @brief Irradiance */
00080 };
00081 
00082 
00083 struct PSN {
00084   struct        Photon  P;
00085   fastf_t               Dist;
00086 };
00087 
00088 
00089 /**
00090  *  Photon Search Structure
00091  */
00092 struct PhotonSearch {
00093   int                   Max;            /**< @brief Max Number of Photons */
00094   int                   Found;          /**< @brief Number of Photons Found */
00095   vect_t                Normal;         /**< @brief Normal */
00096   fastf_t               RadSq;          /**< @brief Search Radius Sq */
00097   point_t               Pos;            /**< @brief Search Position */
00098   struct        PSN     *List;          /**< @brief Located Photon List */
00099 };
00100 
00101 
00102 struct NearestPhotons {
00103   int                   Max;            /**< @brief Max Number of Photons */
00104   int                   Found;          /**< @brief Number of Photons Found */
00105   vect_t                Normal;         /**< @brief Normal */
00106   fastf_t               RadSq;          /**< @brief Search Radius Sq */
00107   point_t               Pos;            /**< @brief Search Position */
00108   struct        Photon  *List;          /**< @brief Located Photon List */
00109 };
00110 
00111 
00112 struct PNode {
00113   struct        Photon  P;
00114   struct        PNode   *L;
00115   struct        PNode   *R;
00116   int                   C;              /**< @brief For Threading Purposes to see if it's been computed yet */
00117 };
00118 
00119 
00120 struct PhotonMap {
00121   int                   StoredPhotons;
00122   int                   MaxPhotons;
00123   struct        PNode   *Root;
00124 };
00125 
00126 
00127 struct IrradNode {
00128   point_t               Pos;
00129   vect_t                RGB;
00130 };
00131 
00132 
00133 struct IrradCache {
00134   int                           Num;
00135   struct        IrradNode       *List;
00136 };
00137 
00138 
00139 OPTICAL_EXPORT extern int PM_Activated; /**< @brief Photon Mapping Activated, 0=off, 1=on */
00140 OPTICAL_EXPORT extern int PM_Visualize; /**< @brief Photon Mapping Visualization of Irradiance Cache */
00141 
00142 OPTICAL_EXPORT BU_EXTERN(void BuildPhotonMap,
00143                          (struct application *ap,
00144                           point_t eye_pos,
00145                           int cpus,
00146                           int width,
00147                           int height,
00148                           int Hypersample,
00149                           int GlobalPhotons,
00150                           double CausticsPercent,
00151                           int Rays,
00152                           double AngularTolerance,
00153                           int RandomSeed,
00154                           int ImportanceMapping,
00155                           int IrradianceHypersampling,
00156                           int VisualizeIrradiance,
00157                           double LightIntensity,
00158                           char pmfile[255]));
00159 OPTICAL_EXPORT BU_EXTERN(void IrradianceEstimate,
00160                          (struct application *ap,
00161                           vect_t irrad,
00162                           point_t pos,
00163                           vect_t normal,
00164                           fastf_t rad,
00165                           int np));
00166 /*@}*/
00167 /*
00168  * Local Variables:
00169  * mode: C
00170  * tab-width: 8
00171  * c-basic-offset: 4
00172  * indent-tabs-mode: t
00173  * End:
00174  * ex: shiftwidth=4 tabstop=8
00175  */
00176 

Generated on Mon Sep 18 01:24:41 2006 for BRL-CAD by  doxygen 1.4.6