Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: mnftg64 on March 28, 2007, 04:30:03 pm

Title: Targeting Reticle Not Aligned
Post by: mnftg64 on March 28, 2007, 04:30:03 pm
Hmm, my targeting reticle is very much unaligned when the targeted ship is not in the center of my screen. It is rediculously far off. I have a wide screen computer, is this expected?

EDIT: I just realized this is the FOV bug... Anyone with a widescreen computer know what a good FOV value may be to fix this?
Title: Re: Targeting Reticle Not Aligned
Post by: WMCoolmon on March 30, 2007, 05:14:07 pm
There are two functions which are critical to this which would probably be very easy to fix to someone who understands the math.

This function seems to convert the x/y/z position of the 3D object into values of 0.0-1.0 which correspond to screen position (0.0 being up/left, 1.0 being down/right)
Code: [Select]
tx = input->x - View_position.x;
ty = input->y - View_position.y;
tz = input->z - View_position.z;

x = tx * View_matrix.right_vector.x;
x += ty * View_matrix.right_vector.y;
x += tz * View_matrix.right_vector.z;

y = tx * View_matrix.up_vector.x;
y += ty * View_matrix.up_vector.y;
y += tz * View_matrix.up_vector.z;

z = tx * View_matrix.forward_vector.x;
z += ty * View_matrix.forward_vector.y;
z += tz * View_matrix.forward_vector.z;

output->x = x;
output->y = y;
output->z = z;

And then the function that converts these values into actual pixel coordinates

Code: [Select]
w = 1.0f / input->z;
output->x = (Screen_width + (input->x*Screen_width*w))*0.5f;
output->y = (Screen_height - (input->y*Screen_height*w))*0.5f;

I've modified the variable names to make both of these code snippets more understandable. Otherwise, these are extracted directly from the code, and seem to be the only chunks which handle the actual calculations.
Title: Re: Targeting Reticle Not Aligned
Post by: Polpolion on March 31, 2007, 01:38:46 pm
Hmm, my targeting reticle is very much unaligned when the targeted ship is not in the center of my screen. It is rediculously far off. I have a wide screen computer, is this expected?

EDIT: I just realized this is the FOV bug... Anyone with a widescreen computer know what a good FOV value may be to fix this?


Are you sure it's FOV? Have you tried in a different resolution?
Title: Re: Targeting Reticle Not Aligned
Post by: Harbinger of DOOM on March 31, 2007, 10:18:19 pm
Go into your drivers and toggle something like "Fixed aspect ratio scaling", It'll shrink your screen... but it won't be screwed up anymore.