Skip to main content
gamedev.net
🔒 Locked

Problems with model loading (+)

Started by Stass 0 replies 350+ views
Original Post
Stass
Stass
I am using Jim Adams' Advanced Animation. I create 3d model in gameSpace (trueSpace addon) - model and jointed skeleton (skinned model). Then I save this model to X file. When I test my model with ParseFrame.exe and ParseMesh.exe - everything is okay - model is skinned and has skeleton in it. But when I load it to my application everything okay till function UpdateMesh runs. It works for TINY.X but not for my models:

HRESULT UpdateMesh(D3DXMESHCONTAINER_EX *pMesh)
{
  // Error checking
  if(!pMesh)   return E_FAIL;
  if(!pMesh->MeshData.pMesh || !pMesh->pSkinMesh || !pMesh->pSkinInfo)  return E_FAIL;
  if(!pMesh->pBoneMatrices || !pMesh->ppFrameMatrices)  return E_FAIL;

  // Copy the bone matrices over (must have been combined before call DrawMesh)
  for(DWORD i=0;i<pMesh->pSkinInfo->GetNumBones();i++) {
    // Start with bone offset matrix
    pMesh->pBoneMatrices = (*pMesh->pSkinInfo->GetBoneOffsetMatrix(i));
    // Apply frame transformation
    if(pMesh->ppFrameMatrices)
      pMesh->pBoneMatrices *= (*pMesh->ppFrameMatrices);
  }

  // Lock the meshes' vertex buffers
  void *SrcPtr, *DestPtr;
  pMesh->MeshData.pMesh->LockVertexBuffer(D3DLOCK_READONLY, (void**)&SrcPtr);
  pMesh->pSkinMesh->LockVertexBuffer(0, (void**)&DestPtr);

//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//            ERROR IS HERE
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  // Update the skinned mesh using provided transformations
  pMesh->pSkinInfo->UpdateSkinnedMesh(pMesh->pBoneMatrices, NULL, SrcPtr, DestPtr);

  // Unlock the meshes vertex buffers
  pMesh->pSkinMesh->UnlockVertexBuffer();
  pMesh->MeshData.pMesh->UnlockVertexBuffer();

  // Return success
  return S_OK;
}

Also, please, tell what tool is better to use for creating skinned skeleton model and saving it to right X file. Right now I am using gameSpace - but it is not very convient and I have errors with custom models. [Edited by - Coder on October 27, 2005 10:54:24 AM]
matthughson
matthughson
Is it crashing 'there'? What is it crashing on, a NULL pointer? That ussually means that you're model isn't being loaded correctly. In this case probably the bones. Step through your loading code, for both tiny and your own model, and see what is different.

I would also export the x in acsii format, and compare it to something like tiny that works. Every X file exporter is different, so there could be something that the one you're using doesn't account for.

Also try some really simple stuff, like exporting a cube and see if that runs. Might help narrow down the problem.

As for apps that do well with X file exporting, I personally use Maya 5, but it is quite expensive, and from what I hear the exporters for the newer version of Maya have some serious issues.

Matt
__________________________________[ Website ] [ Résumé ] [ [email=contact[at]matthughson[dot]com]Contact[/email] ][ Have I been Helpful? Hook me up! ]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.