Jump to content
  • Advertisement
Sign in to follow this  
ote

Assimp : cant' access to texCoords and faces

This topic is 2565 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

I'm trying to use assimp to load some models in my project. I have succesfully installed it, I am able to load some models but I have a problem to get access to two types of data : the texCoords and the indices of faces that form a mesh. When I try to retrieve those informations, my program crash due to segmentation fault. But for all the other things (vertex position, normals, colors, ...) I can get the information without any problem. I don't understand why this is happenning.

I have read the doc, looked at the samples provided with the library and to others codes I found, I think I'm doing the same but doesn't work for me with these two cases.

Here's the lines :


bool Modele::loadGlresources(const aiScene *scene)
{
for(unsigned int i = 0; i < scene->mNumMeshes; i++)
{
aiMesh* mesh = scene->mMeshes;

//temp array to store data
info_vertex *attributes = (info_vertex *)malloc(mesh->mNumVertices * sizeof(info_vertex));

for(unsigned int j = 0; j < mesh->mNumVertices; j++)
{
//get the position, normal, .... without problems

//here's how I do for position :
attributes[j].position.x = mesh->mVertices[j].x;
attributes[j].position.y = mesh->mVertices[j].y;
attributes[j].position.z = mesh->mVertices[j].z;
attributes[j].position.w = 1.0f;

//but here's my problem :
if(mesh->HasTextureCoords(0))
{
attributes[j].texCoord.x = mesh->mTextureCoords[0][j].x;
attributes[j].texCoord.y = mesh->mTextureCoords[0][j].y;
}
}

//and the problem with the faces :
//again temp array
element *indices = (element *)malloc(mesh->mNumFaces * 3 * sizeof(element));

if(!mesh->HasFaces()) //add that to check where the error is, but still pass the test and crash.....
return false;

unsigned int count = 0;
for(unsigned int j = 0; j < mesh->mNumFaces; j++)
{
indices[count].element = mesh->mFaces[j].mIndices[0];
indices[count + 1].element = mesh->mFaces[j].mIndices[1];
indices[count + 2].element = mesh->mFaces[j].mIndices[2];
count += 3;
}
}
return true;
}



I've trying for hours now to make this work, but nothing works. So if someone has an idea of what I'm doing wrong, I'd be very grateful.

Sorry for my english.

Share this post


Link to post
Share on other sites
Advertisement
It works now without changing a single letter of my code. The problem was that I that I get the library from svn. With the latest stable version it works. :)

I have been playing with my code for the day before looking into that...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!