/src/ogre/OgreMain/src/OgreCompositionTargetPass.cpp
Line | Count | Source |
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-2014 Torus Knot Software Ltd |
8 | | |
9 | | Permission is hereby granted, free of charge, to any person obtaining a copy |
10 | | of this software and associated documentation files (the "Software"), to deal |
11 | | in the Software without restriction, including without limitation the rights |
12 | | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
13 | | copies of the Software, and to permit persons to whom the Software is |
14 | | furnished to do so, subject to the following conditions: |
15 | | |
16 | | The above copyright notice and this permission notice shall be included in |
17 | | all copies or substantial portions of the Software. |
18 | | |
19 | | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20 | | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
21 | | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
22 | | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
23 | | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
24 | | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
25 | | THE SOFTWARE. |
26 | | ----------------------------------------------------------------------------- |
27 | | */ |
28 | | #include "OgreStableHeaders.h" |
29 | | #include "OgreCompositionTargetPass.h" |
30 | | #include "OgreCompositionPass.h" |
31 | | |
32 | | namespace Ogre { |
33 | | |
34 | | CompositionTargetPass::CompositionTargetPass(CompositionTechnique *parent): |
35 | 0 | mParent(parent), |
36 | 0 | mInputMode(IM_NONE), |
37 | 0 | mOnlyInitial(false), |
38 | 0 | mVisibilityMask(0xFFFFFFFF), |
39 | 0 | mLodBias(1.0f), |
40 | 0 | mMaterialScheme(MaterialManager::DEFAULT_SCHEME_NAME), |
41 | 0 | mShadowsEnabled(true), |
42 | 0 | mOutputSlice(0) |
43 | 0 | { |
44 | 0 | if (Root::getSingleton().getRenderSystem()) |
45 | 0 | { |
46 | 0 | mMaterialScheme = Root::getSingleton().getRenderSystem()->_getDefaultViewportMaterialScheme(); |
47 | 0 | } |
48 | 0 | } |
49 | | //----------------------------------------------------------------------- |
50 | | CompositionTargetPass::~CompositionTargetPass() |
51 | 0 | { |
52 | 0 | removeAllPasses(); |
53 | 0 | } |
54 | | //----------------------------------------------------------------------- |
55 | | void CompositionTargetPass::setInputMode(InputMode mode) |
56 | 0 | { |
57 | 0 | mInputMode = mode; |
58 | 0 | } |
59 | | //----------------------------------------------------------------------- |
60 | | CompositionTargetPass::InputMode CompositionTargetPass::getInputMode() const |
61 | 0 | { |
62 | 0 | return mInputMode; |
63 | 0 | } |
64 | | //----------------------------------------------------------------------- |
65 | | void CompositionTargetPass::setOutputName(const String &out) |
66 | 0 | { |
67 | 0 | mOutputName = out; |
68 | 0 | } |
69 | | //----------------------------------------------------------------------- |
70 | | const String &CompositionTargetPass::getOutputName() const |
71 | 0 | { |
72 | 0 | return mOutputName; |
73 | 0 | } |
74 | | //----------------------------------------------------------------------- |
75 | | void CompositionTargetPass::setOnlyInitial(bool value) |
76 | 0 | { |
77 | 0 | mOnlyInitial = value; |
78 | 0 | } |
79 | | //----------------------------------------------------------------------- |
80 | | bool CompositionTargetPass::getOnlyInitial() |
81 | 0 | { |
82 | 0 | return mOnlyInitial; |
83 | 0 | } |
84 | | //----------------------------------------------------------------------- |
85 | | void CompositionTargetPass::setVisibilityMask(uint32 mask) |
86 | 0 | { |
87 | 0 | mVisibilityMask = mask; |
88 | 0 | } |
89 | | //----------------------------------------------------------------------- |
90 | | uint32 CompositionTargetPass::getVisibilityMask() |
91 | 0 | { |
92 | 0 | return mVisibilityMask; |
93 | 0 | } |
94 | | //----------------------------------------------------------------------- |
95 | | void CompositionTargetPass::setLodBias(float bias) |
96 | 0 | { |
97 | 0 | mLodBias = bias; |
98 | 0 | } |
99 | | //----------------------------------------------------------------------- |
100 | | float CompositionTargetPass::getLodBias() |
101 | 0 | { |
102 | 0 | return mLodBias; |
103 | 0 | } |
104 | | //----------------------------------------------------------------------- |
105 | | void CompositionTargetPass::setMaterialScheme(const String& schemeName) |
106 | 0 | { |
107 | 0 | mMaterialScheme = schemeName; |
108 | 0 | } |
109 | | //----------------------------------------------------------------------- |
110 | | const String& CompositionTargetPass::getMaterialScheme(void) const |
111 | 0 | { |
112 | 0 | return mMaterialScheme; |
113 | 0 | } |
114 | | //----------------------------------------------------------------------- |
115 | | void CompositionTargetPass::setShadowsEnabled(bool enabled) |
116 | 0 | { |
117 | 0 | mShadowsEnabled = enabled; |
118 | 0 | } |
119 | | //----------------------------------------------------------------------- |
120 | | bool CompositionTargetPass::getShadowsEnabled(void) const |
121 | 0 | { |
122 | 0 | return mShadowsEnabled; |
123 | 0 | } |
124 | | //----------------------------------------------------------------------- |
125 | | CompositionPass *CompositionTargetPass::createPass(CompositionPass::PassType type) |
126 | 0 | { |
127 | 0 | CompositionPass *t = OGRE_NEW CompositionPass(this); |
128 | 0 | t->setType(type); |
129 | 0 | mPasses.push_back(t); |
130 | 0 | return t; |
131 | 0 | } |
132 | | //----------------------------------------------------------------------- |
133 | | |
134 | | void CompositionTargetPass::removePass(size_t index) |
135 | 0 | { |
136 | 0 | assert (index < mPasses.size() && "Index out of bounds."); |
137 | 0 | Passes::iterator i = mPasses.begin() + index; |
138 | 0 | OGRE_DELETE (*i); |
139 | 0 | mPasses.erase(i); |
140 | 0 | } |
141 | | //----------------------------------------------------------------------- |
142 | | void CompositionTargetPass::removeAllPasses() |
143 | 0 | { |
144 | 0 | for (auto p : mPasses) |
145 | 0 | { |
146 | 0 | OGRE_DELETE (p); |
147 | 0 | } |
148 | 0 | mPasses.clear(); |
149 | 0 | } |
150 | | //----------------------------------------------------------------------- |
151 | | CompositionTargetPass::PassIterator CompositionTargetPass::getPassIterator(void) |
152 | 0 | { |
153 | 0 | return PassIterator(mPasses.begin(), mPasses.end()); |
154 | 0 | } |
155 | | |
156 | | //----------------------------------------------------------------------- |
157 | | CompositionTechnique *CompositionTargetPass::getParent() |
158 | 0 | { |
159 | 0 | return mParent; |
160 | 0 | } |
161 | | |
162 | | //----------------------------------------------------------------------- |
163 | | bool CompositionTargetPass::_isSupported(void) |
164 | 0 | { |
165 | | // A target pass is supported if all passes are supported |
166 | 0 | for (auto *p : mPasses) |
167 | 0 | { |
168 | 0 | if (!p->_isSupported()) |
169 | 0 | { |
170 | 0 | return false; |
171 | 0 | } |
172 | 0 | } |
173 | 0 | return true; |
174 | 0 | } |
175 | | |
176 | | } |