Advertisement

Making a Ray for Object Selecting

Started by January 29, 2001 02:10 PM
0 comments, last by Punika 23 years, 9 months ago
Hi Guys, i have try to make a ray for object selecting ( Ray intersecting ) so now my little code:
  
// For LineStart we use the Camera Pos:

CVector LineStart;
LineStart.fX = cam.fX;
LineStart.fY = cam.fY;
LineStart.fZ = cam.fZ;

// New the LineEnd:

CVector LineEnd;
	GLint viewport[4];
	GLdouble mvmatrix[16], projmatrix[16];	
	GLint realy;			//  OpenGL y coordinate position

	GLint realx;

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

	
	
	realx = MouseX;
	realy = viewport[3] - MouseY - 1;



	gluUnProject( (GLdouble)realx, (GLdouble)realy, 1.0f, mvmatrix, projmatrix, viewport, &unpX, &unpY, &unpZ); 	

	LineEnd.x = (float)unpX;	
	LineEnd.y = (float)unpY;	
	LineEnd.z = (float)unpZ;
  
So my question is is this right? If not how i must do it ? Thanks for your help Punika [ Power Productions ]
Punika
Hello ? Can Nobody help me?

Punika

[ Power Productions ]
Punika

This topic is closed to new replies.

Advertisement