1 | /* |
---|
2 | ----------------------------------------------------------------------------- |
---|
3 | This source file is part of OGRE |
---|
4 | (Object-oriented Graphics Rendering Engine) |
---|
5 | For the latest info, see http://www.ogre3d.org/ |
---|
6 | |
---|
7 | Copyright (c) 2000-2006 Torus Knot Software Ltd |
---|
8 | Also see acknowledgements in Readme.html |
---|
9 | |
---|
10 | This program is free software; you can redistribute it and/or modify it under |
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software |
---|
12 | Foundation; either version 2 of the License, or (at your option) any later |
---|
13 | version. |
---|
14 | |
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT |
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU Lesser General Public License along with |
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
---|
22 | http://www.gnu.org/copyleft/lesser.txt. |
---|
23 | |
---|
24 | You may alternatively use this source under the terms of a specific version of |
---|
25 | the OGRE Unrestricted License provided you have obtained such a license from |
---|
26 | Torus Knot Software Ltd. |
---|
27 | ----------------------------------------------------------------------------- |
---|
28 | */ |
---|
29 | #include "OgreStableHeaders.h" |
---|
30 | #include "OgreCompositionTargetPass.h" |
---|
31 | #include "OgreCompositionPass.h" |
---|
32 | #include "OgreMaterialManager.h" |
---|
33 | |
---|
34 | namespace Ogre { |
---|
35 | |
---|
36 | CompositionTargetPass::CompositionTargetPass(CompositionTechnique *parent): |
---|
37 | mParent(parent), |
---|
38 | mInputMode(IM_NONE), |
---|
39 | mOnlyInitial(false), |
---|
40 | mVisibilityMask(0xFFFFFFFF), |
---|
41 | mLodBias(1.0f), |
---|
42 | mMaterialScheme(MaterialManager::DEFAULT_SCHEME_NAME), |
---|
43 | mShadowsEnabled(true) |
---|
44 | { |
---|
45 | } |
---|
46 | //----------------------------------------------------------------------- |
---|
47 | CompositionTargetPass::~CompositionTargetPass() |
---|
48 | { |
---|
49 | removeAllPasses(); |
---|
50 | } |
---|
51 | //----------------------------------------------------------------------- |
---|
52 | void CompositionTargetPass::setInputMode(InputMode mode) |
---|
53 | { |
---|
54 | mInputMode = mode; |
---|
55 | } |
---|
56 | //----------------------------------------------------------------------- |
---|
57 | CompositionTargetPass::InputMode CompositionTargetPass::getInputMode() const |
---|
58 | { |
---|
59 | return mInputMode; |
---|
60 | } |
---|
61 | //----------------------------------------------------------------------- |
---|
62 | void CompositionTargetPass::setOutputName(const String &out) |
---|
63 | { |
---|
64 | mOutputName = out; |
---|
65 | } |
---|
66 | //----------------------------------------------------------------------- |
---|
67 | const String &CompositionTargetPass::getOutputName() const |
---|
68 | { |
---|
69 | return mOutputName; |
---|
70 | } |
---|
71 | //----------------------------------------------------------------------- |
---|
72 | void CompositionTargetPass::setOnlyInitial(bool value) |
---|
73 | { |
---|
74 | mOnlyInitial = value; |
---|
75 | } |
---|
76 | //----------------------------------------------------------------------- |
---|
77 | bool CompositionTargetPass::getOnlyInitial() |
---|
78 | { |
---|
79 | return mOnlyInitial; |
---|
80 | } |
---|
81 | //----------------------------------------------------------------------- |
---|
82 | void CompositionTargetPass::setVisibilityMask(uint32 mask) |
---|
83 | { |
---|
84 | mVisibilityMask = mask; |
---|
85 | } |
---|
86 | //----------------------------------------------------------------------- |
---|
87 | uint32 CompositionTargetPass::getVisibilityMask() |
---|
88 | { |
---|
89 | return mVisibilityMask; |
---|
90 | } |
---|
91 | //----------------------------------------------------------------------- |
---|
92 | void CompositionTargetPass::setLodBias(float bias) |
---|
93 | { |
---|
94 | mLodBias = bias; |
---|
95 | } |
---|
96 | //----------------------------------------------------------------------- |
---|
97 | float CompositionTargetPass::getLodBias() |
---|
98 | { |
---|
99 | return mLodBias; |
---|
100 | } |
---|
101 | //----------------------------------------------------------------------- |
---|
102 | void CompositionTargetPass::setMaterialScheme(const String& schemeName) |
---|
103 | { |
---|
104 | mMaterialScheme = schemeName; |
---|
105 | } |
---|
106 | //----------------------------------------------------------------------- |
---|
107 | const String& CompositionTargetPass::getMaterialScheme(void) const |
---|
108 | { |
---|
109 | return mMaterialScheme; |
---|
110 | } |
---|
111 | //----------------------------------------------------------------------- |
---|
112 | void CompositionTargetPass::setShadowsEnabled(bool enabled) |
---|
113 | { |
---|
114 | mShadowsEnabled = enabled; |
---|
115 | } |
---|
116 | //----------------------------------------------------------------------- |
---|
117 | bool CompositionTargetPass::getShadowsEnabled(void) const |
---|
118 | { |
---|
119 | return mShadowsEnabled; |
---|
120 | } |
---|
121 | //----------------------------------------------------------------------- |
---|
122 | CompositionPass *CompositionTargetPass::createPass() |
---|
123 | { |
---|
124 | CompositionPass *t = new CompositionPass(this); |
---|
125 | mPasses.push_back(t); |
---|
126 | return t; |
---|
127 | } |
---|
128 | //----------------------------------------------------------------------- |
---|
129 | |
---|
130 | void CompositionTargetPass::removePass(size_t index) |
---|
131 | { |
---|
132 | assert (index < mPasses.size() && "Index out of bounds."); |
---|
133 | Passes::iterator i = mPasses.begin() + index; |
---|
134 | delete(*i); |
---|
135 | mPasses.erase(i); |
---|
136 | } |
---|
137 | //----------------------------------------------------------------------- |
---|
138 | |
---|
139 | CompositionPass *CompositionTargetPass::getPass(size_t index) |
---|
140 | { |
---|
141 | assert (index < mPasses.size() && "Index out of bounds."); |
---|
142 | return mPasses[index]; |
---|
143 | } |
---|
144 | //----------------------------------------------------------------------- |
---|
145 | |
---|
146 | size_t CompositionTargetPass::getNumPasses() |
---|
147 | { |
---|
148 | return mPasses.size(); |
---|
149 | } |
---|
150 | //----------------------------------------------------------------------- |
---|
151 | void CompositionTargetPass::removeAllPasses() |
---|
152 | { |
---|
153 | Passes::iterator i, iend; |
---|
154 | iend = mPasses.end(); |
---|
155 | for (i = mPasses.begin(); i != iend; ++i) |
---|
156 | { |
---|
157 | delete(*i); |
---|
158 | } |
---|
159 | mPasses.clear(); |
---|
160 | } |
---|
161 | //----------------------------------------------------------------------- |
---|
162 | CompositionTargetPass::PassIterator CompositionTargetPass::getPassIterator(void) |
---|
163 | { |
---|
164 | return PassIterator(mPasses.begin(), mPasses.end()); |
---|
165 | } |
---|
166 | |
---|
167 | //----------------------------------------------------------------------- |
---|
168 | CompositionTechnique *CompositionTargetPass::getParent() |
---|
169 | { |
---|
170 | return mParent; |
---|
171 | } |
---|
172 | |
---|
173 | //----------------------------------------------------------------------- |
---|
174 | bool CompositionTargetPass::_isSupported(void) |
---|
175 | { |
---|
176 | // A target pass is supported if all passes are supported |
---|
177 | |
---|
178 | PassIterator passi = getPassIterator(); |
---|
179 | while (passi.hasMoreElements()) |
---|
180 | { |
---|
181 | CompositionPass* pass = passi.getNext(); |
---|
182 | if (!pass->_isSupported()) |
---|
183 | { |
---|
184 | return false; |
---|
185 | } |
---|
186 | } |
---|
187 | |
---|
188 | return true; |
---|
189 | } |
---|
190 | |
---|
191 | } |
---|