cloudLayer.h

Engine/source/environment/cloudLayer.h

More...

Classes:

Public Defines

define

Public Functions

GFXDeclareVertexFormat(GFXCloudVertex )

Detailed Description

Public Defines

TEX_COUNT() 3

Public Functions

GFXDeclareVertexFormat(GFXCloudVertex )

  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 _CLOUDLAYER_H_
 25#define _CLOUDLAYER_H_
 26
 27#ifndef _SCENEOBJECT_H_
 28#include "scene/sceneObject.h"
 29#endif
 30#ifndef _GFXTEXTUREHANDLE_H_
 31#include "gfx/gfxTextureHandle.h"
 32#endif
 33#ifndef _GFXVERTEXBUFFER_H_
 34#include "gfx/gfxVertexBuffer.h"
 35#endif
 36#ifndef _GFXPRIMITIVEBUFFER_H_
 37#include "gfx/gfxPrimitiveBuffer.h"
 38#endif
 39#ifndef _MATINSTANCE_H_
 40#include "materials/matInstance.h"
 41#endif
 42
 43GFXDeclareVertexFormat( GFXCloudVertex )
 44{
 45   Point3F point;
 46   Point3F normal;
 47   Point3F binormal;
 48   Point3F tangent; 
 49   Point2F texCoord;
 50};
 51
 52class CloudLayer : public SceneObject
 53{
 54   typedef SceneObject Parent;
 55
 56   enum 
 57   { 
 58      CloudLayerMask    = Parent::NextFreeMask,      
 59      NextFreeMask      = Parent::NextFreeMask << 1,
 60   };  
 61
 62   #define TEX_COUNT 3
 63
 64public:
 65
 66   CloudLayer();
 67   virtual ~CloudLayer() {}
 68
 69   DECLARE_CONOBJECT( CloudLayer );
 70
 71   // ConsoleObject
 72   virtual bool onAdd();
 73   virtual void onRemove();
 74   static void initPersistFields();
 75   virtual void inspectPostApply();   
 76
 77   // NetObject
 78   virtual U32 packUpdate( NetConnection *conn, U32 mask, BitStream *stream );
 79   virtual void unpackUpdate( NetConnection *conn, BitStream *stream );
 80
 81   // SceneObject
 82   void prepRenderImage( SceneRenderState *state );
 83   void renderObject( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *mi );
 84
 85protected:
 86
 87   void _initTexture();
 88   void _initBuffers();
 89
 90protected:
 91
 92   static U32 smVertStride;
 93   static U32 smStrideMinusOne;
 94   static U32 smVertCount;
 95   static U32 smTriangleCount;
 96
 97   GFXTexHandle mTexture;
 98
 99   GFXShaderRef mShader;
100
101   GFXStateBlockRef mStateblock;
102
103   GFXShaderConstBufferRef mShaderConsts;
104   GFXShaderConstHandle *mModelViewProjSC; 
105   GFXShaderConstHandle *mAmbientColorSC;
106   GFXShaderConstHandle *mSunColorSC;
107   GFXShaderConstHandle *mSunVecSC;
108   GFXShaderConstHandle *mTexOffsetSC[3];
109   GFXShaderConstHandle *mTexScaleSC;
110   GFXShaderConstHandle *mBaseColorSC;    
111   GFXShaderConstHandle *mCoverageSC;  
112   GFXShaderConstHandle *mExposureSC;  
113   GFXShaderConstHandle *mEyePosWorldSC;
114   GFXShaderConstHandle *mNormalHeightMapSC;
115
116   GFXVertexBufferHandle<GFXCloudVertex> mVB;
117   GFXPrimitiveBufferHandle mPB;
118
119   Point2F mTexOffset[3];
120   U32 mLastTime;
121
122   // Fields...
123
124   String mTextureName;
125   F32 mTexScale[TEX_COUNT];
126   Point2F mTexDirection[TEX_COUNT];
127   F32 mTexSpeed[TEX_COUNT];   
128   
129   LinearColorF mBaseColor;
130   F32 mExposure;
131   F32 mCoverage;
132   F32 mWindSpeed;   
133   F32 mHeight;
134};
135
136
137#endif // _CLOUDLAYER_H_
138