Advertisement

Question: dragging object under a mouse

Started by January 24, 2001 03:25 PM
0 comments, last by Punika 23 years, 9 months ago
Ok, everythin works fine with this code:
    
	POINT pt;	GetCursorPos(&pt);		
	GLint viewport[4];	
	GLdouble mvmatrix[16], projmatrix[16];	
	GLint realy;			//  OpenGL y coordinate position  	

	GLdouble wx, wy, wz;	//  returned world x, y, z coords  	

	glGetIntegerv (GL_VIEWPORT, viewport);    
	glGetDoublev (GL_MODELVIEW_MATRIX, mvmatrix);    
	glGetDoublev (GL_PROJECTION_MATRIX, projmatrix);//  note viewport[3] is height of window in pixels  	

	realy = viewport[3] - (GLint) pt.y - 1;	
	float depth;	
	glReadPixels(pt.x,realy,1,1,GL_DEPTH_COMPONENT, GL_FLOAT, &depth);    
	gluUnProject((GLdouble) pt.x, (GLdouble) realy, depth, mvmatrix, projmatrix, viewport, &wx, &wy, &wz); 	
	cursor_world_coords = VECTOR(wx,wy,wz);


  
but know i was asking me how i can find out on which Object the Coordinate is. The problem that i had is that every object has a pos but the objects are bigger than the pos so it happens that the mouse is over an object but don`t see it. Are there any good examples or tutorials on this? Thanks Punika [ Power Productions ] Edited by - Punika on January 24, 2001 4:29:20 PM
Punika
see my new post

http://members.xoom.com/myBollux

This topic is closed to new replies.

Advertisement