Advertisement
Guest User

Untitled

a guest
Sep 16th, 2021
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. void CD3DDevice::SetTransforms(size_t count, LPD3DXMATRIX matrices)
  2. {
  3.     static LPDIRECT3DTEXTURE9 boneTexture = nullptr;
  4.  
  5.     DWORD NumBones = MAX_PIVOT + 1;
  6.     DWORD BonesMat = 4; // pixels per bone
  7.     DWORD TexWidth = NumBones * BonesMat;
  8.     DWORD TexHeight = 1; // skeletons
  9.  
  10.     if(!boneTexture) m_pDevice->CreateTexture(TexWidth, TexHeight, 1, D3DUSAGE_DYNAMIC, D3DFMT_A32B32G32R32F, D3DPOOL_DEFAULT, &boneTexture, NULL);
  11.  
  12.     D3DLOCKED_RECT rect;
  13.     boneTexture->LockRect(0, &rect, NULL, D3DLOCK_DISCARD);
  14.  
  15.     ZeroMemory(rect.pBits, NumBones * sizeof(D3DXMATRIX));
  16.     memcpy(rect.pBits, &matrices[0], count * sizeof(D3DXMATRIX));
  17.  
  18.     boneTexture->UnlockRect(0);
  19.  
  20.     if (FAILED(m_pEffect->SetFloat("OneOverWidth", 1.0f / TexWidth))) { CTConsole::GetInstance()->Output("Failed to set OneOverAnimTexWidth!\n"); }
  21.     if (FAILED(m_pEffect->SetFloat("OneOverHeight", 1.0f / TexHeight))) { CTConsole::GetInstance()->Output("Failed to set OneOverAnimTexHeight!\n"); }
  22.     if (FAILED(m_pEffect->SetTexture("bonetexture", boneTexture))) { CTConsole::GetInstance()->Output("Failed to set bone texture!\n"); }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement