예제 #1
0
void RayScreenMenuTool::display(GLContextData&) const
	{
	if(insideWidget||widgetActive||isActive())
		{
		/* Draw the menu selection ray: */
		glPushAttrib(GL_ENABLE_BIT|GL_LINE_BIT);
		glDisable(GL_LIGHTING);
		glColor3f(1.0f,0.0f,0.0f);
		glLineWidth(3.0f);
		glBegin(GL_LINES);
		glVertex(selectionRay.getOrigin());
		glVertex(selectionRay(getDisplaySize()*Scalar(5)));
		glEnd();
		glPopAttrib();
		}
	}
예제 #2
0
void RayScreenMenuTool::frame(void)
	{
	/* Update the selection ray: */
	selectionRay=calcSelectionRay();
	
	if(factory->interactWithWidgets)
		insideWidget=getWidgetManager()->findPrimaryWidget(selectionRay)!=0;
	
	if(widgetActive)
		{
		/* Deliver the event: */
		GLMotif::Event event(true);
		event.setWorldLocation(selectionRay);
		getWidgetManager()->pointerMotion(event);
		
		if(dragging)
			{
			/* Find the closest intersection with any screen: */
			std::pair<VRScreen*,Scalar> si=findScreen(selectionRay);
			
			if(si.first!=0)
				{
				/* Update the dragged widget's transformation: */
				NavTrackerState current=NavTrackerState::translateFromOriginTo(selectionRay(si.second));
				current*=preScale;
				getWidgetManager()->setPrimaryWidgetTransformation(draggedWidget,GLMotif::WidgetManager::Transformation(current));
				}
			}
		}
	else if(isActive())
		{
		/* Update the selection ray: */
		selectionRay=calcSelectionRay();
		
		/* Deliver the event: */
		GLMotif::Event event(true);
		event.setWorldLocation(selectionRay);
		getWidgetManager()->pointerMotion(event);
		}
	}
예제 #3
0
void DaisyWheelTool::display(GLContextData&) const
	{
	if(active)
		{
		/* Save OpenGL state: */
		glPushAttrib(GL_ENABLE_BIT|GL_LINE_BIT);
		
		/* Draw the daisy wheel: */
		glPushMatrix();
		glMultMatrix(wheelTransform);
		
		/* Set up OpenGL state: */
		glDisable(GL_LIGHTING);
		
		glBegin(GL_QUADS);
		Scalar angle0=Scalar(0);
		Scalar angleDiff=zoomAngle-angle0;
		if(angleDiff<-Math::Constants<Scalar>::pi)
			angleDiff+=Scalar(2)*Math::Constants<Scalar>::pi;
		else if(angleDiff>Math::Constants<Scalar>::pi)
			angleDiff-=Scalar(2)*Math::Constants<Scalar>::pi;
		Scalar weight=Math::abs(angleDiff)/Math::Constants<Scalar>::pi;
		angleDiff*=Math::pow(weight,Scalar(1)-zoomStrength)/weight;
		Scalar wAngle0=zoomAngle-angleDiff;
		Scalar c0=Math::cos(wAngle0);
		Scalar s0=Math::sin(wAngle0);
		for(int i=0;i<numCharacters;++i)
			{
			Scalar angle1=angle0+dynamicWeights[i]*Scalar(2)*Math::Constants<Scalar>::pi/dynamicWeightSum;
			angleDiff=zoomAngle-angle1;
			if(angleDiff<-Math::Constants<Scalar>::pi)
				angleDiff+=Scalar(2)*Math::Constants<Scalar>::pi;
			else if(angleDiff>Math::Constants<Scalar>::pi)
				angleDiff-=Scalar(2)*Math::Constants<Scalar>::pi;
			weight=Math::abs(angleDiff)/Math::Constants<Scalar>::pi;
			angleDiff*=Math::pow(weight,Scalar(1)-zoomStrength)/weight;
			Scalar wAngle1=zoomAngle-angleDiff;
			Scalar c1=Math::cos(wAngle1);
			Scalar s1=Math::sin(wAngle1);
			
			if(i%2==0)
				glColor3f(1.0f,0.5f,0.5f);
			else
				glColor3f(0.0f,0.5f,1.0f);
			glVertex3f(s0*factory->innerRadius,0.0f,c0*factory->innerRadius);
			glVertex3f(s1*factory->innerRadius,0.0f,c1*factory->innerRadius);
			glVertex3f(s1*factory->outerRadius,0.0f,c1*factory->outerRadius);
			glVertex3f(s0*factory->outerRadius,0.0f,c0*factory->outerRadius);
			
			angle0=angle1;
			wAngle0=wAngle1;
			c0=c1;
			s0=s1;
			}
		glEnd();
		
		glPopMatrix();
		
		/* Draw the menu selection ray: */
		glLineWidth(3.0f);
		glColor3f(1.0f,0.0f,0.0f);
		glBegin(GL_LINES);
		glVertex(selectionRay.getOrigin());
		glVertex(selectionRay(getDisplaySize()*Scalar(5)));
		glEnd();
		
		/* Restore OpenGL state: */
		glPopAttrib();
		}
	}