Sign in to follow this  
Asem

problem loading objects with assimp

Recommended Posts

I have a problem with assimp itself loading any of the formats it supports. I tried a simple test just to make sure that it had stored any data about the mesh and it sees nothing which is weird since I'm pretty sure I'm not doing anything different from what the library expects.

a simple check to see if assimp sees anything:


const aiScene * mscene = aiImportFile("./Cube.x", 0);
const aiNode * root = mscene->mRootNode;

if(!mscene)
std::cout << "object not loaded!" << std::endl;

std::cout << "number of meshes: " << root->mNumMeshes << std::endl;





root->mNumMeshes returns 0;

I did check to make sure it sees the file which is not the problem.

the program compiles just fine even during runtime as long as I don't try to access the members that are supposed to the mesh data since according to assimp there was none loaded.

Share this post


Link to post
Share on other sites
Have you tried the assimpView executable? You should be able to try to load your file in that. If it works there then you've got a problem in your code, if not than you know that for one reason or another it can't load the .x file.

That would be the first thing I would check.

EDIT: Also try to utilize the logger. There's a command you throw at the start of your program that causes assimp to dump a log, I think any problems it encounters will be reported there (instead of an exception). If you're having problems you should try that as well.

Share this post


Link to post
Share on other sites
From the logger:

Info, T4656: Load ./spider.obj
Debug, T4656: [b]Assimp 2.0.863[/b] x86 msvc shared singlethreaded
Info, T4656: Found a matching importer for this file format
Info, T4656: Import root directory is '.\'
Info, T4656: Entering post processing pipeline
Debug, T4656: TriangulateProcess begin
Debug, T4656: TriangulateProcess finished. There was nothing to be done.
Debug, T4656: SortByPTypeProcess begin
Info, T4656: Points: 0, Lines: 0, Triangles: 19, Polygons: 0 (Meshes, X = removed)
Debug, T4656: SortByPTypeProcess finished
Debug, T4656: Generate spatially-sorted vertex cache
Debug, T4656: JoinVerticesProcess begin
Debug, T4656: Mesh 0 (unnamed) | Verts in: 240 out: 42 | ~82.5%
Debug, T4656: Mesh 1 (unnamed) | Verts in: 180 out: 37 | ~79.4444%
Debug, T4656: Mesh 2 (unnamed) | Verts in: 294 out: 72 | ~75.5102%
Debug, T4656: Mesh 3 (unnamed) | Verts in: 294 out: 72 | ~75.5102%
Debug, T4656: Mesh 4 (unnamed) | Verts in: 294 out: 72 | ~75.5102%
Debug, T4656: Mesh 5 (unnamed) | Verts in: 294 out: 72 | ~75.5102%
Debug, T4656: Mesh 6 (unnamed) | Verts in: 294 out: 72 | ~75.5102%
Debug, T4656: Mesh 7 (unnamed) | Verts in: 294 out: 72 | ~75.5102%
Debug, T4656: Mesh 8 (unnamed) | Verts in: 294 out: 72 | ~75.5102%
Debug, T4656: Mesh 9 (unnamed) | Verts in: 294 out: 72 | ~75.5102%
Debug, T4656: Mesh 10 (unnamed) | Verts in: 126 out: 27 | ~78.5714%
Debug, T4656: Mesh 11 (unnamed) | Verts in: 126 out: 27 | ~78.5714%
Debug, T4656: Mesh 12 (unnamed) | Verts in: 270 out: 57 | ~78.8889%
Debug, T4656: Mesh 13 (unnamed) | Verts in: 60 out: 17 | ~71.6667%
Debug, T4656: Mesh 14 (unnamed) | Verts in: 270 out: 57 | ~78.8889%
Debug, T4656: Mesh 15 (unnamed) | Verts in: 126 out: 27 | ~78.5714%
Debug, T4656: Mesh 16 (unnamed) | Verts in: 126 out: 27 | ~78.5714%
Debug, T4656: Mesh 17 (unnamed) | Verts in: 114 out: 26 | ~77.193%
Debug, T4656: Mesh 18 (unnamed) | Verts in: 114 out: 26 | ~77.193%
Info, T4656: JoinVerticesProcess finished | Verts in: 4104 out: 946 | ~76.9%
Info, T4656: Leaving post processing pipeline






It tries to create the object but no errors are formed which means that the mesh should have been created. I would really like to use assimp so any ideas of why this would happen would be nice.

Yes, I've loaded the objects in the viewer and works fine so it not the object and I can't see it being my code since it's too simple and I'm just trying to make sure it can even see a mesh in the first place before I go grabbing data.

Code:

void main()
{
createAILogger();


const aiScene * scene = importer.ReadFile("./spider.obj", aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices |
aiProcess_SortByPType);

logInfo( importer.GetErrorString() );

if(!scene)
{
cout << "Problem Loading Mesh!" << endl;
exit(0);
}

aiNode * root = scene->mRootNode;

cout << root->mNumMeshes << endl;


destroyAILogger();

}



Share this post


Link to post
Share on other sites
I looked at my own assimp code and I'm pulling my mNumMeshes directly from the scene, not from the root node. Have you tried doing likewise? Maybe only certain filetypes use the rootnode.


const aiScene* scene = importer.ReadFile(RESOURCE_PATH + meshname);

for(uint i=0;i<scene->mNumMaterials;i++){ ... }

for(uint i=0;i<scene->mNumMeshes;i++){ ... }

Share this post


Link to post
Share on other sites
Yes, you're right on the mark there. I just figured that I should do it that way. I'm a little frustrated because they show example code that wouldn't or to me shouldn't work that do it the way I have the code shown in prev post.

In the samples it looked like they had a aiNode* pointing the the scene root and then use it to get the indices for where the mesh was in the scene. It doesn't work since root (which is not null) points to something I don't know?

thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this