X4: Foundations

X4: Foundations

Asp Sentinel
sprIder  [developer] 23 Aug, 2024 @ 2:52pm
Non-related: Modding other ships
This discussion is intended to provide a platform for all modding topics regarding ships that are not directly related to this mod.


We start with Lulu and the Teladi ships.

Rotation of weapons (turrets, engines etc)
Originally posted by Lulu:
I was wondering though if you had an idea on how to rotate a gun ? I put M weapons on fighters and some of them would look sweet if they where horizontal [..].

Answer
Rotation of objects are done with the "quaternion"-part at the corresponding connection in the components-file.
Have a look at the ship_tel_s_scout_01.xml file where you find the weapon-connection as following:

<connection name="con_weapon_01" tags="weapon small standard missile platformcollision combat "> <offset> <position x="0" y="-1.55986" z="10.35549"/> </offset> </connection>

To rotate the weapon 90°, you need e.g.
<quaternion qw="-0.707107" qx="-0.0" qy="0.0" qz="-0.707107"/>

-->

<connection name="con_weapon_01" tags="weapon small standard missile platformcollision combat "> <offset> <position x="0" y="-1.55986" z="10.35549"/> <quaternion qw="-0.707107" qx="-0.0" qy="0.0" qz="-0.707107"/> </offset> </connection>

To rotate 90° in the opposite direction it would be:
<quaternion qw="-0.707107" qx="0.0" qy="-0.0" qz="0.707107"/>


Adding additional weapons to Kestrel and Guillermot

Originally posted by Lulu:
[...] I just replaced the s weapon with an M an it kind of works but... I wonder how difficult it would be to setup like 4 guns in the nose of the kestrel and guillermot instead of the one ? [..].

Answer

In short: simple. I use Blender, import the model, position the weapon dummies, use this:
X4-Blender-Module-Drag-and-Drop [github.com]
to output the exact positions and rotations and then wrap it up nicely in a mod :)
On the other hand, it can look very ugly and squashed. Therefore:

  1. M or S Weapons?
  2. Adding them to the existing Kestrels or to a new Kestrel-variant?
  3. Should it be pretty and look good on the ship or just functional?
  4. Is it a problem if the weapons overlap each other?
< >
Showing 1-15 of 22 comments
Lulu 23 Aug, 2024 @ 3:39pm 
This is so neat ! Thank for making this space. I would like to add that rotation is also usefull for static places, like
<rotation yaw="0" pitch="0" roll="90"/>
after the <offset> position, to put some weapon horizontal but unmoving, which looks cool with railguns

I will try blender, extracting files and converting right now. I wonder also how you would go about making a weapon static ? like, removing the "auto aim" some got, like some lances do ?
Lulu 23 Aug, 2024 @ 4:43pm 
Ok, I tried. When you import the model, do I need to:
Import units ?
custom normals ?
fix leaf bones ?
find bone chains ?
auto connect ?

How do I position the weapon dummy ?
How do I use the blender module ? because the tutorials are very hard to follow

1: I wonder if making the ship bigger would make the M weapon work..
2: Variants seems to have only upsides.
3-4: pretty and balance are both very important I feel, overlap might be less egregious if the weapons move less ?
sprIder  [developer] 24 Aug, 2024 @ 3:19am 
Originally posted by Lulu:
I wonder also how you would go about making a weapon static ? like, removing the "auto aim" some got, like some lances do ?

I am not quite sure. But may have a look at the component-files of a boson lance weapon_spl_m_railgun_01_mk2.xml [\extensions\ego_dlc_split\assets\props\WeaponSystems\heavy] and a different weapon, e.g.
weapon_spl_m_gatling_01_mk2.xml
You' ll find some connections with
<restriction type="rotation_y"> <limits> <min value="-1"/> <max value="1"/> </limits> </restriction>
and
<restriction type="rotation_x"> <limits> <min value="-1"/> <max value="1"/> </limits> </restriction>
at the boson lance.
In contrast, the values for the other weapon are not “1” but “10” / not “-1” but “-10”. That's where I would start to test and play around.
Lulu 24 Aug, 2024 @ 3:51am 
I will try ! That would complete the look.

