Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: Screen Position Calculations - Help Needed

  1. #1
    Newbie Newbie
    Join Date
    Apr 2018

    Screen Position Calculations - Help Needed

    Hello guys,

    I've got three values (angles) - x and y that camera is facing (yaw and pitch, and z if needed), these are:

    x - heading from true north in OGL coordinates
    y - pitch from flat in OGL coordinates

    I am wondering if it is possible by using these values to get Screen Position as a vector of xy?

    Also, if we have a pitch value from flat Surface, would it be possible to recalculate pitch if camera moves up? If yes, how?

    Sorry for asking for help but I am new to OpenGL and desperatly in need of advice.

    Best Regards,

  2. #2
    Intern Newbie
    Join Date
    Apr 2018
    so everyone just left this guy for 12 days, I should start a school.
    I'm going to teach you everything in one minute !!!!!!!

    if you dont want everything, then dont get my example files and dont learn everything,
    -== WORLD-3dpnt to SCREEN ==-

    void w2s(int xy[2],int fol,double v[3],int x,int y) {
    xy[0] = (int)((fol/v[2])*v[0]+x);
    xy[1] = (int)((fol/v[2])*v[1]+y);

    orbital(cameye,3); // .pos has no obliquity. remember
    NORMALIZE(cameye); /// required for dotproduct ANGLE(v,v2)
    /// crossproduct tho, is always a right angle vector,
    /// normal input not needed, normalize crossproduct result.
    set16mat(cmatrix,cameye); /// normal input not required
    INITVECTOR(camup,cmatrix[4],cmatrix[5],cmatrix[6]);///a normal in the matrix
    /// ////////////////// LookAt transform
    /// now begin loop on every point
    if Z is positive infront of camera, draw it, clip out xy limits
    draw at w2s(f,v) <x y

  3. #3
    Intern Newbie
    Join Date
    Apr 2018
    one of these days I might change fol from int to double for more precise adjustments
    now needed in OGL @ 200 fps, awesome !!!

    first examples in main, is the trig - focal length to field of view.

    know the trig laws and right-angle rules

    3D 101, heh

  4. #4
    Intern Newbie
    Join Date
    Apr 2018
    and here's the working prototype almost as described -

    without more testing, I just figure its reversed for leaving ortho2D with 0 at bottom

    uses inverted gluLookAt, and gluPerspective with input of fov/2

  5. #5
    Intern Newbie
    Join Date
    Apr 2018
    Update, after sizing the window I realize, ooops


    I knew 2 was only close but what? it was aspect

  6. #6
    Intern Newbie
    Join Date
    Apr 2018
    ok then - beginners will likely begin wrong if they dont have this...

    BG stars lights camera scene text = the math that IS the Camera!

    Worth taking an hour to Google and make high def tga textures and running as eyeCandy.
    Improvements very welcome, appreciated and worthwhile - chk it out -


    how much does anti Aliasing COST? lol

  7. #7
    Intern Newbie
    Join Date
    Apr 2018
    Latest Features:
    Gravity Simulation: c
    Focal len and user defined star size: S,s
    Random StarGate. Warps to the stars: 5
    StarGate: 6
    this code answers many questions - got know at least this much about the matrix.
    not exactly a newbie - misnomer, hah

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts