Jump to content

  • Log In with Google      Sign In   
  • Create Account


Picking :first call failed,then all the rest are working!


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Jabba   Members   -  Reputation: 122

Like
Likes
Like

Posted 12 October 2001 - 04:22 AM

Why is that?Here is the actual code
  
	GLuint selectBuff[64];
	GLint hits, viewport[4];
	long model_pick=-1;
	// Select buffer parameters

	glDisable(GL_LIGHTING);

  
	glRenderMode(GL_SELECT);
	// Enter to selection mode

	glSelectBuffer(64, selectBuff);
	glGetIntegerv(GL_VIEWPORT, viewport);
	glInitNames();
	glPushName(0);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	// Set-up pick matrix

	gluPickMatrix(x, DispSettings.Height-y, 2, 2, viewport);
	// Set our perpective transformation matrix

	gluPerspective(fCameraYAngle, fXYrap, 0.5,8000);

	
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();


	/* Set up the camera at (CameraPos.x, CameraPos.y, CameraPos.z) looking along vector (CameraLookAt.x, CameraLookAt.y, CameraLookAt.z).*/
	gluLookAt (CameraPos.x, CameraPos.y, CameraPos.z, CameraPos.x+CameraLookAt.x,CameraPos.y+CameraLookAt.y, CameraPos.z+CameraLookAt.z, 0.0, 1.0, 0.0);


	double dist=Dist((double)0,(double)0,(double)CameraLookAt.x,(double)CameraLookAt.z);
	double sina,cosa;
	double difx,difz;
	long nSide;
	if(dist==0)
	{
		sina=0;
		cosa=1;
	}
	else
	{
		sina=CameraLookAt.z/dist;
		cosa=CameraLookAt.x/dist;
	}
	// Render all scene and fill selection buffer

	long i,j;
	i=TotalView.m_nLists-2;
	long nTrgToRender=TotalView.m_pnTrgToRender[i];

	Cf3dSplitColorTrg * pTrgToRender=TotalView.m_ppTrgToRender[i];
	for(j=0;j<nTrgToRender;j++)
	{
		glLoadName(j);
		nSide=(pTrgToRender[j].p[2].z-pTrgToRender[j].p[0].z)/2;
		difx=nSide*sina;
		difz=nSide*cosa;
		RenderBlbTriangle(&pTrgToRender[j],difx,difz,nSide);			
	}
	// Get hits and go back to normal rendering

	hits = glRenderMode(GL_RENDER);

	// Get first model, in selection buffer stack

	if(hits > 0) 
		model_pick = selectBuff[3];
	
	if(bLighting) 
		glEnable(GL_LIGHTING);
    //glPopMatrix ();

	return model_pick;
  
Thanks, Jabba The Truth Is Not To Be Spoken In A Loud Voice

Sponsor:

#2 Jabba   Members   -  Reputation: 122

Like
Likes
Like

Posted 16 October 2001 - 05:02 AM

anyone?

#3 dantas   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 October 2001 - 10:09 PM

You might want to try swapping the buffers before you check for hits. If you are double buffered that is.

#4 sjelkjd   Members   -  Reputation: 171

Like
Likes
Like

Posted 21 October 2001 - 12:02 PM

Two things:
1) (most likely) you need to glPushName(something) to initialize the name stack. Otherwise, your name stack has size zero, and you won''t be able to read it.

2) Your selection buffer size is too small.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS