Page 1 of 3

Gun mount positioning

Posted: Sat Sep 14, 2013 3:26 am
by robn
This is mostly aimed at nozmajner and Zordey, who were asking me about this last night. But feel free to join in.

So it seems that gun mount positions defined in a shipdef file don't seem to match up with positions on the model when viewed in a modelling program, and its making it hard to position them. I've read over the code this morning and I can't obviously see why, but I'm also no good at driving Blender, so its hard for me to test. My suspicions is that the positions are or aren't being scaled correctly when being converted to view space for draw, but I'm really not sure.

So I want to tackle this from two angles.

The first is for someone to determine exactly what's going on. I've made a patch that draws the player ship in wireframe and then highlights the gun positions, like so:

Image

Image

Green is "front", red is "rear". Yellow is actually green, its just what you get when you blend it like that. Its a hack job, remember :)

For Windows users, use this replacement executable (against 201309.32). Anyone building for themselves, build robn/gunmount-debug (or ask me if you want a Linux (32 or 64 bit) or Mac build, and I'll see what I can do). So hopefully that will make it easier to figure out what's going on.

The other thing I want to do is turn the mount points into named positions. But again, I don't know how to drive modelling software to change our models to do that. So, can I get someone to make me a model (existing or new, I don't much mind) with two points "tag_gunmount_front" and "tag_gunmount_rear". Orientation will be important! Once I've got that I can use it to do the code and then hopefully we'll never have to do gunmounts in shipdef files again. And then we can give the cockpit camera position the same treatment too.

Re: Gun mount positioning

Posted: Sat Sep 14, 2013 3:50 am
by bszlrd
Which direction those tags should point? Z for firing direction, like with the thrusters is good? I'll reexport the new kanara with those.
Thankfully this got the light soon, when we don't have loads of ships, so it won't be too much work to include these tags in them.
Is "tag_cockpit" good? I'll put that in the Kanara too.

Re: Gun mount positioning

Posted: Sat Sep 14, 2013 4:08 am
by robn
Yeah, point in the firing direction. Make sure the up vector is correct; I don't have a use for it right now but we might in the future.

Which does mean that "front" and "rear" is a bit crap, hmm. How about we just do "tag_gunmount_0", "tag_gunmount_1", etc? We'll assume 0 & 1 are "front" and "rear" for now, but in the future I could see you be able to choose based on position (eg a top-down view of the ship where you drag guns to mounts). Its not much, but its a little future-proofing.

I expect that when we have turrets we'll use "tag_turret_*", but don't do that yet - we'll change it when the time comes, because it might be a fair way off.

Yes, tag_cockpit for the cockpit seems great.

Re: Gun mount positioning

Posted: Sat Sep 14, 2013 1:19 pm
by NeuralKernel
Would it be possible to use empty objects for weapons and other equipment in blender, like the way thruster placement is handled? Keep it out of the definition file altogether, except maybe for just a number of slots for various things. Leave the geometry details in the 3d Model...

Re: Gun mount positioning

Posted: Sat Sep 14, 2013 1:42 pm
by bszlrd
That's the plan :D

Re: Gun mount positioning

Posted: Sat Sep 14, 2013 5:33 pm
by bszlrd
@Robn:Here's the model with the tag empties.
tag_gunmount_0. tag_gunmount_1, tag_cockpit

Z+ points forwards (back gun has it's X+ to the left and Z+ to the back) X+ right , Y+down

Re: Gun mount positioning

Posted: Sun Sep 15, 2013 11:24 pm
by robn
Ok, so making progress. I'm properly identifying and orienting the tag points. Here's nozmajner's screenshot with the tag points visible:

Image

And the same points displayed in the modelviewer, with the same orientations.

Image

So I've been getting them into the game, starting with the camera because its easy to do first. It doesn't appear to be a big problem except that its coming out upside down, because the Y axis points down. nozmajner, is that a mistake? Its not a big deal for me to rotate it 180 around Z, but I don't want to do it if I don't have to.

A thought about rear/left/right/top/bottom cameras - do we just want to base them off the cockpit position like now (effectively ignoring the tag_cockpit orientation), or do we want to have separate tags for all those different cameras?

Re: Gun mount positioning

Posted: Mon Sep 16, 2013 5:51 am
by bszlrd
I've made them to align their X with the X of the ship, I'm not attached to that orientation, but it's a bit harder to get the feel of it when puting on the model for sure. :)

In this one X+ is to the left Y+ to the top and Y+ to forward. It sure makesmakes more sense and easier to imagine it, since it looks like a 2D coordinate system when we are looking at it from the outside.
https://www.dropbox.com/s/m0fpek6hlbdvf ... mpties.zip
Image

I've included a tag for each viewing direction, if you want to implement those. Having those would add a sense of dimension, especially for larger ships in my opinion. It wouldn't be too noticeable most of the time, mostly when you are flying around spaceports and such. But these little things can add quite much to the overall feel of the game in my opinion.
tag_cockpit_front
tag_cockpit_top
tag_cockpit_bottom
tag_cockpit_left
tag_cockpit_right
tag_cockpit_rear
the guns are the same as before

Re: Gun mount positioning

Posted: Mon Sep 16, 2013 12:34 pm
by robn
Cameras are now implemented on my work branch robn/gunmount-cockpit-tags. The logic goes:

1. tag_camera_front, _rear, _left, _right, _top and _bottom will be used if they they exist.
2. If one is missing, then tag_camera is tried, and if that exists the correct orientation will be computed from it. This a convenience for if you can't be bothered doing them all, or if its not appropriate to do them all for a particular ship.
3. If tag_camera isn't found, then the position from the shipdef file will be used (which defaults to the origin). Again, the orientation will be computed.

(Yes, not tag_cockpit as in nozmajner's test model. We decided the name was wrong).

If you include it a camera_offset field in the shipdef, the game will emit a warning in the log. I intend to have that in place for a few weeks to give mod authors time to update their ships. After that, point 3 above will just become the original always.

I got a bit confused about the coordinate system in use, which I've now resolved to my satisfaction. After load, models are in the OpenGL coordinate system, that is, X to the right, Y up, and -Z "into" the screen. Which means that -Z is at the front of a ship, +Z is at the rear.

The camera and gun tag points point "out" of the ship (in the direction the camera looks or gun fires), X left, Y up, Z out/forward. So the code will rotate 180 about the Y axis for these points. I think that makes them more intuitive for the modeller - set up the point to face the direction you want the thing to work.

This rule is a special case for camera and gun points, and won't necessarily hold for all tag points in the future. Or put another way, their meaning of a point depends on its name. I'll be documenting all this once I'm done, so don't worry too much about it :)

Next up, gun points!

Re: Gun mount positioning

Posted: Mon Sep 16, 2013 9:35 pm
by walterar
Someone has used dsminer canyon?