//*******************************************************************************
void HapticObject::renderDefaultHapticProperties()
{
	// Dummy
	hlMaterialf(HL_FRONT, HL_STIFFNESS, 0.8f);
    hlMaterialf(HL_FRONT, HL_STATIC_FRICTION, 0.0f);
    hlMaterialf(HL_FRONT, HL_DYNAMIC_FRICTION, 0.9f);
}
예제 #2
0
void CTorus::drawHapticScene(bool primary_context)
{
	hlMaterialf(HL_FRONT_AND_BACK, HL_STIFFNESS, m_stiffness);
	hlMaterialf(HL_FRONT_AND_BACK, HL_DAMPING, m_dampening);
	hlMaterialf(HL_FRONT_AND_BACK, HL_STATIC_FRICTION, m_static_friction);
	hlMaterialf(HL_FRONT_AND_BACK, HL_DYNAMIC_FRICTION, m_dynamic_friction);
	if(primary_context)
		hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, m_shapeID);
	else
		hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, m_shapeID_1);
	drawGLScene();
	hlEndShape();
}
예제 #3
0
/* redisplaying graphics */
void Display(void)
{
    hlBeginFrame();

    hlMaterialf(HL_FRONT_AND_BACK, HL_STATIC_FRICTION, 0.1);
    hlMaterialf(HL_FRONT_AND_BACK, HL_DYNAMIC_FRICTION, 0.8);

    hlCheckEvents();

	/* clear the display */
	//glClear(GL_COLOR_BUFFER_BIT);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
	//materialsTest();

	if (mDrawSurface)
		mSurface.DrawSurface();

    // draw the haptic surface
    hlHintb(HL_SHAPE_DYNAMIC_SURFACE_CHANGE, HL_TRUE);
    hlTouchableFace(HL_BACK);
    hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, mSurfaceShapeId);
        mSurface.DrawSurface();
    hlEndShape();
	
	glDisable(GL_LIGHTING);

	if (mDrawSystem)
		mPS.Draw();

	if (mDrawNormals)
		mSurface.DrawSurfaceNormals();

	glEnable(GL_LIGHTING);

    // draw the 3D cursor
    RedrawCursor();

	// show FPS
	if (mDrawInfo != drawInfo_None)
		DisplayInfo();

	// swap the double buffers
	glutSwapBuffers();  

    hlEndFrame();

}
예제 #4
0
/*******************************************************************************
 The main routine for rendering scene haptics.
*******************************************************************************/
void drawSceneHaptics()
{
    hlGetDoublev(HL_PROXY_TOUCH_NORMAL, proxyNormal);
    hlGetDoublev(HL_PROXY_POSITION, proxyPosition);

// Start haptic frame.  (Must do this before rendering any haptic shapes.)
    hlBeginFrame();
    hlPushMatrix();
    hlTouchModel(HL_CONTACT);

// Set material properties for the shapes to be drawn.
    hlMaterialf(HL_FRONT_AND_BACK, HL_STIFFNESS, 0.9f);
    hlMaterialf(HL_FRONT_AND_BACK, HL_DAMPING, 0.0f);
    hlMaterialf(HL_FRONT_AND_BACK, HL_STATIC_FRICTION, 0.1);
    hlMaterialf(HL_FRONT_AND_BACK, HL_DYNAMIC_FRICTION,0.1 );
    hlHinti(HL_SHAPE_FEEDBACK_BUFFER_VERTICES, objmodel->numvertices);
    hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, gShapeId);

// Render haptic shape
    glPushMatrix();
    glCallList(bumpList);
    glPopMatrix();

// End the shape.
    hlEndShape();
    hlPopMatrix();
    hlPushMatrix();
    hlTouchModel(HL_CONSTRAINT);
    hlMaterialf(HL_FRONT_AND_BACK, HL_STIFFNESS, 0.4f);
    hlMaterialf(HL_FRONT_AND_BACK, HL_DAMPING, 0.3f);
    hlMaterialf(HL_FRONT_AND_BACK, HL_STATIC_FRICTION, 0.1);
    hlMaterialf(HL_FRONT_AND_BACK, HL_DYNAMIC_FRICTION,0.1 );

    if (touchedHole && force[2] > -0.1 )
    {
        hlTouchModelf(HL_SNAP_DISTANCE, 300.0);
    }
    else
    {
        hlTouchModelf(HL_SNAP_DISTANCE, 3.0);
    }

    hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, gPointId);
    glPushMatrix();
    glPointSize(5.0);
    glTranslatef(0.0, 0.0, 1.0);
    glBegin(GL_POINTS);
    glVertex3f(0.05,-0.175,-0.975);
    glEnd();

    glPopMatrix();
    hlEndShape();
    hlPopMatrix();

