AB4D Forum
Exporting Models - Printable Version

+- AB4D Forum (https://forum.ab4d.com)
+-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4)
+--- Forum: Ab3d.PowerToys (https://forum.ab4d.com/forumdisplay.php?fid=9)
+--- Thread: Exporting Models (/showthread.php?tid=4248)



Exporting Models - GraPhiX - 03-11-2021

I am loading in OBJ models and rotating them, i then export to FBX using assimp exporter, i am exporting the viewport that contains the model because if i just try to export the model the transform is not saved, this is probably down to me doing something wrong.

I have attached a screenshot of a model i have exported and loaded back in as you can see from the info it is a Model3DGroup with 3 items all i want is to export the Transformed model how can i do this?

code for exporting (VB.NET)
Code:
Private Function ExportViewport3D(ByVal fileName As String, ByVal exportFormatId As String, ByVal viewport3D As Viewport3D, ByVal namedObjects As Dictionary(Of String, Object)) As Boolean
       Dim assimpWpfExporter = New AssimpWpfExporter()
       Dim ModelPath As String = Path.GetDirectoryName(_fileName)
       If exportFormatId = "x" Then
           assimpWpfExporter.ExportFullTexturePaths = False
       End If

       assimpWpfExporter.NamedObjects = _namedObjects

       assimpWpfExporter.AddViewport3D(_viewport3D)

       Dim isExported As Boolean

       Try

           Dim MyFileName As String = Path.GetFileNameWithoutExtension(_fileName)
           Dim MyExt As String = MyFileName & "." & _selectedExportFormatId
           SFD_Export.Filter = "3D model file (*.*)|*.*"
           SFD_Export.FileName = MyExt
           If SFD_Export.ShowDialog = DialogResult.OK Then

               isExported = assimpWpfExporter.Export(SFD_Export.FileName, exportFormatId)
               ExportedFileName = SFD_Export.FileName
           Else

           End If
           If Not isExported Then MsgBox("Asset Not exported", vbOKOnly & vbCritical, "Export Error")

       Catch ex As Exception

           MsgBox("Error exporting:" & vbCrLf & ex.Message, vbOKOnly & vbCritical, "Export Error")
           isExported = False
           Me.Close()
       End Try
       If isExported = True Then
           MsgBox("Model exported : " + SFD_Export.FileName, vbOKOnly & vbInformation, "Export Completed")
       End If

       ContentVisual.Children.Remove(ContentWireframeVisual)


       Return isExported


   End Function
   


RE: Exporting Models - abenedik - 03-12-2021

I see now that this is a problem in the native assimp exporter - it seems that when exporting to fbx the transformation on the root element is not exported. If you export to some other file format, for example dae or gltf, then the transformation is exported correctly, but this does not work for fbx.

A solution to this problem is to add a parent Model3DGroup or ModelVisual3D, then assign our Model3DGroup to that new parent and export the new parent.


RE: Exporting Models - GraPhiX - 03-12-2021

(03-12-2021, 10:12 AM)abenedik Wrote: I see now that this is a problem in the native assimp exporter - it seems that when exporting to fbx the transformation on the root element is not exported. If you export to some other file format, for example dae or gltf, then the transformation is exported correctly, but this does not work for fbx.

A solution to this problem is to add a parent Model3DGroup or ModelVisual3D, then assign our Model3DGroup to that new parent and export the new parent.

Hi thank you :) can you show me this with code C# is fine, i can then follow your code to see what to do