OGRE  1.9.0
OgreShaderExHardwareSkinning.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this software and associated documentation files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in
16all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24THE SOFTWARE.
25-----------------------------------------------------------------------------
26*/
27#ifndef _ShaderExHardwareSkinning_
28#define _ShaderExHardwareSkinning_
29
31
32#ifdef RTSHADER_SYSTEM_BUILD_EXT_SHADERS
34#include "OgreShaderParameter.h"
35#include "OgreRenderSystem.h"
41
42#define HS_MAX_WEIGHT_COUNT 4
43
44namespace Ogre {
45namespace RTShader {
46
47
48class HardwareSkinningFactory;
49
56
61class _OgreRTSSExport HardwareSkinning : public SubRenderState
62{
63public:
64 struct SkinningData
65 {
66 SkinningData() :
67 isValid(true), maxBoneCount(0), maxWeightCount(0), skinningType(ST_LINEAR), correctAntipodalityHandling(false), scalingShearingSupport(false)
68 {}
69
70 bool isValid;
71 ushort maxBoneCount;
72 ushort maxWeightCount;
73 SkinningType skinningType;
74 bool correctAntipodalityHandling;
75 bool scalingShearingSupport;
76 };
77
78// Interface.
79public:
81 HardwareSkinning();
82
86 virtual const String& getType() const;
87
91 virtual int getExecutionOrder() const;
92
96 virtual void copyFrom(const SubRenderState& rhs);
97
108 void setHardwareSkinningParam(ushort boneCount, ushort weightCount, SkinningType skinningType = ST_LINEAR, bool correctAntipodalityHandling = false, bool scalingShearingSupport = false);
109
114 ushort getBoneCount();
115
120 ushort getWeightCount();
121
126 SkinningType getSkinningType();
127
132 bool hasCorrectAntipodalityHandling();
133
138 bool hasScalingShearingSupport();
139
143 virtual bool preAddToRenderState(const RenderState* renderState, Pass* srcPass, Pass* dstPass);
144
148 void _setCreator(const HardwareSkinningFactory* pCreator) { mCreator = pCreator; }
149
150 static String Type;
151
152// Protected methods
153protected:
157 virtual bool resolveParameters(ProgramSet* programSet);
158
162 virtual bool resolveDependencies(ProgramSet* programSet);
163
167 virtual bool addFunctionInvocations(ProgramSet* programSet);
168
169 SharedPtr<LinearSkinning> mLinear;
170 SharedPtr<DualQuaternionSkinning> mDualQuat;
171 SharedPtr<HardwareSkinningTechnique> mActiveTechnique;
172
174 const HardwareSkinningFactory* mCreator;
175 SkinningType mSkinningType;
176};
177
178_OgreRTSSExport void operator<<(std::ostream& o, const HardwareSkinning::SkinningData& data);
179
184class _OgreRTSSExport HardwareSkinningFactory : public SubRenderStateFactory,
185 public Singleton<HardwareSkinningFactory>
186{
187public:
188 HardwareSkinningFactory();
189
193 virtual const String& getType() const;
194
198 virtual SubRenderState* createInstance(ScriptCompiler* compiler, PropertyAbstractNode* prop, Pass* pass, SGScriptTranslator* translator);
199
203 virtual void writeInstance(MaterialSerializer* ser, SubRenderState* subRenderState, Pass* srcPass, Pass* dstPass);
204
208 virtual void setCustomShadowCasterMaterials(const SkinningType skinningType, const MaterialPtr& caster1Weight, const MaterialPtr& caster2Weight,
209 const MaterialPtr& caster3Weight, const MaterialPtr& caster4Weight);
210
214 virtual void setCustomShadowReceiverMaterials(const SkinningType skinningType, const MaterialPtr& receiver1Weight, const MaterialPtr& receiver2Weight,
215 const MaterialPtr& receiver3Weight, const MaterialPtr& receiver4Weight);
216
220 const MaterialPtr& getCustomShadowCasterMaterial(const SkinningType skinningType, ushort index) const;
221
225 const MaterialPtr& getCustomShadowReceiverMaterial(const SkinningType skinningType, ushort index) const;
226
242 void prepareEntityForSkinning(const Entity* pEntity, SkinningType skinningType = ST_LINEAR, bool correctAntidpodalityHandling = false, bool shearScale = false);
243
254 ushort getMaxCalculableBoneCount() const {
255 return mMaxCalculableBoneCount; }
260 void setMaxCalculableBoneCount(ushort count) {
261 mMaxCalculableBoneCount = count; }
262
280 static HardwareSkinningFactory& getSingleton(void);
281
299 static HardwareSkinningFactory* getSingletonPtr(void);
300
301protected:
312 bool extractSkeletonData(const Entity* pEntity, unsigned int subEntityIndex,
313 ushort& boneCount, ushort& weightCount);
314
325 bool imprintSkeletonData(const MaterialPtr& pMaterial, bool isValid,
326 ushort boneCount, ushort weightCount, SkinningType skinningType, bool correctAntidpodalityHandling, bool scalingShearingSupport);
327
328protected:
329
333 virtual SubRenderState* createInstanceImpl();
334
336 MaterialPtr mCustomShadowCasterMaterialsLinear[HS_MAX_WEIGHT_COUNT];
337 MaterialPtr mCustomShadowCasterMaterialsDualQuaternion[HS_MAX_WEIGHT_COUNT];
338
340 MaterialPtr mCustomShadowReceiverMaterialsLinear[HS_MAX_WEIGHT_COUNT];
341 MaterialPtr mCustomShadowReceiverMaterialsDualQuaternion[HS_MAX_WEIGHT_COUNT];
342
345 ushort mMaxCalculableBoneCount;
346};
347
350
351
352}
353}
354
355#endif
356#endif
357
#define _OgreRTSSExport
Abstract factory interface for creating SubRenderState implementation instances.
This class is the base interface of sub part from a shader based rendering pipeline.
std::ostream & operator<<(std::ostream &o, const TRect< T > &r)
Definition OgreCommon.h:636
SharedPtr< Material > MaterialPtr
_StringBase String
unsigned short ushort