PDA

View Full Version : Controlled Animation Question



Paul Domingue
July 12th, 2012, 11:52
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?

Milton Shupe
July 12th, 2012, 16:14
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.

Paul Domingue
July 12th, 2012, 19:52
Thanks Milton. I posted the same question at FSDevelopers as well but have not checked yet.

Flusirainer
July 13th, 2012, 08:16
<part>
<name>XXXXXXXX</name>
<animation>
<parameter>
<code>
(A:AIRSPEED INDICATED, knots) 250 &gt;
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.

Paul Domingue
July 13th, 2012, 09:18
<part>
<name>XXXXXXXX</name>
<animation>
<parameter>
<code>
(A:AIRSPEED INDICATED, knots) 250 &gt;
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.

Flusirainer
July 13th, 2012, 09:35
With Gmax and FSDS but up to 1024 keyframes are possible.

It is also possible to extend the keyframe animation sequences for a very long time. (http://www.fsdeveloper.com/forum/showthread.php?t=75502&highlight=Flusirainer)
In FS9 I use that for smooth movement of the instruments.

Paul Domingue
July 18th, 2012, 15:03
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



<PartInfo>
<Name>su37_slats</Name>
<AnimLength>1000</AnimLength>
<Animation>
<Parameter>
<Code>
(A:AIRSPEED INDICATED, knots) 110 &gt; if{ 148 } els{ 0 }
(A:AIRSPEED INDICATED, knots) 130 &gt; if{ 290 } els{ 148 }
(A:AIRSPEED INDICATED, knots) 150 &gt; if{ 432 } els{ 290 }
(A:AIRSPEED INDICATED, knots) 170 &gt; if{ 574 } els{ 432 }
(A:AIRSPEED INDICATED, knots) 190 &gt; if{ 716 } els{ 574 }
(A:AIRSPEED INDICATED, knots) 210 &gt; if{ 858 } els{ 716 }
(A:AIRSPEED INDICATED, knots) 230 &gt; if{ 1000 } els{ 858 }
</Code>
</Parameter>
<Lag>25</Lag>
</Animation>
</PartInfo>

Paul Domingue
July 19th, 2012, 02:15
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:

<PartInfo>
<Name>su37_slats</Name>
<AnimLength>920</AnimLength>
<Animation>
<Parameter>
<Code>
(A:AIRSPEED INDICATED, knots) 140 &lt; if{ 0 } els{ (A:AIRSPEED INDICATED, knots) 3.4 * 110 + }
</Code>
</Parameter>
<Lag>200</Lag>
</Animation>
</PartInfo>

Dev One
July 19th, 2012, 07:25
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

Flusirainer
July 19th, 2012, 09:59
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>
(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.

Paul Domingue
July 19th, 2012, 10:43
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 ......


<PartInfo>
<Name>su37_slats</Name>
<AnimLength>1000</AnimLength>
<Animation>
<Parameter>
<Code>
(A:AIRSPEED INDICATED, knots) s0 140 &lt; if{ 0 }
l0 140 &gt; if{ 83 }
l0 150 &gt; if{ 166 }
l0 160 &gt; if{ 249 }
l0 170 &gt; if{ 332 }
l0 180 &gt; if{ 415 }
l0 190 &gt; if{ 498 }
l0 200 &gt; if{ 581 }
l0 210 &gt; if{ 664 }
l0 220 &gt; if{ 747 }
l0 230 &gt; if{ 830 }
l0 240 &gt; if{ 913 }
l0 250 &gt; if{ 1000 }
</Code>
</Parameter>
<Lag>400</Lag>
</Animation>
</PartInfo>

Paul Domingue
July 19th, 2012, 13:47
Using your calculations Flusirainer I came up with this.


<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: