playstation coordinate system to OpenGL coordinate system

Discussion in 'Sony Programming and Development' started by gwald, Jun 21, 2016.

  1. gwald

    gwald Net Yaroze '99

    Joined:
    Jan 6, 2016
    Messages:
    105
    Likes Received:
    36
    The PSX is right handed (Right-handed coordinate system, meaning (with your right hand) +X cross +Y gives you +Z. )

    +X axis is to the right of the screen,
    +Y is down on the screen,
    +Z is in towards (behind) the screen (from the viewer into the tv tube).

    OpenGL is also right handed but Y+ is Up and Z+ is towards the viewer

    +X axis is to the right of the screen,
    +Y is Up on the screen,
    +Z is out towards the screen (away from the TV tube to the viewer).


    I know there's two ways to make the PSX like openGL:
    Rotate the camera or the world (vi GsCOORDINATE2) X by 180 degrees
    Or even both.. I'm still testing this out.
    Any tips?
     
  2. Gemini

    Gemini Retro developer

    Joined:
    Apr 1, 2008
    Messages:
    406
    Likes Received:
    88
    The easiest method to make them use an identical coordinate system is to set your up vector for view matrix (glLookAt) to 0.f, -1.f, 0.f. Another point of interest is how you simulate the projection matrix, which is a bit more of work to force aspect ratio and conversion of GteH to FOV. Again, you need to change a few things around since FOV usually corresponds to focal length * 8.88f while the aspect can be achieved via view matrix scaling or by altering an identity matrix to have XZ values different than 1.f.

    In my 3D controller article or in the stream about particles you can see me grabbing a Cinema4D camera and convert it to a PSX view camera + GTE height parameter to simulate glLookAt behavior with just one matrix.
     
    gwald likes this.
  3. gwald

    gwald Net Yaroze '99

    Joined:
    Jan 6, 2016
    Messages:
    105
    Likes Received:
    36
    hmm... I don't want to complicate my 3D pipeline, I'm using cheap/free stuff (fragmo/shade3d/anim8) I can't change the default coordinate system, which is OpenGL's and I don't want to animate upside down lol
    I'll post what I find, speed isn't a concern right now.

    I watched a bit of your particle stream.. pretty cool :)
     
  4. Gemini

    Gemini Retro developer

    Joined:
    Apr 1, 2008
    Messages:
    406
    Likes Received:
    88
    I don't remember if OpenGL matrices naturally translate to what you're trying to do, but if you're counting on porting from PlayStation you gotta use the original coordinate system. In the opposite case, you may probably just flip the view matrix to work with flipped coordinates by rotating the main X axis; just build a flipped view matrix and you're good to go.
     
    gwald likes this.
  5. -=FamilyGuy=-

    -=FamilyGuy=- Site Supporter 2049

    Joined:
    Mar 3, 2007
    Messages:
    3,033
    Likes Received:
    891
    I'm not sure about openGL specifics, but what you need to do to get from one basis to the other is simply a passive rotation of ±180 degrees (or pi rad) around the x axis, which is equivalent for both transformations. Basicaly applying this matix to a vector in x,y,z give one in x',y',z' :
    Code:
    1   0   0
    0  -1   0
    0   0  -1
    
    This simplifies easily to an efficient Hadamar product.
     
    Last edited: Jun 21, 2016
    gwald likes this.
  6. gwald

    gwald Net Yaroze '99

    Joined:
    Jan 6, 2016
    Messages:
    105
    Likes Received:
    36
    yip, I got it :)
    Rotating the camera once works:

    Code:
      
    GsVIEW2 view;  
    SVECTOR rotate;
    MATRIX  rotationMatrix;
    
    rotationMatrix = GsIDMATRIX; 
    
    //#define setVector(v,x,y,z) (v)->vx = (x), (v)->vy = (y), (v)->vz = (z)
    setVector(&rotate,  ONE/2, 0, 0 );
    RotMatrix(&rotate, &rotationMatrix);
    
    view.view = rotationMatrix;
    view.super = WORLD;
    
    Then when creating the screen:
    Code:
    GsSetView2(&view);
    Scene must be in the -Z view
    Now +Y up, +X right , and +Z towards camera :)
     
    Last edited: Jun 22, 2016
sonicdude10
Draft saved Draft deleted
Insert every image as a...
  1.  0%

Share This Page