00001 /* 00002 File: Cluster.h 00003 00004 Function: Implements hierarchical radiosity clusters 00005 00006 Author: Andrew Willmott 00007 00008 Copyright: (c) 1997-2000, Andrew Willmott 00009 */ 00010 00011 #ifndef __Cluster__ 00012 #define __Cluster__ 00013 00014 #include "HRElem.h" 00015 00016 00017 class Cluster : public HRElem 00018 { 00019 public: 00020 Cluster(); 00021 virtual ~Cluster(); 00022 00023 Void SetElems(HRElemList *elemIn); 00024 Cluster *CreateHierarchy(); 00025 00026 Void PushElems(); 00027 Void CreateBounds(); 00028 00029 Void DrawNodeElem(Renderer &r); 00030 Void DrawLeafElem(Renderer &r); 00031 Void DrawPatches(Renderer &r); 00032 00033 Void Print(ostream &s); 00034 00035 // radiosity routines. 00036 Void Reset(); 00037 Bool IsLeaf(); 00038 Void ApplyToChildren(Void (HRElem::*method)(Void*), Void *ref = 0); 00039 00040 Void EltUpdateBounds(Point &, Point &) 00041 { return; }; 00042 GCLReal EltArea() 00043 { return(clusterArea); }; 00044 GCLReal EltProjArea(const Vector &n); 00045 GCLReal EltMaxProjArea(const Vector &n); 00046 Point EltCentre() 00047 { return(centre); }; 00048 Colour EltE() 00049 { return(E); }; 00050 Colour EltRho() 00051 { return(maxRho); }; 00052 Void EltSampleTransport(Int numSamples, Point p[], Vector n[], 00053 Matd &coeffs); 00054 GCLReal EltCalcTransport(HRElem *from, Matd &coeffs); 00055 00056 Void AddIrradiance(const Colour &E, const Vector &m); 00057 Colour GetPower(const Vector &m); 00058 Void EltGetSamples(Int numSamples, Point pts[]); 00059 00060 Void DistributeColours(); 00061 Void DistributeColoursBest(ShadeInfo &shadeInfo); 00062 00063 GCLReal Error(); 00064 Void Add(); 00065 Void Push(); 00066 Void Pull(); 00067 Void ClearB(); 00068 Void ClearR(); 00069 Void CalcLeafRadiosity(); 00070 Void InitRad(); 00071 00072 Void MakeChildLinks(HRElem *other, HRLink *link, 00073 Int which, Int levels); 00074 Void EltSetVisPoints(HRElem *to, Point p[]); 00075 00076 // Misc 00077 Int NumCoeffs() { return(1); } 00078 Colour *B_Coeffs() { return(&B); }; 00079 Colour *R_Coeffs() { return(&R); }; 00080 00081 // Fields 00082 Point min, max; // bounds 00083 Point centre; 00084 Int level; 00085 HRElemList elems; // non-cluster elements held by this cluster 00086 Cluster *child[8]; // child clusters 00087 00088 GCLReal clusterVol; // volume of the cluster 00089 GCLReal clusterArea; // surface area contained by cluster 00090 Colour maxRho; // max reflectivity in cluster 00091 Colour E; // emittance -- currently unused. 00092 Colour B; 00093 Colour R; 00094 static Colour lastB; 00095 }; 00096 00097 #endif