This doesn't exactly fit the topic of bugs, or technical support for that matter, seeing as it is a question to the devs regarding inner mechanics of FTL, however I didn't feel like asking such question over a PM would be appropriate, so I figured I'd put it here...
Either way -- for some time now I've been trying to figure out the formula used to position images of weapons on weapon mounts, so that I could accurately display them in a ship editor of mine. Through observation and trial and error I've gotten to a pretty good approximation - but it's not perfect, and for the life of me I can't seem to be able to figure it out completely.
So, for this reason, I've been wondering whether it would be inappropriate of me to ask the developers for some insight into this specific part of code.
Thank you in advance
Weapon mount image positioning
- kartoFlane
- Posts: 1488
- Joined: Mon Jan 14, 2013 10:20 pm
Weapon mount image positioning
Superluminal2 - a ship editor for FTL
-
- Posts: 2125
- Joined: Thu Sep 20, 2012 3:17 pm
Re: Weapon mount image positioning
From my experience the weapon will be placed on the exact pixel you specify when you define the mounts in shipname.xml.
Now the weapon itself has a tag in animations.xml: <mountPoint x="N" y="N"/> This <mountPoint> is the anchor pixel for the weapon art sprite. If you set it at x="0" y="imageheight"/> the weapon will be anchored at the bottom right corner. Bear in mind that weapons are oriented as in the image below, then rotated and mirrored according to the weapon mount definition. The <mountPoint> tag is usefull for getting the weapon to fit panels as well as making it look better when attached to ship mounts.
Now the weapon itself has a tag in animations.xml: <mountPoint x="N" y="N"/> This <mountPoint> is the anchor pixel for the weapon art sprite. If you set it at x="0" y="imageheight"/> the weapon will be anchored at the bottom right corner. Bear in mind that weapons are oriented as in the image below, then rotated and mirrored according to the weapon mount definition. The <mountPoint> tag is usefull for getting the weapon to fit panels as well as making it look better when attached to ship mounts.
Report spam using the handy Report Button Mod.
- kartoFlane
- Posts: 1488
- Joined: Mon Jan 14, 2013 10:20 pm
Re: Weapon mount image positioning
Oh wow. They actually are anchored at the bottom right corner. Weird... I've always assumed they were anchored in the middle, or at least top left -- seemed much more logical / intuitive.
Well f* me, now that I've included this in the code I'm actually strarting to get the mounts aligned correctly, thanks :)
Well f* me, now that I've included this in the code I'm actually strarting to get the mounts aligned correctly, thanks :)
Superluminal2 - a ship editor for FTL
-
- Posts: 2125
- Joined: Thu Sep 20, 2012 3:17 pm
Re: Weapon mount image positioning
Sorry, that's bottom-left. Dunno why i said bottom-right... 
As for default, i don't know if there is a default anchor, may as well be top-left since it's 0,0. Anyway the key data is the frame size which defines the size of the weapon shown in game, and the mountFrame that sets the anchor.

As for default, i don't know if there is a default anchor, may as well be top-left since it's 0,0. Anyway the key data is the frame size which defines the size of the weapon shown in game, and the mountFrame that sets the anchor.
Report spam using the handy Report Button Mod.
- kartoFlane
- Posts: 1488
- Joined: Mon Jan 14, 2013 10:20 pm
Re: Weapon mount image positioning
Yeah, I have most of that stuff figured, it was the anchoring that kept messing everything up. No idea why, but weapon images seem to actually be anchored to bottom right, not left.
Superluminal2 - a ship editor for FTL