Front Page › Forums › OpenHaptics › Touching and feeling each and every bit of model with Omni device
- This topic has 3 replies, 3 voices, and was last updated 13 years, 7 months ago by luckyyyyyy.
-
AuthorPosts
-
June 30, 2010 at 12:24 pm #734587Jenny_wuiParticipant
I have a very large model having about 132794 vertices. I am using the following command for haptic mapping of the model:
hlHintb(HL_SHAPE_DYNAMIC_SURFACE_CHANGE, HL_TRUE);
hlHinti( HL_SHAPE_FEEDBACK_BUFFER_VERTICES, objmodel->numvertices);
hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, obj.shapeId);When object is in its initial position, I can touch and feel each and every bit of the model. But after the object being rotated, sometimes I find I cannot touch each and every bit like the initial position. I have used model bounding box to update camera and haptic mapping. To be more detail, I have put code snippets as follows:
My model is not centred at origin. It is centred at ( -27.038612, -19.610632, 15.522789). The bounding box of my model is:
Max_x: 3.604006, Min_x: -62.712784, Max_y: 78.721275, Min_y: -104.043892, Max_z: 70.194565 -40.782883
/*******************************************************/
void glutReshape(int width, int height)
{static const double kFovY = 45;
glViewport(0, 0, width, height);
gWindowWidth = width;
gWindowHeight = height;
double nearDist = y_dimension/4;
double farDist = y_dimension*2;
double aspect = (double) width / height;glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(kFovY, aspect, nearDist, farDist);gCameraPosWC[0] = 0;
gCameraPosWC[1] = y_dimension/3;
gCameraPosWC[2] = 1.5*y_dimension;updateCamera();
}void updateCamera()
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(gCameraPosWC[0], gCameraPosWC[1], gCameraPosWC[2], 0, 0, 0, 0, 1, 0);glTranslatef(gCameraTranslationX, gCameraTranslationY, 0);
glMultMatrixd(gCameraRotation);
glScaled(gCameraScale, gCameraScale, gCameraScale);updateHapticMapping();
glutPostRedisplay();
}void updateHapticMapping(void)
{
GLdouble modelview[16];
GLdouble projection[16];
GLint viewport[4];glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
glGetDoublev(GL_PROJECTION_MATRIX, projection);
glGetIntegerv(GL_VIEWPORT, viewport);hlMatrixMode(HL_TOUCHWORKSPACE);
hlLoadIdentity();hduVector3Dd minPt min_x, min_y, min_z);
hduVector3Dd maxPt( max_x, max_y, max_z);
hluFitWorkspaceBox(modelview, minPt, maxPt);gCursorScale = hluScreenToModelScale(modelview, projection, viewport);
gCursorScale *= CURSOR_SIZE_PIXELS;
}/*******************************************************************************/
Any suggestions or error about this will be highly appreciated.
July 2, 2010 at 7:08 am #734604MarkusKeymasterIt seems like you are not using H3DAPI (x3d/python and C++ if you want) nor HAPI (triangles, no OpenGL calls or OpenHaptics calls) but rather only openGL and OpenHaptics. If this is the case then it would probably be better to ask these questions in some forum at http://www.sensable.com, the same goes for your other threads. I really have no good input about the code you posted except that you can always draw your bounding box on screen to see how big it actually is, to make sure it is big enough, and in the correct position.
September 23, 2010 at 6:24 pm #734765luckyyyyyyParticipantyou can not use glTranslatef(gCameraTranslationX, gCameraTranslationY, 0);
at that location…
if you want to translate or rotate the model you should use camera for translation or rotation
if you want to translate the model then you should translate both models graphic and haptic…
you can translate graphic model as glTranslatef(x,y,z)
and Haptic translation with hlTranslatef(x,y,z)..hope you will get the answer of your Question.
September 27, 2010 at 7:25 am #727337Jenny_wuiParticipant -
AuthorPosts
- You must be logged in to reply to this topic.