naturalLight.h

Go to the documentation of this file.
00001 /**********************************************************************
00002  
00003     FILE: naturalLight.h
00004 
00005     DESCRIPTION:  Natural Light definitions
00006 
00007     CREATED BY: Cleve Ard, Discreet
00008 
00009     HISTORY: - created July 24, 2001
00010 
00011  *> Copyright (c) 2001, All Rights Reserved.
00012  **********************************************************************/
00013 #pragma once
00014 
00015 #include "ifnpub.h"
00016 #include "GetCOREInterface.h"
00017 #include "Animatable.h"
00018 #include "plugapi.h"
00019 
00020 // Natural light is supplied by the interaction of several objects:
00021 
00022 // SUN LIGHTS:
00023 
00024 // Direct light
00025 // IES sunlight
00026 // CIE sunlight
00027 
00028 // SKY LIGHTS:
00029 
00030 // Standard Skylight
00031 // IES skylight
00032 // CIE skylight
00033 // Isotropic skylight (why)
00034 // Environmemnt map skylight
00035 // HDR environment map skylight
00036 
00037 // SUN POSITION CONTROLLERS
00038 
00039 // MAX Sun position
00040 // IES Sun position
00041 // CIE Sun position
00042 
00043 // NATURAL LIGHT SYSTEM
00044 
00045 // The natural light system combines these three objects to form natural
00046 // light. It uses a 
00047 
00048 /*===========================================================================*\
00049  | Natural Light Class Interface:
00050 \*===========================================================================*/
00051 
00052 // This interface is used to tell the natural light assembly that the
00053 // objects created by the class are natural light objects. This interface
00054 // is used to decide when the classes are to be displayed in the
00055 // drop down lists for the natural light assembly.
00056 
00057 #define NATURAL_LIGHT_CLASS_INTERFACE_ID Interface_ID(0x75985ea5, 0x115c2791)
00058 
00059 // A sun light is just a direct light. The intensities and
00085 class INaturalLightClass : public FPStaticInterface {
00086 public:
00087     // Function publishing enum
00088     enum {
00089         natLightIsSun = 0,
00090         natLightIsSky = 1
00091     };
00092 
00093     DECLARE_DESCRIPTOR(INaturalLightClass)
00094     #pragma warning(push)
00095     #pragma warning(disable:4100)
00096     BEGIN_FUNCTION_MAP
00097         FN_0(natLightIsSun, TYPE_BOOL, IsSun)
00098         FN_0(natLightIsSky, TYPE_BOOL, IsSky)
00099     END_FUNCTION_MAP
00100     #pragma warning(pop)
00101 
00102     // Is this class a sun?
00105     virtual BOOL IsSun() const = 0;
00106 
00107     // Is this class a sky?
00109     virtual BOOL IsSky() const = 0;
00110 };
00111 
00112 inline INaturalLightClass* GetNaturalLightClass(SClass_ID s, const Class_ID& id)
00113 {
00114     return static_cast<INaturalLightClass*>( GetInterface(s, id, NATURAL_LIGHT_CLASS_INTERFACE_ID) );
00115 }
00116 
00117 inline INaturalLightClass* GetNaturalLightClass(Animatable* a)
00118 {
00119     return a == NULL ? NULL
00120         : GetNaturalLightClass(a->SuperClassID(), a->ClassID());
00121 }
00122 
00123 // This class is used to set up the function publishing
00124 class NaturalLightClassBaseImp : public INaturalLightClass {
00125 public:
00126     NaturalLightClassBaseImp(ClassDesc* cd, int classStrID, int isSunStrID, int isSkyStrID)
00127         : INaturalLightClass(
00128             NATURAL_LIGHT_CLASS_INTERFACE_ID, _M("NaturalLightClass"),
00129                 classStrID, cd, FP_STATIC_METHODS,
00130             natLightIsSun, _M("isSun"), isSunStrID, TYPE_BOOL, 0, 0,
00131             natLightIsSky, _M("isSky"), isSkyStrID, TYPE_BOOL, 0, 0,
00132             end) {}
00133 };
00134 
00135 inline INaturalLightClass* GetNaturalLightClassInterface(ClassDesc* c)
00136 {
00137     return static_cast<INaturalLightClass*>(c->GetInterface(NATURAL_LIGHT_CLASS_INTERFACE_ID));
00138 }
00139 
00140 #define SUNLIGHT_INTERFACE_ID Interface_ID(0x43b76ff2, 0x60ae0d61)
00141 
00142 // A sun light is just a direct light with a constant intensity.
00154 class ISunLight : public BaseInterface {
00155 public:
00156     // Return whether the intensity is in MAX Units. If it isn't
00157     // in MAX units it must be in international units.
00160     virtual bool IsIntensityInMAXUnits() const = 0;
00161 };
00162 
00163 inline ISunLight* GetSunLightInterface(Animatable* o)
00164 {
00165     return static_cast<ISunLight*>(o->GetInterface(SUNLIGHT_INTERFACE_ID));
00166 }
00167 
00168 // This class is used to evaluate the sky for Flow radiosity.
00176 class SkyLightEval : public BaseInterface {
00177 public:
00178     // Delete yourself
00180     virtual void DeleteThis() = 0;
00181 
00182     // Returns the spectral radiance along a ray of given origin
00183     // and direction in world space. Return true if the intensity is in
00184     // MAX units, or false if intensity is in international units
00189     virtual bool Gather(
00190         const Point3&       origin,
00191         const Point3&       direction,
00192         Point3&             radiance
00193     ) = 0;
00194 
00195     // Return the class of the sky that created you.
00199     virtual Class_ID ClassID() const = 0;
00200 
00201     // Compare two skys. Return true if the Gather method
00202     // will return the same result.
00209     virtual bool IsSameSky( const SkyLightEval* sky ) const = 0;
00210 };
00211 
00212 #define SKYLIGHT_INTERFACE_ID Interface_ID(0x47056297, 0x7f8b06e3)
00213 
00214 // This interface is used to create the
00241 class ISkyLight : public BaseInterface {
00242 public:
00243     // Create a SkyLightEval that can be used to evaluate
00244     // this skylight for the radiosity solution. Tm transforms
00245     // (0,0,1) to the zenith direction for the scene.
00259     virtual SkyLightEval* CreateSkyEval(
00260         TimeValue       t,
00261         INode*          node,
00262         const Matrix3&  tm
00263     ) = 0;
00264 
00265     // Return whether the intensity is in MAX Units. If it isn't
00266     // in MAX units it must be in international units.
00268     virtual bool IsIntensityInMAXUnits() const = 0;
00269 };
00270 
00271 inline ISkyLight* GetSkyLightInterface(Animatable* o)
00272 {
00273     return static_cast<ISkyLight*>(o->GetInterface(SKYLIGHT_INTERFACE_ID));
00274 }
00275 
00276 
00277 #define SUNLIGHT_POSITION_INTERFACE_ID Interface_ID(0x6fa56707, 0x4ebe3d73)
00278 
00279 class ISunLightPosition : public BaseInterface {
00280 public:
00281 };
00282 
00283 inline ISunLightPosition* GetSunLightPositionInterface(Animatable* o)
00284 {
00285     return static_cast<ISunLightPosition*>(o->GetInterface(SUNLIGHT_POSITION_INTERFACE_ID));
00286 }
00287