Wednesday, April 12, 2017

TIE fighter in OpenSCAD


OpenSCAD is an excellent 3D CAD tool to create space craft because of their symmetrical, non-organic shape. This video of a space ship is a good example. However I couldn't find much Star Wars models made in OpenSCAD. So I decided to do it myself and start with a simple TIE fighter.

TIE fighter made in OpenSCAD.



When I create a model like this I start with simple primitives and get the position right. In this case a sphere that represents the command pod, two cones that act as pylons and two hexagons as solar arrays. Once I have a basic TIE fighter I start shaping the different parts. Since all these parts are modules this doesn't interfere with the positioning.

Most basic shape of a TIE-fighter consisting of a sphere, two cones and two hexagons. Hexagons still need a 30 degrees rotation around the x-axis.

I use a couple of global constants that mainly determine the positioning of the different parts of the TIE fighter. The're seperate modules for the command pod, solar array and the wing pylon. Also a seperate module exists for the solar panels that are part of the solar array.

Most of the code is pretty standard OpenSCAD maybe with the exception of the solar array. The solar panel is created with a polygon which is a trapezoid. The trapezoid needs to fit between the inner en outer hexagon therefore the points of the trapezoid are depending on these hexagons of the solar array. The angle of the trapezoid is 120 degrees enabling me to calculate the all points of the trapezoid solar panel with basic trigonometry. The variable delta in the solar_panel module enables us to create and edge on the solar_array.

module solar_array (outer_radius, inner_radius) {
    difference() {
        union() {
        for (i=[1:6]) {
            rotate([0,0,i*360/6]) translate([0,inner_radius,0]) translate([0,0,1]) solar_panel(outer_radius,inner_radius);
            rotate([0,0,i*360/6]) translate([0,inner_radius,0]) translate([0,0,-0.3]) solar_panel(outer_radius,inner_radius);

module solar_panel(outer_radius, inner_radius) {
    //delta determines the size of the edge of the solar array.
    delta = 3;
    //x and y determines outer side of the solar panel trapezoid
    x = inner_radius/2 + sin(30) * (outer_radius-inner_radius-delta);
    y = cos(30) * (outer_radius-inner_radius-delta);
    list = [[-inner_radius/2,0],[inner_radius/2,0],[x,y],[-x,y]];

The TIE fighter model is largely parametric meaning that the most of the design of the model can easily can be changed by changing the parameters (constants). This model of the TIE fighter can is still rather basic but it can be expanded by modifiying the different modules.

3D printing

Until now I didn't feel the need for 3D printing the model (my extruder is in repair anyway) but with a few modifications printing shouldn't be a problem. I would print the command pod first and attach the solar array with wing pylon later.

The OpenSCAD file of the TIE fighter can be found here.

OpenSCAD is open source (GPLv2 license) and is well maintained by Marius Kintel et al. Besides the stable releases for Windows, OSX and Linux, development snapshots are available. I recommend using these development snapshots since they have all the latest features.

No comments:

Post a Comment