aspose-free-consulting / projects

The starting point for Aspose free consulting projects
5 stars 5 forks source link

Scene.open() does not open file (aspose-3d-19.3.jar) #355

Closed fafayqa closed 6 months ago

fafayqa commented 6 months ago

Aspose.3d v19.3 (I have to use exactly this version as my NetBeans13 can use only major version 52 builds and this version is the last one with mv52): scene.open() does not work, and the file definitely exist at the specified path/directory (checked several times, even checked what path is sent to scene.open()). BTW that .dae file is produced by Blender 3.6.5 (I can provide the file if needed).

I used this example from your website (with no error in NetBeans):

// Load and open the input DAE file with the Scene class
Scene scene = new Scene();
scene.open(string-abs-pth-to-my-dae-file);

// Initialize an instance of ObjSaveOptions class
ObjSaveOptions options = new ObjSaveOptions();
options.setEnableMaterials(true);

// Convert DAE to OBJ File 
scene.save("Sample.obj", options);

It stops at the scene.open() - checked by adding simple System.err.println("OK") right before and after the scene.open(): the first one fires up but the 2nd one never outputs, which means there it stops as my app also hung-up/freeze there.

There is absolutely no need for any code/app sample as this is clearly only problem of this specific little piece of code of yours - my code stops wortking right at/after your scene.open().

And here is my very simple test file Java code:

package daetoobj;

import com.aspose.threed.ObjSaveOptions;
import com.aspose.threed.Scene;

import java.io.File;
import java.io.IOException;

public class DaeToObj {

    /**
     * @param args the command line arguments
     * @throws java.io.IOException
     */
    public static void main(String[] args) throws IOException {

        // Initialize new Scene class
        Scene scene = new Scene();

        System.err.println("++++++++++ OK1");
        String inputFile = "Z:/test.dae";
        System.err.println(inputFile);
        System.err.println("Does the input DAE file exist = " + new File(inputFile).exists());

        // Load the input DAE file
        scene.open(inputFile);

        System.err.println("++++++++++ OK2 - input DAE file opened successfully");

        // Initialize an instance of ObjSaveOptions class
        ObjSaveOptions options = new ObjSaveOptions();
        options.setEnableMaterials(true);

        scene.save("Z:/test.obj", options);
    }

}

But if I use the same file with your online DAE to OBJ converter here and I use exactly the same DAE file, it converts it with no problem.

fafayqa commented 6 months ago

I think I found where the problem is: this problem happens if a Collada DAE file contains any UV map, that is attribute "semantic" with value "TEXCOORD" under library_geometries->geometry->mesh->triangles, so this geometry would be OK:

<library_geometries>
<geometry id="_001_001-mesh" name="3001.001">
  <mesh>
    <source id="_001_001-mesh-positions">
      <float_array id="_001_001-mesh-positions-array" count="54438">-0.4 0.9600001 -1.2 2.8 0.9600001 -1.2 2.8 0 -1.2 -0.4 0 -1.2 ...many more values here</float_array>
      <technique_common>
        <accessor source="#_001_001-mesh-positions-array" count="18146" stride="3">
          <param name="X" type="float"/>
          <param name="Y" type="float"/>
          <param name="Z" type="float"/>
        </accessor>
      </technique_common>
    </source>
    <source id="_001_001-mesh-normals">
      <float_array id="_001_001-mesh-normals-array" count="61236">-0.991304 0 -0.1315919 -0.9978014 -1.40815e-7 -0.06627607 -0.9978014 ...many more values here</float_array>
      <technique_common>
        <accessor source="#_001_001-mesh-normals-array" count="20412" stride="3">
          <param name="X" type="float"/>
          <param name="Y" type="float"/>
          <param name="Z" type="float"/>
        </accessor>
      </technique_common>
    </source>
    <vertices id="_001_001-mesh-vertices">
      <input semantic="POSITION" source="#_001_001-mesh-positions"/>
    </vertices>
    <triangles material="MainSurface_Material_001-material" count="35584">
      <input semantic="VERTEX" source="#_001_001-mesh-vertices" offset="0"/>
      <input semantic="NORMAL" source="#_001_001-mesh-normals" offset="1"/>
      <p>4511 0 4517 1 4510 2 4512 3 4518 4 4511 0 4513 5 4519 6 4512 3 4513 5 4521 7 4520 8 4515 9 4521 7 4514 10 4516 11 4522 12 4515 ...many more values here</p>
    </triangles>
    <triangles material="Decoration1_Material_007-material" count="128">
      <input semantic="VERTEX" source="#_001_001-mesh-vertices" offset="0"/>
      <input semantic="NORMAL" source="#_001_001-mesh-normals" offset="1"/>
      <p>4560 78 4566 79 4559 80 4561 81 4567 82 4560 78 4562 83 4568 84 4561 81 4563 85 4569 86 4562 83 4564 87 4570 88 4563 85 4565 89 ...many more values here</p>
    </triangles>
  </mesh>
