lightQuery.h

Engine/source/lighting/lightQuery.h

More...

Classes:

class

Used to gather an score lights for rendering.

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 _LIGHTQUERY_H_
25#define _LIGHTQUERY_H_
26
27#ifndef _TVECTOR_H_
28#include "core/util/tVector.h"
29#endif
30
31#ifndef _MSPHERE_H_
32#include "math/mSphere.h"
33#endif
34
35#ifndef _MBOX_H_
36#include "math/mBox.h"
37#endif
38
39
40class LightManager;
41class LightInfo;
42
43
44/// Used to gather an score lights for rendering.
45class LightQuery
46{
47public:
48
49   LightQuery( U32 maxLights = 4 );
50   ~LightQuery();
51
52   /// Set the query volume from a camera position and direction.
53   void init(  const Point3F &cameraPos,
54               const Point3F &cameraDir, 
55               F32 viewDist );
56
57   /// Set the query volume from a sphere.
58   void init( const SphereF &bounds );
59
60   /// Set the query volume from a box.
61   void init( const Box3F &bounds );
62
63   /// This returns the best lights based on the query volume.
64   void getLights( LightInfo** outLights, U32 maxLights );
65
66protected:
67
68   void _scoreLights();
69
70   static S32 _lightScoreCmp( LightInfo* const *a, LightInfo* const *b );
71
72   /// The maximum lights to return from the query.
73   const U32 mMaxLights;
74
75   /// The sorted list of best lights.
76   Vector<LightInfo*> mLights;
77
78   /// The sphere used to query for lights.
79   SphereF mVolume;
80};
81
82
83#endif // _LIGHTQUERY_H_
84