# OpenGL Getting the eye coordinates of an object

This topic is 3720 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I apologise for a very basic post but I haven't been able to figure this one out on my own. I've got basic cubes that I've scaled, translated, rotated... I want to be able to find out what the final coordinates of the cube are after all these transformations have been applied. I *thought* I could use something like the code below to get the matrix that was being applied to my object vertexes and multiply it with the vertex of interest to get its final location, but I think the results in the modelview array are not sensible for the parameters I've put in for the transformations. Using only scaling and translating, I get a matrix of all 0s. When I add the rotation I get the matrix below. Note: the transformations draw correctly on screen and I haven't got any errors from OpenGL. Am I on the right track? Id appreciate any feedback someone can give me! Thanks, Anna Code to get the modelview matrix: glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotatef(90, 0.0, 1.0, 0.0); glTranslatef(1.0, 1.0, 1.0); glScalef(3.0, 1.0, 1.0); GLfloat modelview[16]; glGetFloatv(GL_MODELVIEW_MATRIX, modelview); ModelView matrix with rotation 0: -2147483648 1: 0 2: 0 3: 0 4: 0 5: 0 6: 0 7: 0 8: 0 9: 0 10: -1073741824 11: 0 12: 0 13: 0 14: 0 15: 0

##### Share on other sites
I don't see anything wrong with the code you posted, so the error must be some place else. Perhaps in the code that prints the array?

##### Share on other sites
That code is:

printf("modelview matrix\n");
for (int i = 0; i < 16; i++)
printf("%d: %d \n", i, modelview);

##### Share on other sites
printf("modelview matrix\n");for (int i = 0; i < 16; i++)  printf("%d: %f \n", i, modelview);

%d is for integers, but you've got an array of floats.
Or if you're using C++, this is much better:
std::cout << "modelview matrix\n";for (int i = 0; i < 16; i++)  std::cout << i << ": " << modelview << "\n";

##### Share on other sites
Ack! I spent all day researching the modelview matrix and its my dodgy c++ !

thank you!

1. 1
Rutin
25
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 14
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631758
• Total Posts
3002137
×