Torque3D Documentation / _generateds / lightingInterfaces.h

lightingInterfaces.h

Engine/source/lighting/lightingInterfaces.h

More...

Classes:

Public Typedefs

SceneLightingInterfaces 

Detailed Description

Public Typedefs

typedef Vector< SceneLightingInterface * > SceneLightingInterfaces 
  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23#ifndef _SG_SYSTEM_INTERFACE_H
 24#define _SG_SYSTEM_INTERFACE_H
 25
 26#ifndef _SGSCENEPERSIST_H_
 27#include "lighting/common/scenePersist.h"
 28#endif
 29
 30#ifndef _SCENELIGHTING_H_
 31#include "lighting/common/sceneLighting.h"
 32#endif
 33
 34class ObjectProxy;
 35class ObjectProxyList;
 36class SceneLightingInterface;
 37
 38template <class T> class Vector;
 39typedef Vector<SceneLightingInterface*> SceneLightingInterfaces; 
 40
 41// List of available "systems" that the lighting kit can use
 42class AvailableSLInterfaces
 43{
 44protected:
 45
 46   bool mDirty;
 47   
 48public:
 49   AvailableSLInterfaces()
 50      :  mAvailableObjectTypes( 0 ),
 51         mClippingMask( 0 ),
 52         mZoneLightSkipMask( 0 ),
 53         mDirty( true )
 54   {
 55      VECTOR_SET_ASSOCIATION( mAvailableSystemInterfaces );      
 56   }
 57      
 58   // Register a system 
 59   void registerSystem(SceneLightingInterface* si);
 60
 61   // Init the interfaces
 62   void initInterfaces();
 63   
 64   // The actual list of SceneLightingInterfaces
 65   SceneLightingInterfaces mAvailableSystemInterfaces;  
 66
 67   // Object types that are registered with the system
 68   U32 mAvailableObjectTypes;
 69
 70   // Clipping typemask
 71   U32 mClippingMask;
 72
 73   // Object types that we should skip zone lighting for
 74   U32 mZoneLightSkipMask;
 75};
 76
 77// This object is responsible for returning PersistChunk and ObjectProxy classes for the lighting system to use
 78// We may want to eventually split this into scene lighting vs. dynamic lighting.  getColorFromRayInfo is a dynamic
 79// lighting thing.
 80class SceneLightingInterface
 81{
 82public:
 83   SceneLightingInterface()
 84   {
 85   }
 86   virtual ~SceneLightingInterface() { }
 87
 88   virtual void init() { }
 89
 90   //
 91   // Scene lighting methods
 92   //
 93   // Creates an object proxy for obj
 94   virtual SceneLighting::ObjectProxy* createObjectProxy(SceneObject* obj, SceneLighting::ObjectProxyList* sceneObjects) = 0;
 95
 96   // Creates a PersistChunk based on the chunkType flag
 97   virtual PersistInfo::PersistChunk* createPersistChunk(const U32 chunkType) = 0;
 98
 99   // Creates a PersistChunk if needed for a proxy, returns true if it's "handled" by the system and ret contains the PersistChunk if needed.
100   virtual bool createPersistChunkFromProxy(SceneLighting::ObjectProxy* proxy, PersistInfo::PersistChunk** ret) = 0;
101
102   // Returns which object type flag this system supports (used to query scene graph for objects to light)
103   virtual U32 addObjectType() = 0;
104
105   // Add an object type flag to the "allow clipping mask" (used for blob shadows)
106   virtual U32 addToClippingMask() { return 0; }
107
108   // Add an object type flag to skip zone lighting
109   virtual U32 addToZoneLightSkipMask() { return 0; }
110
111   // Allows for processing/validating of the scene list after loading cached persistant info, return false if a relight is required or true if the data looks good.
112   virtual bool postProcessLoad(PersistInfo* pi, SceneLighting::ObjectProxyList* sceneObjects) { return true; }
113   
114   virtual void processLightingBegin() { }
115   virtual void processLightingCompleted(bool success) { }
116
117   //
118   // Runtime / dynamic methods
119   //
120   // Given a ray, this will return the color from the lightmap of this object, return true if handled
121   virtual bool getColorFromRayInfo(const RayInfo & collision, LinearColorF& result) const { return false; }
122};
123
124#endif
125