Community
Output.pos = (0,0,0);
for(int iBone = 0; iBone < nBones; iBone ++)
{
Output.pos += Input.pos * matrixPalette] * afBlendWeights;
}
S_SKIN_OUTPUT VS_Skin( const VS_SKIN_INPUT vInput, int iNumBones )
{
VS_SKIN_OUTPUT vOutput = (VS_SKIN_OUTPUT) 0;
float fLastWeight = 1.0;
float fWeight;
float afBlendWeights = (float) vInput.vBlendWeights;
int aiIndices = (int) D3DCOLORtoUBYTE4( vInput.vBlendIndices );
for( int iBone = 0; (iBone < 3) && (iBone < iNumBones - 1); ++ iBone )
{
fWeight = afBlendWeights;
fLastWeight -= fWeight;
vOutput.vPos.xyz += mul( vInput.vPos, amPalette ] ) * fWeight;
vOutput.vNor += mul( vInput.vNor, amPalette ] ) * fWeight;
}
vOutput.vPos.xyz += mul( vInput.vPos, amPalette ] ) * fLastWeight;
vOutput.vNor += mul( vInput.vNor, amPalette ] ) * fLastWeight;
return vOutput;
}
float4x3 BoneMatrix = 0;
for(int i = 0; i < nBones; i++)
{
BoneMatrix += matrixPalette ] * afBlendWeights;
}
Output.pos = Input.pos * BoneMatrix *g_mWorld;
VS_SKIN_OUTPUT VS_SkinTotal1( const VS_SKIN_INPUT vInput, int iNumBones )
{
VS_SKIN_OUTPUT vOutput = (VS_SKIN_OUTPUT) 0;
float fLastWeight = 1.0;
float fWeight;
float afBlendWeights = (float) vInput.vBlendWeights;
int aiIndices = (int) D3DCOLORtoUBYTE4( vInput.vBlendIndices );
float4x3 BoneMatrix = float4x3( float3(0,0,0) , float3(0,0,0) , float3(0,0,0), float3(0,0,0) );
for( int iBone = 0; (iBone < 3) && (iBone < iNumBones - 1); ++ iBone )
{
fWeight = afBlendWeights;
fLastWeight -= fWeight;
float4x3 BoneMatrixScaled = amPalette ];
BoneMatrixScaled = mul(BoneMatrixScaled, fWeight);
BoneMatrix = BoneMatrix + BoneMatrixScaled;
}
float4x3 BoneMatrixScaled = amPalette ];
BoneMatrixScaled = mul(BoneMatrixScaled, fLastWeight);
BoneMatrix = BoneMatrix + BoneMatrixScaled;
vOutput.vPos.xyz = mul( mul(vInput.vPos, BoneMatrix), g_mWorld );
vOutput.vNor = mul( mul(vInput.vNor, BoneMatrix), g_mWorld );
return vOutput;
}
It`s good. Doug, write please, how to get bone weights and linked vertices. In examples, i found only Deformer.
Can't find what you're looking for? Ask the community or share your knowledge.