Board index FlightGear Development Aircraft Cockpit development

key + animation

Discussion about creating 2d and 3d cockpits.

key + animation

Postby Jabberwocky » Wed Jul 16, 2014 5:09 pm

Hi,

okay, I have a key binding that toggles a property. Now I need an animation. I have the model, I have everything, but I need to trigger it ...

So, is there a command for a secondary binding that can trigger the animation? Something like:
Code: Select all
         <key n="26">
            <name>Ctrl-Z</name>
            <desc>Toggle master autopilot switch</desc>
            <binding>
               <command>property-toggle</command>
               <property>autopilot/settings/engaged</property>
            </binding>
         </key>
         <key n="26">
            <condition>
               <property>controls/autoflight/autopilot/engage</property>
            </condition>
            <animation>
               <type>select</type>
            </animation>
         </key>


or, the other way, if I have to use command-Nasal-script, how do I trigger the animation from Nasal?

J.
Jabberwocky
Retired
 
Posts: 1319
Joined: Sat Mar 22, 2014 7:36 pm
Callsign: JWOCKY
Version: 3.0.0
OS: Ubuntu 14.04

Re: key + animation

Postby Gijs » Wed Jul 16, 2014 6:16 pm

It's much simpler than that. Animations are constantly evaluated, so as soon as the property changes, the animation will do it's thing. You only need the first key part from your code (get rid of that second block, it is invalid), and then in the animation XML:

Code: Select all
<animation>
  <object-name>theNameOfYourObject</object-name>
  <type>select</type>
  <condition>
    <property>autopilot/settings/engaged</property>
   </condition>
</animation>
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9338
Joined: Tue Jul 03, 2007 2:55 pm
Location: Amsterdam/Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: key + animation

Postby Jabberwocky » Wed Jul 16, 2014 9:41 pm

Now I am confused, because that is what I thought, animation-select should do (according to decription/wiki and board=

in the flightdeck xml I have
Code: Select all
   <animation>
      <type>pick</type>
      <object-name>AP</object-name>
      <object-name>yoke.AP</object-name>
      <action>
         <button>0</button>
         <repeatable type="bool">false</repeatable>
         <binding>
            <command>property-toggle</command>
            <property>controls/autoflight/autopilot/engage</property>
         </binding>
      </action>
   </animation>
   <animation>
      <type>select</type>
      <object-name>AP.light</object-name>
      <condition>
         <property>controls/autoflight/autopilot/engage</property>
      </condition>
   </animation>


Works wonderful is I press the button on the yoke (yoke.AP) with the mouse, works also wonderful for the button on the dashboard, but when I use Xtrl-Z instead, the light remains dark (the property autopilot/settings/engaged goes toggles to true though). That is why I had the idea, I have to do something extra for a key. Any idea?
Jabberwocky
Retired
 
Posts: 1319
Joined: Sat Mar 22, 2014 7:36 pm
Callsign: JWOCKY
Version: 3.0.0
OS: Ubuntu 14.04

Re: key + animation

Postby Philosopher » Wed Jul 16, 2014 9:46 pm

Your properties are different, check them again ;).
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Re: key + animation

Postby Jabberwocky » Wed Jul 16, 2014 11:29 pm

