pioneerspacesim/pioneer — pull request #2422 by robn (2013-09-17 12:10:35+00:00)
Title: Use model tags for gunmounts and cameras

Takes gunmount and camera positions and orientations from tags in the ship model, instead of from the ship def. For now the values in the ship defs are used if appropriate tags are not found in the model, but deprecation warnings are issued. I intend to remove the ship def fields entirely once the stock ships are converted and modders have had time to update their models.

Camera positions and orientations are take from six tags:

* `tag_camera_front`
* `tag_camera_rear`
* `tag_camera_left`
* `tag_camera_right`
* `tag_camera_top`
* `tag_camera_bottom`

If any of these are missing, `tag_camera` is used instead, and the orientation is computed. This is for the simpler or smaller ship or the lazy modeller - you can give one point for everything.

If `tag_camera` is missing then the value from the ship def is used, with computed orientation. Once removed, it will simply default to the origin.

For gunmounts, the two supported tags are `tag_gunmount_0` and `tag_gunmount_1`. These are for front and rear mounts currently, but are generically named as in the future we could potentially have a lot more points. If either is missing, we fallback to the ship def. Again, after removal the position will default to the origin.

Dual laser separation and orientation is still taken from the ship def for now, or defaults to 5 and `HORIZONTAL` (all the stock ships have those values anyway). My intention is to remove dual lasers at some point in the future (probably when `new-equipment` lands, so we only have one savefile break). Dual lasers will be better done by having two front-facing mounts and some kind of fire group control. But that's a project for another time.

All the above points are oriented pointing "out" of the ship, +X left, +Y up, +Z "out". This is different to the regular coordinate system for ships (and OpenGL, +X right, +Y up, +Z behind) but is more intuitive - you can point the +Z vector in the direction you want the camera to look or the gun to shoot. Internally the code rotates the points 180 degrees about Y to correct.

I'll be documenting all this on the wiki after merge.

Related reading: http://pioneerspacesim.net/forum/viewtopic.php?f=3&t=45