Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: arbitrary reflections

  1. #1
    Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Germany
    Posts
    311

    arbitrary reflections

    if i want e.g. to reflect a scene in water, i scale about (1, -1, 1), setup a clipping plane with a normal vector pointing up and offset the scene.

    now i'm trying to figure out how i have to setup the scale matrix and the clipping plane to reflect a scene about an arbitrary plane, for arbitrarily placed and oriented mirrors.

    does someone know how to do that? thanks

  2. #2
    Intern Contributor
    Join Date
    Jul 2004
    Location
    Toronto
    Posts
    97

    Re: arbitrary reflections

    I haven't done this personally, but I'd start with a definition of a reflection matrix here:
    http://en.wikipedia.org/wiki/Transformation_matrix

    So you wouldn't be using the scale transformation but using something like glMultMatrixd on the GL_MODELVIEW_MATRIX.

    If your plane isn't through the origin then you'd have to apply a translation after the reflection.

  3. #3
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: arbitrary reflections

    Look at glhGeneralPlanarMirrorf_1, glhGeneralPlanarMirrorf_2
    in the header file.
    http://www.geocities.com/vmelkon/glhlibrary.html

    It's open source so you can adapt it to your particular way of transforming your mirror to eye space.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Posting Permissions

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