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;
 38
 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 prepass render bin.
 54      /// @RenderPrePassMgr
 55      PrePassBin,
 56   };
 57
 58   /// This defines when we're rendering a special bin 
 59   /// type that the material or lighting system needs
 60   /// to know about.
 61   BinType binType;
 62
 63   // textures
 64   GFXTextureObject *lightmap;
 65   GFXTextureObject *backBuffTex;
 66   GFXTextureObject *reflectTex;
 67   GFXTextureObject *miscTex;
 68   GFXTextureObject *accuTex;
 69   
 70   /// The current lights to use in rendering
 71   /// in order of the light importance.
 72   LightInfo* lights[8];
 73
 74   ///
 75   ColorF ambientLightColor;
 76
 77   // fog      
 78   F32 fogDensity;
 79   F32 fogDensityOffset;
 80   F32 fogHeightFalloff;
 81   ColorF fogColor;
 82  
 83   // misc
 84   const MatrixF *objTrans;
 85   GFXCubemap *cubemap;
 86   F32 visibility;
 87
 88   /// Enables wireframe rendering for the object.
 89   bool wireframe;
 90
 91   /// A generic hint value passed from the game
 92   /// code down to the material for use by shader 
 93   /// features.
 94   void *materialHint;
 95
 96   /// Constructor.
 97   SceneData() 
 98   { 
 99      dMemset( this, 0, sizeof( SceneData ) );
100      objTrans = &MatrixF::Identity;
101      visibility = 1.0f;
102   }
103
104   /// Initializes the data with the scene state setting
105   /// common scene wide parameters.
106   inline void init( const SceneRenderState *state, BinType type = RegularBin )
107   {
108      dMemset( this, 0, sizeof( SceneData ) );
109      setFogParams( state->getSceneManager()->getFogData() );
110      wireframe = GFXDevice::getWireframe();
111      binType = type;
112      objTrans = &MatrixF::Identity;
113      visibility = 1.0f;
114      ambientLightColor = state->getAmbientLightColor();
115   }
116
117   inline void setFogParams( const FogData &data )
118   {
119      fogDensity = data.density;
120      fogDensityOffset = data.densityOffset;
121      if ( !mIsZero( data.atmosphereHeight ) )
122         fogHeightFalloff = 1.0f / data.atmosphereHeight;
123      else
124         fogHeightFalloff = 0.0f;
125
126      fogColor = data.color;
127   }
128};
129
130#endif // _SCENEDATA_H_
131