Viewpoint Change libcaelina

Discussion in '3DS - Homebrew Development and Emulators' started by Urbanshadow, Nov 24, 2015.

  1. Urbanshadow
    OP

    Urbanshadow GBAtemp Maniac

    Member
    1,295
    473
    Oct 16, 2015
    Ok, so I'm trying to set up 3d effects for libcaelina in my custom helper library for c++ and I don't really get how I'm supposed to change the viewpoint.

    We don't have gluLookAt so should I just glOrtho into the new position as in 2d?
    I guess that because glFrustum is set up in the examples.

    What is the "eye" separation advised to avoid headaches ?

    Thanks in advance.

    One more question: In a mid-complex scene how am I supposed to navigate? Moving the world instead of the viewpoint?
    Different question but related: Can I use texture pointers from libsfil into libcaelina's texture matrix and expect to see something?
     
    Last edited by Urbanshadow, Nov 24, 2015
  2. machinamentum

    machinamentum GBAtemp Regular

    Member
    163
    450
    Jul 5, 2015
    United States
    If by viewpoint you mean the conceptual 3D eye, then your view matrix is the inverse of your camera matrix. What this means if that if your camera is at XYZ(10,15,2) you need to apply the translation matrix of XYZ(-10,-15,-2) to your entire scene. To do this you can use set the modelview matrix to the inverse camera position then push the matrix whenever you need to set individual objects matrices. You should really avoid changing GL_PROJECTION as the matrix stack for it is very small and is only really meant to setup the projection transform.

    Example:
    Code:
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslate(-camX,-camY,-camZ);
    
    glPushMatrix();//save camera matrix onto the stack
    glTranslate(objX,objY,objZ);
    DrawMyObject();
    glPopMatrix();//restore camera matrix from the stack
    
    As for textures, Caelina is by design to work just like OpenGL 1.x textures so you can upload textures just as you would on a PC using image buffers (i.e. using stb_image or libpng).
     
  3. Urbanshadow
    OP

    Urbanshadow GBAtemp Maniac

    Member
    1,295
    473
    Oct 16, 2015
    Of course. I didn't actually think of moving into MODELVIEW for that. That's smart. kudos to you.
    libsfil is uses libpng so I assume it's ok. Glad to hear that.

    Thanks.