Board index FlightGear Development Aircraft Cockpit development

Can select animations be nested/grouped?

Discussion about creating 2d and 3d cockpits.

Can select animations be nested/grouped?

Postby MariuszXC » Sun Nov 20, 2022 11:09 pm

Context: a LED-bar type fuel level indicator display consisting of 32 LEDs.

Animating each particular led is not difficult:
Code: Select all
<animation>
  <type>select</type>
  <object-name>led.fuel0.2</object-name>
  <condition>
    <greater-than-equals>
      <property>/consumables/fuel/tank[0]/level-gal_us</property>
      <value>1.0</value>
    </greater-than-equals>
  </condition>
</animation>

and this animation is repeated for other 31 remaining LEDs, with condition values adjusted respectively.

All is nice and good until one wants to include special modes of operation in this indicator. For example:
- when fuel quantity sensor is contaminated, only first and last LED should illuminate, and
- when fuel quantity sensor is defective, all LEDs should remain unlit.

So, I can add two additional animations for the above special cases _and_ complicate the condition logic in_every_ animation.
This seems wasteful and computational resource unfriendly.

Is there a way to define an animation group? Basically, I would like to enclose the 32 separate animations into one group/block, executed where everything is operational, and have two other animations executed for special cases. Something like:
Code: Select all
if (operational)
   execute animation block
elseif (contaminated)
   execute dedicated animation
else
   execute other dedicated animation


What would be the best way to approach this?
INOP
MariuszXC
 
Posts: 1061
Joined: Tue May 18, 2021 5:38 pm
Location: Europe
Callsign: SP-MRM
Version: 2020.4
OS: Ubuntu 16.04

Re: Can select animations be nested/grouped?

Postby Isaak » Sun Nov 20, 2022 11:20 pm

I'd group the led models in the .ac file (e.g. via Blender) and perform the select animation on the group first. Below that, the individual LED select animation with the same (<not> ?) Condition for every LED to make sure they are not applied when one of the group conditions is active. Without this generic extra condition it probably won't work, so the downside is you'll need some nesting on the individual LED's but the upside is that you can probably use one or two generic conditions that you can copy/paste for each of them.
Want to support medical research with your pc? Start Folding at Home and join team FlightGear!
Isaak
 
Posts: 768
Joined: Sat Jun 04, 2011 3:52 pm
Location: Hamme, Belgium
Pronouns: he, him
Callsign: OO-ISA
Version: next
OS: Windows 10

Re: Can select animations be nested/grouped?

Postby MariuszXC » Sun Nov 20, 2022 11:26 pm

I fail to see how this would lessen the number of tests. If I understand your idea, I would need to define a led group for every fuel level threshold - and still have tests responsible for activating the right group, depending on fuel level.

Given the indicator resolution I don't think it is possible to go below 32 test conditions, but I would love to have logic of these conditions as uncomplicaded (therefore fast) as possible..
INOP
MariuszXC
 
Posts: 1061
Joined: Tue May 18, 2021 5:38 pm
Location: Europe
Callsign: SP-MRM
Version: 2020.4
OS: Ubuntu 16.04

Re: Can select animations be nested/grouped?

Postby TheEagle » Sun Nov 20, 2022 11:31 pm

If you have all 32 LED's in one group in Blender, you can have one select animation to hide the group when the indicator is defective. Then you have one select animation for each individual LED where you only test for the fuel level, and for the last and first lamp you add the contaminated condition. That gives 33 select animations ! :)
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Can select animations be nested/grouped?

Postby MariuszXC » Sun Nov 20, 2022 11:36 pm

