Project

General

Profile

SO3Engine
SO3DeferredLightImpl.cpp
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
28
29namespace SO3
30{
31
32SDeferredLightImpl::SDeferredLightImpl(Ogre::Light* originalLight, std::string lightTypeName, SDeferredLightMaterialGenerator* typeLightMaterialGenerator) : ogreParentLight(originalLight),
33 lightType(lightTypeName),
34 lightMaterialGenerator(typeLightMaterialGenerator)
35{
36 // Set up geometry
37 // Allocate render operation
38 mRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
39 mRenderOp.indexData = 0;
40 mRenderOp.vertexData = 0;
41 mRenderOp.useIndexes = true;
42
43 // TODO should be initialized to false
44 debugLight = false;
45}
46
48{
49 // need to release IndexData and vertexData created for renderable
50 delete mRenderOp.indexData;
51 delete mRenderOp.vertexData;
52 lightMaterialGenerator = 0;
53}
54
55SDeferredLightImpl::SDeferredLightImpl()
56{
57 // Forbiden (private).
58}
59
61{
62 #if SO3_ENABLE_DEFERRED_CUSTOM_SHADOWS == 0
63 //disable for point light
64 return (ogreParentLight->_getManager()->isShadowTechniqueInUse() && ogreParentLight->getCastShadows() && (ogreParentLight->getType() == Ogre::Light::LT_DIRECTIONAL || ogreParentLight->getType() == Ogre::Light::LT_SPOTLIGHT));
65 #else
66 return ogreParentLight->getCastShadows();
67 #endif
68}
69
71{
72 return debugLight;
73}
74
75void SDeferredLightImpl::SetDebugRendering(bool enableDebugRendering)
76{
77 debugLight = enableDebugRendering;
78}
79
80const Ogre::MaterialPtr& SDeferredLightImpl::getMaterial() const
81{
82 SDeferredLightPermutation lightPermutation;
83
84 // Debug permutation
85 if(debugLight)
87
88 // Shadow permutation
89 if(GetCastShadows())
91
92 return lightMaterialGenerator->GetMaterial(SDeferredShading::getSingleton().GetGBuffer(), lightPermutation);
93}
94
95}
virtual const Ogre::MaterialPtr & getMaterial() const
void SetDebugRendering(bool enableDebugRendering)
Ogre::Light * ogreParentLight
The light that this SDeferredLight renders.
static SDeferredShading & getSingleton()
const Ogre::MaterialPtr & GetMaterial(SGBuffer *gbuffer, PERMUTATION_CLASS permutation)