• Guest Please check out the Help Wanted thread in Ickie's NewsHawks.
    The future of the Outhouse depends on you!
    Help Wanted

Controlled Animation Question

Paul Domingue

SOH-CM-2023
I have several animated parts on mymodel that need to be controlled by IAS and some by AOA. I have noidea at this point how to enable this. I assume that I will have tocreate a new variable in the model definition file. Are there anyexamples of code available that I could study in relation to what Iwant to achieve?
 
I have several animated parts on mymodel that need to be controlled by IAS and some by AOA. I have noidea at this point how to enable this. I assume that I will have tocreate a new variable in the model definition file. Are there anyexamples of code available that I could study in relation to what Iwant to achieve?

Hi Paul,

You can find working tested xml here:

http://www.aerodynamika.com/cgi-bin/yabb2/YaBB.pl?board=XML


Or, hop over to FSDeveloper to check out their advice.
 
Code:
<part>
    <name>XXXXXXXX</name>
    <animation>
        <parameter>
            <code>
                            (A:AIRSPEED INDICATED, knots) 250 >
                            if{ 1000 } els{ 0 }
            </code>
                        <lag>200</lag>
        </parameter>
    </animation>
</part>


Part Animation:
Keyframe 0 & Keyframe 1000

Is IAS slower than 250 Ktn, moved the animation to keyframe 0.
Is IAS faster than 250 Ktn, moved the animation to keyframe 1000.

<lag>200</lag> is the maximum speed of movement. 200 key frames/second = 5 secounds from keyframe 0 to keyframe 1000 and vice versa.
 
Code:
<part>
    <name>XXXXXXXX</name>
    <animation>
        <parameter>
            <code>
                            (A:AIRSPEED INDICATED, knots) 250 >
                            if{ 1000 } els{ 0 }
            </code>
                        <lag>200</lag>
        </parameter>
    </animation>
</part>


Part Animation:
Keyframe 0 & Keyframe 1000

Is IAS slower than 250 Ktn, moved the animation to keyframe 0.
Is IAS faster than 250 Ktn, moved the animation to keyframe 1000.

<lag>200</lag> is the maximum speed of movement. 200 key frames/second = 5 secounds from keyframe 0 to keyframe 1000 and vice versa.

Thanks for the code sample Flusirainer. It looks relatively simple but since I have not tried adding code to the model def file it will be an interesting exercise. I was woundering if the keyframe 1000 indicates an out of bounds or do I actualy need to have 1000 keyframes in my model animation.
 
I have been digging through as much information as I can but still am at a loss as to how to write what I want to happen in the animation. I have tried several changes but can't grasp what I need to write for it to work. In the following <PartInfo> the only line that works is the first one. How do I have it read each step? I suspect that everything could be written into just the first line but again I have no concept as to how this would be done.
Now to make things even more complicated I want each increment of the slat animation to call a FS keyboard key press, the F6 and F7 keys. Since the animation is only visual I need it to call a leading edge flap section of the aircraft.cfg so that the lift and drag scalars come into effect.


Another question is what is the difference between <Code> and <Sim>? I see both being used.


Oh if only I could write this in Pascal life would be so much easier.


Your grateful code idiot
Paul


Code:
<PartInfo>
    <Name>su37_slats</Name>
    <AnimLength>1000</AnimLength>
    <Animation>
        <Parameter>
            <Code>
                (A:AIRSPEED INDICATED, knots) 110 > if{ 148 } els{ 0 }
                (A:AIRSPEED INDICATED, knots) 130 > if{ 290 } els{ 148 }
                (A:AIRSPEED INDICATED, knots) 150 > if{ 432 } els{ 290 }
                (A:AIRSPEED INDICATED, knots) 170 > if{ 574 } els{ 432 }
                (A:AIRSPEED INDICATED, knots) 190 > if{ 716 } els{ 574 }
                (A:AIRSPEED INDICATED, knots) 210 > if{ 858 } els{ 716 }
                (A:AIRSPEED INDICATED, knots) 230 > if{ 1000 } els{ 858 }
            </Code>
        </Parameter>
        <Lag>25</Lag>
    </Animation>
</PartInfo>
 
I have this code now that works but my math is so rusty I can't quite get proper scale and bias to even out the animation. IAS range is from 140 to 250 and animation length is 920. It's smooth at the high end but not on the low. IAS 250 * 3.4 + 110 = 920 but IAS 141 * 3.4 +110 = 589.4 so that doesn't work quite right. I need to brush up on my algebra 101. :redf:
Code:
<PartInfo>
  <Name>su37_slats</Name>
  <AnimLength>920</AnimLength>
  <Animation>
   <Parameter>
    <Code>
                    (A:AIRSPEED INDICATED, knots) 140 < if{ 0 } els{ (A:AIRSPEED INDICATED, knots) 3.4 * 110 + }
    </Code>
   </Parameter>
   <Lag>200</Lag>
  </Animation>
    </PartInfo>
 
I am certainly no expert on .xml programming - I tend to try it & fly it - sometimes with no success, but first guess is that you might need to round off the calculation with 'near' or 'flr' to get a whole number.
Keith
 
How does work the animation?

140 KIAS = Keyframe 0
250 KIAS = Keyframe 920

???


============================================================
============================================================
============================================================

250 KIAS - 140 KIAS = 110 KIAS

920 Keyframes / 110 KIAS = 8.3636 ( 1 KIAS = 8.3636 Keyframes) that means (A:AIRSPEED INDICATED, knots) 8.3636 *

it follows
0 KIAS = Keyframe 0
110 KIAS = Keyframe 920



How do I get keyframe 0 to 140 KIAS?


140 KIAS * 8.3636 Keyframes = 1170.9; it must be deducted 1170.9 keyframes
it follows
0 KIAS = -1170.9 Keyframes

(A:AIRSPEED INDICATED, knots) 8.3636 * 1170.9 -


Code:
    <Code>
                   (A:AIRSPEED INDICATED, knots) 8.3636 * 1170.9 - 
    </Code>


I hope I have now made no​​ mistake.
I'm not a specialist. I must it all work out and test.
I tested it not.
 
Flusirainer, that is what I tried to figure out but my math skills are rusty. I did get it to work with help from Fr. Bill. He pointed out using the stack to store a value. I will take your logic and apply it for my own understanding and try it in the animation. The code now is ......

Code:
<PartInfo>
  <Name>su37_slats</Name>
  <AnimLength>1000</AnimLength>
  <Animation>
   <Parameter>
    <Code>
     (A:AIRSPEED INDICATED, knots) s0 140 < if{ 0 }
     l0 140 > if{ 83 }
     l0 150 > if{ 166 }
     l0 160 > if{ 249 }     
     l0 170 > if{ 332 }
     l0 180 > if{ 415 }
     l0 190 > if{ 498 }
     l0 200 > if{ 581 }
     l0 210 > if{ 664 }
     l0 220 > if{ 747 }
     l0 230 > if{ 830 }
     l0 240 > if{ 913 }
     l0 250 > if{ 1000 }
    </Code>
   </Parameter>
   <Lag>400</Lag>
  </Animation>
</PartInfo>
 
Using your calculations Flusirainer I came up with this.

Code:
 <PartInfo>
  <Name>su37_slats</Name>
  <AnimLength>1000</AnimLength>
  <Animation>
   <Parameter>
    <Code>
     (A:AIRSPEED INDICATED, knots) 9.0909 * 1272.7272 -
    </Code>
   </Parameter>
   <Lag>400</Lag>
  </Animation>
    </PartInfo>

Both methods work. Now I am a little further in the "XML for Idiots" hand book. :kilroy:
 
Back
Top