00001 /********************************************************************** 00002 *< 00003 FILE: RadiostiyMesh.h 00004 00005 DESCRIPTION: Exposes the radiosity meshes for use by other clients. 00006 00007 CREATED BY: Cleve Ard, Discreet Development 00008 00009 HISTORY: 8/6/02 00010 00011 *> Copyright (c) 2002, All Rights Reserved. 00012 **********************************************************************/ 00013 00014 #pragma once 00015 00016 #include "radiosity.h" 00017 #include "iFnPub.h" 00018 00019 #define RADIOSITY_MESH_INTERFACE_ID Interface_ID(0x3b004730, 0x7957272c) 00020 00021 class RenderGlobalContext; 00022 class Matrix3; 00023 00024 #pragma warning(push) 00025 #pragma warning(disable:4239) 00026 00027 class RadiosityMesh : public FPMixinInterface { 00028 public: 00029 00030 // Does the solution exist. The solution doesn't exist until we 00031 // have actually tried to solve it. CreateMeshes below will 00032 // create the meshes and the can be retrieved, but they won't 00033 // have any useful lighting data in them. 00034 virtual bool DoesSolutionExist() = 0; 00035 00036 // Determine whether the radiosity plugin has a mesh for the INode node. 00037 virtual bool DoesMeshExist(INode* node) = 0; 00038 00039 // Determine whether the radiosity plugin thinks its mesh for the 00040 // INode node is valid at time t. 00041 // 00042 // If rendering is true, a mesh will be considered invalid, if the 00043 // number of faces in it is too large compared to the number of faces 00044 // in the original object. Too large is defined by the ratio of the number 00045 // of faces in the radiosity mesh and the number of faces in the original 00046 // object. If this ratio is bigger than 1.5 then the radiosity mesh is 00047 // too large. This ratio is can be controlled by a setting in 00048 // plugcfg/DiscreetRadiosity.ini: 00049 // 00050 // [Radiosity] 00051 // ShareMeshes=1.5 00052 virtual bool IsMeshValid(TimeValue t, INode* node, bool rendering) = 0; 00053 00054 // Get the Validity for the mesh. If the radiosity plugin cannot 00055 // determine the validity at time t, it returns the NEVER. 00056 virtual ::Interval GetValidity(TimeValue t, INode* node) = 0; 00057 00058 // Create the meshes. This can be called to force the radiosity 00059 // plugin to update its meshes at time t. Once the meshes are 00060 // updated, they will not be deleted when radiosity is solved; 00061 // the light is added to the existing mesh. This method is used 00062 // by the renderer to create the meshes before the radiosity 00063 // solution is calculated. 00064 virtual bool CreateMeshes(TimeValue t, RenderGlobalContext* rgc) = 0; 00065 00066 // Get the mesh for a node. Returns true if the mesh exists. 00067 // Also restricts validity to the validity interval for the mesh. 00068 // If the mesh doesn't exist, the validity is not changed. 00069 // The address of the mesh is returned in mesh. You shouldn't 00070 // keep this address for an extended period. The mesh could 00071 // be deleted when the radiosity solution calculates a new 00072 // solution. There is no instancing for meshes in the radiosity 00073 // solution. Each instance in MAX is assigned a unique mesh 00074 // in the solution. 00075 virtual bool GetMesh(INode* node, Mesh*& mesh, 00076 ::Interval& validity = ::Interval(0,0)) = 0; 00077 00078 // Get the TM for the node. Returns true if the mesh exists. 00079 // Also restricts validity to the validity interval for the TM. 00080 // If the mesh doesn't exist, the validity is not changed. 00081 // TM is the mesh to world space transform. The radiosity 00082 // solution does not keep track of object to world transforms. 00083 // The transform returned is usually just a scale to translate 00084 // the radiosity plugins units, meters, to the MAX units. 00085 virtual bool GetMeshTM(INode* node, Matrix3& TM, 00086 ::Interval& validity = ::Interval(0,0)) = 0; 00087 00088 // Get the mesh and TM for a node. Returns NULL if the mesh doesn't 00089 // exist. TM is the mesh to world space transform (See GetMeshTM). 00090 // Also restricts meshValid to the validity interval for the mesh, 00091 // and tmValid to the validity interval for the TM. If the mesh 00092 // doesn't exist, neither validity interval is changed. 00093 virtual Mesh* GetMeshAndTM(INode* node, Matrix3& TM, 00094 ::Interval& meshValid = ::Interval(0,0), 00095 ::Interval& tmValid = ::Interval(0,0)) = 0; 00096 }; 00097 00098 #pragma warning(pop) 00099 00100 inline RadiosityMesh* GetRadiosityMesh(RadiosityEffect* rad) 00101 { 00102 return static_cast<RadiosityMesh*>(rad->GetInterface( 00103 RADIOSITY_MESH_INTERFACE_ID)); 00104 } 00105