[TOOL] Blender hard-point drag and drop V4

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

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

rjtwins
Posts: 20
Joined: Wed, 3. Nov 10, 13:50
x4

[TOOL] Blender hard-point drag and drop V4

Post by rjtwins » Tue, 18. Dec 18, 04:30

I've moved all the documentation to the GitHub, feel free to continue to comment and ask questions here tough.

GitHub Repository

Any bugs encounterd please report them here.



V3 post
Show
Python script to enable drag and drop of hard-points in Blender (or any tool that can export to x3d).
To be clear here, this is NOT a tool that allows you to modify ships and import them. Just their surface hard-points.
If you want to import/export ships I suggest you goto: viewtopic.php?f=181&t=404786#p4769763
or search the forums as there are several topics on this.

Also, keep an eye on the version since it's still regularly updated.
For python script users
Show
The script is written in Python 3.7 so you will need a python installation :

https://www.python.org/

As well as the pyquaternion module.

If you have no idea what I'm talking about here I suggest you use the EXE instead.
Short video tutorial (OUTDATED)

How this works
-Convert your XML to DAE (viewtopic.php?f=181&t=404786#p4769763)
-Open your model in blender and start putting down your "hard-points" the script can mirror (well be querried when script is run) for you so you only need to do one side.
NOTE: There are templates for supported modules in the scripts root/templates, all combined in a BLEND file and each individually in DAE files.
-READ THE NAMING SCHEME!
-Rename hard-points according to the naming scheme so the script can recognize what you are putting down.
-Select all to be exported hard-points (you do not want to select the ship here) and export to X3D with the right settings to the root directory of where the script is located.
settings
Show
Image

NOTE: If you are not using Blender the upward and forward axis might be different, you will have to experiment to find out what is what by trial and error.
-Run gui.py or main.exe, an interface will open up where you can choose what files, if you want to mirror and or inject into an existing ship file.
-If needed open the output files with a text editor and copy over the connections into your ship file (assets/units/size_xx/ship_file.xml between <connections> </connections>.
Using Engines and Shields
Show
Engines:
Engines can only look directly backward and will show in odd angles if given angular information.
Therefore whatever angle you place the hardpoint at, engines will always be translated to having no pitch/yaw/roll and look directly behind.
You can only have ONE size of engines on your ship :cry: , if you put more then one size things will start to behave weirdly in game.

Shields:
Shields can either be in no group (by including the nogroup group name), in which case they provide shielding for the ship. Or in a group in which case they provide
shielding for the group ONLY. So if you have only shield in a group they will still only shield each other and not the ship.
naming scheme
Show

Code: Select all

Naming scheme:
NOTE: _ is used as separator do not use this outside of as stated below.

groupname_type_nr-in-group

groupname				Can be anything if it contains 'nogroup' no group will be assigned. 
					This MUST be done for ship wide shields otherwise the shield will shield the components in the group only.
type					Type of component (see list below for possibilities)
nr					Nr. of component in group.

options:
include 'left' or 'right' in your group name if you want the group to be mirrored.

Examples:
left-top-bat-1_lturret_2
let-nogroup_lshield_1
funcannongroup-1_mturret_666
supported modules
Show

Code: Select all

In these the m in lmturret indicates it can fire missiles.

 lturret
 lmturret	
 mturret
 mmturret
 sturret
 ssturret
 xlshield
 lshield
 mshield
 sshield
 xlengine
 lengine
 mengine
 sengine
Files: https://github.com/rjtwins/X4-Blender-M ... g-and-Drop
old post
Show
First off, if a method of doing this already exists, please relief me from my suffering.

Now, I've been working on little python script where you can simply drag and drop modules on an "object" into Blender (using blenders many amazing functionalities),
run a script and boom connection point schema to copy paste into your ship XML.

https://github.com/rjtwins/dea-turret-translator

How this works
-Convert your XML to DAE (viewtopic.php?f=181&t=404786#p4769763)
-Open your model in blender and start putting down your "modules" the script will mirror for you (turned off atm) so you only need to do one side.
-Rename modules according to the naming scheme so the script can recognize what you are putting down (turrets only for now but all modules are possible).
-Select all to be exported modules and export to DAE with the right settings (Selection Only, Transformation type: TransRotLoc)
Spoiler
Show
Image
Spoiler
Show
Image
Now here is where I run into some trouble, this works just fine, as long as the module you are putting down is not facing too much towards the origins of x and y (aka forward) If that happens an effect known as gimble lock occurs. To fix this you can store the rotation in another format, like quaternion, however, I've not been able to get this
working so far. The rotation is way off and inconsistent when converting to a quaternion. Is there perhaps a better method?
Last edited by rjtwins on Sun, 23. Dec 18, 20:05, edited 42 times in total.

Lc4Hunter
Posts: 2170
Joined: Sun, 2. Apr 06, 16:15
x4

Re: [TOOL/WIP/HELP] Blender mudule drag and drop

Post by Lc4Hunter » Tue, 18. Dec 18, 05:31

Wow! Thats awesome. Great work.
Unfortunately i canß´t help you but i hope you will find a solution for that.

Do you coincidentally also know MAXScript?
Such an exporter would be great for 3dsMax, too. Or i have to learn how to use blender :o :oops:

A.Persyn
Posts: 121
Joined: Sun, 14. Mar 10, 13:14
x3tc

Re: [TOOL/WIP/HELP] Blender mudule drag and drop

Post by A.Persyn » Tue, 18. Dec 18, 10:39

The reason the quaternions are messed up is because the game uses Y for vertical and Blender uses Z vertical. To get it to work you have to switch them. I did it a while back, but now I forget the details. I do remember it was a pain to sort out though.

Parcipal
Posts: 2
Joined: Thu, 21. Jan 16, 10:49
x4

Re: [TOOL/WIP/HELP] Blender mudule drag and drop

Post by Parcipal » Tue, 18. Dec 18, 12:37

You should be able to easily change the axis-up in the .dae after converting it

https://i.imgur.com/l2ReDHx.png

rjtwins
Posts: 20
Joined: Wed, 3. Nov 10, 13:50
x4

Re: [TOOL/WIP/HELP] Blender module drag and drop

Post by rjtwins » Tue, 18. Dec 18, 14:16

I already know, blender is a left-handed Z up world, and the game a right-handed Y up world. And I do switch out the appropriate axis in the script according to several sources I've managed to find. Also changing the tag in a DAE file so it is "y up" does just that, change a tag it doesn't change how all the translation and rotation are encoded in the file.
I fear I may need to head over to stack overflow with this one :P
Lc4Hunter wrote:
Tue, 18. Dec 18, 05:31
Wow! Thats awesome. Great work.
Unfortunately i canß´t help you but i hope you will find a solution for that.

Do you coincidentally also know MAXScript?
Such an exporter would be great for 3dsMax, too. Or i have to learn how to use blender :o :oops:
I believe 3dsMax can (with plugin) also import/export DAE.
As long as you export to the COLLADA DEA file type, have a Z-up left-handed world and use the TransRotLoc schema when exporting you should be able to use this.

sco1981
Posts: 282
Joined: Fri, 14. Sep 18, 14:47
x4

Re: [TOOL] Blender module drag and drop

Post by sco1981 » Wed, 19. Dec 18, 08:40

Hi,

i am a beginner in modding and dont know how i install and use this.
May i ask for a complete install instruction/tutorial please?

Thanks in advanced.

ZEFFEZ
Posts: 10
Joined: Thu, 6. Sep 18, 06:15
x4

Re: [TOOL] Blender module drag and drop

Post by ZEFFEZ » Wed, 19. Dec 18, 11:39

sco1981 wrote:
Wed, 19. Dec 18, 08:40
Hi,

i am a beginner in modding and dont know how i install and use this.
May i ask for a complete install instruction/tutorial please?

Thanks in advanced.
+1 I just need help on using this but also how to export stuff to .xml format, seems like my .dae file does not convert to .xml properly

rjtwins
Posts: 20
Joined: Wed, 3. Nov 10, 13:50
x4

Re: [TOOL] Blender module drag and drop

Post by rjtwins » Wed, 19. Dec 18, 14:20

I'll see about a more in-depth guide.

sco1981
Posts: 282
Joined: Fri, 14. Sep 18, 14:47
x4

Re: [TOOL] Blender module drag and drop

Post by sco1981 » Thu, 20. Dec 18, 09:44

rjtwins wrote:
Wed, 19. Dec 18, 14:20
I'll see about a more in-depth guide.
That would be great, thank you.
I am looking forward to use this tool for some ship mods. :D

rjtwins
Posts: 20
Joined: Wed, 3. Nov 10, 13:50
x4

Re: [TOOL] Blender hard-point drag and drop

Post by rjtwins » Thu, 20. Dec 18, 15:37

Tbo at this point I don't know what else to write in terms of guides and tutorials.
You will just have to try and ask questions, I'll rewrite the how-to depending on questions then.

sco1981
Posts: 282
Joined: Fri, 14. Sep 18, 14:47
x4

Re: [TOOL] Blender hard-point drag and drop

Post by sco1981 » Thu, 20. Dec 18, 18:27

rjtwins wrote:
Thu, 20. Dec 18, 15:37
Tbo at this point I don't know what else to write in terms of guides and tutorials.
You will just have to try and ask questions, I'll rewrite the how-to depending on questions then.
your video tutorial helps a lot, thank you.
Now i get an error for creating the xml.

KeyError: 2 [8620] Failed to execute script main.

i think i have all things done to this point, what you did in the video.

this is the content of input.x3d:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D version="3.0" profile="Immersive" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="http://www.web3d.org/specifications/x3d-3.0.xsd">
	<head>
		<meta name="filename" content="input.x3d" />
		<meta name="generator" content="Blender 2.79 (sub 0)" />
	</head>
	<Scene>
		<NavigationInfo headlight="true"
		                visibilityLimit="0.0"
		                type='"EXAMINE", "ANY"'
		                avatarSize="0.25, 1.75, 0.75"
		                />
		<Background DEF="World"
		            groundColor="0.051 0.051 0.051"
		            skyColor="0.051 0.051 0.051"
		            />
		<Transform DEF="left-top-L-lturret_2_ifs_TRANSFORM"
		           translation="1.255379 2.505108 1.665561"
		           scale="0.295000 0.305000 0.002500"
		           rotation="-0.037649 0.993917 -0.103495 0.706145"
		           >
			<Group DEF="template_007">
				<Shape>
					<Appearance>
					</Appearance>
					<IndexedFaceSet solid="false"
					                coordIndex="0 4 11 8 -1 2 0 8 9 -1 10 11 4 6 -1 6 0 2 -1 7 10 9 3 -1 1 9 8 -1 9 10 6 2 -1 5 10 7 -1 3 1 5 7 -1 6 4 0 -1 1 3 9 -1 5 11 10 -1 5 1 8 11 -1 "
					                >
						<Coordinate DEF="coords_template_007"
						            point="-1.000000 -1.000000 -1.000000 -0.220199 0.508693 22.962940 -1.000000 1.000000 -1.000000 -0.220199 0.923999 22.962940 1.000000 -1.000000 -1.000000 0.195107 0.508693 22.962940 1.000000 1.000000 -1.000000 0.195107 0.923999 22.962940 -1.000000 -1.000000 1.000000 -1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 -1.000000 1.000000 "
						            />
					</IndexedFaceSet>
				</Shape>
			</Group>
		</Transform>
		<Transform DEF="left-top-L-lturret_1_ifs_TRANSFORM"
		           translation="1.289292 3.201737 1.637023"
		           scale="0.295000 0.305000 0.002500"
		           rotation="-0.037649 0.993917 -0.103496 0.706145"
		           >
			<Group DEF="template_006">
				<Shape>
					<Appearance>
					</Appearance>
					<IndexedFaceSet solid="false"
					                coordIndex="0 4 11 8 -1 2 0 8 9 -1 10 11 4 6 -1 6 0 2 -1 7 10 9 3 -1 1 9 8 -1 9 10 6 2 -1 5 10 7 -1 3 1 5 7 -1 6 4 0 -1 1 3 9 -1 5 11 10 -1 5 1 8 11 -1 "
					                >
						<Coordinate DEF="coords_template_006"
						            point="-1.000000 -1.000000 -1.000000 -0.220199 0.508693 22.962940 -1.000000 1.000000 -1.000000 -0.220199 0.923999 22.962940 1.000000 -1.000000 -1.000000 0.195107 0.508693 22.962940 1.000000 1.000000 -1.000000 0.195107 0.923999 22.962940 -1.000000 -1.000000 1.000000 -1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 -1.000000 1.000000 "
						            />
					</IndexedFaceSet>
				</Shape>
			</Group>
		</Transform>
	</Scene>
</X3D>

rjtwins
Posts: 20
Joined: Wed, 3. Nov 10, 13:50
x4

Re: [TOOL] Blender hard-point drag and drop

Post by rjtwins » Thu, 20. Dec 18, 18:50

Your group name and type should be separated by an _ you are separating them by -
This is important as the script will separate the name into 3 elements (group name, type and nr in group) based on separation by _
See the naming convention spoiler tap for this.

morbideth
Posts: 391
Joined: Sun, 9. Nov 08, 03:07
x3tc

Re: [TOOL] Blender hard-point drag and drop

Post by morbideth » Thu, 20. Dec 18, 19:13

I'm not someone with the skills to mod ships, but even I can see how this would be an incredibly useful tool. Thanks for your hard work.

sco1981
Posts: 282
Joined: Fri, 14. Sep 18, 14:47
x4

Re: [TOOL] Blender hard-point drag and drop

Post by sco1981 » Thu, 20. Dec 18, 19:36

rjtwins wrote:
Thu, 20. Dec 18, 18:50
Your group name and type should be separated by an _ you are separating them by -
This is important as the script will separate the name into 3 elements (group name, type and nr in group) based on separation by _
See the naming convention spoiler tap for this.
ok, if i name it left-top-L_lturret_1 it works, my bad, sorry.
This is a really good script and save a lot of time, you are genious!

One small request, is it possible to mark a turret for not clone on the other side?
And maybe a pause-function, so the window will keep open...for error analysis. :D

rjtwins
Posts: 20
Joined: Wed, 3. Nov 10, 13:50
x4

Re: [TOOL] Blender hard-point drag and drop

Post by rjtwins » Thu, 20. Dec 18, 20:41

Af you DO NOT include left, or right or DO center in your group name the object will not be mirrored. I'm going to make a popup menu series in the future asking you for mirroring.

sco1981
Posts: 282
Joined: Fri, 14. Sep 18, 14:47
x4

Re: [TOOL] Blender hard-point drag and drop

Post by sco1981 » Thu, 20. Dec 18, 21:51

rjtwins wrote:
Thu, 20. Dec 18, 20:41
Af you DO NOT include left, or right or DO center in your group name the object will not be mirrored. I'm going to make a popup menu series in the future asking you for mirroring.
very good, thank you!

sco1981
Posts: 282
Joined: Fri, 14. Sep 18, 14:47
x4

Re: [TOOL] Blender hard-point drag and drop V2

Post by sco1981 » Fri, 21. Dec 18, 20:18

May i ask for engine and docking port implemention in the future? :-)

rjtwins
Posts: 20
Joined: Wed, 3. Nov 10, 13:50
x4

Re: [TOOL] Blender hard-point drag and drop V2

Post by rjtwins » Fri, 21. Dec 18, 21:07

sco1981 wrote:
Fri, 21. Dec 18, 20:18
May i ask for engine and docking port implemention in the future? :-)
Engines are in, docking location for big ships to stations not yet but that should not be to hard. As for ship to ship docking locations that is probably going to take some more time.

sco1981
Posts: 282
Joined: Fri, 14. Sep 18, 14:47
x4

Re: [TOOL] Blender hard-point drag and drop V2

Post by sco1981 » Sat, 22. Dec 18, 11:59

rjtwins wrote:
Fri, 21. Dec 18, 21:07
sco1981 wrote:
Fri, 21. Dec 18, 20:18
May i ask for engine and docking port implemention in the future? :-)
Engines are in, docking location for big ships to stations not yet but that should not be to hard. As for ship to ship docking locations that is probably going to take some more time.
Thank you, will test it. :thumb_up:
Docking locations for big ships would be really good. At the moment it is a pain in the ass to find out good waypoints.
Front weapons would be a fine addition too. :D

BlackRain
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 7411
Joined: Mon, 15. Dec 03, 18:53
x4

Re: [TOOL] Blender hard-point drag and drop V3

Post by BlackRain » Sat, 22. Dec 18, 16:38

I am trying this out so I imported the DAE for the xenon K. The ship in blender is just pure black. How do I get it with the grayish color shown in your video. It is hard for me to see where I am putting the turret because the ships is entirely black lol

Return to “X4: Foundations - Scripts and Modding”