How do you get the coordinates of ship components out of blender?

The place to discuss scripting and game modifications for X4: Foundations.

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

Max Bain
Posts: 1463
Joined: Wed, 27. Jun 18, 19:05
x3ap

How do you get the coordinates of ship components out of blender?

Post by Max Bain »

Hello,

I need to get the coordinates of a ship I have put together of existing ship components (I dont mean the modules like weapons but big hull elements like the side engine parts of the arawn) in blender.
WHat do I have to do? I dont get it...
XR Ship Pack (adds several ships from XR) Link
Weapon Pack (adds several new weapons) Link
Economy Overhaul (expands the X4 economy with many new buildings) Link
X4 Editor (view stats of objects and make your own mod within a few clicks) Link
Max Bain
Posts: 1463
Joined: Wed, 27. Jun 18, 19:05
x3ap

Re: How do you get the coordinates of ship components out of blender?

Post by Max Bain »

I tried to put a countermeasure object of X4-Blender-Module-Drag-and-Drop-master at the position of the element I need the positions of, but when I export it and convert it with the X4-Blender-Module-Drag-and-Drop-master tool, the position in game is different.

My dream would be to just put a ship together with all modules and parts in blender and export them as one xml file. Why cant I put the parts and modules in blender and see how they really look and then export them all together? Or is there something similar I can do?
XR Ship Pack (adds several ships from XR) Link
Weapon Pack (adds several new weapons) Link
Economy Overhaul (expands the X4 economy with many new buildings) Link
X4 Editor (view stats of objects and make your own mod within a few clicks) Link
BrummBear02
Posts: 310
Joined: Fri, 3. Oct 08, 20:43
x3ap

Re: How do you get the coordinates of ship components out of blender?

Post by BrummBear02 »

you should really just ping me in discord, that way i would not have to upload the pic to imgur and could answer questions directly^^

you can add modules in blender. just convert them to .dae like you would do with a ship. in fact i just run the converter over the whole x4 folder and thus converted everything there is (a bit different story for mods, but besides that everything)

now you import the module .dae into blender and maybe delete meshes that obstuct the view (turrets have a big box around them as collision mesh. u wanna delete that)

Press "N" in blender to get some extra tab, whatever its called, there you can see the position in the "location" tab. alternatively you can see it in the nodes propertys.
Always select the root node of the desired object since child nodes only show relative positions to the root node.
also keep in mind that Y and Z Axis are switched most of the time and sometimes the negative value u have is actually positive. this depends on global transformations and if u put the object inside the ships root node since ship transformations then apply.
its a real pain and i always end up fixing it by try and error. but since that didnt bother me much i never started digging for a solution or a reason.

also dont forget scale. imported ships scale at 0.01 at start if im not mistaken. i change that to 1 for S and M ships by hand and to 0.1 for L and XL ships. u need to apply that scale to your position. so if blender shows 12 as X position and your scale is 0.01 you need to write 1200 into your xml file.

[ external image ]
Gebt mir einen Spiegel dann schlage ich ihn mit seinem eigenen Gesicht
Max Bain
Posts: 1463
Joined: Wed, 27. Jun 18, 19:05
x3ap

Re: How do you get the coordinates of ship components out of blender?

Post by Max Bain »

BrummBear02 wrote: Wed, 23. Oct 19, 00:23 you should really just ping me in discord, that way i would not have to upload the pic to imgur and could answer questions directly^^

you can add modules in blender. just convert them to .dae like you would do with a ship. in fact i just run the converter over the whole x4 folder and thus converted everything there is (a bit different story for mods, but besides that everything)

now you import the module .dae into blender and maybe delete meshes that obstuct the view (turrets have a big box around them as collision mesh. u wanna delete that)

Press "N" in blender to get some extra tab, whatever its called, there you can see the position in the "location" tab. alternatively you can see it in the nodes propertys.
Always select the root node of the desired object since child nodes only show relative positions to the root node.
also keep in mind that Y and Z Axis are switched most of the time and sometimes the negative value u have is actually positive. this depends on global transformations and if u put the object inside the ships root node since ship transformations then apply.
its a real pain and i always end up fixing it by try and error. but since that didnt bother me much i never started digging for a solution or a reason.

