Results 1 to 4 of 4

Thread: How to draw a frustrum from a given position

  1. #1
    Member Newbie
    Join Date
    Aug 2008
    Posts
    37

    How to draw a frustrum from a given position

    hi,

    i'm doing projective texture mapping. I want to visualise the projection that I'm using - i.e draw say a pyramid with the top at the light position and the rest aligned with the projection (frustrum) i'm using.

    I would like to use the terms given to glFrustrum = i.e a top, bottom, left right, near and far.

    I know glFrustrum calculates a matrix in eye space, and I would initially create my pyramid according to these coordinates. How can I take this pyramid and transform it to the light position?

    I have a modelview matrix for the light, which allows me to render from that position. I'm not sure how to go from this to a transform that I can actually apply to my "pyramid" though.

    Thanks for any help>!

    EDIT: I know how to do construct this using vectors (i have a light direction) but would like to know how to do this by transforming a given set of vertices in eye space. cheers!

  2. #2
    V-man
    Guest

    Re: How to draw a frustrum from a given position

    There is a demo at
    http://developer.download.nvidia.com...s_samples.html

    "Simple Soft Shadows"

    which draws the frustum as a pyramid.

  3. #3
    Member Newbie
    Join Date
    Aug 2008
    Posts
    37

    Re: How to draw a frustrum from a given position

    Hmm I don't see it..(the frustrum)
    - There are a couple of other shadow mapping examples there, it may be one of those (Hardware Shadow Mapping looks promising)

  4. #4
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: How to draw a frustrum from a given position

    Assuming you have the direction from light to the scene, lets call it lz and the camera vertical direction (from light point of view) is world Y.

    You can compute basis vectors in light space: (lx,ly,lz) expressed in world space like this:

    lx = normalize(cross(Y,lz)); // cross is cross product
    ly = normalize(cross(lz,lx);
    lz = lz

    I am not sure about the vector order inside cross product, I let you verify this.

    Then, you move along the lz axis until the near plane and move along lx and ly to left, right, up (the glFrustum arguments) and down to find the pyramide points coordinates (on the near plane).

    Finally you can easily find the view volume points on the far plane which lengthens vectors from light to points on the near plane.

    Hoping this is clear enough (sorry, I don't have time to draw a figure).

Similar Threads

  1. Draw frustrum in opengl
    By debinair in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 06-08-2014, 07:36 PM
  2. how to draw at right position?
    By imported_davie in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 04-15-2010, 09:13 AM
  3. Draw objects at the same position
    By ame_nguyenanhtai in forum OpenGL: Basic Coding
    Replies: 9
    Last Post: 05-14-2008, 02:33 AM
  4. Draw object at particular position
    By girish3110 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-05-2008, 06:07 AM
  5. how to draw a cylinder in specific position
    By wf in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 02-22-2002, 11:02 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