</geometry>
</library_geometries>

...but this one here would be not:

<library_geometries>
<geometry id="_001_001-mesh" name="3001.001">
  <mesh>
    <source id="_001_001-mesh-positions">
      <float_array id="_001_001-mesh-positions-array" count="54438">-0.4 0.9600001 -1.2 2.8 0.9600001 -1.2 2.8 0 -1.2 -0.4 0 -1.2 ...many more values here</float_array>
      <technique_common>
        <accessor source="#_001_001-mesh-positions-array" count="18146" stride="3">
          <param name="X" type="float"/>
          <param name="Y" type="float"/>
          <param name="Z" type="float"/>
        </accessor>
      </technique_common>
    </source>
    <source id="_001_001-mesh-normals">
      <float_array id="_001_001-mesh-normals-array" count="61209">-0.991304 0 -0.1315919 -0.9978014 -1.40815e-7 -0.06627607 -0.9978014 ...many more values here</float_array>
      <technique_common>
        <accessor source="#_001_001-mesh-normals-array" count="20403" stride="3">
          <param name="X" type="float"/>
          <param name="Y" type="float"/>
          <param name="Z" type="float"/>
        </accessor>
      </technique_common>
    </source>
    <source id="_001_001-mesh-map-0">
      <float_array id="_001_001-mesh-map-0-array" count="214272">0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...many more values here</float_array>
      <technique_common>
        <accessor source="#_001_001-mesh-map-0-array" count="107136" stride="2">
          <param name="S" type="float"/>
          <param name="T" type="float"/>
        </accessor>
      </technique_common>
    </source>
    <vertices id="_001_001-mesh-vertices">
      <input semantic="POSITION" source="#_001_001-mesh-positions"/>
    </vertices>
    <triangles material="MainSurface_Material_001-material" count="35584">
      <input semantic="VERTEX" source="#_001_001-mesh-vertices" offset="0"/>
      <input semantic="NORMAL" source="#_001_001-mesh-normals" offset="1"/>
      <input semantic="TEXCOORD" source="#_001_001-mesh-map-0" offset="2" set="0"/>
      <p>4511 0 0 4517 1 1 4510 2 2 4512 3 3 4518 4 4 4511 0 5 4513 5 6 4519 6 7 4512 3 8 4513 5 9 4521 7 10 4520 8 11 4515 9 12 4521 7 ...many more values here</p>
    </triangles>
    <triangles material="Decoration1_Material_007-material" count="128">
      <input semantic="VERTEX" source="#_001_001-mesh-vertices" offset="0"/>
      <input semantic="NORMAL" source="#_001_001-mesh-normals" offset="1"/>
      <input semantic="TEXCOORD" source="#_001_001-mesh-map-0" offset="2" set="0"/>
      <p>4560 78 192 4566 79 193 4559 80 194 4561 81 195 4567 82 196 4560 78 197 4562 83 198 4568 84 199 4561 81 200 4563 85 201 4569 86 ...many more values here</p>
    </triangles>
  </mesh>
</geometry>
</library_geometries>

If a Collada DAE file does not contain any UV map, it converts the file without any problem whatsoever...so possible BUG???

asadalikhan90 commented 6 months ago

@fafayqa

Looks like you have posted a similar inquiry in our official support forum where we have responded you accordingly. You may please follow up there.

fafayqa commented 6 months ago

Yes, that is correct - I will follow only there from now on, thank you.