- bone animations now also work with Disabled Materials Shader. There should be something missing, but it works. Strange...

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@222 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
ulfjorensen 2008-11-02 21:24:27 +00:00
parent 42123de268
commit d54c695be4
2 changed files with 31 additions and 21 deletions

View File

@ -1988,7 +1988,15 @@ int CDisplay::RenderNode (aiNode* piNode,const aiMatrix4x4& piMatrix,
*tempmat++ = mat.d1; *tempmat++ = mat.d2; *tempmat++ = mat.d3; *tempmat++ = mat.d4;
//tempmat += 4;
}
if( g_sOptions.bRenderMats)
{
helper->piEffect->SetMatrixTransposeArray( "gBoneMatrix", (D3DXMATRIX*)matrices, 60);
} else
{
g_piDefaultEffect->SetMatrixTransposeArray( "gBoneMatrix", (D3DXMATRIX*)matrices, 60);
g_piDefaultEffect->CommitChanges();
}
}
// now setup the material

View File

@ -260,19 +260,19 @@ std::string g_szDefaultShader = std::string(
"float3 vCameraPos : CAMERAPOSITION;\n"
// Bone matrices
"#ifdef AV_SKINNING \n"
// "#ifdef AV_SKINNING \n"
"float4x3 gBoneMatrix[60]; \n"
"#endif // AV_SKINNING \n"
// "#endif // AV_SKINNING \n"
// Vertex shader input structure
"struct VS_INPUT\n"
"{\n"
"float3 Position : POSITION;\n"
"float3 Normal : NORMAL;\n"
"#ifdef AV_SKINNING \n"
// "#ifdef AV_SKINNING \n"
"float4 BlendIndices : BLENDINDICES;\n"
"float4 BlendWeights : BLENDWEIGHT;\n"
"#endif // AV_SKINNING \n"
// "#endif // AV_SKINNING \n"
"};\n"
// Vertex shader output structure for pixel shader usage
@ -295,16 +295,17 @@ std::string g_szDefaultShader = std::string(
"{\n"
"VS_OUTPUT Out;\n"
"#ifdef AV_SKINNING \n"
// "#ifdef AV_SKINNING \n"
"float4 weights = IN.BlendWeights; \n"
"weights.w = 1.0f - dot( weights.xyz, float3( 1, 1, 1)); \n"
"float3 objPos = mul( IN.Position, gBoneMatrix[IN.BlendIndices.x]) * weights.x; \n"
"objPos += mul( IN.Position, gBoneMatrix[IN.BlendIndices.y]) * weights.y; \n"
"objPos += mul( IN.Position, gBoneMatrix[IN.BlendIndices.z]) * weights.z; \n"
"objPos += mul( IN.Position, gBoneMatrix[IN.BlendIndices.w]) * weights.w; \n"
"#else \n"
"float3 objPos = IN.Position; \n"
"#endif // AV_SKINNING \n"
"float4 localPos = float4( IN.Position, 1.0f); \n"
"float3 objPos = mul( localPos, gBoneMatrix[IN.BlendIndices.x]) * weights.x; \n"
"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.y]) * weights.y; \n"
"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.z]) * weights.z; \n"
"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.w]) * weights.w; \n"
// "#else \n"
// "float3 objPos = IN.Position; \n"
// "#endif // AV_SKINNING \n"
// Multiply with the WorldViewProjection matrix
"Out.Position = mul( float4( objPos, 1.0f), WorldViewProjection);\n"
@ -320,16 +321,17 @@ std::string g_szDefaultShader = std::string(
"{\n"
"VS_OUTPUT_FF Out;\n"
"#ifdef AV_SKINNING \n"
// "#ifdef AV_SKINNING \n"
"float4 weights = IN.BlendWeights; \n"
"weights.w = 1.0f - dot( weights.xyz, float3( 1, 1, 1)); \n"
"float3 objPos = mul( IN.Position, gBoneMatrix[IN.BlendIndices.x]) * weights.x; \n"
"objPos += mul( IN.Position, gBoneMatrix[IN.BlendIndices.y]) * weights.y; \n"
"objPos += mul( IN.Position, gBoneMatrix[IN.BlendIndices.z]) * weights.z; \n"
"objPos += mul( IN.Position, gBoneMatrix[IN.BlendIndices.w]) * weights.w; \n"
"#else \n"
"float3 objPos = IN.Position; \n"
"#endif // AV_SKINNING \n"
"float4 localPos = float4( IN.Position, 1.0f); \n"
"float3 objPos = mul( localPos, gBoneMatrix[IN.BlendIndices.x]) * weights.x; \n"
"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.y]) * weights.y; \n"
"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.z]) * weights.z; \n"
"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.w]) * weights.w; \n"
// "#else \n"
// "float3 objPos = IN.Position; \n"
// "#endif // AV_SKINNING \n"
// Multiply with the WorldViewProjection matrix
"Out.Position = mul( float4( objPos, 1.0f), WorldViewProjection);\n"