Unsure if this is "quick" but, it's hard to do anything in blender, I wonder, how would I go about just making a ship 20% bigger ? just straight-up resizing it, that way my M weapon slot would look better, instead of adding more S
sprIder  [developer] 24 Aug, 2024 @ 4:49am 
Originally posted by Lulu:
Ok, I tried. When you import the model, do I need to:
Import units ?
custom normals ?
fix leaf bones ?
find bone chains ?
auto connect ?

How do I position the weapon dummy ?

I will refer to the following picture: https://ibb.co/dGjQ8BD

Import: Just use the presets --> only "Custom Normals" is active.

For weapon dummys i created my own templates: additional templates [www.dropbox.com]

Before you import the ship: Hide or remove Camera, Cuve and Light. (Light blue rectangle). Use shift and Left Mouse at the eye symbol. Or right click on the object -> Delete Hierarchy.

After you imported the ship:
1. select in "Object Mode" (top left) with the Mouse / Select Box (left, red highlighted) the part of your ship, where you want to place new things. In this case: black circle.
--> Now at bottom right, red rectangle, there is a object path displayed. You'll find this object in the object tree / Collection above, orange rectangle.
2. Hide the collision part and the lod1 - lod3. This leaves only lod0, which is the most detailed geometry.
3. Import the weapon template, e.g. smweap_1_template.
4. Activate the magnet, top middle, blue rectangle. Activate "Face Project" and "Align Rotation to Target"
5. Select the weapon in the Collection tree on the right side. And on the left side, red rectangle, use "Move". Now move the weapon to your wanted location.

Originally posted by Lulu:
How do I use the blender module ? because the tutorials are very hard to follow

After you placed all the new objects,
1. select them with shift or ctrl and left mouse.
2. Export it with File -> export -> X3D Extensible 3D. Important:
a: Only have "Selection Only" selected.
b: At "Transform": Set "Y Forward" and "Z Up"
c: Nothing at "Geometry" is selected.
3. Now, start the "main.exe" from "X4-Blender-Module-Drag-and-Drop-master".
4. Top left, open your exported file.
5. If you have placed all weapons in blender, you can press "Start".
6. The programm generates a xml file with your new connections in the same folder as your .x3d file. You have to insert the "Connection" parts of the file into your actual component-file.
7. There will be some tags missing, like "combat". You have to add them. Just compare it with existing weapons.
8. An ugly thing: Weapons need sometimes "symmetrie" tags. And "left" and "right". You have to look at and copy from other ships.
Last edited by sprIder; 24 Aug, 2024 @ 4:59am
sprIder  [developer] 24 Aug, 2024 @ 5:11am 
I never tried to make a ship bigger.
But I think, if you do so, you have to
1. check if all the textures are correct and correctly placed
2. change all the positions in the xml-file. Ladder, cockpit, shields, animations, what ever. S and M ships are way more complex than L and XL ships.
3. Do a total new export of the ship. Use this tutorial: https://forum.egosoft.com/viewtopic.php?f=181&t=453487

Please have in mind that every import and export (xmf -> dae -> blender -> dae -> xmf) results in losses of details and maybe textures.

Resizing in general: Use "Transform" in "Object Mode". After that, apply it via Object -> Apply -> Scale / or All Transforms.
Lulu 24 Aug, 2024 @ 11:21am 
You are a goldmine, very clear instructions ! Thank you so much, I will try
sprIder  [developer] 25 Aug, 2024 @ 2:27am 
Thank you! You're welcome :)
Lulu 25 Aug, 2024 @ 1:45pm 
So I have a few issues, I have trouble even starting.

First, it seems every single ship I try to mod have a bug where the doors do not move; the cockpits of S ships do not open and the doors and hatches of M ships also do not move at all, not matter what I try both in game and out. Any idea why and how to fix it ?

I will try your instructions but getting the modules to work or even start took time, nothing I launch seems to work as intended, when it launched at all, every step is a struggle haha. How did you learn all that ?
sprIder  [developer] 26 Aug, 2024 @ 9:38am 
Since i don't know, how you create your mod(s) i just can guess. A link to your mod / data (dropbox, Google Drive, what ever) would be helpful.
But maybe following brings you further:

Animations only work, when there is the geometry, the animations-file (*_data.ani) and, sometimes, the animations described in the components-file. If you reuse existing geometry / ships / whatever and you do not change the geomety, you do not have the worry about animations.

