Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate function not working?? #17

Closed
nasser225 opened this issue Mar 13, 2018 · 3 comments
Closed

Translate function not working?? #17

nasser225 opened this issue Mar 13, 2018 · 3 comments
Assignees
Labels

Comments

@nasser225
Copy link

I have this from a tutorial:

vec = glm.vec4(1.0,0.0,0.0,1.0)
id_matrix = glm.mat4()
trans_matrix = glm.translate(id_matrix, glm.vec4(1.0, 1.0, 0.0))
vec = trans_matrix * vec

printing vec gives 0.0,0.0,0.0 and I was expecting 2.0,1.0,0.0

Please help! Thanks

Zuzu-Typ added a commit that referenced this issue Mar 13, 2018
+ Fixed translate() function ( #17 )
@Zuzu-Typ Zuzu-Typ self-assigned this Mar 13, 2018
@Zuzu-Typ
Copy link
Owner

Hi nasser225,
you are indeed correct - the translate() function was not working as intended, however that is actually not the reason why the code above is not functional.
In gtruc/glm (the original glm) there has been a change to the way matrices are initialized (or rather - they removed the initialization completely) g-truc/glm@4cf8a10 .
This results into glm.mat4() returning an uninitialized (empty) matrix:

[0, 0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0]

That's why the translation doesn't work.
You have to use glm.mat4(1.0) instead.

I'm trying to get gtruc to revert this change (because I ran into the same problem as you did).

@dwtd
Copy link

dwtd commented May 28, 2019

I also noticed that translate (and scale) don't seem to be working, but unrelated to the matrix initialization issue you mentioned from the original GLM. As a simple example:

    M = glm.translate(glm.mat4(1.0), glm.vec3(2.0, 2.0, 2.0))
    print("M:\n{}".format(M))

produces:

M:
[            1 |            0 |            0 |            0 ]
[            0 |            1 |            0 |            0 ]
[            0 |            0 |            1 |            0 ]
[            0 |            0 |            0 |            1 ]

If I change translate to scale I get:

M:
[            0 |            0 |            0 |            0 ]
[            0 |            0 |            0 |            0 ]
[            0 |            0 |            0 |            0 ]
[            0 |            0 |            0 |            1 ]

Something here is clearly not right. For a sanity check, I confirmed that in C++ the translate and scale functions do the right thing, and they do.

@Zuzu-Typ
Copy link
Owner

I accidentally screwed up the macro that generates the two of these functions, resulting in them always using empty arguments.
I'll release a fix soon

@Zuzu-Typ Zuzu-Typ reopened this May 28, 2019
@Zuzu-Typ Zuzu-Typ added bug and removed invalid labels May 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants