Board index FlightGear Development Documentation

Does the rotate animation also support random start pos ?

Discussion of the FlightGear documentation, how it can be improved and coordination of people working on it.

Does the rotate animation also support random start pos ?

Postby TheEagle » Fri Oct 22, 2021 5:58 pm

I found this snippet in the animation file of a wind turbine scenery object:
Code: Select all
   <animation>
      <type>spin</type>
      <object-name>hub</object-name>
      <object-name>wing_01</object-name>
      <object-name>wing_02</object-name>
      <object-name>wing_03</object-name>
      <use-personality type="bool">true</use-personality>
      <property>/environment/wind-speed-kt</property>
      
      <interpolation>
         <entry><ind>  0.0 </ind><dep>  0.0 </dep></entry>
         <entry><ind> 23.3 </ind><dep>  6.0 </dep></entry>
         <entry><ind> 54.0 </ind><dep> 19.5 </dep></entry>
         <entry><ind>100.0 </ind><dep>  0.0 </dep></entry>
      </interpolation>
      <starting-pos-deg>
         <random>
            <min>0</min>
            <max>360</max>
         </random>
      </starting-pos-deg>
      <axis>
         <x1-m> 0.000</x1-m>
         <y1-m>-7.378</y1-m>
         <z1-m>85.646</z1-m>
         <x2-m> 0.000</x2-m>
         <y2-m> 4.557</y2-m>
         <z2-m>84.601</z2-m>
      </axis>
   </animation>

Is there anything similar available for rotate ? This would be very helpful for animating bobbing boats.
Also, what does use-personality do ? I could not find any documentation. neither for this, nor for the starting-pos-deg.
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: Does the rotate animation also support random start pos

Postby erik » Sat Oct 23, 2021 12:50 pm

I guess bobbing could be animated by positioning the craft slightly off-center from the center of gravity using the translate animation first and then applying a rotation animation.

Erik
Current: Parachutist, Paraglider, Pterosaur, Pilatus PC-9M and variants, ERCO Ercoupe, Fokker Dr.1, Fokker 50, Fokker 100
Less active: Cessna T-37, T-38, Santa Claus. Previous: General Dynamics F-16. Worked on: Wright Flyer
erik
 
Posts: 2244
Joined: Thu Nov 01, 2007 2:41 pm

Re: Does the rotate animation also support random start pos

Postby TheEagle » Sat Oct 23, 2021 2:27 pm

The problem isn't the bobbing itself, but rather that all boats of the same model bob the same amount. With a random <offset-deg> for rotation or a random <offset-m> for translation, this could be remedied very simply.
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: Does the rotate animation also support random start pos

Postby merspieler » Sat Oct 23, 2021 4:26 pm

Hm... can you access the location of a model? if so, you can use that as some sort of seed... also with a bit tuning, this could make things even more realistic as the movement at least on bigger waves (in comparison to the boat) affects all boats.. just not at the same time so you could have the effect of a wave rolling under the boats
Nia (you&, she/her)

Please use gender neutral terms when referring to a group of people!

Be the change you wish to see in the world, be an ally to all!

Join the official matrix space
merspieler
 
Posts: 2241
Joined: Thu Oct 26, 2017 11:43 am
Location: Wish to be in YBCS
Pronouns: you&, she/her
Callsign: you&, she/her
IRC name: merspieler
Version: next
OS: NixOS

Re: Does the rotate animation also support random start pos

Postby TheEagle » Sat Oct 23, 2021 4:32 pm

Through Nasal it probably could be done, but anything I do with Nasal has to be communicated to the model through a property, and there we are again at the old problem - all models share the same property tree. Would be great if one could determine the property for each model individually at runtime. I have seen that in the type 1 interactive jetways, the property paths are relative (such as ../../../../position-norm or something). That would be just the thing we need for the boats.
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: Does the rotate animation also support random start pos

Postby Thorsten » Sat Oct 23, 2021 6:28 pm

and there we are again at the old problem - all models share the same property tree


A simple solution is equally old - create ~5 different driving properties via property rules, assign each of the models one of the five, and you get a credible illusion. It's a common assumption that for 500 models you need 500 different animations to make them look random - much less will actually do the trick.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Does the rotate animation also support random start pos

Postby TheEagle » Sat Oct 23, 2021 6:42 pm

