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 4 of 4

Thread: [glm] Best way to zero out translation component

  1. #1
    Junior Member Newbie
    Join Date
    May 2011
    Posts
    9

    [glm] Best way to zero out translation component

    What is the easiest way to zero out the translation component of a glm::mat4....


    Thanks for any advice

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,716

    Re: [glm] Best way to zero out translation component

    It's the fourth column.

  3. #3
    Junior Member Newbie
    Join Date
    May 2011
    Posts
    9

    Re: [glm] Best way to zero out translation component

    Thanks Alfonse

    So should this work:

    glm::mat4 no_translation = view_matrix;
    no_translation[3].x=0;
    no_translation[3].y=0;
    no_translation[3].z=0;
    no_translation[3].w=0;

  4. #4
    Super Moderator Frequent Contributor Groovounet's Avatar
    Join Date
    Jul 2004
    Posts
    936

    Re: [glm] Best way to zero out translation component

    Actually:
    no_translation[3] = glm::vec4(0, 0, 0, 1);

    Or using the component names if you want.

Posting Permissions

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