Anim8or Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Ian Ross has just released a book on Anim8or. It's perect for a beginner and a good reference for experienced users. It contains detailed chapters on every aspect, with many examples. Get your own copy here: "Anim8or Tutorial Book"

Author Topic: Space launcher Project : how do i add colors?  (Read 10331 times)

Clem

  • Newbie
  • *
  • Posts: 1
    • View Profile
Space launcher Project : how do i add colors?
« on: July 10, 2012, 09:44:38 am »

Hello everybody
I'm new on this forum and in the 3D modelling world aswell, so please excuse me if i'm not always using the right terms.
I'm currently working on a student project wich goal is to design quickly space launchers. I have already created programs that computes the masses, trajectory, aerodynamic coefficients, etc., but this project wouldn't be complete without a small visualisation program.
that's why i have chosen to work with anim8or

the idea is simple : i extract from all the programs i already have the geometrical data of my launcher, i insert them in a ASL script(using a fortran program, since i haven't found any read file in ASL), and then i draw the launcher using a few basic shapes that i have already created.

here is an example of a "basic shape" i use, inspired mainly of the shape script database i found in this forum ;)

Code: [Select]

shape $cylindric, $fond, $cc;
float $radius, $work, $height_top, $height_bottom, $height_summit, $height_rear,$top_tank_length,$bottom_tank_length, $abs, $rho, $outter_cylinder_length, $inter;
float $height_nozzle_fixation, $nozzle_throat_radius, $nozzle_exit_radius, $nozzle_length;
point3 $p;
int $i, $j, $V, $H;





$radius = 8.;
$height_top = 3.;
$height_bottom = 3.5;
$height_summit = 3.2;
$height_rear = 2.8;
$top_tank_length = 18.;
$height_nozzle_fixation = 1;
$nozzle_throat_radius = 2.5;
$nozzle_exit_radius = 4.5;
$nozzle_length = 7;
$bottom_tank_length =12.5;
$inter = 2.5;
$outter_cylinder_length = $height_top + $height_bottom + $height_summit + $height_rear + $top_tank_length + $bottom_tank_length +$inter +$nozzle_length+2*$nozzle_throat_radius/3;

$V = 100;
$H = 100;
$work = $V;


/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/


/*top tank top bulkhead*/

$fond = mesh();

$fond.Open();

$rho = (pow($radius,2) + pow($height_top,2))/(2*$height_top);

/*Create the 1st point (the peak)*/

$fond.AddPoint((0,$height_top,0));
/*---*/

/*Create the rest of the points*/

for $i = 1 to $H do {

  for $j = 1 to $V do {
    $p.x = ($j/$work)*$radius*cos(((2*3.14159)/$H)*($i-1));
    $p.z = ($j/$work)*$radius*sin(((2*3.14159)/$H)*($i-1));
    $abs = sqrt($p.x*$p.x+$p.z*$p.z);
    $p.y = (sqrt(pow($rho,2)-pow($abs,2))+$height_top-$rho);
    $fond.AddPoint($p);
  }

}
/*---*/

/*Now build the bottom row of faces (trigons)*/

for $i = 0 to ($H-2) do {

  $fond.OpenFace(0,0);
  $fond.VertexN(0);
  $fond.VertexN(1+(($i+1)*$V));
  $fond.VertexN(1+($i*$V));
  $fond.CloseFace();

}

$fond.OpenFace(0,0);
$fond.VertexN(0);
$fond.VertexN(1);
$fond.VertexN(1+($i*$V));
$fond.CloseFace();
/*---*/

/*Build the rest of the faces*/

for $j = 0 to ($V-2) do {

  for $i = 0 to ($H-2) do {

    $fond.OpenFace(0,0);
    $fond.VertexN(1+($j+1)+($i*$V));
    $fond.VertexN(1+$j+($i*$V));
    $fond.VertexN(1+$j+(($i+1)*$V));
    $fond.VertexN(1+($j+1)+(($i+1)*$V));
    $fond.CloseFace();

  }

  $fond.OpenFace(0,0);
  $fond.VertexN(1+($j+1)+($i*$V));
  $fond.VertexN(1+$j+($i*$V));
  $fond.VertexN(1+$j);
  $fond.VertexN(1+($j+1));
  $fond.CloseFace();

}

$fond.Close();
$fond.loc = (0,-$height_top,0);

/*end top tank top bulkhead*/

/*top tank cylinder*/

