Small viewer fixes, at least something is visible now.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@207 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
9f92c7098e
commit
e1261bb9fe
|
@ -135,6 +135,7 @@ void AnimEvaluator::Evaluate( double pTime)
|
|||
mat.a2 *= presentScaling.y; mat.b2 *= presentScaling.y; mat.c2 *= presentScaling.y;
|
||||
mat.a3 *= presentScaling.z; mat.b3 *= presentScaling.z; mat.c3 *= presentScaling.z;
|
||||
mat.a4 = presentPosition.x; mat.b4 = presentPosition.y; mat.c4 = presentPosition.z;
|
||||
//mat.Transpose();
|
||||
}
|
||||
|
||||
mLastTime = time;
|
||||
|
|
|
@ -740,7 +740,7 @@ int CDisplay::OnRender()
|
|||
// update possible animation
|
||||
if( g_pcAsset)
|
||||
{
|
||||
assert( g_pcAsset->mAnimator);
|
||||
ai_assert( g_pcAsset->mAnimator);
|
||||
g_pcAsset->mAnimator->Calculate( double( clock()) / double( CLOCKS_PER_SEC));
|
||||
}
|
||||
// begin the frame
|
||||
|
@ -1974,29 +1974,35 @@ int CDisplay::RenderNode (aiNode* piNode,const aiMatrix4x4& piMatrix,
|
|||
}
|
||||
else if (bAlpha)continue;
|
||||
|
||||
// Upload bone matrices. This maybe is the wrong place to do it, but for the heck of it I don't understand this code flow
|
||||
if( mesh->HasBones())
|
||||
{
|
||||
static float matrices[4*4*60];
|
||||
float* tempmat = matrices;
|
||||
const std::vector<aiMatrix4x4>& boneMats = g_pcAsset->mAnimator->GetBoneMatrices( piNode, i);
|
||||
ai_assert( boneMats.size() == mesh->mNumBones);
|
||||
|
||||
for( unsigned int a = 0; a < mesh->mNumBones; a++)
|
||||
{
|
||||
const aiMatrix4x4& mat = boneMats[a];
|
||||
*tempmat++ = mat.a1; *tempmat++ = mat.a2; *tempmat++ = mat.a3;
|
||||
tempmat++;
|
||||
*tempmat++ = mat.a4; *tempmat++ = mat.b1; *tempmat++ = mat.b2;
|
||||
tempmat++;
|
||||
*tempmat++ = mat.b3; *tempmat++ = mat.b4; *tempmat++ = mat.c1;
|
||||
tempmat++;
|
||||
*tempmat++ = mat.c2; *tempmat++ = mat.c3; *tempmat++ = mat.c4;
|
||||
tempmat++;
|
||||
}
|
||||
helper->piEffect->SetMatrixArray( "gBoneMatrix", (D3DXMATRIX*)matrices, 60);
|
||||
}
|
||||
|
||||
// now setup the material
|
||||
if (g_sOptions.bRenderMats)
|
||||
{
|
||||
CMaterialManager::Instance().SetupMaterial( helper, pcProj, aiMe, pcCam, vPos);
|
||||
}
|
||||
|
||||
// Upload bone matrices. This maybe is the wrong place to do it, but for the heck of it I don't understand this code flow
|
||||
if( mesh->HasBones())
|
||||
{
|
||||
static float matrices[4*3*60];
|
||||
float* tempmat = matrices;
|
||||
const std::vector<aiMatrix4x4>& boneMats = g_pcAsset->mAnimator->GetBoneMatrices( piNode, i);
|
||||
assert( boneMats.size() == mesh->mNumBones);
|
||||
|
||||
for( unsigned int a = 0; a < mesh->mNumBones; a++)
|
||||
{
|
||||
const aiMatrix4x4& mat = boneMats[a];
|
||||
*tempmat++ = mat.a1; *tempmat++ = mat.a2; *tempmat++ = mat.a3; *tempmat++ = mat.a4;
|
||||
*tempmat++ = mat.b1; *tempmat++ = mat.b2; *tempmat++ = mat.b3; *tempmat++ = mat.b4;
|
||||
*tempmat++ = mat.c1; *tempmat++ = mat.c2; *tempmat++ = mat.c3; *tempmat++ = mat.c4;
|
||||
}
|
||||
helper->piEffect->SetFloatArray( "gBoneMatrix", matrices, 3*60*4);
|
||||
}
|
||||
g_piDevice->SetVertexDeclaration( gDefaultVertexDecl);
|
||||
|
||||
if (bAlpha)CMeshRenderer::Instance().DrawSorted(piNode->mMeshes[i],aiMe);
|
||||
else CMeshRenderer::Instance().DrawUnsorted(piNode->mMeshes[i]);
|
||||
|
|
|
@ -933,6 +933,9 @@ int CMaterialManager::CreateMaterial(
|
|||
if ((pcMesh->fOpacity != 1.0f ? true : false) != (pc->fOpacity != 1.0f ? true : false))
|
||||
continue;
|
||||
|
||||
if (pcSource->HasBones() != g_pcAsset->pcScene->mMeshes[i]->HasBones())
|
||||
continue;
|
||||
|
||||
// we can reuse this material
|
||||
if (pc->piEffect)
|
||||
{
|
||||
|
@ -1113,6 +1116,22 @@ int CMaterialManager::CreateMaterial(
|
|||
{
|
||||
pcMesh->piEffect->SetTexture("lw_tex_envmap",CBackgroundPainter::Instance().GetTexture());
|
||||
}
|
||||
|
||||
// setup bones if neccessary
|
||||
if( !pcSource->HasBones())
|
||||
{
|
||||
static float matrices[4*3*60];
|
||||
float* tempmat = matrices;
|
||||
for( unsigned int a = 0; a < 60; a++)
|
||||
{
|
||||
// HACK: (thom) set identity matrices for all bones for the moment so that you see something
|
||||
*tempmat++ = 1.0f; *tempmat++ = 0.0f; *tempmat++ = 0.0f; *tempmat++ = 0.0f;
|
||||
*tempmat++ = 0.0f; *tempmat++ = 1.0f; *tempmat++ = 0.0f; *tempmat++ = 0.0f;
|
||||
*tempmat++ = 0.0f; *tempmat++ = 0.0f; *tempmat++ = 1.0f; *tempmat++ = 0.0f;
|
||||
}
|
||||
pcMesh->piEffect->SetVectorArray( "gBoneMatrix", (const D3DXVECTOR4*) matrices, 3*60);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
|
@ -1140,11 +1159,11 @@ int CMaterialManager::SetupMaterial (
|
|||
apcVec[0].x = g_avLightDirs[0].x;
|
||||
apcVec[0].y = g_avLightDirs[0].y;
|
||||
apcVec[0].z = g_avLightDirs[0].z;
|
||||
apcVec[0].w = 0.0f;
|
||||
apcVec[0].w = 0.0f;
|
||||
apcVec[1].x = g_avLightDirs[0].x * -1.0f;
|
||||
apcVec[1].y = g_avLightDirs[0].y * -1.0f;
|
||||
apcVec[1].z = g_avLightDirs[0].z * -1.0f;
|
||||
apcVec[1].w = 0.0f;
|
||||
apcVec[1].w = 0.0f;
|
||||
D3DXVec4Normalize(&apcVec[0],&apcVec[0]);
|
||||
D3DXVec4Normalize(&apcVec[1],&apcVec[1]);
|
||||
piEnd->SetVectorArray("afLightDir",apcVec,5);
|
||||
|
@ -1154,19 +1173,19 @@ int CMaterialManager::SetupMaterial (
|
|||
apcVec[0].z = ((g_avLightColors[0]) & 0xFF) / 255.0f;
|
||||
apcVec[0].w = 1.0f;
|
||||
|
||||
if( g_sOptions.b3Lights)
|
||||
{
|
||||
apcVec[1].x = ((g_avLightColors[1] >> 16) & 0xFF) / 255.0f;
|
||||
apcVec[1].y = ((g_avLightColors[1] >> 8) & 0xFF) / 255.0f;
|
||||
apcVec[1].z = ((g_avLightColors[1]) & 0xFF) / 255.0f;
|
||||
apcVec[1].w = 0.0f;
|
||||
} else
|
||||
{
|
||||
apcVec[1].x = 0.0f;
|
||||
apcVec[1].y = 0.0f;
|
||||
apcVec[1].z = 0.0f;
|
||||
apcVec[1].w = 0.0f;
|
||||
}
|
||||
if( g_sOptions.b3Lights)
|
||||
{
|
||||
apcVec[1].x = ((g_avLightColors[1] >> 16) & 0xFF) / 255.0f;
|
||||
apcVec[1].y = ((g_avLightColors[1] >> 8) & 0xFF) / 255.0f;
|
||||
apcVec[1].z = ((g_avLightColors[1]) & 0xFF) / 255.0f;
|
||||
apcVec[1].w = 0.0f;
|
||||
} else
|
||||
{
|
||||
apcVec[1].x = 0.0f;
|
||||
apcVec[1].y = 0.0f;
|
||||
apcVec[1].z = 0.0f;
|
||||
apcVec[1].w = 0.0f;
|
||||
}
|
||||
|
||||
apcVec[0] *= g_fLightIntensity;
|
||||
apcVec[1] *= g_fLightIntensity;
|
||||
|
@ -1232,6 +1251,9 @@ int CMaterialManager::SetupMaterial (
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// setup the correct shader technique to be used for drawing
|
||||
if( g_sCaps.PixelShaderVersion < D3DPS_VERSION(2,0))
|
||||
{
|
||||
|
|
|
@ -133,9 +133,9 @@ const aiMatrix4x4& SceneAnimator::GetGlobalTransform( const std::string& pNodeNa
|
|||
// Calculates the bone matrices for the given mesh.
|
||||
const std::vector<aiMatrix4x4>& SceneAnimator::GetBoneMatrices( const aiNode* pNode, size_t pMeshIndex /* = 0 */)
|
||||
{
|
||||
assert( pMeshIndex < pNode->mNumMeshes);
|
||||
ai_assert( pMeshIndex < pNode->mNumMeshes);
|
||||
size_t meshIndex = pNode->mMeshes[pMeshIndex];
|
||||
assert( meshIndex < mScene->mNumMeshes);
|
||||
ai_assert( meshIndex < mScene->mNumMeshes);
|
||||
const aiMesh* mesh = mScene->mMeshes[meshIndex];
|
||||
|
||||
// resize array and initialise it with identity matrices
|
||||
|
@ -203,7 +203,7 @@ void SceneAnimator::UpdateTransforms( SceneAnimNode* pNode, const std::vector<ai
|
|||
// update node local transform
|
||||
if( pNode->mChannelIndex != -1)
|
||||
{
|
||||
assert( pNode->mChannelIndex < pTransforms.size());
|
||||
ai_assert( pNode->mChannelIndex < pTransforms.size());
|
||||
pNode->mLocalTransform = pTransforms[pNode->mChannelIndex];
|
||||
|
||||
// update global transform as well
|
||||
|
|
|
@ -611,10 +611,10 @@ std::string g_szMaterialShader = std::string(
|
|||
"float3 Tangent : TEXCOORD0;\n"
|
||||
"float3 Bitangent : TEXCOORD1;\n"
|
||||
"float2 TexCoord0 : TEXCOORD2;\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
|
||||
|
@ -689,7 +689,7 @@ std::string g_szMaterialShader = std::string(
|
|||
// Vertex shader for pixel shader usage and one light
|
||||
"VS_OUTPUT MaterialVShader_D1(VS_INPUT IN)\n"
|
||||
"{\n"
|
||||
"VS_OUTPUT Out;\n"
|
||||
"VS_OUTPUT Out = (VS_OUTPUT)0;\n"
|
||||
|
||||
"#ifdef AV_SKINNING \n"
|
||||
"float4 weights = IN.BlendWeights; \n"
|
||||
|
@ -724,7 +724,7 @@ std::string g_szMaterialShader = std::string(
|
|||
// Vertex shader for pixel shader usage and two lights
|
||||
"VS_OUTPUT MaterialVShader_D2(VS_INPUT IN)\n"
|
||||
"{\n"
|
||||
"VS_OUTPUT Out;\n"
|
||||
"VS_OUTPUT Out = (VS_OUTPUT)0;\n"
|
||||
|
||||
"#ifdef AV_SKINNING \n"
|
||||
"float4 weights = IN.BlendWeights; \n"
|
||||
|
@ -760,7 +760,7 @@ std::string g_szMaterialShader = std::string(
|
|||
// Vertex shader for zero to five lights using the fixed function pixel pipeline
|
||||
"VS_OUTPUT_FF MaterialVShader_FF(VS_INPUT IN)\n"
|
||||
"{\n"
|
||||
"VS_OUTPUT_FF Out;\n"
|
||||
"VS_OUTPUT_FF Out = (VS_OUTPUT_FF)0;\n"
|
||||
|
||||
"#ifdef AV_SKINNING \n"
|
||||
"float4 weights = IN.BlendWeights; \n"
|
||||
|
|
|
@ -577,7 +577,7 @@ int CreateAssetData()
|
|||
{
|
||||
unsigned char boneIndices[4] = { 0, 0, 0, 0 };
|
||||
unsigned char boneWeights[4] = { 0, 0, 0, 0 };
|
||||
assert( weightsPerVertex[x].size() <= 4);
|
||||
ai_assert( weightsPerVertex[x].size() <= 4);
|
||||
for( unsigned int a = 0; a < weightsPerVertex[x].size(); a++)
|
||||
{
|
||||
boneIndices[a] = weightsPerVertex[x][a].mVertexId;
|
||||
|
|
|
@ -68,6 +68,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#undef max
|
||||
#endif // min
|
||||
|
||||
#include <time.h>
|
||||
|
||||
// default movement speed
|
||||
#define MOVE_SPEED 3.f
|
||||
|
||||
|
|
Loading…
Reference in New Issue