also dont forget scale. imported ships scale at 0.01 at start if im not mistaken. i change that to 1 for S and M ships by hand and to 0.1 for L and XL ships. u need to apply that scale to your position. so if blender shows 12 as X position and your scale is 0.01 you need to write 1200 into your xml file.

[ external image ]
Thank you!
I was in discord yesterday but only wrote in open X4 mod chat. Next time I will try to send you a message directly ;).

So i was pretty close. I already imported the .dae parts to the model and I also used N to get the coordinates. But I was confused that the coordinates were much smaller and didnt fit to the X4 coordinates.
Is the factor 100 fixed for all parts? When I understand you right, I should not try to put a hull part as child node to the root node of the main ship?

I also use the Drag and Drop tool to add modules to the ship and I would like to use this tool for the coordinates of hull parts too, but somehow it does not work for the parts. Shouldnt this work the same way as with hull parts? The tool could simply use the main node and transform its coordinates like it does with the module coordinates. But it does not. I even tried to place a countermeasure object at the node position but when I used these coordinates, the part was at a wrong position which confused me a lot.
XR Ship Pack (adds several ships from XR) Link
Weapon Pack (adds several new weapons) Link
Economy Overhaul (expands the X4 economy with many new buildings) Link
X4 Editor (view stats of objects and make your own mod within a few clicks) Link
BrummBear02
Posts: 310
Joined: Fri, 3. Oct 08, 20:43
x3ap

Re: How do you get the coordinates of ship components out of blender?

Post by BrummBear02 »

Max Bain wrote: Wed, 23. Oct 19, 08:37
BrummBear02 wrote: Wed, 23. Oct 19, 00:23 you should really just ping me in discord, that way i would not have to upload the pic to imgur and could answer questions directly^^

you can add modules in blender. just convert them to .dae like you would do with a ship. in fact i just run the converter over the whole x4 folder and thus converted everything there is (a bit different story for mods, but besides that everything)

now you import the module .dae into blender and maybe delete meshes that obstuct the view (turrets have a big box around them as collision mesh. u wanna delete that)

Press "N" in blender to get some extra tab, whatever its called, there you can see the position in the "location" tab. alternatively you can see it in the nodes propertys.
Always select the root node of the desired object since child nodes only show relative positions to the root node.
also keep in mind that Y and Z Axis are switched most of the time and sometimes the negative value u have is actually positive. this depends on global transformations and if u put the object inside the ships root node since ship transformations then apply.
its a real pain and i always end up fixing it by try and error. but since that didnt bother me much i never started digging for a solution or a reason.

also dont forget scale. imported ships scale at 0.01 at start if im not mistaken. i change that to 1 for S and M ships by hand and to 0.1 for L and XL ships. u need to apply that scale to your position. so if blender shows 12 as X position and your scale is 0.01 you need to write 1200 into your xml file.

[ external image ]
Thank you!
I was in discord yesterday but only wrote in open X4 mod chat. Next time I will try to send you a message directly ;).

So i was pretty close. I already imported the .dae parts to the model and I also used N to get the coordinates. But I was confused that the coordinates were much smaller and didnt fit to the X4 coordinates.
Is the factor 100 fixed for all parts? When I understand you right, I should not try to put a hull part as child node to the root node of the main ship?

I also use the Drag and Drop tool to add modules to the ship and I would like to use this tool for the coordinates of hull parts too, but somehow it does not work for the parts. Shouldnt this work the same way as with hull parts? The tool could simply use the main node and transform its coordinates like it does with the module coordinates. But it does not. I even tried to place a countermeasure object at the node position but when I used these coordinates, the part was at a wrong position which confused me a lot.
no. you dont put it in any root node. the scale of the module needs to be the same as the model itself. at scale 0.01 its factor 100 and at scale 0.1 its factor 10. at scale 1 the coordinates are correct.

i also used the tool once. i dont like it. its very dependant on the naming of the node and it works with templates which act as placeholder for the actual modules. those templates are just boxes and i disliked the idea that they dont show me how it will actually look ingame.

[ external image ]
Gebt mir einen Spiegel dann schlage ich ihn mit seinem eigenen Gesicht
Max Bain
Posts: 1463
Joined: Wed, 27. Jun 18, 19:05
x3ap

Re: How do you get the coordinates of ship components out of blender?

Post by Max Bain »