$cylindric = mesh();
$cylindric.Open();
for $i = 1 to $H+1 do {

  for $j = 1 to $V do {
    $p.x = $radius*cos((2*3.14159/$H)*($i-1));
    $p.z = -$radius*sin((2*3.14159/$H)*($i-1));
    $p.y = $top_tank_length*($j-1)/($work-1);

    $cylindric.AddPoint($p);
}
}

for $j = 0 to ($V-2) do {

  for $i = 0 to ($H-1) do {

    $cylindric.OpenFace(0,0);
    $cylindric.VertexN(1+($j)+($i*$V));
    $cylindric.VertexN(1+($j-1)+($i*$V));
    $cylindric.VertexN(1+($j-1)+(($i+1)*$V));
    $cylindric.VertexN(1+($j)+(($i+1)*$V));
    $cylindric.CloseFace();

  }
  if($j < ($V-2)){
  $cylindric.OpenFace(0,0);
  $cylindric.VertexN(1+($j+1)+($i*$V));
  $cylindric.VertexN(1+$j+($i*$V));
  $cylindric.VertexN(1+$j);
  $cylindric.VertexN(1+($j+1));
  $cylindric.CloseFace();}

}

$cylindric.Close();
$cylindric.loc = (0,-$top_tank_length-$height_top,0);

/*end top tank cylinder*/

/* top tank rear bulkhead*/

$fond = mesh();

$fond.Open();

$rho = (pow($radius,2) + pow($height_bottom,2))/(2*$height_bottom);

/*Create the 1st point (the peak)*/

$fond.AddPoint((0,-$height_bottom,0));
/*---*/

/*Create the rest of the points*/

for $i = 1 to $H do {

  for $j = 1 to $V do {
    $p.x = ($j/$work)*$radius*cos(((2*3.14159)/$H)*($i-1));
    $p.z = ($j/$work)*$radius*sin(((2*3.14159)/$H)*($i-1));
    $abs = sqrt($p.x*$p.x+$p.z*$p.z);
    $p.y = -(sqrt(pow($rho,2)-pow($abs,2))+$height_bottom-$rho);
    $fond.AddPoint($p);
  }

}
/*---*/

/*Now build the bottom row of faces (trigons)*/

for $i = 0 to ($H-2) do {

  $fond.OpenFace(0,0);
  $fond.VertexN(0);
  $fond.VertexN(1+(($i+1)*$V));
  $fond.VertexN(1+($i*$V));
  $fond.CloseFace();

}

$fond.OpenFace(0,0);
$fond.VertexN(0);
$fond.VertexN(1);
$fond.VertexN(1+($i*$V));
$fond.CloseFace();
/*---*/

/*Build the rest of the faces*/

for $j = 0 to ($V-2) do {

  for $i = 0 to ($H-2) do {

    $fond.OpenFace(0,0);
    $fond.VertexN(1+($j+1)+($i*$V));
    $fond.VertexN(1+$j+($i*$V));
    $fond.VertexN(1+$j+(($i+1)*$V));
    $fond.VertexN(1+($j+1)+(($i+1)*$V));
    $fond.CloseFace();

  }

  $fond.OpenFace(0,0);
  $fond.VertexN(1+($j+1)+($i*$V));
  $fond.VertexN(1+$j+($i*$V));
  $fond.VertexN(1+$j);
  $fond.VertexN(1+($j+1));
  $fond.CloseFace();

}

$fond.Close();
$fond.loc = (0,-$height_top-$top_tank_length,0);

/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/

/*rear tank top bulkhead*/

$fond = mesh();

$fond.Open();

$rho = (pow($radius,2) + pow($height_summit,2))/(2*$height_summit);

/*Create the 1st point (the peak)*/

$fond.AddPoint((0,$height_summit,0));
/*---*/

/*Create the rest of the points*/

for $i = 1 to $H do {

  for $j = 1 to $V do {
    $p.x = ($j/$work)*$radius*cos(((2*3.14159)/$H)*($i-1));
    $p.z = ($j/$work)*$radius*sin(((2*3.14159)/$H)*($i-1));
    $abs = sqrt($p.x*$p.x+$p.z*$p.z);
    $p.y = (sqrt(pow($rho,2)-pow($abs,2))+$height_summit-$rho);
    $fond.AddPoint($p);
  }

}
/*---*/

/*Now build the bottom row of faces (trigons)*/

for $i = 0 to ($H-2) do {

  $fond.OpenFace(0,0);
  $fond.VertexN(0);
  $fond.VertexN(1+(($i+1)*$V));
  $fond.VertexN(1+($i*$V));
  $fond.CloseFace();

}

