Reputation: 96
I am using glm::lookAt
to get a matrix to transform the world by. This works fine, I can generate the matrix, the feed it into the shader, and it all works. What I now need to do is transform an arbitrary vector (ie 100,100,100,1) by the lookAt
matrix. For some reason, I get garbage values
glm::mat4 model = glm::lookAt(glm::vec3(current_pos.x,
current_pos.y,
current_pos.z),
glm::vec3(current_pos.x + dir.x,
current_pos.y + dir.y,
current_pos.z + dir.z),
glm::vec3(up.x,up.y,up.z));
GLfloat fmodel[16] =
{
model[0][0],
model[0][1],
model[0][2],
model[0][3],
model[1][0],
model[1][1],
model[1][2],
model[1][3],
model[2][0],
model[2][1],
model[2][2],
model[2][3],
model[3][0],
model[3][1],
model[3][2],
model[3][3]
};
A printout of model
's values: 0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3
I am calculating the point using model * vec4(x, y, z, 1)
The matrix is duplicated so I can pass it as a uniform. Both using the original matrix an constructing the matrix from the array yield identical results.
EDIT
Printing code is as follows:
for (unsigned i = 0; i < 16; ++i)
printf("%d,", fmodel[i]);
This yields the output of 3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
no matter what my vectors are
Upvotes: 0
Views: 861
Reputation: 96
Oddly, after using glm::value_ptr()
rewriting large swathes of code, this is now working
Upvotes: 1