Actually I had the exactly same idea, and it probably is the simplest solution. But all the many boat objects (> 400, probably far more !) would need to be deleted and re-placed one by one. If we could just have some random offset for each model independently, we would just have to update the models, and not re-place the objects.
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: Does the rotate animation also support random start pos

Postby erik » Sun Oct 24, 2021 7:53 am

I just remembered that both YASim and JSBSim use the following code for "bumpiness" of the surface (line 113):
https://sourceforge.net/p/flightgear/fl ... m/Gear.cpp

Code: Select all
float Gear::getBumpAltitude()
{
    if (_ground_bumpiness<0.001) return 0.0;
    double x = _global_x*0.1;
    double y = _global_y*0.1;
    x -= Math::floor(x);
    y -= Math::floor(y);
    x *= 2*YASIM_PI;
    y *= 2*YASIM_PI;
    //now x and y are in the range of 0..2pi
    //we need a function, that is periodically on 2pi and gives some
    //height. This is not very fast, but for a beginning.
    //maybe this should be done by interpolating between some precalculated
    //values
    float h = Math::sin(x)+Math::sin(7*x)+Math::sin(8*x)+Math::sin(13*x);
    h += Math::sin(2*y)+Math::sin(5*y)+Math::sin(9*y*x)+Math::sin(17*y);

    return h*(1/8.)*_ground_bumpiness*maxGroundBumpAmplitude;
}

Where _global_x and _global_y are global Cartastian coordinates.
You could use the same functionality as a starting point and then use time to move from there.

Erik
Current: Parachutist, Paraglider, Pterosaur, Pilatus PC-9M and variants, ERCO Ercoupe, Fokker Dr.1, Fokker 50, Fokker 100
Less active: Cessna T-37, T-38, Santa Claus. Previous: General Dynamics F-16. Worked on: Wright Flyer
erik
 
Posts: 2244
Joined: Thu Nov 01, 2007 2:41 pm

Re: Does the rotate animation also support random start pos

Postby TheEagle » Sun Oct 24, 2021 2:25 pm

Looks good, but how am I supposed to get _global_x and _global_y into an <expression> ?
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: Does the rotate animation also support random start pos

Postby erik » Sun Oct 24, 2021 2:37 pm

I see there is a property global-x and global-y in the position sub tree of AI aircraft.
But I guess this isn't about AI models but rather about scenery models?

Erik
Current: Parachutist, Paraglider, Pterosaur, Pilatus PC-9M and variants, ERCO Ercoupe, Fokker Dr.1, Fokker 50, Fokker 100
Less active: Cessna T-37, T-38, Santa Claus. Previous: General Dynamics F-16. Worked on: Wright Flyer
erik
 
Posts: 2244
Joined: Thu Nov 01, 2007 2:41 pm

Re: Does the rotate animation also support random start pos

Postby TheEagle » Sun Oct 24, 2021 4:23 pm

@erik I think everything in /ai is either AI traffic or multiplayer models. But I will look.
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: Does the rotate animation also support random start pos

Postby TheEagle » Sun Oct 24, 2021 4:53 pm

I spawned directly besides my bobbing boats, and the only thing I found inside /ai were two carriers. So no luck in that direction.
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: Does the rotate animation also support random start pos

Postby Thorsten » Sun Oct 24, 2021 5:00 pm

But all the many boat objects (> 400, probably far more !) would need to be deleted and re-placed one by one.


There's that marvelous invention called 'shell script' - if there's a menial task, usually you let the computer do it :mrgreen:
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Does the rotate animation also support random start pos

Postby TheEagle » Sun Oct 24, 2021 5:08 pm

Hmm, that would be an idea in case we find no better solution …
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: Does the rotate animation also support random start pos

Postby erik » Mon Oct 25, 2021 8:33 am

Maybe someone with more Nasal experience than I do could create a function which turns lat and lon (properties) into an initial value using this code.

Erik
Current: Parachutist, Paraglider, Pterosaur, Pilatus PC-9M and variants, ERCO Ercoupe, Fokker Dr.1, Fokker 50, Fokker 100
Less active: Cessna T-37, T-38, Santa Claus. Previous: General Dynamics F-16. Worked on: Wright Flyer
erik
 
Posts: 2244
Joined: Thu Nov 01, 2007 2:41 pm


Return to Documentation

Who is online

Users browsing this forum: No registered users and 3 guests