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
QtWS25 Last Chance

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.
  • PoortiP Offline
    PoortiP Offline
    Poorti
    wrote on 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.

    jsulmJ 1 Reply Last reply
    0
    • PoortiP Poorti

      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.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on 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
      • PoortiP Offline
        PoortiP Offline
        Poorti
        wrote on 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.

        jsulmJ 1 Reply Last reply
        0
        • PoortiP Poorti

          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.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on 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
          • PoortiP Offline
            PoortiP Offline
            Poorti
            wrote on 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.sueM Offline
              m.sueM Offline
              m.sue
              wrote on 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
              • PoortiP Offline
                PoortiP Offline
                Poorti
                wrote on 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

                • Login

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