Author Topic: Camera scaling in field files.  (Read 4002 times)

Akari

  • *
  • Posts: 766
    • View Profile
Camera scaling in field files.
« on: 2006-12-05 10:46:23 »
I trying to guess what is the scale value in field file.
Now I think this is zoom. Ie we move camera to where it looks. But I can't get value that works in all cases. Now I use this formula for calculate matrix translation.

Code: [Select]
    oz += (scale - 512) * 4;
    float tx = ox * vxx + oy * vyx + oz * vzx;
    float ty = ox * vxy + oy * vyy + oz * vzy;
    float tz = ox * vxz + oy * vyz + oz * vzz;

I just move camera along Z axis. It almost works, but not entirely. Looks like I need fix my perspective projection  :|

Does anyone have any guesses?

Akari

  • *
  • Posts: 766
    • View Profile
Re: Camera scaling in field files.
« Reply #1 on: 2006-12-05 13:45:44 »
After little thinking I start think that this is RTPS/RTPT packet for GTE

First Rotation matrix, next are translation vector and last are View plane distance.

Code: [Select]
--------------------------------------------------------------------------
RTPS     15       Perspective transformation         
Fields:  none
Opcode:  cop2 $0180001

In:      V0       Vector to transform.                         [1,15,0]
         R        Rotation matrix                              [1,3,12]
         TR       Translation vector                           [1,31,0]
         H        View plane distance                          [0,16,0]
         DQA      Depth que interpolation values.              [1,7,8]
         DQB                                                   [1,7,8]
         OFX      Screen offset values.                        [1,15,16]
         OFY                                                   [1,15,16]
Out:     SXY fifo Screen XY coordinates.(short)                [1,15,0]
         SZ fifo  Screen Z coordinate.(short)                  [0,16,0]
         IR0      Interpolation value for depth queing.        [1,3,12]
         IR1      Screen X (short)                             [1,15,0]
         IR2      Screen Y (short)                             [1,15,0]
         IR3      Screen Z (short)                             [1,15,0]
         MAC1     Screen X (long)                              [1,31,0]
         MAC2     Screen Y (long)                              [1,31,0]
         MAC3     Screen Z (long)                              [1,31,0]

Cyberman

  • *
  • Posts: 1572
    • View Profile
Re: Camera scaling in field files.
« Reply #2 on: 2006-12-05 21:58:16 »
It would make sense if the camera data were the PS1's GTE coprocessor opcode parameters.
The next question though is with large backgrounds doesn't the perspective trransform change as you move the background whilst moving about in it?
Hmmm Seems that data must be dumped into the GTE etc. etc.
If that is the case, you can use the transform done by the GTE (instead of a floating point one), we still need to know what the distance used no?
By the above I mean you like WILL have to do the same transform operation that they do in fixed point or trim data at the point where it would be normally. I know the playstation does not have fractional points for display usage.  Anyhow, there will be substantial losses in terms of acuracy (just like the difference between using a fast integer compression in the DCT for a JPEG and a FP one).

Well back to my twiddling with my CD-ROM plugin I guess.


Cyb

Akari

  • *
  • Posts: 766
    • View Profile
Re: Camera scaling in field files.
« Reply #3 on: 2006-12-06 09:38:21 »
This seems to set perspective projection to fit background almost perfectly.

Code: [Select]
    // projection matrix
    float aspect = 640.0f/480.0f;
    float angley = atanf(320.0f / scale) * 1.5f;
    float znear  = 1;
    float zfar   = 100000;

    float ymax   =  znear * tanf(angley / 2);
    float ymin   = -ymax;
    float xmin   =  ymin * aspect;
    float xmax   =  ymax * aspect;

    projection = DISPLAY->GetFrustumMatrix(xmin, xmax, ymin, ymax, znear, zfar);

 I don't know why you need to multiply to 1.5 instead of 2. Maybe this have something to do with screen width (640). But this works.
« Last Edit: 2006-12-06 10:20:45 by Akari »

Cyberman

  • *
  • Posts: 1572
    • View Profile
Re: Camera scaling in field files.
« Reply #4 on: 2006-12-06 14:35:23 »
Akari do you have the NTSC version of FF7?
If I remember correctly the PAL version might be somewhat different, they have higher vertical resolution I believe?
The PC media obviously will use 640x480.

Jari

  • Guest
Re: Camera scaling in field files.
« Reply #5 on: 2006-12-06 14:46:18 »
576 lines versus the 480 of NTSC.

EDIT: That's for the standards in general, not specifically for FF7 - although I suppose that a PAL port would have to comply with it. :)

Then there's the issue of Square's "great" PAL ports...  :x I don't have FF7 at hand, but FFX certainly has so massive black borders above and below the picture that I'm fairly certain the engine itself runs at 480 lines, and the output gets letterboxed.

And before you ask - yes - it makes Tidus look even more of a fathead than he acts - meaning that it will screw up the aspect ratio. :-D Which is why I prefer to play it on a computer screen, via video capture card and DScaler; whereas TV's geometry is not that easy to adjust, I can easily stretch the picture of my (CRT) monitor, to compensate for Square's "greatness". :P
« Last Edit: 2006-12-06 14:51:09 by Jari »