Exemplo n.º 1
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();
}
//*******************************************************************************
void HapticConstraint::renderConstraint( HapticObject * pObj )
{
	// den Constraint nur dann rendern, wenn er aktiviert ist
	if (!m_Enabled)
	{
		return;
	}

	hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, m_HLConstraintID);

    hlTouchModel(HL_CONSTRAINT);
    hlTouchModelf(HL_SNAP_DISTANCE, m_SnapDistance);
	
	pObj->renderShapeAtPosition();

	hlEndShape();
}