Results 1 to 4 of 4

Thread: Scaling x,y,z coordinates appropriately

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2005
    Posts
    6

    Scaling x,y,z coordinates appropriately

    Hi all,

    I have a square printed on screen (for example, positioned with: glTranslatef(-10.0, 10.5, -40.0) and I want to animate it as it is brought forward from -40 to -10. However, as I have tried this, the x and y coordinates change scale (and results in the image changing its location on screen which I don't want). Is there a simple way to convert the x and y so that i am able to bring this square forward with it staying in its initial x and y position (while leaving all objects on the screen untouched). In other words, I am making this object appear bigger without moving it left or right. Quite new to this so please bear with me!

    thanks

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,595

    Re: Scaling x,y,z coordinates appropriately

    Hi !

    It is a question on when you scale it, if you scale it before you translate it (and render it around the origin) it will scale equal in all directions, if you translate it before you scale it you will get different movement of each corner.

    If you do not render it around the origina you can of course translate it so that it is located at the origin, scale it and then translate it back to where it was.

    Mikael

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2005
    Posts
    6

    Re: Scaling x,y,z coordinates appropriately

    Hi,

    thanks for the reply. Don't quite understand what you mean - I think i should rephrase my question. I am displaying a square using glTranslatef(-5.5, 5.0, -15), which is x = 15 and y = 559 of my screen. I want to draw another square that is -25 into the screen (instead of -15) but want to draw it directly below that square - at x = 15 and y = 468 of my screen. Is there an easy way to draw it directly below - when I next use glTranslate(x, y, -25) i need to figure out what values to set x and y to (at run-time). If i was drawing the square at the same z, i could just use glTranslatef(-5.5, 4.7, -15), but because i'm changing the z it won't be in the right position.

    Hope this makes a bit of sense!

  4. #4
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,595

    Re: Scaling x,y,z coordinates appropriately

    Hi !

    Don't change Z then....

    It is a bit messy to try to calculate the correct value to align it I guess, you could try to use gluProject/gluUnproject to map the first rectangles coordinates to window coordinates and then convert them back to world coordinates with different Z value, but you will have to convert the Z value to get correct results because it is not in world coordinates range.

    Mikael

Similar Threads

  1. Texture Coordinates and Depth Buffer to obtain world coordinates
    By snkhan42 in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 04-27-2018, 11:52 AM
  2. Replies: 4
    Last Post: 06-08-2016, 07:01 PM
  3. Scaling i want to add scaling to my codeould someone advise me how
    By cloudracer in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-27-2014, 02:07 PM
  4. [Camera] Can't make the camera move appropriately
    By onion_bread in forum OpenGL ES
    Replies: 0
    Last Post: 12-01-2011, 07:36 PM
  5. Scaling World Coordinates...
    By cutting_crew in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 10-31-2003, 09:56 AM

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