So you copy the values directly out of blender and multiply them with 100? How do you get the angles? They are in degrees in blender but in quaternions in X4?
XR Ship Pack (adds several ships from XR) Link
Weapon Pack (adds several new weapons) Link
Economy Overhaul (expands the X4 economy with many new buildings) Link
X4 Editor (view stats of objects and make your own mod within a few clicks) Link
BrummBear02
Posts: 310
Joined: Fri, 3. Oct 08, 20:43
x3ap

Re: How do you get the coordinates of ship components out of blender?

Post by BrummBear02 »

Max Bain wrote: Wed, 23. Oct 19, 20:38 So you copy the values directly out of blender and multiply them with 100? How do you get the angles? They are in degrees in blender but in quaternions in X4?
no. i multiply them with whatever i used as scale. if u didnt change scale, thats 100. yes. but its not 100 in general.
angels can be given in quaternion, which i dont understand at all even after doing quite some research, or in yaw pitch roll.

here a example how i did it in my ship "Envy"

Code: Select all

			<connection name="con_turret_top" tags="turret medium standard missile platformcollision unhittable ">
				<offset>
<!-- 					<position x="seitwärts/sidways" y="hoch/up" z="vorwärts/forward"/> -->
<!-- 					<rotation yaw="vertikal/gieren/schlingern" pitch="quer/nicken/stampfen" roll="längs/rollen/wanken"/>  -->
					<position x="0" y="18.5933" z="-35.0143"/>
					<rotation yaw="0" pitch="0" roll="0"/> 
				</offset>
			</connection>
the stuff between <!-- --> wont be considered by the game. its simply for me to make it easier to find out which axis to use. i even added the english description to my german ones :P

use the yaw pitch roll INSTEAD of the quaternion. not both

also keep the general 90° along the X axis, meaning pitch, in mind. if u select the root node of your ship ull see what i mean. this is also the reason for the switched Y and Z axis for positions. this becomes relevant if u place modules or need angles for something inside your ship node. outside of it you can ignore that.
Gebt mir einen Spiegel dann schlage ich ihn mit seinem eigenen Gesicht
Max Bain
Posts: 1463
Joined: Wed, 27. Jun 18, 19:05
x3ap

Re: How do you get the coordinates of ship components out of blender?

Post by Max Bain »

BrummBear02 wrote: Thu, 24. Oct 19, 01:15
Max Bain wrote: Wed, 23. Oct 19, 20:38 So you copy the values directly out of blender and multiply them with 100? How do you get the angles? They are in degrees in blender but in quaternions in X4?
no. i multiply them with whatever i used as scale. if u didnt change scale, thats 100. yes. but its not 100 in general.
angels can be given in quaternion, which i dont understand at all even after doing quite some research, or in yaw pitch roll.

here a example how i did it in my ship "Envy"

Code: Select all

			<connection name="con_turret_top" tags="turret medium standard missile platformcollision unhittable ">
				<offset>
<!-- 					<position x="seitwärts/sidways" y="hoch/up" z="vorwärts/forward"/> -->
<!-- 					<rotation yaw="vertikal/gieren/schlingern" pitch="quer/nicken/stampfen" roll="längs/rollen/wanken"/>  -->
					<position x="0" y="18.5933" z="-35.0143"/>
					<rotation yaw="0" pitch="0" roll="0"/> 
				</offset>
			</connection>
the stuff between <!-- --> wont be considered by the game. its simply for me to make it easier to find out which axis to use. i even added the english description to my german ones :P

use the yaw pitch roll INSTEAD of the quaternion. not both

also keep the general 90° along the X axis, meaning pitch, in mind. if u select the root node of your ship ull see what i mean. this is also the reason for the switched Y and Z axis for positions. this becomes relevant if u place modules or need angles for something inside your ship node. outside of it you can ignore that.
Do you set the yaw, pitch and roll values in degrees like in blender? That would be really cool!
XR Ship Pack (adds several ships from XR) Link
Weapon Pack (adds several new weapons) Link
Economy Overhaul (expands the X4 economy with many new buildings) Link
X4 Editor (view stats of objects and make your own mod within a few clicks) Link
BrummBear02
Posts: 310
Joined: Fri, 3. Oct 08, 20:43
x3ap

Re: How do you get the coordinates of ship components out of blender?

Post by BrummBear02 »

Correct
Gebt mir einen Spiegel dann schlage ich ihn mit seinem eigenen Gesicht

Return to “X4: Foundations - Scripts and Modding”