开发者

Objective-c OpenGLES Knowing 3D object position xyz

开发者 https://www.devze.com 2023-03-15 04:41 出处:网络
Is there a way you can get the position of an object in the 3d world? I read I had to multiply my vertices position (what vertices? Isn\'t that what i\'开发者_JS百科m looking for?) and the GL_MODELVIE

Is there a way you can get the position of an object in the 3d world? I read I had to multiply my vertices position (what vertices? Isn't that what i'开发者_JS百科m looking for?) and the GL_MODELVIEW. How am I supose to do this? Can someone post some code?

For example I have:

glpushmatrix();
glrotatef(something, 1.0, 0.0, .0);
glrotatef(anotherting, .0, 1.0, .0);
glRotatef(more, .0, 1.0, .0);
glTranslatef(.0, .0, 100);
PaintObect();
glPopMatrix();

Is it possible to know the 3d world absolut coordinates?

Thanks guys.


Nevermind i just found out.

GLfloat matrix[16]; 
glGetFloatv (GL_MODELVIEW_MATRIX, matrix);
const float position_x = matrix[12];
const float position_y = matrix[13];
const float position_z = matrix[14];
0

精彩评论

暂无评论...
验证码 换一张
取 消