Here's script to make it easier to animate all those cowl flaps on
radial engines. It probably works well for waste flaps on jet engine
intakes as well. Plus, I bet it works a treat on variable cross section
jet nozzles too.

At some point it should be up on 
http://jrbabcock.home.comcast.net/flightgear/scripts/

Josh


#!/usr/bin/perl -w
# (c) 2005 Josh Babcock [EMAIL PROTECTED]

# Script to generate FlightGear xml for animating arcs of engine flaps.
# usage: cat <some csv file> | cowl_anim.pl > <some xml file>

# Feed me a csv file of vertexes. There should be $engines * ($flaps +1) 
vertexes in the file.
# The vertexes are the intersections of the hinges, lined up and going around 
in a
# clockwise direction as seen from the back of the aircraft. Each vertex except 
the first and
# last for each engine is shared between two flap hinges. Mind you, the flaps 
don't actually
# have to be touching, but the axis of each flap must intersect the axis of 
both adjoining
# flap's hinges for this to work, though how you will get these coords if the 
flaps don't share
# vertexes I don't know :) I did it by hand from the Blender interface.

# Once you do that, I should spit out some xml suitable to be included in a 
FlightGear animation
# file. To use the xml, the flaps must be named starting at $base1a. Be sure to 
also adjust $swing.
# There is also a handy $indent variable. Use it wisely.

# Change these values to suit.
my $engines=4;
my $flaps=12; # Remember you need $flaps+1 vertexes for each engine.
my $swing=-15; # Negative for swinging out from a LE hinge, in for a TE hinge.
my $prop_beg="/controls/engines/engine[";
my $prop_end="]/cowl-flaps-norm";
my $base="CowlFlap"; # eg. CowlFlap for CowlFlap1a .. CowlFlap4l with 
$engines=4 and $flaps=12.
my $indent=" ";

# Internal stuff
my @coord;
my @last_coord;
my $d;
my $e;
my $f;
my $n;
my $o;

for ($e=1; $e<=$engines; $e++) {
    $d = $e - 1;
    $line = <stdin> or die "Unexpected end of file";
    chop $line;
    @last_coord = split(/,/, $line);

    for ($n=0; $n<$flaps; $n++) {
        $o = $n +1;
        print "${indent}<!-- Engine $e Flap $o -->\n\n";
        # 97 = ASCII 'a'
        $f=chr($n + 97);

        $line = <stdin> or die "Unexpected end of file";
        chop $line;
        @coord = split(/,/, $line);

        print "${indent}<animation>\n";
        print "${indent} <type>rotate</type>\n";
        print "${indent} <object-name>${base}${e}${f}</object-name>\n";
        print "${indent} <property>${prop_beg}${d}${prop_end}</property>\n";
        print "${indent} <factor>$swing</factor>\n";
        print "${indent} <axis>\n";
        print "${indent}  <x1-m>$last_coord[0]</x1-m>\n";
        print "${indent}  <y1-m>$last_coord[1]</y1-m>\n";
        print "${indent}  <z1-m>$last_coord[2]</z1-m>\n";
        print "${indent}  <x2-m>$coord[0]</x2-m>\n";
        print "${indent}  <y2-m>$coord[1]</y2-m>\n";
        print "${indent}  <z2-m>$coord[2]</z2-m>\n";
        print "${indent} </axis>\n";
        print "${indent}</animation>\n\n";
        @last_coord = @coord;
    }
}

exit 0;

_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@flightgear.org
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d

Reply via email to