-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDLight.h
93 lines (75 loc) · 2.51 KB
/
DLight.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2009 Torus Knot Software Ltd
Also see acknowledgements in Readme.html
You may use this sample code for anything you like, it is not covered by the
same license as the rest of the engine.
-----------------------------------------------------------------------------
*/
#ifndef H_WJ_DLight
#define H_WJ_DLight
#include "OgreSimpleRenderable.h"
#include "MaterialGenerator.h"
/** Deferred light geometry. Each instance matches a normal light.
Should not be created by the user.
XXX support other types of light other than point lights.
*/
class DLight: public Ogre::SimpleRenderable
{
public:
DLight(MaterialGenerator *gen, Ogre::Light* parentLight);
~DLight();
/** Update the information from the light that matches this one
*/
void updateFromParent();
/** Update the information that is related to the camera
*/
void updateFromCamera(Ogre::Camera* camera);
/** Does this light cast shadows?
*/
virtual bool getCastChadows() const;
/** @copydoc MovableObject::getBoundingRadius */
virtual Ogre::Real getBoundingRadius(void) const;
/** @copydoc Renderable::getSquaredViewDepth */
virtual Ogre::Real getSquaredViewDepth(const Ogre::Camera*) const;
/** @copydoc Renderable::getMaterial */
virtual const Ogre::MaterialPtr& getMaterial(void) const;
/** @copydoc Renderable::getBoundingRadius */
virtual void getWorldTransforms(Ogre::Matrix4* xform) const;
protected:
/** Check if the camera is inside a light
*/
bool isCameraInsideLight(Ogre::Camera* camera);
/** Create geometry for this light.
*/
void rebuildGeometry(float radius);
/** Create a sphere geometry.
*/
void createSphere(float radius, int nRings, int nSegments);
/** Create a rectangle.
*/
void createRectangle2D();
/** Create a cone.
*/
void createCone(float radius, float height, int nVerticesInBase);
/** Set constant, linear, quadratic Attenuation terms
*/
void setAttenuation(float c, float b, float a);
/** Set the specular colour
*/
void setSpecularColour(const Ogre::ColourValue &col);
/// The light that this DLight renders
Ogre::Light* mParentLight;
/// Mode to ignore world orientation/position
bool bIgnoreWorld;
/// Bounding sphere radius
float mRadius;
/// Deferred shading system this minilight is part of
MaterialGenerator *mGenerator;
/// Material permutation
Ogre::uint32 mPermutation;
};
#endif