Wings 3D Development Forum
X Import for wpc_x - Printable Version

+- Wings 3D Development Forum (https://www.wings3d.com/forum)
+-- Forum: Wings 3D (https://www.wings3d.com/forum/forumdisplay.php?fid=1)
+--- Forum: Design & Development (https://www.wings3d.com/forum/forumdisplay.php?fid=6)
+--- Thread: X Import for wpc_x (/showthread.php?tid=3104)



X Import for wpc_x - edb - 04-26-2023

Hello,

I've added .x import to complement the export part of the wpc_x plugin. I've tested with various .x files and I've added a pull request.

wpc_x.tar

branch name: eb/x-import


RE: X Import for wpc_x - tkbd - 05-15-2023

I found and tried importing some x file models by googling.
It was difficult to find x file data...
The sites introduced below are programming tech blog so,sample models are simple.
In each site,there is a screenshot about the 3D model for itself.

Also,I installed Blender-XFileImporter for what kind model inside in the files.
Some sample files(Contain Animation,skinning,terrain) could not import even by Blender.
So you don't have to deal with everything.Smile

------------------------------------------------
Import failed
dosei.x in XMesh.cab
It is a charactor model with 3 material colors using.(9668polygons)
https://asura.iaigiri.com/OpenGL/gl44.html
https://asura.iaigiri.com/OpenGL/Download/XMesh/XMesh.cab
Import the file but nothing action.
------------------------------------------------
Import failed
Box.x it can download from Box.x XFile from a tutorial site.
https://yttm-work.jp/gmpg/gmpg_0022.html
It simple data just a cube only. But Import failed both of Wings3D and Blender.
Nothing happen(It has no UV data)
https://yttm-work.jp/res/gmpg/Box.x

Nothing happen
It simple data just a cube,all faces are textured(bomb.png) (12polygons)
https://yttm-work.jp/res/gmpg/BoxUV.x
https://yttm-work.jp/res/gmpg/bomb.png
------------------------------------------------

Import failed
car.x in xfile.lzh
https://t-pot.com/program/10_xfile/index.html
https://t-pot.com/program/10_xfile/xfile.lzh
It is a simple car model that has 3 colored materials.(44polygons)
Author said the file it made by LightWave6.5 with DirectX Exporter plug-in.

output a following Error log
Code:
.x Import Error: function_clause in [{x_import,get_material_in_list,
       [[{word,"Material"},
         open,
         {word,"1.000000"},
         d2,
         {word,"1.000000"},
         d2,
         {word,"0.000000"},
         d2,
         {word,"1.000000"},
         d4,
         {word,"51.200001"},
         d2,
         {word,"0.000000"},
         d2,
         {word,"0.000000"},
         d2,
         {word,"0.000000"},
         d4,
         {word,"0.000000"},
         d2,
         {word,"0.000000"},
         d2,
         {word,"0.000000"},
         d4,close,
         {word,"Material"},
         open,
         {word,"0.156863"},
         d2,
         {word,"0.078431"},
         d2,
         {word,"0.000000"},
         d2,
         {word,"1.000000"},
         d4,
         {word,"51.200001"},
         d2,
         {word,"0.000000"},
         d2,
         {word,"0.000000"},
         d2,
         {word,"0.000000"},
         d4,
         {word,"0.000000"},
         d2,
         {word,"0.000000"},
         d2,
         {word,"0.000000"},
         d4,close,
         {word,"Material"},
         open,
         {word,"0.784314"},
         d2,
         {word,"0.784314"},
         d2,
         {word,"0.784314"},
         d2,
         {word,"1.000000"},
         d4,
         {word,"51.200001"},
         d2,
         {word,"0.000000"},
         d2,
         {word,"0.000000"},
         d2,
         {word,"0.000000"},
         d4,
         {word,"0.000000"},
         d2,
         {word,"0.000000"},
         d2,
         {word,"0.000000"},
         d4,close,close,close,close,close],
        []],
       [{file,"src/x_import.erl"},{line,667}]},
                                     {x_import,parse_mesh_material_list,1,
       [{file,"src/x_import.erl"},{line,640}]},
                                     {x_import,
       parse_frame_1_mesh_1_meshmtllist,2,
       [{file,"src/x_import.erl"},{line,517}]},
                                     {x_import,parse_frame_1_l,2,
       [{file,"src/x_import.erl"},{line,454}]},
                                     {x_import,parse_frame_1,1,
       [{file,"src/x_import.erl"},{line,467}]},
                                     {x_import,parse_frame_1_l,2,
       [{file,"src/x_import.erl"},{line,454}]},
                                     {x_import,parse_element,1,
       [{file,"src/x_import.erl"},{line,298}]},
                                     {x_import,parse_1,2,
       [{file,"src/x_import.erl"},{line,279}]},
                                     {x_import,import_x_file,1,
       [{file,"src/x_import.erl"},{line,210}]},
                                     {x_import,'-import_fun/1-fun-2-',2,
       [{file,"src/x_import.erl"},{line,79}]},
                                     {wpa,do_import,3,
       [{file,"wpa.erl"},{line,143}]},
                                     {lists,foldl,3,
       [{file,"lists.erl"},{line,1267}]},
                                     {wings_file,command,2,
       [{file,"wings_file.erl"},{line,232}]},
                                     {wings_develop,time_command,2,
       [{file,"wings_develop.erl"},{line,87}]},
                                     {wings,raw_command,4,
       [{file,"wings.erl"},{line,643}]},
                                     {wings_wm,handle_event,3,
       [{file,"wings_wm.erl"},{line,1039}]},
                                     {wings_wm,send_event,2,
       [{file,"wings_wm.erl"},{line,1005}]},
                                     {wings_wm,do_dispatch,2,
       [{file,"wings_wm.erl"},{line,897}]},
                                     {wings_wm,get_and_dispatch,0,
       [{file,"wings_wm.erl"},{line,692}]},
                                     {wings,init_part2,3,
       [{file,"wings.erl"},{line,108}]},
                                     {proc_lib,init_p_do_apply,3,
       [{file,"proc_lib.erl"},{line,226}]}]
------------------------------------------------
Import failed
kyouko00.x in the dx3d07.zip
https://ss1.xrea.com/pipan9737.g1.xrea.com/DirectX/DirectX9.htm#item07
https://ss1.xrea.com/pipan9737.g1.xrea.com/download.cgi?name=dx3d07&type=zip
It is famele model with bone skinninged
Code:
Reason: {badmatch,{error,none}}

Stack trace:
[{x_import,import_mat_image,1,[{file,"src/x_import.erl"},{line,156}]},
{x_import,import_mat,2,[{file,"src/x_import.erl"},{line,135}]},
{x_import,'-import_fun/1-lc$^1/1-1-',1,[{file,"src/x_import.erl"},{line,82}]},
{x_import,'-import_fun/1-lc$^1/1-1-',1,[{file,"src/x_import.erl"},{line,82}]},
{x_import,'-import_fun/1-fun-2-',2,[{file,"src/x_import.erl"},{line,82}]},
{wpa,do_import,3,[{file,"wpa.erl"},{line,143}]},
{lists,foldl,3,[{file,"lists.erl"},{line,1267}]},
{wings_file,command,2,[{file,"wings_file.erl"},{line,232}]},
{wings_develop,time_command,2,[{file,"wings_develop.erl"},{line,87}]},
{wings,raw_command,4,[{file,"wings.erl"},{line,643}]},
{wings_wm,handle_event,3,[{file,"wings_wm.erl"},{line,1039}]},
{wings_wm,send_event,2,[{file,[...]},{line,...}]},
{wings_wm,do_dispatch,2,[{file,...},{...}]},
{wings_wm,get_and_dispatch,0,[{...}|...]},
{wings,init_part2,3,[...]},
{proc_lib,init_p_do_apply,3,...}]
------------------------------------------------
A following sites develop blender's plugin for xfiles.
And I cound found many x file data.
------------------------------------------------
io_import_x for blender plugin
https://github.com/poikilos/io_import_x
Success
test_cube_text.x -----OK, a simple cube
Testwuson.X --------OK, it is a cow lowpoly model
BCN_Epileptic.X --------OK, it is a human lowpoly model

Nothing happen
directxterrain.x ----- No object appeared in Blender,too.

No support : ".x import error" error dialog appeared
incrediblylongname.x ----- Textured dice,(12polygons)
blender_xport_sphere_locate369.x ----A sphere model
blender_xport.x
tests_exportX_armaBoneParent.x
tests_exportX_armatured.x
tests_exportX_parented_empties.x
tests_exportX_parented.x
tests_exportX.x
wispwind_mac.x ---- Line feed code = CR (Old Mac's format)
wispwind_unix.x --- Line feed code = LF, A soldier model,(3058polygons)
wispwind.x LF --- Line feed code = LF


Wings3D output Crash log
non_inline_data.x --- bad data, Blender output Error log too
commented.x ----- Blender output Error log too
Code:
.x Import Error: unexpected in [{x_import,parse_element_unknown,3,
                                    [{file,"src/x_import.erl"},{line,328}]},
                                {x_import,parse_1,2,
                                    [{file,"src/x_import.erl"},{line,279}]},
                                {x_import,import_x_file,1,
                                    [{file,"src/x_import.erl"},{line,210}]},
                                {x_import,'-import_fun/1-fun-2-',2,
                                    [{file,"src/x_import.erl"},{line,79}]},
                                {wpa,do_import,3,
                                    [{file,"wpa.erl"},{line,143}]},
                                {lists,foldl,3,
                                    [{file,"lists.erl"},{line,1267}]},
                                {wings_file,command,2,
                                    [{file,"wings_file.erl"},{line,232}]},
                                {wings_develop,time_command,2,
                                    [{file,"wings_develop.erl"},{line,87}]},
                                {wings,raw_command,4,
                                    [{file,"wings.erl"},{line,643}]},
                                {wings_wm,handle_event,3,
                                    [{file,"wings_wm.erl"},{line,1039}]},
                                {wings_wm,send_event,2,
                                    [{file,"wings_wm.erl"},{line,1005}]},
                                {wings_wm,do_dispatch,2,
                                    [{file,"wings_wm.erl"},{line,897}]},
                                {wings_wm,get_and_dispatch,0,
                                    [{file,"wings_wm.erl"},{line,692}]},
                                {wings,init_part2,3,
                                    [{file,"wings.erl"},{line,108}]},
                                {proc_lib,init_p_do_apply,3,
                                    [{file,"proc_lib.erl"},{line,226}]}]

------------------------------------------------
https://github.com/oguna/Blender-XFileImporter
Success
test_cube_text.x -----OK, a simple cube
Testwuson.X --------OK, it is a cow model
BCN_Epileptic.X --------OK, it is a human body model

No support : ".x import error" error dialog appeared
anim_test.x
test.x (Simple Texture test)
kwxport_test_cubewithvcolors.x
models-nonbsd/dwarf.x ----- A dwarf with hand axe,textured(1896polygons)

Wings3D output Crash log
test_cube_compressed.x
test_cube_binary.x
fromtruespace_bin32.x -------- A green colored dinosaur.6656poly

for example a following log.
Code:
Dump written 2023-5-15_18-9
Version: 2.2.9
Window: geom
Reason: function_clause

Short stack trace:
[{x_import,x_str,2,[{file,"src/x_import.erl"},{line,265}]},
{x_import,xf,3,[{file,"src/x_import.erl"},{line,238}]},
{x_import,import_x_file,1,[{file,"src/x_import.erl"},{line,206}]},
{x_import,'-import_fun/1-fun-2-',2,[{file,"src/x_import.erl"},{line,79}]},
{wpa,do_import,3,[{file,"wpa.erl"},{line,143}]},
{lists,foldl,3,[{file,"lists.erl"},{line,1267}]},
{wings_file,command,2,[{file,"wings_file.erl"},{line,232}]},
{wings_develop,time_command,2,[{file,"wings_develop.erl"},{line,87}]},
{wings,raw_command,4,[{file,"wings.erl"},{line,643}]},
{wings_wm,handle_event,3,[{file,"wings_wm.erl"},{line,1039}]},
{wings_wm,send_event,2,[{file,"wings_wm.erl"},{line,1005}]},
{wings_wm,do_dispatch,2,[{file,"wings_wm.erl"},{line,897}]},
{wings_wm,get_and_dispatch,0,[{file,"wings_wm.erl"},{line,692}]},
{wings,init_part2,3,[{file,"wings.erl"},{line,108}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]

Long stack trace:
[{x_import,x_str,
           [<<>>,
            [0,11,0,11,0,11,0,11,0,0,0,0,0,0,0,0,0,0,0,0,61,204,204,204,61,
             204,204,204,61,204,204,204,66,142,0,0,63,128,0,0,0,0,0|...]],
           [{file,"src/x_import.erl"},{line,265}]},
{x_import,xf,3,[{file,"src/x_import.erl"},{line,238}]},
{x_import,import_x_file,1,[{file,"src/x_import.erl"},{line,206}]},
{x_import,'-import_fun/1-fun-2-',2,[{file,"src/x_import.erl"},{line,79}]},
{wpa,do_import,3,[{file,"wpa.erl"},{line,143}]},
{lists,foldl,3,[{file,"lists.erl"},{line,1267}]},
{wings_file,command,2,[{file,"wings_file.erl"},{line,232}]},
{wings_develop,time_command,2,[{file,"wings_develop.erl"},{line,87}]},
{wings,raw_command,4,[{file,"wings.erl"},{line,643}]},
{wings_wm,handle_event,3,[{file,"wings_wm.erl"},{line,1039}]},
{wings_wm,send_event,2,[{file,"wings_wm.erl"},{line,1005}]},
{wings_wm,do_dispatch,2,[{file,"wings_wm.erl"},{line,897}]},
{wings_wm,get_and_dispatch,0,[{file,"wings_wm.erl"},{line,692}]},
{wings,init_part2,3,[{file,"wings.erl"},{line,108}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]

OS: macOS Mojave Version 10.14.6 (Build 18G9323)
GPU: Intel Inc. | Intel Iris OpenGL Engine
------------------------------------------------
https://github.com/adrs2002/threeXfileLoader
https://github.com/adrs2002/threeXfileLoader/tree/master/sample/content
Success
Nothing happen
attack.x
stand.x
track.x----- Kahki colored army truck,textured(1002polygons)
wark.x
SSR06_anime.x
SSR06_init.x

NO support : ".x import error" error dialog appeared
tank_1.x ----- Textured octagonal prism,broken? (38polygons)
SSR06_model.x


RE: X Import for wpc_x - edb - 05-19-2023

Thanks tkbd, I'll be looking into those .x files soon.
I might also implement binary support.


RE: X Import for wpc_x - edb - 05-23-2023

I've made a bunch of fixes after trying the different files,

The newest beam build of x_import.beam:
wpc_x_import_1.tar


RE: X Import for wpc_x - edb - 09-04-2023

Hello,

While doing tests with the importer a few months ago I've noticed the exporter wasn't making the models "left handed".

I've found some time to make a change to DirectX export to add handedness and the models can be exported "left handed", with "right handed" being the same as before.
wpc_x.tar

My github branch for this change is:
eb/x-export-handedness