Ah, ok, so if indicator is inop, the whole group is hidden and unavailable to the rest of animations (won't they complain?)
In the remaining 33 animations I would still have to complicate the condition logic, by checking (in 32 of them) for both fuel level _and_ sensor not contaminated condition, right?
INOP
MariuszXC
 
Posts: 1061
Joined: Tue May 18, 2021 5:38 pm
Location: Europe
Callsign: SP-MRM
Version: 2020.4
OS: Ubuntu 16.04

Re: Can select animations be nested/grouped?

Postby TheEagle » Mon Nov 21, 2022 12:45 am

MariuszXC wrote in Sun Nov 20, 2022 11:36 pm:(won't they complain?)

I don't think so, but I haven't tried it either.

MariuszXC wrote:In the remaining 33 animations I would still have to complicate the condition logic, by checking (in 32 of them) for both fuel level _and_ sensor not contaminated condition, right?

Yeah, you're right - you need a top-level group with all LED's then which is hidden when the indicator is inoperative, inside that the first and last LED which need a special condition and a group which contains all but the first and last lamps which is hidden when the sensor is contaminated, and then have the select animation for each individual lamp based on the fuel level. Like this:

Code: Select all
AllLEDs -> shown when operative
    LED1 -> shown when fuel level > 0 or contaminated
    MainLEDs -> shown when not contaminated
        LED2 -> shown when fuel level > x
        LED3 -> shown when fuel level > y
        …
    LED32 -> shown when fuel level == 1 or contaminated
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Can select animations be nested/grouped?

Postby MariuszXC » Mon Nov 21, 2022 9:31 am

So I ended up with this. First and last led:
Code: Select all
   <animation>
      <type>select</type>
      <object-name>led.fuel0.1</object-name>
      <condition>
         <or>
            <and>
               <property>/fuelsystem/left-tank-quantity-sensor-contaminated</property>
               <property>/fuelsystem/left-tank-quantity-sensor-operational</property>
            </and>
            <and>
               <property>/fuelsystem/left-tank-quantity-sensor-operational</property>
               <less-than>
                  <property>/consumables/fuel/tank[0]/level-gal_us</property>
                  <value>1</value>
               </less-than>
            </and>
         </or>
      </condition>
   </animation>


Code: Select all
   <animation>
      <type>select</type>
      <object-name>led.fuel0.32</object-name>
      <condition>
         <or>
            <and>
               <property>/fuelsystem/left-tank-quantity-sensor-contaminated</property>
               <property>/fuelsystem/left-tank-quantity-sensor-operational</property>
            </and>
            <and>
               <property>/fuelsystem/left-tank-quantity-sensor-operational</property>
               <greater-than-equals>
                  <property>/consumables/fuel/tank[0]/level-gal_us</property>
                  <value>14.0</value>
               </greater-than-equals>
            </and>
         </or>
      </condition>
   </animation>


and all others like that (with different values in a level test ofc):

Code: Select all
   <animation>
      <type>select</type>
      <object-name>led.fuel0.31</object-name>
      <condition>
         <and>
            <property>/fuelsystem/left-tank-quantity-sensor-operational</property>
            <not>
               <property>/fuelsystem/left-tank-quantity-sensor-contaminated</property>
            </not>
            <greater-than-equals>
               <property>/consumables/fuel/tank[0]/level-gal_us</property>
               <value>13.57</value>
            </greater-than-equals>
         </and>
      </condition>
   </animation>


Not happy with that (and if I include further condition for whole display unit inoperable it will start looking messy).
For now I can only hope that FG uses early termination approach in evaluating logic statements (i.e. if a first condition in an AND block evaluates to false, it won't waste time evaluating the rest).
I really wish we had a way to group animation statements into logical blocks for use cases like this.
INOP
MariuszXC
 
Posts: 1061
Joined: Tue May 18, 2021 5:38 pm
Location: Europe
Callsign: SP-MRM
Version: 2020.4
OS: Ubuntu 16.04

Re: Can select animations be nested/grouped?

Postby WoodSTokk » Mon Nov 21, 2022 11:47 pm

AFAIK, you can group all LEDs for operational in one select animation and
most of it for contaminated sensor.
If an object has more than one select animation, all must be true to select the object.

Code: Select all
    <animation>
      <type>select</type>
      <object-name>led.fuel0.1</object-name>
      <object-name>led.fuel0.2</object-name>
      <object-name>led.fuel0.3</object-name>
      <object-name>led.fuel0.4</object-name>
      <object-name>led.fuel0.5</object-name>
      <object-name>led.fuel0.6</object-name>
      <object-name>led.fuel0.7</object-name>
      <object-name>led.fuel0.8</object-name>
      <object-name>led.fuel0.9</object-name>
      <object-name>led.fuel0.10</object-name>
      <object-name>led.fuel0.11</object-name>
      <object-name>led.fuel0.12</object-name>
      <object-name>led.fuel0.13</object-name>
      <object-name>led.fuel0.14</object-name>
      <object-name>led.fuel0.15</object-name>
      <object-name>led.fuel0.16</object-name>
      <object-name>led.fuel0.17</object-name>
      <object-name>led.fuel0.18</object-name>
      <object-name>led.fuel0.19</object-name>
      <object-name>led.fuel0.20</object-name>
      <object-name>led.fuel0.21</object-name>
      <object-name>led.fuel0.22</object-name>
      <object-name>led.fuel0.23</object-name>
      <object-name>led.fuel0.24</object-name>
      <object-name>led.fuel0.25</object-name>
      <object-name>led.fuel0.26</object-name>
      <object-name>led.fuel0.27</object-name>
      <object-name>led.fuel0.28</object-name>
      <object-name>led.fuel0.29</object-name>
      <object-name>led.fuel0.30</object-name>
      <object-name>led.fuel0.31</object-name>
      <object-name>led.fuel0.32</object-name>
      <condition>
        <property>/fuelsystem/left-tank-quantity-sensor-operational</property>
      </condition>
    </animation>

    <animation>
      <type>select</type>
      <object-name>led.fuel0.2</object-name>
      <object-name>led.fuel0.3</object-name>
      <object-name>led.fuel0.4</object-name>
      <object-name>led.fuel0.5</object-name>
      <object-name>led.fuel0.6</object-name>
      <object-name>led.fuel0.7</object-name>
      <object-name>led.fuel0.8</object-name>
      <object-name>led.fuel0.9</object-name>
      <object-name>led.fuel0.10</object-name>
      <object-name>led.fuel0.11</object-name>
      <object-name>led.fuel0.12</object-name>
      <object-name>led.fuel0.13</object-name>
      <object-name>led.fuel0.14</object-name>
      <object-name>led.fuel0.15</object-name>
      <object-name>led.fuel0.16</object-name>
      <object-name>led.fuel0.17</object-name>
      <object-name>led.fuel0.18</object-name>
      <object-name>led.fuel0.19</object-name>
      <object-name>led.fuel0.20</object-name>
      <object-name>led.fuel0.21</object-name>
      <object-name>led.fuel0.22</object-name>
      <object-name>led.fuel0.23</object-name>
      <object-name>led.fuel0.24</object-name>
      <object-name>led.fuel0.25</object-name>
      <object-name>led.fuel0.26</object-name>
      <object-name>led.fuel0.27</object-name>
      <object-name>led.fuel0.28</object-name>
      <object-name>led.fuel0.29</object-name>
      <object-name>led.fuel0.30</object-name>
      <object-name>led.fuel0.31</object-name>
      <condition>
        <not><property>/fuelsystem/left-tank-quantity-sensor-contaminated</property></not>
      </condition>
    </animation>


Than you have only the normal condition on all LEDs expext the first and last.

Code: Select all
    <animation>
      <type>select</type>
      <object-name>led.fuel0.1</object-name>
      <condition>
        <or>
          <less-than>
            <property>/consumables/fuel/tank[0]/level-gal_us</property>
            <value>1</value>
          </less-than>
          <property>/fuelsystem/left-tank-quantity-sensor-contaminated</property>
        </or>
      </condition>
    </animation>

    <animation>
      <type>select</type>
      <object-name>led.fuel0.32</object-name>
      <condition>
        <or>
          <greater-than-equals>
            <property>/consumables/fuel/tank[0]/level-gal_us</property>
            <value>14</value>
          </greater-than-equals>
          <property>/fuelsystem/left-tank-quantity-sensor-contaminated</property>
        </or>
      </condition>
    </animation>

    <animation>
      <type>select</type>
      <object-name>led.fuel0.31</object-name>
      <condition>
        <greater-than-equals>
          <property>/consumables/fuel/tank[0]/level-gal_us</property>
          <value>13.57</value>
        </greater-than-equals>
      </condition>
    </animation>
WoodSTokk
 
Posts: 1077
Joined: Tue Oct 17, 2017 3:30 pm
Location: Milky Way/Sol/Earth/Europe
Callsign: SX-W57
IRC name: WoodSTokk
Version: 2020.4.0
OS: Debian Bullseye

Re: Can select animations be nested/grouped?

Postby MariuszXC » Tue Nov 22, 2022 12:07 pm

WoodSTokk wrote in Mon Nov 21, 2022 11:47 pm:If an object has more than one select animation, all must be true to select the object.


And this is the key piece of knowledge I was missing. Thank you a lot!
BTW: is it documented anywhere?
INOP
MariuszXC
 
Posts: 1061
Joined: Tue May 18, 2021 5:38 pm
Location: Europe
Callsign: SP-MRM
Version: 2020.4
OS: Ubuntu 16.04


Return to Cockpit development

Who is online

Users browsing this forum: No registered users and 2 guests

cron