hi there. here are the relevant parts of my code. when i run the first part with the printfs found after every time i set a variable in the for loop they print the right values on the screen but when trying to print the values from the array where i stored the values i get garbage, 0's and numbers in the billions. I have spent a couple of hours on this. please help!!
Code:
struct aiMesh* mesh = scene->mMeshes[0];
ObjectMesh->MeshIndexListSize = mesh->mNumFaces;
ObjectMesh->MeshIndexList = (struct TypeVertexIndexList3 *)malloc(sizeof(struct TypeVertexIndexList3) * mesh->mNumFaces);
for (int i = 0; i < mesh->mNumFaces; i++)
{
const struct aiFace* face = &mesh->mFaces[i];
ObjectMesh->MeshIndexList[i].i0 = face->mIndices[0];
printf("\n%u\n", face->mIndices[0]);
ObjectMesh->MeshIndexList[i].i1 = face->mIndices[1];
printf("\n%u\n", face->mIndices[1]);
ObjectMesh->MeshIndexList[i].i2 = face->mIndices[2];
printf("\n%u\n", face->mIndices[2]);
}
Code:
typedef struct TypeVertexIndexList3
{
union
{
unsigned int indexlist[3];
struct
{
unsigned int i0, i1, i2;
};
};
} IndexTriangle, VertexIndexList3;
thanks again