Advertisement

screen visible border question / visual range object

Started by January 28, 2003 05:52 AM
5 comments, last by BlackBox 22 years, 1 month ago
When drawing objects in 3d, How do I know when an object gets out of the visual range of the screen? Example I have a cube in the middle of the screen 0,0,0 (x,y,z), if I move the cube in the x axis when it will go out of the screen and stop being visible? I know it depends on the z axis but is there a way of knowing when it goes out of screen without doing the time wastefull test programs? Thank you. ps. Im writing this because I want to have a mouse on screen draw by a simple figure, but how do I prevent the mouse going out of screen! ARRHH ---------------------------- ^_^
---------------------------- ^_^
select buffer may help you.
Advertisement
gluProject or gluUnProject may help you too.
It all depends on your projection matrix.

Death of one is a tragedy, death of a million is just a statistic.
If at first you don't succeed, redefine success.
quote:
Original post by vincoof
gluProject or gluUnProject may help you too.



Any tip on how can I implement this.

Thankyou for your answers!


----------------------------
^_^
---------------------------- ^_^
quote:
It all depends on your projection matrix.

Not only. It also depends on the modelview matrix.

gluProject and gluUnProject are GLU functions. Please wait a few seconds...

[edited by - vincoof on January 28, 2003 8:49:17 AM]
Advertisement

  int is_point_visible(GLdouble x, GLdouble y, GLdouble z){GLdouble modelMatrix[16];GLdouble projMatrix[16];GLint viewport[4];GLdouble winx, winy, winz;glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);glGetIntegerv(GL_VIEWPORT, viewport);gluProject(x, y, z, modelMatrix, projMatrix, viewport, &winx, &winy, &winz);return (winx >= viewport[0]) && (winx <= viewport[0]+viewport[2]) && (winy >= viewport[1]) && (winy <= viewport[1]+viewport[3]);}  

Please note there are alot of calls to glGet which are pretty slow. If you have to do it for one point only, it''s really affordable. For more points you may want to optimize it by grouping calls to glGet.

This topic is closed to new replies.

Advertisement