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

The place to discuss scripting and game modifications for X Rebirth.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

Post Reply
User avatar
arc_
Posts: 62
Joined: Sat, 7. Dec 13, 20:30

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

Post by arc_ » Tue, 24. Dec 13, 19:25

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)
Last edited by arc_ on Tue, 24. Jun 14, 21:42, edited 7 times in total.

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

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

Post by UniTrader » Tue, 24. Dec 13, 19:32

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..
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

TargetLost
Posts: 474
Joined: Wed, 23. Nov 05, 20:27
x3tc

Post by TargetLost » Wed, 25. Dec 13, 16:15

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

User avatar
Fumblesneeze
Posts: 75
Joined: Tue, 26. Nov 13, 10:07
x3tc

Post by Fumblesneeze » Thu, 26. Dec 13, 09:27

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.
Streaming while writing mods: twitch.tv/fumblesneeze

Deleted User

Post by Deleted User » Thu, 26. Dec 13, 11:08

amazing :) well done!

User avatar
arc_
Posts: 62
Joined: Sat, 7. Dec 13, 20:30

Post by arc_ » Sat, 28. Dec 13, 13:15

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 :)

TargetLost
Posts: 474
Joined: Wed, 23. Nov 05, 20:27
x3tc

Post by TargetLost » Sat, 28. Dec 13, 17:56

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. :)

StephenWebb
Posts: 3
Joined: Sun, 10. Nov 13, 19:07
x4

Doesn't seem to work.

Post by StephenWebb » Sun, 29. Dec 13, 15:55

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?

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Sun, 29. Dec 13, 16:14

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?
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

StephenWebb
Posts: 3
Joined: Sun, 10. Nov 13, 19:07
x4

CTD == Program Not Responding

Post by StephenWebb » Sun, 29. Dec 13, 16:26

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

ICO_hr
Posts: 415
Joined: Sat, 31. Aug 13, 17:56

Post by ICO_hr » Sun, 29. Dec 13, 17:25

Yep some files crashes the program or just dont want to convert to .dae because file doesnt contain any LOD's.

User avatar
arc_
Posts: 62
Joined: Sat, 7. Dec 13, 20:30

Post by arc_ » Sun, 29. Dec 13, 17:55

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.

killerog
Posts: 3464
Joined: Fri, 28. Oct 05, 16:31
x4

Post by killerog » Sun, 29. Dec 13, 21:12

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.
Image

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Sun, 29. Dec 13, 21:26

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
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

killerog
Posts: 3464
Joined: Fri, 28. Oct 05, 16:31
x4

Post by killerog » Sun, 29. Dec 13, 21:43

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.
Image

User avatar
arc_
Posts: 62
Joined: Sat, 7. Dec 13, 20:30

Post by arc_ » Sun, 29. Dec 13, 22:21

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.

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Sun, 29. Dec 13, 22:46

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)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

killerog
Posts: 3464
Joined: Fri, 28. Oct 05, 16:31
x4

Post by killerog » Mon, 30. Dec 13, 00:15

Thanks for that UniTrader. Ill try that out. Still not sure if that will work tho but we will see.
Image

killerog
Posts: 3464
Joined: Fri, 28. Oct 05, 16:31
x4

Post by killerog » Mon, 30. Dec 13, 00:53

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.
Image

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Mon, 30. Dec 13, 00:56

it would be interesting to know if there is anything related in the debuglog.txt
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

Post Reply

Return to “X Rebirth - Scripts and Modding”