Page 1 of 10

[Tool] .xmf/.xac <-> .dae converter

Posted: Tue, 24. Dec 13, 19:25
by arc_
This tool converts .xmf files (X Rebirth static meshes) and .xac files (EMotionFX actors) to and from .dae. The current version is 0.2.1 and can be downloaded here:
Converter
Source code (C++, VS2010)

Usage:
  • If you haven't already, extract all of the game's .dat files to some folder (eg using XCatTool).
  • Find an .xml file that you want to edit, e.g. assets\interiors\crates\interiors_crates_size_l.xml
  • Launch XRConvertersMain.exe from the command line, passing it the path to the folder where you extracted the .dat files and the path of the .xml file. For example:

Code: Select all

XRConvertersMain.exe importxmf "D:\X Rebirth files" "D:\X Rebirth files\assets\interiors\crates\interiors_crates_size_l.xml"
  • The converter will convert all the .xmf's referenced by the .xml and put them in a .dae file next to the .xml.
  • Edit the .dae file in a modeling program of choice.
  • Once you're done, run XRConvertersMain.exe again with the following arguments - it will overwrite the .xml and .xmf files:

Code: Select all

XRConvertersMain.exe exportxmf "D:\X Rebirth files" "D:\X Rebirth files\assets\interiors\crates\interiors_crates_size_l.dae"
Collision meshes and LOD meshes are indicated by a naming convention ("Xcollision" and "Xlod0" suffixes). The same goes for the material assignment ("collectionXmaterial" suffix in the node names).

Limitations:
  • You should only move nodes in the .dae file, not rotate or scale them; the converter will ignore such transformations (since I'm not sure how and if the .xml files support this). Rotate and scale the actual meshes instead.
  • Material definitions in the .dae are ignored, the converter simply takes the material name from the node name suffix and assigns that (i.e. you can only use materials that are defined in material_library.xml, be it by the game itself or an extension).
For .xac files, the steps are mostly the same. Simply specify an .xac file instead .xml, and use "importxac"/"exportxac" instead of "importxmf"/"exportxmf".

________
In case other people want to make tools that work with the X Rebirth file formats, here's some information about them:
.xac (NPC meshes)
.xmf (static meshes)
.xpm (morph-based animation for NPC's)
.xsm (skeleton-based animation for NPC's)

Re: [Tool] .xmf <-> .dae converter

Posted: Tue, 24. Dec 13, 19:32
by UniTrader
arc_ wrote:Limitations:
  • You should only move nodes in the .dae file, not rotate or scale them; the converter will ignore such transformations (since I'm not sure how and if the .xml files support this). Rotate and scale the actual meshes instead.

Code: Select all

<connection name="ConnectionFor_units_size_l_carrier_kit_extender1_b_2" tags="destructible">
  <offset>
    <position x="-3.415958E-05" y="-45" z="19.07472"/>
    <quaternion qx="0" qy="0" qz="1" qw="0"/>
  </offset>
</connection>
taken from my Rahanas Hybrid Plus-Mod ;) first three are rotation (qx, qy and qz ), but not sure what qw does..

Posted: Wed, 25. Dec 13, 16:15
by TargetLost
The Rotation is described through a Quaternion. A very interesting not quite easy to understand mathematic construct. You can google or wiki it up.

It always has 4 values and when its used to describe a rotation they are always normalized.
That means the absolut value or the length is always 1.
sqrt( qx^2 + qy^2 + qz^2 + qw^2) = 1

I believe the standard initialisation is qx="0" qy="0" qz="0" qw="1"
not quite sure about that and then you rotate it to what you want to have.
(there are formula for this)

Quaternions benefit are that you dont have a gimbal lock problem like you have it when you operate with Euler angles as much as I understand it.

@arc: you should add your file format specs links

Posted: Thu, 26. Dec 13, 09:27
by Fumblesneeze
Quaternions have the advantage that you can do rotation animation by linear interpolation, while this same task requires a lot of computing power if you have to work with sin/cos/etc calls in euclidian space.

To learn more, the orge engine has a nice little text about it:
http://www.ogre3d.org/tikiwiki/Quaterni ... ion+Primer

It also has a table of some useful quaternion rotations, e.g. 180° turns and 90° turns.

Posted: Thu, 26. Dec 13, 11:08
by Deleted User
amazing :) well done!

Posted: Sat, 28. Dec 13, 13:15
by arc_
Started working on an .xac converter as well. .xac -> .dae is as good as complete: body with complete skeleton and vertex weights, head with complete morph targets. If/when I get a working .dae -> .xac converter I'll post an update of the tool :)

Posted: Sat, 28. Dec 13, 17:56
by TargetLost
Just to make sure you dont miss it: I closed my .xac to .dae converter project. Found no more time or motivation for it.

I am glad to read you are already working on an own converter so I dont have to feel so bad letting the community down. :)

All the best and much success. :)

Doesn't seem to work.

Posted: Sun, 29. Dec 13, 15:55
by StephenWebb
I see that others have gotten this converter to work, but for some reason the program CTD. The assets are all unpacked, the first command line parameter is correct, and so is the second...is anyone else getting a CTD?

Posted: Sun, 29. Dec 13, 16:14
by UniTrader
this program has no GUI/Window and therefore cannt CTD - it simply does what it is told and then exits without saying anything further.. are there the converted files where you expect them?

CTD == Program Not Responding

Posted: Sun, 29. Dec 13, 16:26
by StephenWebb
Specifically the program doesn't work, it goes into Not Responding after the xml file and source directory where the .DAT files are given to it.

I had gotten it to respond correctly once, and it replied that access was denied so I changed permissions on the file and haven't been able to reproduce an instance where it didn't crash.

I changed the permissions back to the way they were and it just crashes now. I turned off my antivirus security as well, still nothing

Posted: Sun, 29. Dec 13, 17:25
by ICO_hr
Yep some files crashes the program or just dont want to convert to .dae because file doesnt contain any LOD's.

Posted: Sun, 29. Dec 13, 17:55
by arc_
If you have a crash/bug, please give *specific* details i.e.: what command line are you using, which file are you trying to import/export. If you're converting a .dae, upload it and provide a link. If you just say "it doesn't work" I can't help.

Posted: Sun, 29. Dec 13, 21:12
by killerog
So far after playing around with this tool today, I have been able to get a ship into 3dsmax/blender and export one with some minor changes. What I cant get it too do is show those changes in game. So if anyone has managed that part yet then any help would be great.

edit: One thing I have noticed is the ...._data.dae file is not updated and if you comment that out the game crashes. And it looks like it is linked to in the ....xml file.

Posted: Sun, 29. Dec 13, 21:26
by UniTrader
how did you try to get these changes in the Game? if its with an extension: did you make a new Ship from the received data? (making a diff could be a bit difficult ^^) or did you try to replace whole files? (which is not possible in Extensions for xmls - they are either merged or or diffed, but not replaced - you can replace the whole content though)

also see my rahanas hybrid plus extension on how to add a new Ship to the Game - basically its linking the macro and components in the respective index files so the Game knows they exist, define necescary materials in the wares.wml and add the macro to a Shipyard build Module

Posted: Sun, 29. Dec 13, 21:43
by killerog
Ill take a look at your mod and see what's different and go from there. Ill write something up once ive got a model in game if no one beats me to it.

Edit: Bit more info now im not eating. Im trying to replace a mode, not create a new one yet.

I have got a diff for both the components and macro files. I am guessing its the XML file for the model I need to change using a "diff" file. But as far as I can tell it uses the _data.dae file for model info. This line in the XML file
"<source geometry="assets\units\size_l\units_size_l_hydrogen_collector_data" />"

needs to become "<source geometry="extensions\SBMod_Test\assets\units\size_l\units_size_l_hydrogen_collector_data" />"

At the moment that file is not changing using this tool so I don't think it will work if even if I change the xml file correctly.

Posted: Sun, 29. Dec 13, 22:21
by arc_
If you're only changing existing meshes and not adding/moving/removing any, no changes are needed in the .xml - only the .xmf's change in this case. Since texture mods work by simply having a .dds file with the same name and the same relative folder as the original in the extension, I would expect the same to work for .xmf's. That being said, I also didn't get it to actually work... So far I've only seen that hhr got a modified .xmf ingame by overwriting the original inside the .dat.

Posted: Sun, 29. Dec 13, 22:46
by UniTrader
killerog wrote:Ill take a look at your mod and see what's different and go from there. Ill write something up once ive got a model in game if no one beats me to it.

Edit: Bit more info now im not eating. Im trying to replace a mode, not create a new one yet.

I have got a diff for both the components and macro files. I am guessing its the XML file for the model I need to change using a "diff" file. But as far as I can tell it uses the _data.dae file for model info. This line in the XML file
"<source geometry="assets\units\size_l\units_size_l_hydrogen_collector_data" />"

needs to become "<source geometry="extensions\SBMod_Test\assets\units\size_l\units_size_l_hydrogen_collector_data" />"

At the moment that file is not changing using this tool so I don't think it will work if even if I change the xml file correctly.
in short:
<diff>
<replace sel="//source[@geometry='assets\units\size_l\units_size_l_hydrogen_collector_data']/@geometry">extensions\SBMod_Test\assets\units\size_l\units_size_l_hydrogen_collector_data</replace>
</diff>

(a better/shorter sel value could be possible, eg the part in [] is not necesary if there is only one <source> node in the source file, but not sure about that currently)

Posted: Mon, 30. Dec 13, 00:15
by killerog
Thanks for that UniTrader. Ill try that out. Still not sure if that will work tho but we will see.

Posted: Mon, 30. Dec 13, 00:53
by killerog
Next interesting thing, using your line of code UniTrader and using a quick MD script that spawn that ship in the players zone. The ship is no longer appearing. Where as before I made the change it was there on ever start.

I wonder if the game if it knows a file is incorrect for some reason doesn't spawn the ships at all (unlike in X3 where you just got no model but the ship was there). Anyway that's me done for today, let me know if you have any more ideas.

Posted: Mon, 30. Dec 13, 00:56
by UniTrader
it would be interesting to know if there is anything related in the debuglog.txt