A working example could be seen in this mod: Manager Plus
The same technique was used in X-Rebirth's mod Capital Ship Bridge
We will add a monitor to the manager who sits in the Manager's Office.
From this moment I will refer to the holographic image as 'monitor' to save time and space. Keyboard and other stuff can be added in a similar way based on your imagination.
At first let's create mod's folder in 'Steam/streamapps/common/X4 Foundations/extensions' folder. (Note, that other mods can be located in the '/Documents/Egosoft/X4/.../extensions' folder, but for our mod this will not work because we will add additional assets and the game would not recognize them if they would be in the /Documents... folder).
I called this mod: "Manager Plus" and named the folder "lt_manager_plus". It has the following structure:
You should download Manager Plus mod and use the folder structure and files as a baseline.
content.xml describes the mod, you can copy-paste it and change details inside based on your needs.
To simplify the editing we will totally overwrite the file which describes the manager's office, that would be "room_gen_managersoffice_01.xml"
We copy this file from the extracted game's files to the folder /assets/interiors/rooms and we will have:
Also, we copy the whole folder with all its contents "room_gen_managersoffice_01_data".
Now we need to tell the game to use our copied files in the game instead of the original files. For that we need to tell the game where to look for the manager's office 'component' - e.g. description in XML.
This is done in the file /index/components.xml
We add XML patch "code" to the file:
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<diff xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<replace sel="//entry[@name='room_gen_managersoffice_01']/@value">\extensions\lt_manager_plus\assets\interiors\rooms\room_gen_managersoffice_01</replace>
</diff>
Then we need to edit the file itself. We open '\extensions\lt_manager_plus\assets\interiors\rooms\room_gen_managersoffice_01.xml' and inside we edit the line at the top:
Code: Select all
<source geometry="\extensions\lt_manager_plus\assets\interiors\rooms\room_gen_managersoffice_01_data"/>
After these changes, the game (after restart) will use the files from the mod's folder.
We can add holo-monitor now.
At first, let's create an image of the monitor. Based on the 3D file I am using, the picture of the monitor should be a rectangle with the size of 2048x2048.
Use any software to make a picture you want. My monitor looks like this:
Notice that the majority of the picture is black. Black space will be transparent in the final result.
Now save this image and convert it to the DDS format picture (DDS DXT1). I use DXTBmp software for it. Photoshop has a DDS plugin for the same task.
When we have a DDS image, rename it to 1.dds. And compress to the gz file. I use 7-Zip software to archive files to .gz. Looks like this:
Place this 1.gz file to the folder /textures/monitors:
Now we need to tell the game to use this file as a texture. For that we have a file /libraries/material_library.xml with the following 'code':
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<diff>
<add sel="/materiallibrary" >
<collection name="heads">
<material name="displayBlock_gen0001" shader="P1_simple_unlit.fx" blendmode="ADDITIVE" preview="none">
<properties>
<property type="BitMap" name="diffuse_map" preload="1" value="extensions\lt_manager_plus\textures\monitors\1"></property>
<property type="Float" name="diffuseStr" value="2"></property>
</properties>
</material>
</collection>
</add>
</diff>
Code: Select all
<collection name="heads">
<material name="displayBlock_gen0001" shader="P1_simple_unlit.fx" blendmode="ADDITIVE" preview="none">
<property type="BitMap" name="diffuse_map" preload="1" value="extensions\lt_manager_plus\textures\monitors\1">
- collection name "heads"
- material name "displayBlock_gen0001"
- path to our texture: "extensions\lt_manager_plus\textures\monitors\1"
For this I use files part_m1-collision.xmf and part_m1-lod0.xmf. They should be in the folder: \extensions\lt_manager_plus\assets\interiors\rooms\room_gen_managersoffice_01_data
Just copy-paste these files and feel free to use them.
part_m1-collision.xmf file can be used unchanged.
File part_m1-lod0.xmf inside holds the information about the texture it uses.
We need to open it with Hex Editor (I use HxD) and inside we see:
In red I marked the part where our texture is described.
As you can see it is 'heads.displayBlock_gen001' same as in our texture description:
Code: Select all
collection name "heads"
material name "displayBlock_gen0001"
And use this file for a second element. As an example check Manager Plus mod as there I use the second element for the keyboard.
Now as we have our 3D element and texture connected, we need to tell our component in the XML file to place holo-monitor in the scene.
This is done in the file \extensions\lt_manager_plus\assets\interiors\rooms\room_gen_managersoffice_01.xml by adding following section:
Code: Select all
<connection name="Connection18" tags="part detail_l nocollision forceoutline ">
<offset>
<position x="0" y="1.5" z="-8"/>
<rotation yaw="0" pitch="-15" roll="0" />
</offset>
<parts>
<part name="part_m1">
<lods>
<lod index="0">
<materials>
<material id="1" ref="heads.displayBlock_gen0001"/>
</materials>
</lod>
</lods>
<size>
<max x="0.0950315" y="0.2610982" z="0.2626635"/>
<center x="3.576279E-07" y="0" z="4.768372E-07"/>
</size>
</part>
</parts>
</connection>
connection name="Connection18" - make sure you add connection which is not existent in the file to do not overwrite the old connections. If last connection has a name Connection17 - name yours Connection18 and so on.
<part name="part_m1"> indicates to use 3D element from the files: part_m1*.xmf. In our situation these are part_m1-lod0.xmf and part_m1-collision.xmf
<material id="1" ref="heads.displayBlock_gen0001"/> indicates the texture we are using: heads.displayBlock_gen0001 (but it seems this line can be removed, it does not impact anything - texture from the xmf file will be used in any case).
Now restart the game and you should see the holo-monitor on the manager's table.
It takes some time to adjust the position and the placement of the monitor at the start.
It is done by using these parameters:
Code: Select all
<position x="0" y="1.5" z="-8"/>
<rotation yaw="0" pitch="-15" roll="0" />
Happy modding!