Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. My 3d rendering application crashes if textures not found

My 3d rendering application crashes if textures not found

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt5.73drendertextureassimp-cpp
7 Posts 3 Posters 2.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Poorti
    wrote on 29 Sept 2016, 16:01 last edited by
    #1

    Hi!

    I have created a sample application to render 3d models using the assimp-cpp sample. I am using Qt5.7.
    The application is meant to work for both win and mac environments.

    Now, I had been working first on Windows, and was able to create a working application that loads and displays .dae files.
    These files also use image textures. I noted, that if the application could not locate the textures(incorrect path etc.), it just crashed without giving any additional info.

    Same thing happens on Mac as well.

    How can I ensure that my application does not crash, and the scenario is handled appropriately?
    Any exception handling that I can do?

    Here is a link to the assimp-cpp sample in qt5.7.

    Please guide me here. I am very new to Qt.

    J 1 Reply Last reply 30 Sept 2016, 04:56
    0
    • P Poorti
      29 Sept 2016, 16:01

      Hi!

      I have created a sample application to render 3d models using the assimp-cpp sample. I am using Qt5.7.
      The application is meant to work for both win and mac environments.

      Now, I had been working first on Windows, and was able to create a working application that loads and displays .dae files.
      These files also use image textures. I noted, that if the application could not locate the textures(incorrect path etc.), it just crashed without giving any additional info.

      Same thing happens on Mac as well.

      How can I ensure that my application does not crash, and the scenario is handled appropriately?
      Any exception handling that I can do?

      Here is a link to the assimp-cpp sample in qt5.7.

      Please guide me here. I am very new to Qt.

      J Online
      J Online
      jsulm
      Lifetime Qt Champion
      wrote on 30 Sept 2016, 04:56 last edited by
      #2

      @Poorti Well, in your main() function you do:

      if (sourceFileName.isEmpty())
              return 0;
       
      sceneLoader->setSource(sourceFileName);
      

      So, if you do not have a file name you just return - returning in main() means exit the program.
      You should do:

      if (!sourceFileName.isEmpty())
              sceneLoader->setSource(sourceFileName);
      

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Poorti
        wrote on 30 Sept 2016, 08:39 last edited by
        #3

        Thanks for the response..

        Modifying the code to what you suggested won't work either because sourceFileName contains the name of the .dae file. The .dae file is present on the system and is found.

        My problem is when the 3d model is parsed, it looks for textures referred in the .dae..
        If you open the .dae as text, you'll see the references, for eg,

        <library_images>
        	<image id="Front_png-image" name="Front_png">
        		<init_from>file://Textures\Front.png</init_from>
        	</image>
        	<image id="Back_png-image" name="Back_png">
        		<init_from>file://Textures\Back.png</init_from>
        	</image>
        	<image id="Right_Arm_png-image" name="Right_Arm_png">
        		<init_from>file://Textures\Right-Arm.png</init_from>
        	</image>
        	<image id="Left_Arm_png-image" name="Left_Arm_png">
        		<init_from>file://Textures\Left-Arm.png</init_from>
        	</image>
        </library_images>
        

        The above is how my .dae file appears on my Windows machine.
        Now, if these images are missing on disk, the crash happens.
        I thought the .dae files are cross platform, so tried the same on Mac. It crashed.
        Also, what is with the path separators..? This file won't load textures on my Mac, and so it crashes.

        J 1 Reply Last reply 30 Sept 2016, 11:46
        0
        • P Poorti
          30 Sept 2016, 08:39

          Thanks for the response..

          Modifying the code to what you suggested won't work either because sourceFileName contains the name of the .dae file. The .dae file is present on the system and is found.

          My problem is when the 3d model is parsed, it looks for textures referred in the .dae..
          If you open the .dae as text, you'll see the references, for eg,

          <library_images>
          	<image id="Front_png-image" name="Front_png">
          		<init_from>file://Textures\Front.png</init_from>
          	</image>
          	<image id="Back_png-image" name="Back_png">
          		<init_from>file://Textures\Back.png</init_from>
          	</image>
          	<image id="Right_Arm_png-image" name="Right_Arm_png">
          		<init_from>file://Textures\Right-Arm.png</init_from>
          	</image>
          	<image id="Left_Arm_png-image" name="Left_Arm_png">
          		<init_from>file://Textures\Left-Arm.png</init_from>
          	</image>
          </library_images>
          

          The above is how my .dae file appears on my Windows machine.
          Now, if these images are missing on disk, the crash happens.
          I thought the .dae files are cross platform, so tried the same on Mac. It crashed.
          Also, what is with the path separators..? This file won't load textures on my Mac, and so it crashes.

          J Online
          J Online
          jsulm
          Lifetime Qt Champion
          wrote on 30 Sept 2016, 11:46 last edited by
          #4

          @Poorti Did you try to replace \ with / ?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • P Offline
            P Offline
            Poorti
            wrote on 30 Sept 2016, 12:20 last edited by
            #5

            Yes, I tried replacing the path separators.
            Doing so, the application loads the model and displays it. But textures are missing.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              m.sue
              wrote on 30 Sept 2016, 12:33 last edited by m.sue
              #6

              Hi,
              file://Textures/Front.png is a relative path Textures/Front.png, isn't it. But relative to what? To the current path of the application or to the .dae file?
              -Michael.

              1 Reply Last reply
              0
              • P Offline
                P Offline
                Poorti
                wrote on 3 Oct 2016, 07:20 last edited by
                #7

                It should be relative to the .dae..
                I am saying this because, I tried opening it using FBX Review which renders 3d.
                FBX Review loaded the 3d model without the textures.

                Moreover, the application does not know anything about textures. It just renders whatever is in the .dae
                and all the information about the textures is inside the .dae...

                My concern is that if some .dae file is created on Windows which refers textures as in my example, how will I be able to open the same on Mac (with textures), and vice-versa.

                I tried changing the path to full path too in the .dae.
                No change.

                1 Reply Last reply
                0

                1/7

                29 Sept 2016, 16:01

                • Login

                • Login or register to search.
                1 out of 7
                • First post
                  1/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved