blobShadow.h

Engine/source/lighting/common/blobShadow.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
24#ifndef _BLOBSHADOW_H_
25#define _BLOBSHADOW_H_
26
27#include "collision/depthSortList.h"
28#include "scene/sceneObject.h"
29#include "ts/tsShapeInstance.h"
30#include "lighting/common/shadowBase.h"
31
32class ShapeBase;
33class LightInfo;
34
35class BlobShadow : public ShadowBase
36{
37   F32 mRadius;
38   F32 mInvShadowDistance;
39   MatrixF mLightToWorld;
40   MatrixF mWorldToLight;
41
42   Vector<DepthSortList::Poly> mPartition;
43   Vector<Point3F> mPartitionVerts;
44   GFXVertexBufferHandle<GFXVertexPCT> mShadowBuffer;
45
46   static U32 smShadowMask;
47
48   static DepthSortList smDepthSortList;
49   static GFXTexHandle smGenericShadowTexture;
50   static F32 smGenericRadiusSkew;
51   static S32 smGenericShadowDim;
52
53   U32 mLastRenderTime;
54
55   static void collisionCallback(SceneObject*,void *);
56
57private:
58   SceneObject* mParentObject;
59   ShapeBase* mShapeBase;
60   LightInfo* mParentLight;
61   TSShapeInstance* mShapeInstance;
62   GFXStateBlockRef mShadowSB;
63   F32 mDepthBias;
64
65   void setupStateBlocks();
66   void setLightMatrices(const Point3F & lightDir, const Point3F & pos);
67   void buildPartition(const Point3F & p, const Point3F & lightDir, F32 radius, F32 shadowLen);
68public:
69
70   BlobShadow(SceneObject* parentobject, LightInfo* light, TSShapeInstance* shapeinstance);
71   ~BlobShadow();
72
73   void setRadius(F32 radius);
74   void setRadius(TSShapeInstance *, const Point3F & scale);
75
76   bool prepare(const Point3F & pos, Point3F lightDir, F32 shadowLen);
77
78   bool shouldRender(F32 camDist);
79
80   void update( const SceneRenderState *state ) {}
81   void render( F32 camDist, const TSRenderState &rdata );
82   U32 getLastRenderTime() const { return mLastRenderTime; }
83
84   static void generateGenericShadowBitmap(S32 dim);
85   static void deleteGenericShadowBitmap();
86};
87
88#endif
89