Board index FlightGear Development Nasal

Nasal function for textranslate

Nasal is the scripting language of FlightGear.

Nasal function for textranslate

Postby wlbragg » Mon Jul 23, 2018 9:59 pm

I made a helper function to give me the parameters for the textranslate animation. I find the method used to supply parameters for this animation bothersome, but probably because I am not well versed in this stuff. Anyway, here it is if anyone wants it. there is tons of room for improvement like an input interface. I use it so rarely though it wasn't worth the effort for me to create an input interface.
Oh, as written it only works for a square texture, maybe someone would want to add the conversion for a rectangle texture.
If there is an easier way to get this information, please don't laugh at me.

Code: Select all
var orgXpos=918.21;
var orgYpos=19.15;
var newXpos=848.74;
var newYpos=104.33;
var texSize=1024;

var xDist = newXpos - orgXpos;
var yDist = newYpos - orgYpos;

var squXdist = xDist * xDist;
var squYdist = yDist * yDist;

var fd = math.sqrt(squXdist + squYdist);

var factor = func (fd, texSize) {
    return fd / texSize;
}

var textTranFactor = factor(fd, texSize);
var textTranX = xDist / fd;
var textTranY = yDist / fd;

setprop("AtextTranFactor", textTranFactor);
setprop("AtextTranX", textTranX);
setprop("AtextTranY", textTranY);
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7587
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Return to Nasal

Who is online

Users browsing this forum: No registered users and 2 guests