skyBox.h

Engine/source/environment/skyBox.h

More...

Classes:

Public Functions

GFXDeclareVertexFormat(GFXSkyVertex )

Detailed Description

Public Functions

GFXDeclareVertexFormat(GFXSkyVertex )

  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
 24#ifndef _SKYBOX_H_
 25#define _SKYBOX_H_
 26
 27#ifndef _SCENEOBJECT_H_
 28#include "scene/sceneObject.h"
 29#endif
 30
 31#ifndef _GFXDEVICE_H_
 32#include "gfx/gfxDevice.h"
 33#endif
 34
 35#ifndef _CUBEMAPDATA_H_
 36#include "gfx/sim/cubemapData.h"
 37#endif
 38
 39#ifndef _MATERIALLIST_H_
 40#include "materials/materialList.h"
 41#endif
 42
 43#ifndef _GFXVERTEXBUFFER_H_
 44#include "gfx/gfxVertexBuffer.h"
 45#endif
 46
 47#ifndef _GFXPRIMITIVEBUFFER_H_
 48#include "gfx/gfxPrimitiveBuffer.h"
 49#endif
 50
 51
 52GFXDeclareVertexFormat( GFXSkyVertex )
 53{
 54   Point3F point;
 55   Point3F normal;
 56   GFXVertexColor color;
 57};
 58
 59
 60struct SkyMatParams
 61{
 62   void init( BaseMatInstance *matInst ) {};
 63};
 64
 65class MatrixSet;
 66
 67class SkyBox : public SceneObject
 68{
 69   typedef SceneObject Parent;
 70
 71public:
 72
 73   SkyBox();
 74   virtual ~SkyBox();
 75
 76   DECLARE_CONOBJECT( SkyBox );
 77
 78   // SimObject
 79   void onStaticModified( const char *slotName, const char *newValue );
 80
 81   // ConsoleObject
 82   virtual bool onAdd();
 83   virtual void onRemove();
 84   static void initPersistFields();
 85   virtual void inspectPostApply();      
 86
 87   // NetObject
 88   virtual U32 packUpdate( NetConnection *conn, U32 mask, BitStream *stream );
 89   virtual void unpackUpdate( NetConnection *conn, BitStream *stream );
 90
 91   // SceneObject
 92   void prepRenderImage( SceneRenderState* state );
 93
 94   /// Our render delegate.
 95   void _renderObject( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *mi );
 96
 97   /// Prepares rendering structures and geometry.
 98   void _initRender();
 99
100protected:
101
102   // Material 
103   String mMatName;
104   BaseMatInstance *mMatInstance;
105   SkyMatParams mMatParamHandle;
106
107   SimObjectPtr<Material> mMaterial;
108   
109   GFXVertexBufferHandle<GFXVertexPNT> mVB;
110
111   GFXVertexBufferHandle<GFXVertexPC> mFogBandVB;
112   Material *mFogBandMat;
113   BaseMatInstance *mFogBandMatInst;
114
115   LinearColorF mLastFogColor;
116
117   bool mDrawBottom;
118   bool mIsVBDirty;
119   U32 mPrimCount;
120
121   MatrixSet *mMatrixSet;
122
123   F32 mFogBandHeight;   
124
125   void _updateMaterial();
126   void _initMaterial();
127
128   BaseMatInstance* _getMaterialInstance();
129};
130
131#endif // _SKYBOX_H_
132