@Philosopher: Yep, found it just a minute ago. It's a derivate of a plane I didn't develop (because I'm not able yet to develop a whole plane) so I inherited a lot of those little glitches.

@Gijs: Thanks for the help, the error was another on though, my bad.
Jabberwocky
Retired
 
Posts: 1319
Joined: Sat Mar 22, 2014 7:36 pm
Callsign: JWOCKY
Version: 3.0.0
OS: Ubuntu 14.04

Re: key + animation

Postby agor » Fri Aug 08, 2014 11:25 am

I have a similar one and can't figure out how to solve that.

It is in regard with the sf25b i created, the model is finished and i am trying to make the panel look like the real one.

There's a lever on the panel that opens a ventilation shaft in front of the canopy.
by pressing a key the ventilation opens/closes, that's happens with a small nasal script.
But the lever on the panel does not.
Vice versa, when the lever is clicked it moves, but the ventilation not.
Here are the nasal and the xml codes:

nasal:
Code: Select all
var toggle_ventilation = func {
  ventilation = aircraft.door.new ("/controls/ventilation/",1);
  if(getprop("/controls/ventilation/position-norm") > 0) {
      ventilation.close();
  } else {

      ventilation.open();
  }


set:
Code: Select all
         <key n="100">
            <name>d</name>
            <desc>Toggle Air Ventilation</desc>
            <binding n="0">
               <command>nasal</command>
               <script>sf25b.toggle_ventilation()</script>
            </binding>
         </key>


lever xml:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<PropertyList>
   <path>lever.ac</path>
   <animation>
      <type>translate</type>
      <object-name>lever</object-name>
      <property>/controls/ventilation</property>
      <interpolation>
         <entry><ind>0.0</ind><dep>0.0</dep></entry>
         <entry><ind>1.0</ind><dep>0.03</dep></entry>
      </interpolation>

      <axis>
         <x>1</x>
         <y>0</y>
         <z>0</z>
      </axis>
   </animation>
   <animation>
      <type>pick</type>
      <object-name>lever</object-name>
      <action>
      <button>0</button>
         <binding>
            <command>property-toggle</command>
            <property>/controls/ventilation</property>
            <min>0</min>
            <max>1</max>
            <wrap>0</wrap>
         </binding>

      </action>
   </animation>
</PropertyList>


Attached is an image.

Image

Any suggestions will be appreciated.

PS: Two questions, not related to the topic:
1. The model is way over 10000 vertices, it's about 17000. Is that ok?
2. I created some new instruments, the textures are 512x512, should i convert them to 256x256?

Cheers.
agor
 
Posts: 21
Joined: Tue Dec 09, 2008 8:14 am

Re: key + animation

Postby Gijs » Fri Aug 08, 2014 11:33 am

Hi,

The door Nasal function output to the /position-norm child. So you want to bind your animation to /controls/ventilation/position-norm and use the same Nasal script binding on the lever as on the key. See our wiki for details. http://wiki.flightgear.org/Howto:Animat ... y_or_doors

Acceptable vertice/poly count and texture resolutions depend on what you're doing with them. Without looking at the model or the instruments, it's impossible to say what's acceptable.

Cheers,
Gijs

PS: Instead of using interpolaton, you could just as well use <factor>; saves a few lines ;-)
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9338
Joined: Tue Jul 03, 2007 2:55 pm
Location: Amsterdam/Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: key + animation

Postby agor » Fri Aug 08, 2014 12:00 pm

Wow, that was superfast! Thanks.

I'll have a look later, i think that is the answer though.

In regards with question 2, somewhere in the howtos it is statde that the textures should be 256x256, is it ok if i leave them 512x512 (that vhf fsg50 was a pain!
agor
 
Posts: 21
Joined: Tue Dec 09, 2008 8:14 am

Re: key + animation

Postby Gijs » Fri Aug 08, 2014 12:28 pm

That was probably just an example of powers of two. All textures must be powers of two (2^x), but not necessarily squares (eg. 16x16). Eg. 16x256, 512x8, 1024x1024 etc. are all allowed.
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9338
Joined: Tue Jul 03, 2007 2:55 pm
Location: Amsterdam/Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: key + animation

Postby hvengel » Fri Aug 08, 2014 3:40 pm

Modern graphics cards can handle very large textures and huge numbers of vertices with minimal frame rate impact. A typical scene in FlightGear (with clouds, buildings rivers, roads...) has millions of vertices which simply dwarfs a 17K aircraft making the aircraft model an insignificant factor. The general rule is use enough vertices and large enough textures to make things look right and no more. More recent aircraft efforts tend to have much higher vertex counts, much larger textures and a lot more detail then older work because of how capable modern hardware is. It is not unusual to see newer aircraft exceeding 100K vertices. For example the P-51D that will be released with 3.2 has an external model that is slightly over 100K vertices and this had a minimal frame rate impact on my (newer high end) hardware compared to the old 10K external model.

If you can't see the difference between using a 512x512 instrument texture compared to a 256x256 texture then use the smaller texture. But if you can see the difference then use the larger texture. On modern hardware the difference in frame rate will be very small but it may impact those with older/slower/obsolete hardware in a noticeable way. All of the instruments in the P-51D are 512x512 for larger gauges or 256x256 for smaller gauges and at least to me they have a sharp appearance even when zoomed in fairly close. Many older aircraft use 128x128 textures for instruments but to me at least on the larger instruments on a very high resolution monitor these textures are a little bit fuzzy in appearance. The other thing I do is I create the textures at much higher resolution and then scale it to final size. This allows the scaling algorithm in the graphics package to apply anti aliasing during the scaling process which I think helps make the smaller textures look good since it reduces the appearance of jaggies.
hvengel
Retired
 
Posts: 1128
Joined: Sun Dec 24, 2006 4:35 am
Location: Minden Nevada

Re: key + animation

Postby agor » Fri Aug 08, 2014 4:42 pm

@Gijs
Yes, your suggestion worked perfectly, i also replaced the interpolation with factor . The code looks much nicer. Moving on to other stuff now.

@Gijs and @hvengel
That covers it all.
My machine at home with a quad i5, loads of ram and a recent graphics card has no issues.
At work with a dual core pentium D, 2g of ram and an older 7600GT a test flight resulted in a crash when i moved close to mountains with lots of trees.
Both machines running LinuxMint17x64.
Probably that's a ram issue due to the new scenery.

Thanks to both.
agor
 
Posts: 21
Joined: Tue Dec 09, 2008 8:14 am

Re: key + animation

Postby agor » Sat Aug 09, 2014 12:10 am

Spamming today eh?
Ok, I've trying to set startup values to the transponder and failed until now.
A look at the previous image will reveal our sf25b is using the Bendix/King kt76a.
I messed with the original xml and the panel xml but the property-assign doesn't have any effect.
I am trying to set the original 1200 value to 7000. Do i have to go nasal?

Goodnight, time to go to bed here.
agor
 
Posts: 21
Joined: Tue Dec 09, 2008 8:14 am


Return to Cockpit development

Who is online

Users browsing this forum: No registered users and 0 guests