Results 1 to 8 of 8

Thread: Rendering at constant size.

  1. #1
    Senior Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    569

    Rendering at constant size.

    I hope this will make sense:

    Anyone that is familiar with 3DSMax will notice that when a light is placed in the scene as well as a camera and the camera is moved about the light icon stays a fixed size.

    In other words, suppose I want to render a unit cube and regardless of where I move the camera I want the cube to remain unit size (even if the camera moves far from the cube or I move the cube far back along the Z-axis).

    Currently, I'm using gluProject to project the vertices of the cube and find the size of it after camera transforms. I then determine a scale value based on the projected size of the cube and scale the cube up or down as needed. This sort of works but seems a bit quirky.

    Sorry about the long post. If anyone has any idea what I'm talking about and knows how to implement this I would be greatful.

    Cheers.

  2. #2
    Junior Member Newbie
    Join Date
    Jun 2007
    Posts
    6

    Re: Rendering at constant size.

    I'm using the same approach, and, like you said, it works pretty well but is slightly quirky. I would be interested in developing a better method as well.

  3. #3
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,931

    Re: Rendering at constant size.

    I would try using an orthogonal projection for the cube.

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    569

    Re: Rendering at constant size.

    There are two problems with that approach:

    1) It distorts the cube.
    2) Suppose my cube is resting on a plane. I haven't found a way to have the camera transformations affect the plane (rendered in a perspective projection) and the cube (rendered in an ortho projection) in the same way. Different transformations are needed when transforming in perspective versus ortho.

  5. #5
    Senior Member Regular Contributor remdul's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands
    Posts
    346

    Re: Rendering at constant size.

    I think you can just measure the distance from near plane to the cube center, and use that to scale the cube when drawing it. You may need to do some extra work to take in account FOV changes.

  6. #6
    Senior Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    569

    Re: Rendering at constant size.

    Or perhaps better yet use the distance from the camera to the cube center? This way changing the near clip plane won't scale the cube.

    This is an interesting idea and seems simple and elegant. Thank you, i'll give it a try.

  7. #7
    Senior Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    569

    Re: Rendering at constant size.

    Flatus, here's what I did and it works rather well, no more quirkyness!

    Take the vector defined by the two points that are the camera position and the center of the object you wish to keep at constant size.

    The length of this vector becomes your scale value.

    So, when the camera is 1 unit away from the object the length of the vector is one and so is your scale value. As you move the camera further away - say to two units your object becomes half the size (it is twice as far away). Now the length of the vector is 2. Scaling up the object twice as large.

    It's simple, straight forward, and most importantly, it works

    Thank you for the suggestion remdul.

  8. #8
    Junior Member Newbie
    Join Date
    Jun 2007
    Posts
    6

    Re: Rendering at constant size.

    Yeah, that is pretty slick. Thanks guys!

Similar Threads

  1. rendering a scene graph with a constant number of draw calls
    By Taylor Holliday in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 05-21-2014, 04:53 PM
  2. Constant manipulators size.
    By rom222 in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 03-22-2013, 02:24 AM
  3. Object rendering at constant size from camera view
    By Norris in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-31-2011, 10:01 AM
  4. How draw a constant size object in all zoom?
    By ncn213 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-31-2009, 02:29 PM
  5. 3D Constant size quads
    By imported_Ffelagund in forum OpenGL: General
    Replies: 2
    Last Post: 09-01-2008, 04:58 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