Let's say, you want to create a mod with a new version of the kestrel, where you add some weapons. Nothing more, no change of the geometry. So the easiest way would be:
1. Just copy the component-file and the macro-file to your own mod.
2. rename the component file and the macro file, e.g. ship_tel_s_scout_01_super.xml and ship_tel_s_scout_01_super_macro. Change also in these files the "component name", the "macro name" and the "component ref" accordingly.
3. Do not copy the _data folder and do not change the source geomety path of the component file (4th line). In this case, the animations should work, since Egosoft already created them.
The animation-file (ship_tel_s_scout_01.ani) for the geometry data (ship_tel_s_scout_01_data) exist and will be reused.
4. Add your weapon connections from blender.
5. Create the components.xml and macros.xml under \index. (Just like this mod)
6. Create your own wares.xml under \libraries. Maybe just copy the entry of the original wares.xml from the game and change the component ref.
7. Find a name. Naming is (normally) done via the t-file. E.g. the Kestrel Sentinel is {20101,20103}. The curly brackets are important. Thereby is the first number the page id and the second number the t / text id. It also works to put some together: {20101,20101} {20111,1201}. The first one is "Kestrel", the second one is "Sentinel". Just have a look at \t\0001-l044.xml (the english one). You can create your own t-file. And you can write text between the "", without using the t-file and the {}.

But, if you change the geometry, you have to do an geometry export, which creates a *_data-folder. And now, you need your own *_data.ani- file. If you don't change a animated object, maybe just the hull of a ship, it could/should work, that
1. you copy the original *_data.ani-file to your mod and name it analogous to your data-folder, e.g. ship_tel_s_scout_01_super_data.ani.
2. Compare the component files from the original ship and that one from the export (Notepad++ has an integrated compare function)
2.a You'll see many differents and many things, that are missing in the newer file. It is sometimes easier or better, to reuse to original file and just change the parts, you also changed in blender. e.g. the part "anim_main" (the main hull).
2.b Maybe even the animations parts are missing, e.g. at the connection of "anim_main" the landinggears animation. Copy / reuse it from the original file.

The biggest problems start, when you want to create your own animations or want to change animations. Unfortunately, I don't know how to do this. I can only offer this link: https://forum.egosoft.com/viewtopic.php?f=181&t=442905.

I learnd it via other mods and the classic trial and error. I unpacked the mods and took a look at how they are structured. Then I compared them with the X4 data and drew my conclusions. I read a lot in the Egosoft modding forum and tried out a lot myself. Even after more than 2 years I am still learning and understanding a lot of new things.
Lulu 27 Aug, 2024 @ 11:09am 
I managed to unstuck it ! I renamed the data file to the new ship name and it destroyed every animation, it works fine with the original ship name, even if I made more than a variant. I still struggle with blender though, but I'll keep trying. This is work ! I already did most of the 1-7 you mentionned, still got to do that blender weapon thing though. You explain VERY well by the way, impressive how clear and easy to follow you make it, almost sound easy when you read it

Literal days spent just to up-gun some scout ships lol, I guess I'm just not very smart but I'll keep trying, I love theses little ships to death, just sad to have a single gun for what they cost
sprIder  [developer] 28 Aug, 2024 @ 6:55am 
Sounds good! Yep, that's work. But once you've done it more often, it gets easier :D
Thank you very much! I'm glad I can help you. That's my goal.

Well, everything new takes time to work well and quickly. It's the same for me.
Lulu 28 Aug, 2024 @ 9:02am 
I am making good progress and am almost done with my first try, just a quick question though, what happens to the old weapon point ? will it not appear ?
Last edited by Lulu; 28 Aug, 2024 @ 9:35am
sprIder  [developer] 28 Aug, 2024 @ 9:13am 
It will appear, if it is still in your component file. If you commented the whole connection out or deleted it, it will not appear.
Lulu 28 Aug, 2024 @ 9:35am 
I see !

Small problem, I do not have a x3d export option in my blender apparently. I have obj, usd, ply, stl, fbx and glb/glbf, any of theses compatible ?

( I have a free version thats up to date, is there a newer one or is it just not an option with that version ?)
< >
Showing 1-15 of 22 comments
Per page: 1530 50