Results 1 to 4 of 4

Thread: Rotation problem

  1. #1
    Junior Member Newbie
    Join Date
    May 2018
    Posts
    23

    Rotation problem

    Hello,
    I loaded my model from an STL file, I don`t have any problem to display and translate it, the problem is when I try to rotate.
    My gl_postion is:

    gl_Position = projection * rotation * translation * model * position;

    Where projection is orthographic matrix, rotation is a simple rotation around Y, translation is a matrix translation of (400, 300, 0) as my window is 800x600, and model is a simple identity matrix.

    I think the problem is about axis rotation, I thought that a simple translation to the center could resolve the problem, but it isn`t that.

    Could someone help me?

    Thank you

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,112
    The viewport transformation will place the clip-space origin in the centre of the viewport. Normally, you'd define the projection matrix so that the eye-space origin is also in the centre of the window (e.g. for an orthographic projection, you'd make the left and right edges equal and opposite, e.g. left=-400 and right=400).

    If you can't do that (e.g. because the eye-space origin needs to be in one corner of the window), the translation should come after the projection transformation and before the rotation.

  3. #3
    Junior Member Newbie
    Join Date
    May 2018
    Posts
    23
    Thank you GClements for your answer,
    now my ortho trasnformation is (-400, 400, -300, 300, -1.0f, 100.0f);


    and my gl_postion is

    rotation * projection * translation * model * position; --------> translation is 0 now

    But the problem remain, seems as the model don`t rotate around its origin but around something else.

    Thank you

  4. #4
    Junior Member Newbie
    Join Date
    May 2018
    Posts
    23
    If I rotate around Z seems OK, if I rotate for example around Y the model is stretched.
    Tried some translation in Z, but no solution...

Similar Threads

  1. Rotation problem.
    By Joshhua5 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-18-2011, 05:31 AM
  2. problem with rotation
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-08-2005, 07:25 PM
  3. need help with this rotation problem
    By imported_spooky in forum OpenGL: General
    Replies: 1
    Last Post: 04-15-2004, 11:08 PM
  4. rotation problem
    By hoganh in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 11-28-2003, 08:02 AM
  5. Rotation problem, i even do a WEB page to let you see my problem
    By sicklab in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 12-19-2000, 12:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean