ReadSkinData() 함수에서
void Converter::ReadSkinData()
{
for (UINT i = 0; i < scene->mNumMeshes; i++)
{
aiMesh* aiMesh = scene->mMeshes[i];
if (aiMesh->HasBones() == false) continue;
asMesh* mesh = meshes[i];
vector boneWeights;
boneWeights.assign(mesh->Vertices.size(), asBoneWeights());
for (UINT b = 0; b < aiMesh->mNumBones; b++)
{
aiBone* aiMeshBone = aiMesh->mBones[b];
UINT boneIndex = 0;
for (asBone* bone : bones)
{
if (bone->Name == (string)aiMeshBone->mName.C_Str())
{
boneIndex = bone->Index;
break;
}
}//for(bone)
for (UINT w = 0; w < aiMeshBone->mNumWeights; w++)
{
UINT index = aiMeshBone->mWeights[w].mVertexId;
float weight = aiMeshBone->mWeights[w].mWeight;
boneWeights[index].AddWeights(boneIndex, weight);
}
}//for(b)
for (UINT w = 0; w < boneWeights.size(); w++)
{
boneWeights[i].Normalize();
asBlendWeight blendWeight;
boneWeights[w].GetBlendWeights(blendWeight);
mesh->Vertices[w].BlendIndices = blendWeight.Indices;
mesh->Vertices[w].BlendWeights = blendWeight.Weights;
}
}
}
boneWeights[i].Normalize(); <- 이부분이 각 버텍스의 웨이트 값을 normalize 해주는것에 대해서는 이해가 가는데
boneWeights[i] 에서 i를 인덱스로 쓰는것이 잘 이해가 가지 않습니다.
for (UINT w = 0; w < boneWeights.size(); w++)
{
boneWeights[w].Normalize();
}이렇게 따로 노말라이즈를 해줘야 될것같아서요
안녕하세요 게임클래스 프로그래밍 강사 하민우 입니다.
우선 학습에 혼동을 드려서 죄송합니다. 질문 주신 내용이 맞습니다!
boneWeights[w].Normalize(); 로 작성해야 합니다.
영상 및 수업소스는 수정 예정 입니다.
해당 부분은 가중치 관련 값이다보니 노멀라이즈가 되지 않도라도 일부 리소스에서는 실행시 큰 차이가 나지 않다보니 발견 되지 않았던 것 같습니다.
오타 확인 감사드립니다!
항상 열공하시고 궁금한 점이 있을 때는 언제든지 질문 주시기 바랍니다.
게임 개발자가 되는 가장 빠른 길, 게임클래스!