The center of the center of the y axs of the Attitude Indicator don't line up with the Aircraft Symbol (the open yellow triangle)
What is the problem and how i can fix it?
And here is a screen shot of the problem:
For the code is current revision in my git repository https://github.com/www2000/Farmin.
And open the file $farminRoot/G1000/Nasal/PFD/PFD.nas and the problem is between line 17 and 28 (loading of the svg file) or between line 40 and 81 ( update the Artificial Horizon horizon).
And the svg is locate at: /G1000/Pages/PFD/PFD.svg
Btw i use the current git version of flightgear.
Edit i found the bug in my code:
old code:
- Code: Select all
var PFD = {
new: func(canvas_group)
{
var m = { parents: [PFD] };
m.data = {};
var pfd = canvas_group;
var font_mapper = func(family, weight)
{
if( family == "Liberation Sans" and weight == "normal" )
return "LiberationFonts/LiberationSans-Regular.ttf";
elsif( family == "Sans" and weight == "normal" )
return "LiberationFonts/LiberationSans-Regular.ttf";
elsif( family == "BoeingCDULarge" and weight == "normal" )
return "LiberationFonts/LiberationSans-Regular.ttf";
};
canvas.parsesvg(pfd, "Aircraft/Instruments-3d/Farmin/G1000/Pages/PFD/PFD.svg", {'font-mapper': font_mapper});
var Speed = {};
var svg_keys = ["LindSpeed","SpeedNonLint","SpeedLastDigitLint", "Horizon","bankPointer","bankPointerLineL", "bankPointerLineR","Compass","AltNonLintBig","AltNonLintSmall","AltLint","SlipSkid","CompassText","VSI","VSIText","PitchScale","HorizonLine"];
foreach(var key; svg_keys) {
print(key);
m[key] = {};
m[key].Element = pfd.getElementById(key);
m[key].Element.updateCenter();
m[key].center = m[key].Element.getCenter();
m[key].roll = m[key].Element.createTransform();
m[key].pitch = m[key].Element.createTransform();
};
#5,715272637
#clip
m.bankPointerLineL.Element.set("clip", "rect(0,1024,768,459.500)");
m.bankPointerLineR.Element.set("clip", "rect(0,459.500,768,0)");
m.PitchScale.Element.set("clip", "rect(134,590,394,330)");
#note to my self clip for the Pitch Scale is: top = 134 right = 590 bottem = 394 left = 330
return m
},
updateAi: func(Roll,Pitch){
#offset = 392.504021806/2;
offset = 10;
#if(Pitch < 1.3962634)
#{
# Pitch = 1.3962634;
#}
#elsif (Pitch > -1.3962634)
#{
# Pitch = 1.3962634;
#};
RollR = -Roll*D2R;
Bpc = me.bankPointer.Element.getCenter();
me.bankPointer.roll.setRotation(RollR, Bpc);
me.bankPointerLineL.roll.setRotation(RollR, Bpc);
me.bankPointerLineR.roll.setRotation(RollR, Bpc);
me.Horizon.roll.setRotation(RollR, Bpc);
me.HorizonLine.roll.setRotation(RollR, Bpc);
me.PitchScale.roll.setRotation(RollR, Bpc);
print(Bpc);
if (RollR < 0) #top, right, bottom, left
{
me.bankPointerLineL.Element.set("clip", "rect(0,1,1,0)"); #459,500
me.bankPointerLineR.Element.set("clip", "rect(0,459.500,768,0)");
}
elsif (RollR > 0)
{
me.bankPointerLineL.Element.set("clip", "rect(0,1024,768,459.500)"); #459,500
me.bankPointerLineR.Element.set("clip", "rect(0,1,1,0)");
}
else
{
me.bankPointerLineL.Element.set("clip", "rect(0,1024,768,459.500)"); #459,500
me.bankPointerLineR.Element.set("clip", "rect(0,459.500,768,0)");
}
me.Horizon.pitch.setTranslation(0,Pitch*offset);
me.HorizonLine.pitch.setTranslation(0,Pitch*offset);
me.PitchScale.pitch.setTranslation(0,Pitch*offset);
},
}
new code:
- Code: Select all
var PFD = {
new: func(canvas_group)
{
var m = { parents: [PFD] };
m.data = {};
var pfd = canvas_group;
var font_mapper = func(family, weight)
{
if( family == "Liberation Sans" and weight == "normal" )
return "LiberationFonts/LiberationSans-Regular.ttf";
elsif( family == "Sans" and weight == "normal" )
return "LiberationFonts/LiberationSans-Regular.ttf";
elsif( family == "BoeingCDULarge" and weight == "normal" )
return "LiberationFonts/LiberationSans-Regular.ttf";
};
canvas.parsesvg(pfd, "Aircraft/Instruments-3d/Farmin/G1000/Pages/PFD/PFD.svg", {'font-mapper': font_mapper});
var Speed = {};
var svg_keys = ["LindSpeed","SpeedNonLint","SpeedLastDigitLint", "Horizon","bankPointer","bankPointerLineL", "bankPointerLineR","Compass","AltNonLintBig","AltNonLintSmall","AltLint","SlipSkid","CompassText","VSI","VSIText","HorizonLine", "PitchScale"];
foreach(var key; svg_keys) {
print(key);
m[key] = nil;
m[key] = pfd.getElementById(key);
m[key].updateCenter();
m[key].trans = m[key].createTransform();
m[key].rot = m[key].createTransform();
};
#5,715272637
#clip
m.bankPointerLineL.set("clip", "rect(0,1024,768,459.500)");
m.bankPointerLineR.set("clip", "rect(0,459.500,768,0)");
m.PitchScale.set("clip", "rect(134,590,394,330)");
#note to my self clip for the Pitch Scale is: top = 134 right = 590 bottem = 394 left = 330
return m
},
updateAi: func(roll,pitch){
if (pitch > 80 )
{
pitch = 80;
}
elsif(pitch < -80)
{
pitch = -80;
}
RollR = -roll*D2R;
me.Horizon.rot.setRotation(RollR, me.PitchScale.getCenter());
me.Horizon.trans.setTranslation(0,pitch*6.8571428);
me.HorizonLine.rot.setRotation(RollR, me.PitchScale.getCenter());
me.HorizonLine.trans.setTranslation(0,pitch*6.8571428);
me.PitchScale.rot.setRotation(RollR, me.PitchScale.getCenter());
me.PitchScale.trans.setTranslation(0,pitch*6.8571428);
brot = me.bankPointer.getCenter();
me.bankPointer.rot.setRotation(RollR,brot);
me.bankPointerLineL.rot.setRotation(RollR,brot);
me.bankPointerLineR.rot.setRotation(RollR,brot);
if (RollR < 0) #top, right, bottom, left
{
me.bankPointerLineL.set("clip", "rect(0,1,1,0)"); #459,500
me.bankPointerLineR.set("clip", "rect(0,459.500,768,0)");
}
elsif (RollR > 0)
{
me.bankPointerLineL.set("clip", "rect(0,1024,768,459.500)"); #459,500
me.bankPointerLineR.set("clip", "rect(0,1,1,0)");
}
else
{
me.bankPointerLineL.set("clip", "rect(0,1024,768,459.500)"); #459,500
me.bankPointerLineR.set("clip", "rect(0,459.500,768,0)");
}
},
}
and here id the diff:
- Code: Select all
19c19
< var svg_keys = ["LindSpeed","SpeedNonLint","SpeedLastDigitLint", "Horizon","bankPointer","bankPointerLineL", "bankPointerLineR","Compass","AltNonLintBig","AltNonLintSmall","AltLint","SlipSkid","CompassText","VSI","VSIText","PitchScale","HorizonLine"];
---
> var svg_keys = ["LindSpeed","SpeedNonLint","SpeedLastDigitLint", "Horizon","bankPointer","bankPointerLineL", "bankPointerLineR","Compass","AltNonLintBig","AltNonLintSmall","AltLint","SlipSkid","CompassText","VSI","VSIText","HorizonLine", "PitchScale"];
22,27c22,27
< m[key] = {};
< m[key].Element = pfd.getElementById(key);
< m[key].Element.updateCenter();
< m[key].center = m[key].Element.getCenter();
< m[key].roll = m[key].Element.createTransform();
< m[key].pitch = m[key].Element.createTransform();
---
> m[key] = nil;
> m[key] = pfd.getElementById(key);
> m[key].updateCenter();
> m[key].trans = m[key].createTransform();
> m[key].rot = m[key].createTransform();
>
32,35c32,34
<
< m.bankPointerLineL.Element.set("clip", "rect(0,1024,768,459.500)");
< m.bankPointerLineR.Element.set("clip", "rect(0,459.500,768,0)");
< m.PitchScale.Element.set("clip", "rect(134,590,394,330)");
---
> m.bankPointerLineL.set("clip", "rect(0,1024,768,459.500)");
> m.bankPointerLineR.set("clip", "rect(0,459.500,768,0)");
> m.PitchScale.set("clip", "rect(134,590,394,330)");
40,60c39,61
< updateAi: func(Roll,Pitch){
< #offset = 392.504021806/2;
< offset = 10;
< #if(Pitch < 1.3962634)
< #{
< # Pitch = 1.3962634;
< #}
< #elsif (Pitch > -1.3962634)
< #{
< # Pitch = 1.3962634;
< #};
< RollR = -Roll*D2R;
<
< Bpc = me.bankPointer.Element.getCenter();
< me.bankPointer.roll.setRotation(RollR, Bpc);
< me.bankPointerLineL.roll.setRotation(RollR, Bpc);
< me.bankPointerLineR.roll.setRotation(RollR, Bpc);
<
< me.Horizon.roll.setRotation(RollR, Bpc);
< me.HorizonLine.roll.setRotation(RollR, Bpc);
< me.PitchScale.roll.setRotation(RollR, Bpc);
---
> updateAi: func(roll,pitch){
> if (pitch > 80 )
> {
> pitch = 80;
> }
> elsif(pitch < -80)
> {
> pitch = -80;
> }
>
> RollR = -roll*D2R;
>
> me.Horizon.rot.setRotation(RollR, me.PitchScale.getCenter());
> me.Horizon.trans.setTranslation(0,pitch*6.8571428);
> me.HorizonLine.rot.setRotation(RollR, me.PitchScale.getCenter());
> me.HorizonLine.trans.setTranslation(0,pitch*6.8571428);
> me.PitchScale.rot.setRotation(RollR, me.PitchScale.getCenter());
> me.PitchScale.trans.setTranslation(0,pitch*6.8571428);
>
> brot = me.bankPointer.getCenter();
> me.bankPointer.rot.setRotation(RollR,brot);
> me.bankPointerLineL.rot.setRotation(RollR,brot);
> me.bankPointerLineR.rot.setRotation(RollR,brot);
62d62
< print(Bpc);
65,66c65,66
< me.bankPointerLineL.Element.set("clip", "rect(0,1,1,0)"); #459,500
< me.bankPointerLineR.Element.set("clip", "rect(0,459.500,768,0)");
---
> me.bankPointerLineL.set("clip", "rect(0,1,1,0)"); #459,500
> me.bankPointerLineR.set("clip", "rect(0,459.500,768,0)");
70,71c70,71
< me.bankPointerLineL.Element.set("clip", "rect(0,1024,768,459.500)"); #459,500
< me.bankPointerLineR.Element.set("clip", "rect(0,1,1,0)");
---
> me.bankPointerLineL.set("clip", "rect(0,1024,768,459.500)"); #459,500
> me.bankPointerLineR.set("clip", "rect(0,1,1,0)");
75,76c75,76
< me.bankPointerLineL.Element.set("clip", "rect(0,1024,768,459.500)"); #459,500
< me.bankPointerLineR.Element.set("clip", "rect(0,459.500,768,0)");
---
> me.bankPointerLineL.set("clip", "rect(0,1024,768,459.500)"); #459,500
> me.bankPointerLineR.set("clip", "rect(0,459.500,768,0)");
78,80d77
< me.Horizon.pitch.setTranslation(0,Pitch*offset);
< me.HorizonLine.pitch.setTranslation(0,Pitch*offset);
< me.PitchScale.pitch.setTranslation(0,Pitch*offset);