// End the haptic frame.
    hlEndFrame();
}
예제 #5
0
void Window::hapticRendering()
{
	hlBeginFrame();

	hlMaterialf(HL_FRONT_AND_BACK, HL_STIFFNESS, haptic.getStiffness());
	hlMaterialf(HL_FRONT_AND_BACK, HL_DAMPING, haptic.getDamping());
	hlMaterialf(HL_FRONT_AND_BACK, HL_STATIC_FRICTION, haptic.getStaticFriction());
	hlMaterialf(HL_FRONT_AND_BACK, HL_DYNAMIC_FRICTION, haptic.getDynamicFriction());
	hlMaterialf(HL_FRONT_AND_BACK, HL_POPTHROUGH, haptic.getPopthroughValue());

	hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, haptic.getShapeID());
	//vertexArrayObject.bind();
	shaderProgram->bind();
	shaderProgram->setUniformValue("translateFactor", -1.0f, -1.0f, 0.0f);
	shaderProgram->setUniformValue("mvp", QMatrix4x4(glm::value_ptr(mvp)));
	glDrawElements(GL_TRIANGLES, mesh->getNumberOfIndices(), GL_UNSIGNED_INT,
		0);
	//vertexArrayObject.release();
	shaderProgram->release();
	hlEndShape();

	hlEndFrame();
}
예제 #6
0
	void CybPhantom::hapticRendering()
	{
		if(!shapeIdListIscreated)
		{
			genShapeIdList(cybCore->numLayer);
			shapeIdListIscreated = true;
		}
	
		if(habHapticLayers == NULL)
		{
			cout<<"Message Error: Haptic Layer don't exist!"<<endl;
		}
		else{
			hlBeginFrame();
	
			glPushMatrix();
	
			//cout << "Haptic layers " << numHapticLayers << endl;
			for(int j = 0; j < numHapticLayers; j++){

				if(habHapticLayers[j] == true){
	

					glTranslated(cybCore->xTrans + cybCore->layerTrans[j][0], cybCore->yTrans + cybCore->layerTrans[j][1], cybCore->zTrans + cybCore->layerTrans[j][2]);
					glScaled(cybCore->xScale * cybCore->layerSca[j][0], cybCore->yScale * cybCore->layerSca[j][1], cybCore->zScale * cybCore->layerSca[j][2]);

					glTranslated(cybCore->cX, cybCore->cY, cybCore->cZ);
					glRotated(cybCore->getXAngle() + cybCore->layerRot[j][0],1,0,0);
					glRotated(cybCore->getYAngle() + cybCore->layerRot[j][1],0,1,0);
					glRotated(cybCore->getZAngle() + cybCore->layerRot[j][2],0,0,1);
					glTranslated(-cybCore->cX, -cybCore->cY, -cybCore->cZ);


					if(materialPropertiesIsEnable){
	
						if(cybCore->materialPropertyContextCreated() && cybCore->propertyFaceModified())
							updateHapticsFaces();
	
						if(habHapticLayersMaterial == NULL)
						{
							cout<<"Message Error: Material context don't exist!"<<endl;
						}
						else{
							if(habHapticLayersMaterial[j] == true){		
								hlMaterialf(propertyFace[j][0], HL_STIFFNESS, cybCore->getMaterialPropertyValue(j, STIFFNESS));
	
								hlMaterialf(propertyFace[j][1], HL_DAMPING, cybCore->getMaterialPropertyValue(j, DAMPING));
	
								hlMaterialf(propertyFace[j][2], HL_STATIC_FRICTION, cybCore->getMaterialPropertyValue(j, STATIC_FRICTION));
	
								hlMaterialf(propertyFace[j][3], HL_DYNAMIC_FRICTION, cybCore->getMaterialPropertyValue(j, DYNAMIC_FRICTION));
	
								if(ambientPropertyIsEnable){
									hlMaterialf(HL_FRONT_AND_BACK, HL_POPTHROUGH,1);
								}
								else{
									hlMaterialf(propertyFace[j][4], HL_POPTHROUGH,cybCore->getMaterialPropertyValue(j, POPTHROUGH));
								}
							}
						}
					}
	
	
					hlHinti(HL_SHAPE_FEEDBACK_BUFFER_VERTICES, cybCore->nv[j]);				  
					hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, shapeId[j]);
	
					if(ambientPropertyIsEnable)
						hlTouchableFace(CybViscosity::ViscosityShapeAttribute[j].currentFace);
					else hlTouchableFace(HL_FRONT_AND_BACK);
	
					CybVector3D<float> v1;
	
	
					for(int i = 0; i < cybCore->nt[j]; i++){
	
						glBegin(GL_TRIANGLES);
	
						v1 = cybCore->vNormalCell[j][i];
						glNormal3f(v1[0], v1[1], v1[2]);
	
						v1 = cybCore->coordList[j][cybCore->v[j][i][0]];
						glVertex3f(v1[0], v1[1], v1[2]);
	
						v1 = cybCore->coordList[j][cybCore->v[j][i][1]];
						glVertex3f(v1[0], v1[1], v1[2]);
	
						v1 = cybCore->coordList[j][cybCore->v[j][i][2]];
						glVertex3f(v1[0], v1[1],v1[2]);		  
	
						glEnd();
						glFlush();
					}
	
					hlEndShape();
	

				}
	
				glLoadIdentity();
			}
	
			glPopMatrix();
			hlEndFrame();
		}
		hlCheckEvents();
	}
