OgreShaderExHardwareSkinning.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef _ShaderExHardwareSkinning_
#define _ShaderExHardwareSkinning_
#include "OgreShaderPrerequisites.h"
#ifdef RTSHADER_SYSTEM_BUILD_EXT_SHADERS
#include "OgreShaderSubRenderState.h"
#include "OgreShaderParameter.h"
#include "OgreRenderSystem.h"
#include "OgreShaderFunctionAtom.h"
#include "OgreShaderExLinearSkinning.h"
#include "OgreShaderExHardwareSkinningTechnique.h"
#include "OgreShaderExDualQuaternionSkinning.h"
#include "OgreShaderExLinearSkinning.h"
#define HS_MAX_WEIGHT_COUNT 4
namespace Ogre {
namespace RTShader {
class HardwareSkinningFactory;
class _OgreRTSSExport HardwareSkinning : public SubRenderState
{
public:
struct SkinningData
{
SkinningData() :
isValid(true), maxBoneCount(0), maxWeightCount(0), skinningType(ST_LINEAR), correctAntipodalityHandling(false), scalingShearingSupport(false)
{}
bool isValid;
ushort maxBoneCount;
ushort maxWeightCount;
SkinningType skinningType;
bool correctAntipodalityHandling;
bool scalingShearingSupport;
};
// Interface.
public:
HardwareSkinning();
virtual const String& getType() const;
virtual int getExecutionOrder() const;
virtual void copyFrom(const SubRenderState& rhs);
void setHardwareSkinningParam(ushort boneCount, ushort weightCount, SkinningType skinningType = ST_LINEAR, bool correctAntipodalityHandling = false, bool scalingShearingSupport = false);
ushort getBoneCount();
ushort getWeightCount();
SkinningType getSkinningType();
bool hasCorrectAntipodalityHandling();
bool hasScalingShearingSupport();
virtual bool preAddToRenderState(const RenderState* renderState, Pass* srcPass, Pass* dstPass);
void _setCreator(const HardwareSkinningFactory* pCreator) { mCreator = pCreator; }
static String Type;
// Protected methods
protected:
virtual bool resolveParameters(ProgramSet* programSet);
virtual bool resolveDependencies(ProgramSet* programSet);
virtual bool addFunctionInvocations(ProgramSet* programSet);
SharedPtr<LinearSkinning> mLinear;
SharedPtr<DualQuaternionSkinning> mDualQuat;
SharedPtr<HardwareSkinningTechnique> mActiveTechnique;
const HardwareSkinningFactory* mCreator;
SkinningType mSkinningType;
};
_OgreRTSSExport void operator<<(std::ostream& o, const HardwareSkinning::SkinningData& data);
class _OgreRTSSExport HardwareSkinningFactory : public SubRenderStateFactory,
public Singleton<HardwareSkinningFactory>
{
public:
HardwareSkinningFactory();
virtual const String& getType() const;
virtual SubRenderState* createInstance(ScriptCompiler* compiler, PropertyAbstractNode* prop, Pass* pass, SGScriptTranslator* translator);
virtual void writeInstance(MaterialSerializer* ser, SubRenderState* subRenderState, Pass* srcPass, Pass* dstPass);
virtual void setCustomShadowCasterMaterials(const SkinningType skinningType, const MaterialPtr& caster1Weight, const MaterialPtr& caster2Weight,
const MaterialPtr& caster3Weight, const MaterialPtr& caster4Weight);
virtual void setCustomShadowReceiverMaterials(const SkinningType skinningType, const MaterialPtr& receiver1Weight, const MaterialPtr& receiver2Weight,
const MaterialPtr& receiver3Weight, const MaterialPtr& receiver4Weight);
const MaterialPtr& getCustomShadowCasterMaterial(const SkinningType skinningType, ushort index) const;
const MaterialPtr& getCustomShadowReceiverMaterial(const SkinningType skinningType, ushort index) const;
void prepareEntityForSkinning(const Entity* pEntity, SkinningType skinningType = ST_LINEAR, bool correctAntidpodalityHandling = false, bool shearScale = false);
ushort getMaxCalculableBoneCount() const {
return mMaxCalculableBoneCount; }
void setMaxCalculableBoneCount(ushort count) {
mMaxCalculableBoneCount = count; }
static HardwareSkinningFactory& getSingleton(void);
static HardwareSkinningFactory* getSingletonPtr(void);
protected:
bool extractSkeletonData(const Entity* pEntity, unsigned int subEntityIndex,
ushort& boneCount, ushort& weightCount);
bool imprintSkeletonData(const MaterialPtr& pMaterial, bool isValid,
ushort boneCount, ushort weightCount, SkinningType skinningType, bool correctAntidpodalityHandling, bool scalingShearingSupport);
protected:
virtual SubRenderState* createInstanceImpl();
MaterialPtr mCustomShadowCasterMaterialsLinear[HS_MAX_WEIGHT_COUNT];
MaterialPtr mCustomShadowCasterMaterialsDualQuaternion[HS_MAX_WEIGHT_COUNT];
MaterialPtr mCustomShadowReceiverMaterialsLinear[HS_MAX_WEIGHT_COUNT];
MaterialPtr mCustomShadowReceiverMaterialsDualQuaternion[HS_MAX_WEIGHT_COUNT];
ushort mMaxCalculableBoneCount;
};
}
}
#endif
#endif
OgreShaderExHardwareSkinningTechnique.h
Ogre::RTShader::ST_LINEAR
Definition: OgreShaderPrerequisites.h:90
OgreShaderParameter.h
OgreShaderExLinearSkinning.h
OgreShaderPrerequisites.h
Ogre::MaterialPtr
SharedPtr< Material > MaterialPtr
Definition: OgrePrerequisites.h:314
Ogre::RTShader::SkinningType
SkinningType
Definition: OgreShaderPrerequisites.h:88
Ogre::operator<<
std::ostream & operator<<(std::ostream &o, const TRect< T > &r)
Definition: OgreCommon.h:636
OgreShaderExDualQuaternionSkinning.h
OgreRenderSystem.h
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
OgreShaderSubRenderState.h
_OgreRTSSExport
#define _OgreRTSSExport
Definition: OgreShaderPrerequisites.h:108
Ogre
Definition: OgreAndroidLogListener.h:34
OgreShaderFunctionAtom.h
Ogre::ushort
unsigned short ushort
Definition: OgrePrerequisites.h:113

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.