Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ DirectX Blend Indexes
Hello. I am currently working on a rendering engine which is meant to render character animations. Right now I am working on vertex blending to make the body parts move with the bones.
 

For each vertex declaration, I have a short that represents the first bone's weight, and 2 shorts representing which bones the vertex is affected by. These 2 shorts also are indexes to an array of combined transformation matrices (in world space) which represent each bone's transformation in world space.
 

When the model is loaded from the file, this loop is run for each vertex to build the array of vertices that will be uploaded to the vertex buffer:
 
for (int i=0;i<(int)_numVertex;i++)
{
  cVertices[i].x = vertex[i].pos[0];
  cVertices[i].y = vertex[i].pos[1];
  cVertices[i].z = vertex[i].pos[2];
  cVertices[i].normal.x = vertex[i].normal[0];
  cVertices[i].normal.y = vertex[i].normal[1];
  cVertices[i].normal.z = vertex[i].normal[2];
  cVertices[i].tu = vertex[i].uv[0];
  cVertices[i].tv = vertex[i].uv[1];
  cVertices[i].su = (float)(vertex[i].normal[0]/2)+0.5;
  cVertices[i].sv = (float)(vertex[i].normal[1]/2)+0.5;
  _bone1List[i] = vertex[i].boneID[0];
  _bone2List[i] = vertex[i].boneID[1];
  _boneWeight1[i] = vertex[i].boneWeight1*0.01f;
 
  cVertices[i].b1 = _boneWeight1[i];
 
  cVertices[i].matIndices = ((_bone2List[i] & 0xFF) << 8) | (_bone1List[i] & 0xFF);
}
 
"b1" is the bone weight, and "matIndices" is the packed DWORD with the matrix palette indices.
 

For each frame, this loop is then called to update the world transformation matrices palette which contains each bone's combined transformation matrix:
 
for (int i=0;i<boneController._numBones;i++)
{
dev->SetTransform(D3DTS_WORLDMATRIX(i), boneController.getBoneList()[i].getCombinedTransAdr());
}
 

The problem is, when the model is loaded, the entire character is overly stretched and goes off the top of the screen. Does anyone know why this could be happening?
 
Here is my FVF declatation:
 
#define MDLFVF (D3DFVF_XYZB2 | D3DFVF_LASTBETA_UBYTE4 | D3DFVF_NORMAL | D3DFVF_TEX1 | D3DFVF_TEX2)
struct MDLVERTEX
{
FLOAT x, y, z;
FLOAT b1;
DWORD matIndices;
D3DVECTOR normal;
FLOAT tu, tv;
FLOAT su, sv;
};
Posted 27-Jun-12 8:01am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

There could be a host of different reasons for this. First of all, two bone weights is too low. 4 is respectable. But this is most probably not the problem.
 
The problem could be bad math in your vertex shader. In any case, you would need to provide more info for us ti diagnose the problem.
 
-Debdatta Basu
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 451
1 Afzaal Ahmad Zeeshan 184
2 /\jmot 176
3 Marcin Kozub 150
4 Sergey Alexandrovich Kryukov 150
0 OriginalGriff 8,344
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,634
3 Maciej Los 5,024
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 22 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100