sceneData.h

Engine/source/materials/sceneData.h

More...

Classes:

Detailed Description

  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 _SCENEDATA_H_
 24#define _SCENEDATA_H_
 25
 26#ifndef _SCENERENDERSTATE_H_
 27#include "scene/sceneRenderState.h"
 28#endif
 29#ifndef _LIGHTMANAGER_H_
 30#include "lighting/lightManager.h"
 31#endif
 32#ifndef _GFXDEVICE_H_
 33#include "gfx/gfxDevice.h"
 34#endif
 35
 36class GFXTexHandle;
 37class GFXCubemap;
 38class CustomShaderBindingData;
 39
 40struct SceneData
 41{
 42   /// The special bin types.
 43   enum BinType
 44   {
 45      /// A normal render bin that isn't one of 
 46      /// the special bins we care about.
 47      RegularBin = 0,
 48
 49      /// The glow render bin.
 50      /// @see RenderGlowMgr
 51      GlowBin,
 52
 53      /// The deferred render bin.
 54      /// @RenderDeferredMgr
 55      DeferredBin,
 56      /// The selection-highlight render bin.  
 57      /// @afxRenderHighlightMgr  
 58      HighlightBin,
 59   };
 60
 61   /// This defines when we're rendering a special bin 
 62   /// type that the material or lighting system needs
 63   /// to know about.
 64   BinType binType;
 65
 66   // textures
 67   GFXTextureObject *lightmap;
 68   GFXTextureObject *backBuffTex;
 69   GFXTextureObject *reflectTex;
 70   GFXTextureObject *miscTex;
 71   GFXTextureObject *accuTex;
 72   
 73   /// The current lights to use in rendering
 74   /// in order of the light importance.
 75   LightInfo* lights[8];
 76
 77   ///
 78   LinearColorF ambientLightColor;
 79
 80   // fog      
 81   F32 fogDensity;
 82   F32 fogDensityOffset;
 83   F32 fogHeightFalloff;
 84   LinearColorF fogColor;
 85  
 86   // misc
 87   const MatrixF *objTrans;
 88   GFXCubemap *cubemap;
 89   F32 visibility;
 90
 91   /// Enables wireframe rendering for the object.
 92   bool wireframe;
 93
 94   /// A generic hint value passed from the game
 95   /// code down to the material for use by shader 
 96   /// features.
 97   void *materialHint;
 98
 99   Vector<CustomShaderBindingData*> customShaderData;
100
101   /// Constructor.
102   SceneData() 
103   { 
104      dMemset( this, 0, sizeof( SceneData ) );
105      objTrans = &MatrixF::Identity;
106      visibility = 1.0f;
107   }
108
109   /// Initializes the data with the scene state setting
110   /// common scene wide parameters.
111   inline void init( const SceneRenderState *state, BinType type = RegularBin )
112   {
113      dMemset( this, 0, sizeof( SceneData ) );
114      setFogParams( state->getSceneManager()->getFogData() );
115      wireframe = GFXDevice::getWireframe();
116      binType = type;
117      objTrans = &MatrixF::Identity;
118      visibility = 1.0f;
119      ambientLightColor = state->getAmbientLightColor();
120   }
121
122   inline void setFogParams( const FogData &data )
123   {
124      fogDensity = data.density;
125      fogDensityOffset = data.densityOffset;
126      if ( !mIsZero( data.atmosphereHeight ) )
127         fogHeightFalloff = 1.0f / data.atmosphereHeight;
128      else
129         fogHeightFalloff = 0.0f;
130
131      fogColor = data.color;
132   }
133};
134
135#endif // _SCENEDATA_H_
136