$fond.OpenFace(0,0);
$fond.VertexN(0);
$fond.VertexN(1);
$fond.VertexN(1+($i*$V));
$fond.CloseFace();
/*---*/

/*Build the rest of the faces*/

for $j = 0 to ($V-2) do {

  for $i = 0 to ($H-2) do {

    $fond.OpenFace(0,0);
    $fond.VertexN(1+($j+1)+($i*$V));
    $fond.VertexN(1+$j+($i*$V));
    $fond.VertexN(1+$j+(($i+1)*$V));
    $fond.VertexN(1+($j+1)+(($i+1)*$V));
    $fond.CloseFace();

  }

  $fond.OpenFace(0,0);
  $fond.VertexN(1+($j+1)+($i*$V));
  $fond.VertexN(1+$j+($i*$V));
  $fond.VertexN(1+$j);
  $fond.VertexN(1+($j+1));
  $fond.CloseFace();

}

$fond.Close();
$fond.loc = (0,-$height_top-$top_tank_length-$height_bottom-$inter-$height_summit,0);

/*end rear tank top bulkhead*/

/*bottom tank cylinder*/

$cylindric = mesh();
$cylindric.Open();
for $i = 1 to $H+1 do {

  for $j = 1 to $V do {
    $p.x = $radius*cos((2*3.14159/$H)*($i-1));
    $p.z = -$radius*sin((2*3.14159/$H)*($i-1));
    $p.y = $bottom_tank_length*($j-1)/($work-1);

    $cylindric.AddPoint($p);
}
}

for $j = 0 to ($V-2) do {

  for $i = 0 to ($H-1) do {

    $cylindric.OpenFace(0,0);
    $cylindric.VertexN(1+($j)+($i*$V));
    $cylindric.VertexN(1+($j-1)+($i*$V));
    $cylindric.VertexN(1+($j-1)+(($i+1)*$V));
    $cylindric.VertexN(1+($j)+(($i+1)*$V));
    $cylindric.CloseFace();

  }
  if($j < ($V-2)){
  $cylindric.OpenFace(0,0);
  $cylindric.VertexN(1+($j+1)+($i*$V));
  $cylindric.VertexN(1+$j+($i*$V));
  $cylindric.VertexN(1+$j);
  $cylindric.VertexN(1+($j+1));
  $cylindric.CloseFace();}

}

$cylindric.Close();
$cylindric.loc = (0,-$top_tank_length-$height_top-$height_bottom-$inter-$height_summit-$bottom_tank_length,0);

/*end top tank cylinder*/

/* bottom tank rear bulkhead*/

$fond = mesh();

$fond.Open();

$rho = (pow($radius,2) + pow($height_rear,2))/(2*$height_rear);

/*Create the 1st point (the peak)*/

$fond.AddPoint((0,-$height_rear,0));
/*---*/

/*Create the rest of the points*/

for $i = 1 to $H do {

  for $j = 1 to $V do {
    $p.x = ($j/$work)*$radius*cos(((2*3.14159)/$H)*($i-1));
    $p.z = ($j/$work)*$radius*sin(((2*3.14159)/$H)*($i-1));
    $abs = sqrt($p.x*$p.x+$p.z*$p.z);
    $p.y = -(sqrt(pow($rho,2)-pow($abs,2))+$height_rear-$rho);
    $fond.AddPoint($p);
  }

}
/*---*/

/*Now build the bottom row of faces (trigons)*/

for $i = 0 to ($H-2) do {

  $fond.OpenFace(0,0);
  $fond.VertexN(0);
  $fond.VertexN(1+(($i+1)*$V));
  $fond.VertexN(1+($i*$V));
  $fond.CloseFace();

}

$fond.OpenFace(0,0);
$fond.VertexN(0);
$fond.VertexN(1);
$fond.VertexN(1+($i*$V));
$fond.CloseFace();
/*---*/

/*Build the rest of the faces*/

for $j = 0 to ($V-2) do {

  for $i = 0 to ($H-2) do {

    $fond.OpenFace(0,0);
    $fond.VertexN(1+($j+1)+($i*$V));
    $fond.VertexN(1+$j+($i*$V));
    $fond.VertexN(1+$j+(($i+1)*$V));
    $fond.VertexN(1+($j+1)+(($i+1)*$V));
    $fond.CloseFace();

  }

  $fond.OpenFace(0,0);
  $fond.VertexN(1+($j+1)+($i*$V));
  $fond.VertexN(1+$j+($i*$V));
  $fond.VertexN(1+$j);
  $fond.VertexN(1+($j+1));
  $fond.CloseFace();

}

