define_model('shuttle', { -- unique name by which the model is called internally
info = {
scale = 1.75, -- a scaler, i've set here to 1.75 to represent a doubled ship size compared to FFE (1 meter = ~1.14 FFE units)
lod_pixels = {20, 50, 100, 0}, -- the lod table, higher values let the details vanish earlier
bounding_radius = 30, -- the size of the "frame" in which the ship sits in in preview
materials = {'grey', 'win', 'alu', 'anth', 'matvar0', 'text', 'thrusters'}, -- material listing, all materials used must be listed here
tags = {'ship'}, -- definies what kind of model it is
ship_defs = {
{
'Interplanetary Shuttle', -- the name of the ship as in shipyard selection
{ 5*10^5,-8*10^5,2*10^5,-2*10^5,-2*10^5,2*10^5 }, -- accelaration table
5*10^5,
{
{ v(0,0,-8), v(0,0,-1) }, -- gun positions
{ v(0,0,0), v(0,0,0) },
},
{ 10, 1, 2, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1 }, -- ship commodities space
10, 6, 2000000, -- netto mass, tara mass, price in 1/100 credits
1 -- drive type fitted
}
}
},
static = function(lod)
set_material('grey', 0.3, 0.3, 0.3, 1, 0.3, 0.3, 0.3, 1)
set_material('win', 0,0,0.1, 1, 0.7, 0.7, 0.7, 100)
set_material('alu', .5, .51, .65,1, .5, .5, .7, 50)
set_material('anth', .2,.2,.2,1,.5,.5,.5,10)
local v00 = v(3.1,2.5,-5.0) -- localized vectors for vertices makes life easier ;)
local v01 = v(-3.1,2.5,-5.0)
local v02 = v(3.1,2.5,6.8)
local v03 = v(-3.1,2.5,6.8)
local v04 = v(3.7,0,-7.5)
local v05 = v(-3.7,0,-7.5)
local v06 = v(3.7,0,7.5)
local v07 = v(-3.7,0,7.5)
local v08 = v(3.1,-1.2,-6.8)
local v09 = v(-3.1,-1.2,-6.8)
local v10 = v(3.1,-1.2,6.8)
local v11 = v(-3.1,-1.2,6.8)
local v12 = v(2.8,2.3,-5.21)
local v13 = v(-2.8,2.3,-5.21)
local v14 = v(3.2,0.8,-6.71)
local v15 = v(-3.2,0.8,-6.71)
local v18 = v(-3.4,1.2,-5.2)
local v20 = v(1.8,-1,-2.5)
local v22 = v(3.1,-2.5,-2.5)
local v24 = v(1.8,-1,2.5)
local v26 = v(3.1,-2.5,2.5)
local v28 = v(3.1,-2.5,-5.0)
local v30 = v(3.1,-2.5,5.0)
use_material('grey')
texture('tex01.png', v08, v(0,0.4,0), v(0,0,0.8) )
quad(v08, v10, v11, v09) -- a grey textured rectangular shaped polygon
texture('tex01.png', v10, v(0,0.8,0), v(0,0,0.2) )
xref_quad(v10, v08, v04, v06)
texture('tex01.png', v08, v(0.4,0,0), v(0,0.8,0) )
quad(v08,v09,v05,v04)
quad(v11,v10,v06,v07)
use_material('matvar0')
texture('tex08.png', v00, v(0.3,0,0), v(0,0,0.7))
quad(v02,v00,v01,v03) -- a colorvariable textured rectangular shaped polygon
texture('tex08.png', v04, v(0,0.8,0), v(0,0,0.4) )
xref_quad(v06,v04,v00,v02)
texture('tex08.png', v04, v(0.3,0,0), v(0,0.35,0.35) )
quad(v04,v05,v01,v00)
quad(v07,v06,v02,v03)
if lod >= 2 then
use_material('alu')
texture(nil)
xref_ring(3*lod,v22,v20,v(0,1,0),0.06) -- a x axis mirrored cylinder without tap
xref_ring(3*lod,v26,v24,v(0,1,0),0.06)
xref_cylinder(3*lod,v28,v30,v(0,1,0),0.09)
cylinder(3*lod, v(0,0,-7.9), v(0,0,-7.2), v(0,1,0),0.08) -- a common cylinder with tap at front and end
use_material('win')
quad(v14,v15,v13,v12)
end
if lod >= 2 then
call_model('decal', v(3.56,0.6,-5), v(1,0,0), v(-0.235,1,0), 1) -- calls the decal sub_model
call_model('decal', v(-3.56,0.6,-4), v(-1,0,0), v(0.235,1,0), 1)
end
if lod >= 2 then
use_material('anth')
call_model('nazzle_s', v(2.5,-0.6,-7.1), v(1,0,0), v(0,0,-1),0.5) -- small nazzles for reverse thrusters
call_model('nazzle_s', v(-2.5,-0.6,-7.1), v(1,0,0), v(0,0,-1),0.5)
call_model('nazzle_s', v(0,2.4,-3), v(1,0,0), v(0,1,0),0.5) -- front top thruster
call_model('nazzle_s', v(0,2.4,5), v(1,0,0), v(0,1,0),0.5) -- back top thruster
call_model('nazzle_s', v(0,-1.1,-3), v(1,0,0), v(0,-1,0),0.5) -- front bottom thruster
call_model('nazzle_s', v(0,-1.1,5), v(1,0,0), v(0,-1,0),0.5) -- back bottom thruster
call_model('nazzle_s', v(-3.3,-0.6,-3), v(0,1,0), v(-1,0,0),0.5) -- front left thruster
call_model('nazzle_s', v(-3.3,-0.6,5), v(0,1,0), v(-1,0,0),0.5) -- back left thruster
call_model('nazzle_s', v(3.3,-0.6,-3), v(0,1,0), v(1,0,0),0.5) -- front right thruster
call_model('nazzle_s', v(3.3,-0.6,5), v(0,1,0), v(1,0,0),0.5) -- back right thruster
end
if lod > 1 then
if lod <= 3 then
use_material('anth')
call_model('nazzle_s', v(2.5,-0.6,7), v(1,0,0), v(0,0,1),1) -- small nazzles for main thrusters
call_model('nazzle_s', v(-2.5,-0.6,7), v(1,0,0), v(0,0,1),1)
end
end
if lod > 3 then
use_material('anth')
call_model('nazzle_l', v(2.5,-0.6,7), v(1,0,0), v(0,0,1),1) -- large nazzles for main thrusters
call_model('nazzle_l', v(-2.5,-0.6,7), v(1,0,0), v(0,0,1),1)
end
set_material('thrusters', .30, .30, .30,1, .30, .30, .30, 20) -- this evades the vanishing of thruster material, happens sometimes when not specified
use_material('thrusters')
local BackThrust = v(2.5, -0.6, 7.7) -- localization of the main thrusters
local FrontThrust = v(2.5, -0.6, -7.4)
xref_thruster(BackThrust, v(0,0,1), 6, true) -- x axis mirrored directional vectors for main thrusters and size of thruster flame, true for not influenced by steering of ship
xref_thruster(FrontThrust, v(0,0,-1), 3, true)
local FrontTopThrust = v(0, 2.7, -3)
local FrontBottomThrust = v(0, -1.4, -3)
thruster(FrontTopThrust, v(0,1,0), 2)
thruster(FrontBottomThrust, v(0,-1,0), 2)
local BackTopThrust = v(0, 2.7, 5)
local BackBottomThrust = v(0, -1.4, 5)
thruster(BackTopThrust, v(0,1,0), 2)
thruster(BackBottomThrust, v(0,-1,0), 2)
local BackLeftThrust = v(-3.6, -0.6, 5)
local BackRightThrust = v(3.6, -0.6, 5)
thruster(BackLeftThrust, v(-1,0,0), 2)
thruster(BackRightThrust, v(1,0,0), 2)
local FrontLeftThrust = v(-3.6, -0.6, -3)
local FrontRightThrust = v(3.6, -0.6, -3)
thruster(FrontLeftThrust, v(-1,0,0), 2)
thruster(FrontRightThrust, v(1,0,0), 2)
end,
dynamic = function(lod)
set_material('matvar0', get_arg_material(0)) -- requests colorvariable material
set_material('text', .6,.6,.6, 1)
local v16 = v(-3.37,1.4,1)
local v17 = v(3.37,1.4,1)
local v31 = v(0,2.49,3)
if lod >= 2 then
use_material('text')
geomflag(0x8000)
reg = get_arg_string(0) -- requests registration no.
text(reg, v16, v(-1,0.235,0), v(0,0,1), 2, {center = true})
text(reg, v17, v(1,0.235,0), v(0,0,-1), 2, {center = true})
geomflag(0)
end
if lod >= 2 then
use_material('matvar0')
local factor = (os.clock()*math.pi)*0.5 -- sets value for rotation speed
call_model('scanner', v31, v(math.cos(factor),0,math.sin(factor)), v(0,1,0),0.75) -- calls and rotates scanner along y axis
end
end
})