bool GeometryRenderer::render()
{
	if (!m_GeometryArray) {
		return false;
	}

	bool ret1; 
	glEnable(GL_LIGHTING);

	// determine the max dimension
	double aspectX,aspectY,aspectZ;
	double centerX,centerY,centerZ;
	aspectX = m_Extent->getXMax() - m_Extent->getXMin();
	aspectY = m_Extent->getYMax() - m_Extent->getYMin();
	aspectZ = m_Extent->getZMax() - m_Extent->getZMin();
	double max = (aspectX>aspectY?aspectX:aspectY);
	max = (max>aspectZ?max:aspectZ);

	// compute the center of the space
	centerX = (m_Extent->getXMax() + m_Extent->getXMin()) / 2.0;
	centerY = (m_Extent->getYMax() + m_Extent->getYMin()) / 2.0;
	centerZ = (m_Extent->getZMax() + m_Extent->getZMin()) / 2.0;
	aspectX/=max;
	aspectY/=max;
	aspectZ/=max;

	setClipPlanes(aspectX, aspectY, aspectZ);

	Matrix matrix;
	// center
	matrix.preMultiplication(Matrix::translation(
		(float)(-centerX),
		(float)(-centerY),
		(float)(-centerZ)
		));
	// scale to aspect ratio
	matrix.preMultiplication(Matrix::scale(
		(float)(1.0/max),
		(float)(1.0/max),
		(float)(1.0/max)
		));
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glMultMatrixf(matrix.getMatrix());
	ret1 = m_GeometryArray->render();
	glPopMatrix();

	disableClipPlanes();

	return ret1;
}
Beispiel #2
0
	void Terrain::resetInteractionStates()
	{
		state = 0;

		//Reset height-selecting states
		setHeight = false;
		enableHeightVis = false;

		//Reset clippling-Plane information
		enableFirstClip = false;
		enableSecondClip = false;
		disableClipPlanes();
		firstClipY = 0.0f;
		secondClipY = 0.0f;
		setFirstClip = false;
		setSecondClip = false;
		enableSecondClipVis = false;
		enableFirstClipVis = false;
		clipPlaneFirstVisOffset = -0.0001f; //Ensures rendering of clipPlane visualizations at start
		clipPlaneSecondVisOffset = 0.0001f;

		//Reset endpoint-drawing states
		settingStartPath = false;
		settingEndPath = false;

		//Reset direct freehand drawing states
		drawingPath = false;

		//Reset ROI drawing states
		settingRoi = false;
		settingRoiRadius = false;

		//Reset POI drawing states
		settingPoi = false;

	}
Beispiel #3
0
	void Terrain::handleHeightFiltering(int &state)
	{

		const int RESET = 0;
		const int PLACING_FIRST = 1;
		const int PLACING_SECOND = 2;
		const int FINISH = 3;

		switch(state){
			case RESET: //Resets start and end positions of path
				enableFirstClip = false;
				enableSecondClip = false;
				disableClipPlanes();
				firstClipY = 0.0f;
				secondClipY = 0.0f;
				if(pinch && currDelay == 0)
				{
					state = PLACING_FIRST;
					currDelay = 40;
				}
				break;
			case PLACING_FIRST: //Placing the bottom clip plane
				//enableBotClip = true;
				enableFirstClipVis = true;
				setFirstClip = true;
				//clipPlaneFirstVisOffset = 0.0001f;
				if(pinch && currDelay == 0){

					state = PLACING_SECOND;
					currDelay = 40;
				}
				break;
			case PLACING_SECOND: //Placing the top clip plane
				//enableTopClip = true;
				enableSecondClipVis = true;
				setFirstClip = false;
				setSecondClip = true;
				if(firstClipY > secondClipY){
					clipPlaneFirstVisOffset = -0.0001f;
					clipPlaneSecondVisOffset = 0.0001f;
				}
				else{
					clipPlaneFirstVisOffset = 0.0001f;
					clipPlaneSecondVisOffset = -0.0001f;
				}
				
				if((pinch && currDelay == 0) && !((firstClipY > maxDisplayY && secondClipY > maxDisplayY) || (firstClipY < minDisplayY && secondClipY < minDisplayY))){
					//((firstClipY < maxDisplayY && firstClipY > minDisplayY) || (secondClipY < maxDisplayY && secondClipY > minDisplayY)) &&  ){
					state = FINISH;
					currDelay = 40;
				}
				break;
			case FINISH: //Start and End have both been placed, pinch to go back to starting state
				setSecondClip = false;
				enableFirstClip = true;
				enableSecondClip = true;
				enableSecondClipVis = false;
				enableFirstClipVis = false;
				if(pinch && currDelay == 0)
				{
					state = RESET;
					clipPlaneFirstVisOffset = -0.0001f; //Ensures rendering of clipPlane visualizations
					clipPlaneSecondVisOffset = 0.0001f;
					currDelay = 40;
				}
						
				break;
		}
	}