[692] | 1 | /**
|
---|
| 2 | *******************************************************************************
|
---|
| 3 | Copyright (c) W.J. van der Laan
|
---|
| 4 |
|
---|
| 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
|
---|
| 6 | this software and associated documentation files (the "Software"), to deal in
|
---|
| 7 | the Software without restriction, including without limitation the rights to use,
|
---|
| 8 | copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
---|
| 9 | Software, and to permit persons to whom the Software is furnished to do so, subject
|
---|
| 10 | to the following conditions:
|
---|
| 11 |
|
---|
| 12 | The above copyright notice and this permission notice shall be included in all copies
|
---|
| 13 | or substantial portions of the Software.
|
---|
| 14 |
|
---|
| 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
---|
| 16 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
---|
| 17 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
---|
| 18 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
---|
| 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE
|
---|
| 20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
| 21 | *******************************************************************************
|
---|
| 22 | */
|
---|
| 23 | #ifndef H_WJ_MLight
|
---|
| 24 | #define H_WJ_MLight
|
---|
| 25 |
|
---|
| 26 | #include "OgreCompositorInstance.h"
|
---|
| 27 | #include "OgreSceneManager.h"
|
---|
| 28 | #include "OgreSceneNode.h"
|
---|
| 29 | #include "DeferredShading.h"
|
---|
| 30 |
|
---|
| 31 | /** Renderable minilight. Do not create this directly, but use
|
---|
| 32 | DeferredShadingSystem::createMLight.
|
---|
| 33 | XXX support other types of light other than point lights.
|
---|
| 34 | */
|
---|
| 35 | class MLight: public Ogre::SimpleRenderable
|
---|
| 36 | {
|
---|
| 37 | public:
|
---|
| 38 | MLight(MaterialGenerator *gen);
|
---|
| 39 | ~MLight();
|
---|
| 40 |
|
---|
| 41 | /** Permutatation of light materials
|
---|
| 42 | */
|
---|
| 43 | enum MaterialID
|
---|
| 44 | {
|
---|
| 45 | MI_QUAD = 0x1, // Rendered as fullscreen quad
|
---|
| 46 | MI_ATTENUATED = 0x2, // Rendered attenuated
|
---|
| 47 | MI_SPECULAR = 0x4 // Specular component is calculated
|
---|
| 48 | };
|
---|
| 49 |
|
---|
| 50 | /** Set constant, linear, quadratic Attenuation terms
|
---|
| 51 | */
|
---|
| 52 | void setAttenuation(float c, float b, float a);
|
---|
| 53 |
|
---|
| 54 | /** Set the diffuse colour
|
---|
| 55 | */
|
---|
| 56 | void setDiffuseColour(const Ogre::ColourValue &col);
|
---|
| 57 | void setDiffuseColour(float r=1.0f, float g=1.0f, float b=1.0f, float a=1.0f)
|
---|
| 58 | {
|
---|
| 59 | setDiffuseColour(Ogre::ColourValue(r,g,b,a));
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | /** Set the specular colour
|
---|
| 63 | */
|
---|
| 64 | void setSpecularColour(const Ogre::ColourValue &col);
|
---|
| 65 | void setSpecularColour(float r=1.0f, float g=1.0f, float b=1.0f, float a=1.0f)
|
---|
| 66 | {
|
---|
| 67 | setSpecularColour(Ogre::ColourValue(r,g,b,a));
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | /** Get diffuse colour.
|
---|
| 71 | */
|
---|
| 72 | Ogre::ColourValue getDiffuseColour();
|
---|
| 73 |
|
---|
| 74 | /** Get specular colour.
|
---|
| 75 | */
|
---|
| 76 | Ogre::ColourValue getSpecularColour();
|
---|
| 77 |
|
---|
| 78 | /** Create geometry for this light.
|
---|
| 79 | */
|
---|
| 80 | void rebuildGeometry(float radius);
|
---|
| 81 |
|
---|
| 82 | /** Create a sphere geometry.
|
---|
| 83 | */
|
---|
| 84 | void createSphere(const float r, const int nRings = 16, const int nSegments = 16);
|
---|
| 85 |
|
---|
| 86 | /** Create a rectangle.
|
---|
| 87 | */
|
---|
| 88 | void createRectangle2D();
|
---|
| 89 |
|
---|
| 90 | /** @copydoc MovableObject::getBoundingRadius */
|
---|
| 91 | virtual Ogre::Real getBoundingRadius(void) const;
|
---|
| 92 | /** @copydoc Renderable::getSquaredViewDepth */
|
---|
| 93 | virtual Ogre::Real getSquaredViewDepth(const Ogre::Camera*) const;
|
---|
| 94 | /** @copydoc Renderable::getMaterial */
|
---|
| 95 | virtual const Ogre::MaterialPtr& getMaterial(void) const;
|
---|
| 96 | protected:
|
---|
| 97 | /// Mode to ignore world orientation/position
|
---|
| 98 | bool bIgnoreWorld;
|
---|
| 99 | /// Bounding sphere radius
|
---|
| 100 | float mRadius;
|
---|
| 101 | /// Deferred shading system this minilight is part of
|
---|
| 102 | MaterialGenerator *mGenerator;
|
---|
| 103 | /// Material permutation
|
---|
| 104 | size_t mPermutation;
|
---|
| 105 | };
|
---|
| 106 |
|
---|
| 107 | #endif
|
---|