예제 #7
0
void CCylinder::drawHapticScene(bool primary_context)
{
	hlMaterialf(HL_FRONT_AND_BACK, HL_STIFFNESS, m_stiffness);
	hlMaterialf(HL_FRONT_AND_BACK, HL_DAMPING, m_dampening);
	hlMaterialf(HL_FRONT_AND_BACK, HL_STATIC_FRICTION, m_static_friction);
	hlMaterialf(HL_FRONT_AND_BACK, HL_DYNAMIC_FRICTION, m_dynamic_friction);

	if ( !m_customRendered )
	{
		if(primary_context)
			hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, m_shapeID);
		else
			hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, m_shapeID_1);

		drawGLScene();
		hlEndShape();
	}
	else
	{
		// Draw cylinder section
		if(primary_context)
			hlBeginShape(HL_SHAPE_CALLBACK, m_shapeID );
		else
			hlBeginShape(HL_SHAPE_CALLBACK, m_shapeID_1 );

		hlCallback(HL_SHAPE_INTERSECT_LS, 
			(HLcallbackProc) CHapticCylinder::intersectSurface, (void *) customCylinder);
		hlCallback(HL_SHAPE_CLOSEST_FEATURES, 
			(HLcallbackProc) CHapticCylinder::closestSurfaceFeatures, (void *) customCylinder);
		hlEndShape();

		// Draw disk A
		if(primary_context)
			hlBeginShape(HL_SHAPE_CALLBACK, diskAShape->GetShapeID () );
		else
			hlBeginShape(HL_SHAPE_CALLBACK, diskAShape->GetShapeID_1 ());

		diskATrans->makeIdentity ();

		diskATrans->multRight ( hduMatrix::createRotation ( 1, 0, 0, 0.5*PI ) );
		diskATrans->multRight ( hduMatrix::createTranslation ( 0, 0, 0.5 ) );

		diskATrans->multRight ( hduMatrix::createScale ( getSizeX(), getSizeY(), getSizeZ() ) );
		diskATrans->multRight ( getHduMatrix ( getRotation () ) );
		diskATrans->multRight ( hduMatrix::createTranslation ( getLocationX(), getLocationY(), getLocationZ () ) );

		hlCallback(HL_SHAPE_INTERSECT_LS, 
			(HLcallbackProc) CHapticDisk::intersectSurface, (void *) diskA);
		hlCallback(HL_SHAPE_CLOSEST_FEATURES, 
			(HLcallbackProc) CHapticDisk::closestSurfaceFeatures, (void *) diskA);
		hlEndShape();

		// Draw disk B
		if(primary_context)
			hlBeginShape(HL_SHAPE_CALLBACK, diskBShape->GetShapeID () );
		else
			hlBeginShape(HL_SHAPE_CALLBACK, diskBShape->GetShapeID_1 ());

		diskBTrans->makeIdentity ();

		diskBTrans->multRight ( hduMatrix::createRotation ( 1, 0, 0, -0.5*PI ) );
		diskBTrans->multRight ( hduMatrix::createTranslation ( 0, 0, -0.5 ) );

		diskBTrans->multRight ( hduMatrix::createScale ( getSizeX(), getSizeY(), getSizeZ() ) );
		diskBTrans->multRight ( getHduMatrix ( getRotation () ) );
		diskBTrans->multRight ( hduMatrix::createTranslation ( getLocationX(), getLocationY(), getLocationZ () ) );

		hlCallback(HL_SHAPE_INTERSECT_LS, 
			(HLcallbackProc) CHapticDisk::intersectSurface, (void *) diskB);
		hlCallback(HL_SHAPE_CLOSEST_FEATURES, 
			(HLcallbackProc) CHapticDisk::closestSurfaceFeatures, (void *) diskB);
		hlEndShape();
	}

}