Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

NULL face pointers on C++ importer.

Help
andreucm
2014-03-24
2014-05-16
  • andreucm
    andreucm
    2014-03-24

    Dear all,

    I'm just trying to import some .obj models by using the C++ interface. I get valid (non NULL) scene pointer, with a positive number of faces for the most of the meshes, but however the pointers to face data are always NULL.

    Below, I attach a small main() that isolates the problem (just the first mesh of the firts node). Thereafter I've also attached the output of the program. Please see after the logger output, how, even if a mesh of a node has a positive number of faces, its method HasFaces() returns false, and its pointer to these faces is NULL.

    Do you have some advice on what is happening ? Am I using correctly the C++ interface ?

    I'm using assimp 3.0.1264. (I don't know why the logger says "Assimp 2.0.863")

    #include <iostream>
    #include <assimp/Importer.hpp> // C++ importer interface
    #include <assimp/scene.h> // Output data structure
    #include <assimp/postprocess.h> // Post processing flags
    #include <assimp/Logger.h> // logger
    #include <assimp/DefaultLogger.h> // logger
    
    int main()
    {
          //importer
          Assimp::Importer importer;
    
          //logger
          Assimp::DefaultLogger::create("", Assimp::Logger::VERBOSE, aiDefaultLogStream_STDOUT);
    
          //import a given file
          const aiScene* scene = importer.ReadFile( "../models/secretarysDesk.obj", 
                                                    aiProcess_CalcTangentSpace | 
                                                    aiProcess_Triangulate | 
                                                    aiProcess_JoinIdenticalVertices | 
                                                    aiProcess_SortByPType);
    
          //kill here the logger, just to see what has happened with the importer
          Assimp::DefaultLogger::kill();
    
          //check if scene
          if (scene == NULL) 
          {
                std::cout << __LINE__ << ": Error importing scene. Check if file exists ! " << std::endl;
                return -1; 
          }
          else 
          {
              int meshIdx = scene->mRootNode->mChildren[0]->mMeshes[0];
              std::cout << __LINE__ << ": mNumFaces: " << scene->mMeshes[meshIdx]->mNumFaces << std::endl;
              std::cout << __LINE__ << ": HasFaces(): " << scene->mMeshes[meshIdx]->HasFaces() << std::endl;
              std::cout << __LINE__ << ": ptr mFace[0]: " << &(scene->mMeshes[meshIdx]->mFaces[0]) << std::endl;            
          }
    
          //exit main
          return 0; 
    }
    

    And the ouptut is the following:

    andreu@rocgros:~/dev/btr-libs/faramotics/build$ ../bin/assimpTest 
    Info,  T0: Load ../models/secretarysDesk.obj
    Debug, T0: Assimp 2.0.863 amd64 gcc debug shared singlethreaded
    Info,  T0: Found a matching importer for this file format
    Info,  T0: Import root directory is '../models/'
    Info,  T0: Entering post processing pipeline
    Debug, T0: TriangulateProcess begin
    Debug, T0: TriangulateProcess finished. There was nothing to be done.
    Debug, T0: SortByPTypeProcess begin
    Info,  T0: Points: 0, Lines: 0, Triangles: 31, Polygons: 0 (Meshes, X = removed)
    Debug, T0: SortByPTypeProcess finished
    Debug, T0: Generate spatially-sorted vertex cache
    Debug, T0: CalcTangentsProcess begin
    Error, T0: Unable to compute tangents: UV0 and normals must be there 
    Skipping one or more lines with the same contents
    Debug, T0: CalcTangentsProcess finished
    Debug, T0: JoinVerticesProcess begin
    Debug, T0: Mesh 0 (unnamed) | Verts in: 864 out: 146 | ~83.1019%
    Debug, T0: Mesh 1 (unnamed) | Verts in: 1104 out: 186 | ~83.1522%
    Debug, T0: Mesh 2 (unnamed) | Verts in: 1104 out: 186 | ~83.1522%
    Debug, T0: Mesh 3 (unnamed) | Verts in: 72 out: 14 | ~80.5556%
    Debug, T0: Mesh 4 (unnamed) | Verts in: 72 out: 14 | ~80.5556%
    Debug, T0: Mesh 5 (unnamed) | Verts in: 2280 out: 382 | ~83.2456%
    Debug, T0: Mesh 6 (unnamed) | Verts in: 72 out: 14 | ~80.5556%
    Debug, T0: Mesh 7 (unnamed) | Verts in: 264 out: 46 | ~82.5758%
    Debug, T0: Mesh 8 (unnamed) | Verts in: 264 out: 46 | ~82.5758%
    Debug, T0: Mesh 9 (unnamed) | Verts in: 156 out: 28 | ~82.0513%
    Debug, T0: Mesh 10 (unnamed) | Verts in: 156 out: 28 | ~82.0513%
    Debug, T0: Mesh 11 (unnamed) | Verts in: 72 out: 14 | ~80.5556%
    Debug, T0: Mesh 12 (unnamed) | Verts in: 72 out: 14 | ~80.5556%
    Debug, T0: Mesh 13 (unnamed) | Verts in: 72 out: 14 | ~80.5556%
    Debug, T0: Mesh 14 (unnamed) | Verts in: 72 out: 14 | ~80.5556%
    Debug, T0: Mesh 15 (unnamed) | Verts in: 72 out: 14 | ~80.5556%
    Debug, T0: Mesh 16 (unnamed) | Verts in: 72 out: 14 | ~80.5556%
    Debug, T0: Mesh 17 (unnamed) | Verts in: 72 out: 14 | ~80.5556%
    Debug, T0: Mesh 18 (unnamed) | Verts in: 72 out: 14 | ~80.5556%
    Debug, T0: Mesh 19 (unnamed) | Verts in: 180 out: 32 | ~82.2222%
    Debug, T0: Mesh 20 (unnamed) | Verts in: 180 out: 32 | ~82.2222%
    Debug, T0: Mesh 21 (unnamed) | Verts in: 7488 out: 1250 | ~83.3066%
    Debug, T0: Mesh 22 (unnamed) | Verts in: 7488 out: 1250 | ~83.3066%
    Debug, T0: Mesh 23 (unnamed) | Verts in: 7488 out: 1250 | ~83.3066%
    Debug, T0: Mesh 24 (unnamed) | Verts in: 7488 out: 1250 | ~83.3066%
    Debug, T0: Mesh 25 (unnamed) | Verts in: 7488 out: 1250 | ~83.3066%
    Debug, T0: Mesh 26 (unnamed) | Verts in: 7488 out: 1250 | ~83.3066%
    Debug, T0: Mesh 27 (unnamed) | Verts in: 7488 out: 1250 | ~83.3066%
    Debug, T0: Mesh 28 (unnamed) | Verts in: 7488 out: 1250 | ~83.3066%
    Debug, T0: Mesh 29 (unnamed) | Verts in: 72 out: 14 | ~80.5556%
    Debug, T0: Mesh 30 (unnamed) | Verts in: 654 out: 111 | ~83.0275%
    Info,  T0: JoinVerticesProcess finished | Verts in: 67974 out: 11391 | ~83.2%
    Info,  T0: Leaving post processing pipeline
    39: mNumFaces: 288
    40: HasFaces(): 0
    41: ptr mFace[0]: 0
    

    THank you very much !

    Andreu

     
  • Kim Kulling
    Kim Kulling
    2014-03-25

    This is an interesting result: The faces have not been stored. Do you have an example to reproduce this issue?

    And thanks for the report :-)...

    Kimmi

     
  • andreucm
    andreucm
    2014-04-29

    Hi,

    how the issue is evolving ? Is there anyone working on it ?

    Please let me know if you need some extra failing code.

    Thanks !

    Andreu

     
  • Kim Kulling
    Kim Kulling
    2014-04-29

    HI,

    I took a look into the code and I wasn't able to see an issue. And I cannot find your mail with the model, maybe my spam filter was too careful. Could you please upload the file fore relasing the next version.

    at github ( gist )? That would be great. I can work on this issue in the next days before the 3.1 release.

    Kimmi

     
  • andreucm
    andreucm
    2014-05-06

    DEar Kimmi,
    I uploaded the model in this forum on 26March. I attach it again.
    GitHUb issue-tracker does not allow me to upload non-image files.
    Please, tell me if you need some extra information,

    Thanks,
    andreu

     
    Last edit: andreucm 2014-05-06
  • Kim Kulling
    Kim Kulling
    2014-05-06

    Ops sorry, I just looked into the false forum :-(.

    Kimmi

     
  • Not sure if this is a bug. I am using a build from the weekend and I can load the model no problem. I have attached the result. You could possibly test it on the latest build and do a diff with the Obj*.cpp files.

     
    Attachments
  • andreucm
    andreucm
    2014-05-09

    Dear all,

    I've discovered that I had an old assimp version 2.0 at /usr/include and at /usr/lib, so CMake took first that old version than the newest installed at /usr/local/include and /usr/local/lib !!

    I've removed the old lib and headers and things go well ! (hope no other program in my machine were using them ... :-)

    Thanks Kimmi for the support and thanks Jonathan for giving me the hope with your clear evidence attaching the Desk.PNG.

    I'm sorry for posting this false bug ! You can label it as Solved!

    By the way, to avoid such false issues, I suggest that with the installation, you could install also a file Findassimp.cmake at ${CMAKE_ROOT}/Modules/ (typically /usr/share/cmake-2.8/Modules) by just including the following line at your CMakeLists.txt:

    INSTALL(FILES ../Findassimp.cmake DESTINATION ${CMAKE_ROOT}/Modules/)
    

    I attach an instance of such Find*.cmake file for another project called faramotics, just you have a starting point. Having this file installed at ${CMAKE_ROOT}/Modules/ would allow to use FIND_PACKAGE(assimp REQUIRED) to CMakeLists.txt requiring assimp lib, and correct paths to includes and libs would be automatically set.

    best regards,

    andreu

     
    Last edit: andreucm 2014-05-09
    Attachments
  • Kim Kulling
    Kim Kulling
    2014-05-11

    Thanks a lot for the hint. I have just introdued one.

    Kimmi

     
  • andreucm
    andreucm
    2014-05-16

    ... aha!

    ROS rviz package (http://wiki.ros.org/rviz), is currently using assimp2.0 in its Hyrdo version!!

    I hope guys from ROS-OSRF will update that, ROS is a very active project.

    That was the origin of all this issue !

    Just for your knowledge

    best,

    andreu