Stars_to_mel.split.perl
#!/usr/bin/perl
# used files : star.speck # will split the stars data into multiple maya scenes .
# the number of stars imported on each scene is defined by the linenum variable.


$linenum=1;
$file_num=0;
$D_FACTOR=50;

open (STARS_IN, "stars.speck");
open ( STARS_OUT, ">stars.$file_num.mel" );
print STDOUT ("what should the MEL file be called? \n ");
chop ($CONST_OUT2 = <STDIN>);
if (rename "And.mel", $CONST_OUT2) {
    print STDOUT "WORKING\n";
}
else {print STDOUT "NOT WORKING\n";}



#while-loop to go through each line of the dataset
while (defined($line = <STARS_IN>)) {
     
    $linenum++;
    $line =~ s/^\s+//;
    ($x, $y, $z, $colorb_v, $lum, $absmag, $appmag, $txno, $dist, $dcalc, $plx, $vz ,$speed ,$unknown1, $unknown2 , $unknown3,$num ,$asterix,  $name) = split(/\s+/, $line);


    if ($x eq "#") {
    ;
    }else{
    
    if($linenum >=20000){
        $file_num++;
        open ( STARS_OUT, ">stars.$file_num.mel" );
        $linenum =0;
        print($linenum);
        
    }
    
    printf STARS_OUT ("polySphere -r 1 -sx 4 -sy 4 -ax 0 1 0 -tx 1 -ch 0 -name \"%s\";\n", $name);
    $absmag = $colorb_v/2;
    $x= $x*$D_FACTOR;
    $y=  $y*$D_FACTOR;
    $z= $z*$D_FACTOR;
    printf STARS_OUT ("scale -r %g %g %g;\n", $absmag, $absmag, $absmag);
    printf STARS_OUT ("move -r %s %s %s;\n", $x, $y, $z);
    printf STARS_OUT ("sets -e -forceElement STAR_BLINN;\n");
     }
}

printf STDOUT ("written to specified MEL file.\n");