$fond.Close();
$fond.loc = (0,-$height_top-$top_tank_length-$height_bottom-$inter-$height_summit-$bottom_tank_length,0);



/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/

/*outter cylinder*/

$cylindric = mesh();
$cylindric.Open();
for $i = 1 to $H+1 do {

  for $j = 1 to $V do {
    $p.x = $radius*1.01*cos((1.5*3.14159/$H)*($i-1));
    $p.z = -$radius*1.01*sin((1.5*3.14159/$H)*($i-1));
    $p.y = $outter_cylinder_length*($j-1)/($work-1);

    $cylindric.AddPoint($p);
}
}

for $j = 0 to ($V-2) do {

  for $i = 0 to ($H-1) do {

    $cylindric.OpenFace(0,0);
    $cylindric.VertexN(1+($j)+($i*$V));
    $cylindric.VertexN(1+($j-1)+($i*$V));
    $cylindric.VertexN(1+($j-1)+(($i+1)*$V));
    $cylindric.VertexN(1+($j)+(($i+1)*$V));
    $cylindric.CloseFace();

  }


}

$cylindric.Close();
$cylindric.loc = (0,-$outter_cylinder_length,0);


/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
$cc =cube($nozzle_throat_radius);
$cc.ysize = 2*$nozzle_throat_radius/3;
$cc.loc =(-$nozzle_throat_radius/2,-($height_top + $height_bottom + $height_summit + $height_rear + $top_tank_length + $bottom_tank_length +$inter+$nozzle_throat_radius/3),$nozzle_throat_radius/2);
$cc.ConvertToMesh;
$cc =cube($nozzle_throat_radius);
$cc.ysize = 2*$nozzle_throat_radius/3;
$cc.loc =(-$nozzle_throat_radius/2,-($height_top + $height_bottom + $height_summit + $height_rear + $top_tank_length + $bottom_tank_length +$inter+$nozzle_throat_radius/3),-$nozzle_throat_radius/2);
$cc.ConvertToMesh;
$cc =cube($nozzle_throat_radius);
$cc.ysize = 2*$nozzle_throat_radius/3;
$cc.loc =($nozzle_throat_radius/2,-($height_top + $height_bottom + $height_summit + $height_rear + $top_tank_length + $bottom_tank_length +$inter+$nozzle_throat_radius/3),-$nozzle_throat_radius/2);
$cc.ConvertToMesh;
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/
/*----------------------------------------------------------*/

$cylindric = mesh();
$cylindric.Open();
for $i = 1 to $H+1 do {

  for $j = 1 to $V do {
    $p.x = ($nozzle_throat_radius+(($j-1)/($work-1)*($nozzle_exit_radius-$nozzle_throat_radius)))*cos((1.5*3.14159/$H)*($i-1));
    $p.z = -($nozzle_throat_radius+(($j-1)/($work-1)*($nozzle_exit_radius-$nozzle_throat_radius)))*sin((1.5*3.14159/$H)*($i-1));
    $p.y = -$nozzle_length*($j-1)/($work-1);

    $cylindric.AddPoint($p);
}
}

for $j = 0 to ($V-2) do {

  for $i = 0 to ($H-1) do {

    $cylindric.OpenFace(0,0);
    $cylindric.VertexN(1+($j)+($i*$V));
    $cylindric.VertexN(1+($j-1)+($i*$V));
    $cylindric.VertexN(1+($j-1)+(($i+1)*$V));
    $cylindric.VertexN(1+($j)+(($i+1)*$V));
    $cylindric.CloseFace();

  }


}

$cylindric.Close();
$cylindric.loc = (0,-$outter_cylinder_length+$nozzle_length,0);

the question now is : how can i "paint" the top tank in red and the rear tank in blue in my script?
i've tried to define materials and then to do $shape.AddMaterial or $shape.SetMaterial, but it doesn't work...
Any Idea?

Thanks a lot

Clem
Logged

davdud101

  • Hero Member
  • *****
  • Posts: 1067
  • Couldn't ever use Blender or Maya. Anim8or's good.
    • View Profile
Re: Space launcher Project : how do i add colors?
« Reply #1 on: September 30, 2012, 04:58:14 pm »

I'm assuming you tried to add them directly to the model in Anim8or before exporting the coordinates? Under both 'Object' and 'File'?
Hopefully something I throw out will be helpful to someone in the community, so if this doesn't work, do tell.
Hope your projects go well!
Logged
?