Page 1 of 1

Weapon mount image positioning

Posted: Sun Mar 03, 2013 4:44 pm
by kartoFlane
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

Re: Weapon mount image positioning

Posted: Mon Mar 04, 2013 4:41 am
by UltraMantis
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.
FRSS_impact_strip9.png
The <mountPoint> tag is usefull for getting the weapon to fit panels as well as making it look better when attached to ship mounts.

Re: Weapon mount image positioning

Posted: Mon Mar 04, 2013 11:22 am
by kartoFlane
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 :)

Re: Weapon mount image positioning

Posted: Mon Mar 04, 2013 11:37 am
by UltraMantis
Sorry, that's bottom-left. Dunno why i said bottom-right... :roll:

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.

Re: Weapon mount image positioning

Posted: Mon Mar 04, 2013 12:15 pm
by kartoFlane
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.