pioneerspacesim/pioneer — pull request #2603 by fluffyfreak (2013-12-31 12:24:59+00:00)
Title: Backport of 3D Cockpit

# Description:
3D cockpits, we've long discussed them and there's mixed responses from the Pioneer team but code talks and here is Paragons working 3D cockpit code.

This is yet-another-backport from Paragon by @Salwan, the guy is churning out some great stuff!

# How it works:
You define a separate model for the cockpit (`I've been working with @nozmajner on getting a single cockpit model ready that can be used in Pioneer`) then you add a reference too it in the ships Lua definition file.

That's it, it appears as the 4th option when pressing the F1 key.

You can re-use the same cockpit for multiple ships, so all of the fighters from a certain manufacturer might use a common cockpit module. That means we don't need to create special cockpit models for each and every ship. Also the ships work fine without ANY cockpit model being defined.
In that instance the F1 key will skip right over the cockpit mode and cycle back around to the default internal view.

# Testing it:
@nozmajner has provided me with a work-in-progress cockpit that [you can download](https://www.dropbox.com/s/yr3crpbexvz665t/default_cockpit.zip) for testing.
Just put that in the mod folder and then add the line `cockpit='cockpit',` to whichever ships Lua definition file that you want to test the cockpit with.

For example the `wave.lua` file becomes:
>-- Copyright © 2008-2013 Pioneer Developers. See AUTHORS.txt for details
>-- Licensed under the terms of CC-BY-SA 3.0. See licenses/CC-BY-SA-3.0.txt
>
>define_ship {
name='Wave Heavy Hypersonic Fighter',
model='wave',
cockpit='cockpit',
forward_thrust = 88e5,
reverse_thrust = 29e5,
up_thrust = 15e5,
down_thrust = 15e5,
left_thrust = 15e5,
right_thrust = 15e5,
angular_thrust = 140e5,
camera_offset = v(0,.6,-13),
gun_mounts =
{
{ v(0,-0.5,-10.7), v(0,0,-1), 5, 'HORIZONTAL' },
{ v(0,-0.5,0), v(0,0,1), 5, 'HORIZONTAL' },
},
max_cargo = 30,
max_laser = 2,
max_missile = 4,
max_cargoscoop = 0,
max_fuelscoop = 0,
min_crew = 1,
max_crew = 1,
capacity = 30,
hull_mass = 13,
fuel_tank_mass = 22,
-- Exhaust velocity Vc [m/s] is equivalent of engine efficiency and depend on used technology. Higher Vc means lower fuel consumption.
-- Smaller ships built for speed often mount engines with higher Vc. Another way to make faster ship is to increase fuel_tank_mass.
effective_exhaust_velocity = 65000e3,
price = 93000,
hyperdrive_class = 2,
}

# Issues and Future work:
No known Issues as such but it's quite obvious that we're going to have to continue to use the 2D control panel for the time being because there's no support for rendering controls to a texture and displaying them inside the 3D HUD yet.

There's some future work right there of course and it's something that I've already started to look into but I'm backlogged so it's going to take me a few days / weeks. Eventually I'll just render things like the scanner and other instruments / information to texture which will be used by the model. It's conceptually trivial except where it meet the Pioneer codebase ;)

@Salwan I don't want to step on your toes with this stuff so if you're interested in discussing rendering instruments to textures then let me know and we'll discuss it on the forums.

# Reason for putting it forward now:
It's important to get this first block into Pioneer to minimise code-drift and rot between Paragon<->Pioneer as I want the future work to flow both ways more easily.

Also to stop it becoming a single huge EPIC commit that takes 6 months to do and another 3 to review.

People can try it out without affecting Pioneer itself by using the cockpits and ships as mods which will give our modelers time to create assets, we can also gather feedback about who likes what and any potential issues.

FluffyFreak