亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? hellosphere.cpp

?? 此為open haptics的應用。需要phantom儀器進行操作。模擬的是一個cursor去觸摸一個球。你能得到觸覺和視覺的反饋
?? CPP
字號:
/*****************************************************************************

Copyright (c) 2004 SensAble Technologies, Inc. All rights reserved.

OpenHaptics(TM) toolkit. The material embodied in this software and use of
this software is subject to the terms and conditions of the clickthrough
Development License Agreement.

For questions, comments or bug reports, go to forums at: 
    http://dsc.sensable.com

Module Name:

  HelloSphere.cpp

Description: 

  This example demonstrates basic haptic rendering of a shape.

******************************************************************************/

#include <math.h>
#include <assert.h>

#ifdef WIN32
#include <windows.h>
#endif

#include <GL/gl.h>
#include <GL/glut.h>

#include <HL/hl.h>
#include <HDU/hduMatrix.h>
#include <HDU/hduError.h>

#include <HLU/hlu.h>

// haptic device and rendering context handles
static HHD hHD = HD_INVALID_HANDLE;
static HHLRC hHLRC = 0;

// shape id for shape we will render haptically
HLuint sphereShapeId;

#define CURSOR_SIZE_PIXELS 20
static double gCursorScale;
static GLuint gCursorDisplayList = 0;

/* Function prototypes. */
void glutDisplay(void);
void glutReshape(int width, int height);
void glutIdle(void);    

void exitHandler(void);

void initGL();
void initHL();
void initScene();
void drawSceneHaptics();
void drawSceneGraphics();
void drawCursor();
void updateWorkspace();

/*******************************************************************************
 Initializes GLUT for displaying a simple haptic scene
*******************************************************************************/
int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

    glutInitWindowSize(500, 500);
    glutCreateWindow("HelloSphere Example");

    /* Set glut callback functions. */
    glutDisplayFunc(glutDisplay);
    glutReshapeFunc(glutReshape);
    glutIdleFunc(glutIdle);
    
    /* Provide a cleanup routine for handling application exit. */
    atexit(exitHandler);

    initScene();

    glutMainLoop();

    return 0;
}

/*******************************************************************************
 GLUT callback for redrawing the view 
*******************************************************************************/
void glutDisplay()
{   
    drawSceneHaptics();

    drawSceneGraphics();

    glutSwapBuffers();
}

/*******************************************************************************
 GLUT callback for reshaping the window. This is the main place where the 
 viewing and workspace transforms get initialized.
*******************************************************************************/
void glutReshape(int width, int height)
{
    static const double kPI = 3.1415926535897932384626433832795;
    static const double kFovY = 40;

    double nearDist, farDist, aspect;

    glViewport(0, 0, width, height);

    /* Compute the viewing parameters based on a fixed fov and viewing
     * a canonical box centered at the origin */

    nearDist = 1.0 / tan((kFovY / 2.0) * kPI / 180.0);
    farDist = nearDist + 2.0;
    aspect = (double) width / height;
   
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(kFovY, aspect, nearDist, farDist);

    /* Place the camera down the Z axis looking at the origin */
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();            
    gluLookAt(0, 0, nearDist + 1.0,
              0, 0, 0,
              0, 1, 0);
    
    updateWorkspace();
}

/*******************************************************************************
 GLUT callback for idle state. Use this as an opportunity to request a redraw.
 Also check for HLAPI errors that have occurred since the last idle check
*******************************************************************************/
void glutIdle()
{
    HLerror error;

    while (HL_ERROR(error = hlGetError()))
    {
        fprintf(stderr, "HL Error: %s\n", error.errorCode);
        
        if (error.errorCode == HL_DEVICE_ERROR)
        {
            hduPrintError(stderr, &error.errorInfo,
                "Error during haptic rendering\n");
        }
    }
    
    glutPostRedisplay();
}

/*******************************************************************************
 Initialize the scene. Handle initializing both OpenGL and HL
*******************************************************************************/
void initScene()
{
    initGL();
    initHL();
}

/*******************************************************************************
 Setup general OpenGL rendering properties, like lights, depth buffering, etc.
*******************************************************************************/
void initGL()
{
    static const GLfloat light_model_ambient[] = {0.3f, 0.3f, 0.3f, 1.0f};
    static const GLfloat light0_diffuse[] = {0.9f, 0.9f, 0.9f, 0.9f};   
    static const GLfloat light0_direction[] = {0.0f, -0.4f, 1.0f, 0.0f};    
    
    /* Enable depth buffering for hidden surface removal. */
    glDepthFunc(GL_LEQUAL);
    glEnable(GL_DEPTH_TEST);
    
    /* Cull back faces. */
    glCullFace(GL_BACK);
    glEnable(GL_CULL_FACE);
    
    /* Set lighting parameters */
    glEnable(GL_LIGHTING);
    glEnable(GL_NORMALIZE);
    glShadeModel(GL_SMOOTH);
    
    glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE);
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);    
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, light_model_ambient);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse);
    glLightfv(GL_LIGHT0, GL_POSITION, light0_direction);
    glEnable(GL_LIGHT0);   
}

/*******************************************************************************
 Initialize the HDAPI. This involves initing a device configuration, enabling
 forces, and scheduling a haptic thread callback for servicing the device.
*******************************************************************************/
void initHL()
{
    HDErrorInfo error;

    hHD = hdInitDevice(HD_DEFAULT_DEVICE);
    if (HD_DEVICE_ERROR(error = hdGetError()))
    {
        hduPrintError(stderr, &error, "Failed to initialize haptic device");
        fprintf(stderr, "Press any key to exit");
        getchar();
        exit(-1);
    }
    
    hHLRC = hlCreateContext(hHD);
    hlMakeCurrent(hHLRC);

    // Enable optimization of the viewing parameters when rendering
    // geometry for OpenHaptics
    hlEnable(HL_HAPTIC_CAMERA_VIEW);

    // generate id's for the three shapes
    sphereShapeId = hlGenShapes(1);

    hlTouchableFace(HL_FRONT);
}

/*******************************************************************************
 This handler will get called when the application is exiting.
 Deallocates any state and cleans up.
*******************************************************************************/
void exitHandler()
{
    // deallocate the sphere shape id we reserved in in initHL
    hlDeleteShapes(sphereShapeId, 1);

    // free up the haptic rendering context
    hlMakeCurrent(NULL);
    if (hHLRC != NULL)
    {
        hlDeleteContext(hHLRC);
    }

    // free up the haptic device
    if (hHD != HD_INVALID_HANDLE)
    {
        hdDisableDevice(hHD);
    }
}

/*******************************************************************************
 Use the current OpenGL viewing transforms to initialize a transform for the
 haptic device workspace so that it's properly mapped to world coordinates.
*******************************************************************************/
void updateWorkspace()
{
    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();
    
    /* fit haptic workspace to view volume */
    hluFitWorkspace(projection);

    /* compute cursor scale */
    gCursorScale = hluScreenToModelScale(modelview, projection, viewport);
    gCursorScale *= CURSOR_SIZE_PIXELS;
}

/*******************************************************************************
 The main routine for displaying the scene. Get the latest snapshot of state
 from the haptic thread and use it for displaying a 3D cursor.
*******************************************************************************/
void drawSceneGraphics()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);           

    // draw 3D cursor at haptic device position
    drawCursor();

    // draw a sphere using OpenGL
    glutSolidSphere(0.5, 32, 32);
}

/*******************************************************************************
 The main routine for rendering scene haptics. 
 Renders the sphere haptically.
*******************************************************************************/
void drawSceneHaptics()
{    
    // start haptic frame - must do this before rendering any haptic shapes
    hlBeginFrame();

    // set material properties for the shapes to be drawn
    hlMaterialf(HL_FRONT_AND_BACK, HL_STIFFNESS, 0.7f);
    hlMaterialf(HL_FRONT_AND_BACK, HL_DAMPING, 0.1f);
    hlMaterialf(HL_FRONT_AND_BACK, HL_STATIC_FRICTION, 0.2f);
    hlMaterialf(HL_FRONT_AND_BACK, HL_DYNAMIC_FRICTION, 0.3f);

    // start a new haptic shape, use the feedback buffer to
    // capture OpenGL geometry for haptic rendering
    hlBeginShape(HL_SHAPE_FEEDBACK_BUFFER, sphereShapeId);

    // use OpenGL commands to create geometry
    glutSolidSphere(0.5, 32, 32);

    // end the shape
    hlEndShape();

    // end the haptic frame
    hlEndFrame();
}


/*******************************************************************************
 Draw a 3D cursor for the haptic device using the current local transform,
 the workspace to world transform and the screen coordinate scale.
*******************************************************************************/
void drawCursor()
{
    static const double kCursorRadius = 0.5;
    static const double kCursorHeight = 1.5;
    static const int kCursorTess = 15;
    HLdouble proxyxform[16];

    GLUquadricObj *qobj = 0;

    glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_LIGHTING_BIT);
    glPushMatrix();

    if (!gCursorDisplayList)
    {
        gCursorDisplayList = glGenLists(1);
        glNewList(gCursorDisplayList, GL_COMPILE);
        qobj = gluNewQuadric();
               
        gluCylinder(qobj, 0.0, kCursorRadius, kCursorHeight,
                    kCursorTess, kCursorTess);
        glTranslated(0.0, 0.0, kCursorHeight);
        gluCylinder(qobj, kCursorRadius, 0.0, kCursorHeight / 5.0,
                    kCursorTess, kCursorTess);
    
        gluDeleteQuadric(qobj);
        glEndList();
    }
    
    /* Get the proxy transform in world coordinates */
    hlGetDoublev(HL_PROXY_TRANSFORM, proxyxform);
    glMultMatrixd(proxyxform);

    /* Apply the local cursor scale factor. */
    glScaled(gCursorScale, gCursorScale, gCursorScale);

    glEnable(GL_COLOR_MATERIAL);
    glColor3f(0.0, 0.5, 1.0);

    glCallList(gCursorDisplayList);

    glPopMatrix(); 
    glPopAttrib();
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久国产精品99久久人人澡| 亚洲视频精选在线| 美女网站在线免费欧美精品| 欧美一二三区精品| 欧美性色综合网| 亚洲成人一区二区在线观看| 欧美网站一区二区| 日韩成人精品在线| 久久在线免费观看| 99久久99久久精品免费观看| 亚洲人成在线播放网站岛国| 欧美影视一区二区三区| 日韩精品一二区| xfplay精品久久| 欧美一区二区在线看| 男女男精品视频| 日本一区二区三区高清不卡| 色综合欧美在线| 日本成人在线电影网| 国产色一区二区| 91黄色免费观看| 美女性感视频久久| 亚洲欧洲日韩女同| 欧美精选在线播放| 国产v日产∨综合v精品视频| 亚洲精品国产第一综合99久久 | 国产精品不卡在线观看| 在线观看一区二区精品视频| 毛片av一区二区| 亚洲欧美日本在线| 日韩欧美在线综合网| 成人av网站免费| 麻豆精品久久精品色综合| 亚洲欧洲在线观看av| 日韩午夜激情免费电影| 成人av第一页| 久久精品国产色蜜蜜麻豆| 亚洲三级在线看| 久久香蕉国产线看观看99| 欧美三级视频在线观看| 粉嫩一区二区三区性色av| 日韩高清不卡一区二区| 亚洲色图欧美激情| 国产欧美日本一区视频| 日韩一区二区免费在线电影 | 色网站国产精品| 国模少妇一区二区三区| 日韩精品欧美精品| 亚洲男人的天堂av| 国产目拍亚洲精品99久久精品| 欧美日韩国产乱码电影| 久久这里都是精品| 欧美视频完全免费看| 成人短视频下载| 国产一区二三区好的| 日韩电影免费在线看| 亚洲一区av在线| 亚洲精品欧美激情| 亚洲国产精品成人久久综合一区 | 91成人在线观看喷潮| 国产精品一区二区三区乱码 | 亚洲人成精品久久久久| 久久综合给合久久狠狠狠97色69| 欧美日本高清视频在线观看| 色欧美乱欧美15图片| av激情综合网| 不卡一区二区中文字幕| 国产精品伊人色| 国产资源在线一区| 国模套图日韩精品一区二区| 精品在线播放免费| 精品一区二区三区在线观看| 久久精品国产99国产| 蜜桃免费网站一区二区三区| 青青草97国产精品免费观看无弹窗版 | 精品一区二区免费视频| 人人精品人人爱| 蜜臀av性久久久久av蜜臀妖精| 无码av免费一区二区三区试看| 亚洲h在线观看| 日日夜夜免费精品视频| 丝袜美腿亚洲一区二区图片| 亚洲国产人成综合网站| 丝袜亚洲另类欧美| 在线观看中文字幕不卡| 色婷婷国产精品| 精品视频在线免费| 欧美美女直播网站| 日韩三级在线观看| 精品国产成人系列| 日本一区二区三区久久久久久久久不 | 不卡的av在线| 色av综合在线| 91精品国产综合久久婷婷香蕉 | 国产一区欧美一区| 成人丝袜高跟foot| 91亚洲精品一区二区乱码| 97成人超碰视| 欧美美女黄视频| 久久这里只有精品视频网| 国产精品私房写真福利视频| 自拍偷自拍亚洲精品播放| 亚洲综合丝袜美腿| 免费一级片91| 处破女av一区二区| 在线观看国产一区二区| 欧美一区二区在线免费播放| 国产三级三级三级精品8ⅰ区| 国产精品国产三级国产| 亚洲国产精品一区二区久久恐怖片 | 天天综合天天做天天综合| 久久精品国产一区二区三 | 免费观看在线色综合| 国产91露脸合集magnet| 欧美午夜理伦三级在线观看| 日韩欧美精品三级| 亚洲欧美综合色| 免费人成在线不卡| 不卡av在线免费观看| 在线电影院国产精品| 国产日韩av一区| 日韩在线a电影| 成人动漫在线一区| 91精品国产色综合久久不卡蜜臀 | 精品入口麻豆88视频| 亚洲欧美日韩小说| 久久99热狠狠色一区二区| 91免费看片在线观看| 精品精品国产高清一毛片一天堂| 亚洲品质自拍视频网站| 国产一区二区精品久久99| 欧美三级日本三级少妇99| 国产女主播一区| 青椒成人免费视频| 在线亚洲高清视频| 国产精品无圣光一区二区| 裸体一区二区三区| 欧美在线免费视屏| 1024国产精品| 精品亚洲国产成人av制服丝袜| 欧美在线短视频| 国产精品午夜电影| 国产美女娇喘av呻吟久久| 亚洲欧洲日韩在线| 国产永久精品大片wwwapp| 7777精品伊人久久久大香线蕉的| 亚洲免费在线播放| 成人精品亚洲人成在线| 精品不卡在线视频| 美女视频免费一区| 7777精品伊人久久久大香线蕉超级流畅| 亚洲丝袜自拍清纯另类| 成人激情黄色小说| 国产色产综合色产在线视频| 精品在线免费视频| 欧美tk—视频vk| 精品一区二区三区久久| 欧美一区二区三区在线电影| 亚洲国产日韩a在线播放| 欧美性感一区二区三区| 亚洲精品久久嫩草网站秘色| 99re在线视频这里只有精品| 国产精品丝袜一区| 成人久久18免费网站麻豆| 欧美国产日本韩| 成人av免费观看| 国产精品国产自产拍高清av| 成人综合婷婷国产精品久久免费| 国产日产精品1区| 国产成人在线视频网站| 国产午夜亚洲精品午夜鲁丝片| 国产老肥熟一区二区三区| 国产三级三级三级精品8ⅰ区| 国产精品性做久久久久久| 国产三级久久久| av在线播放一区二区三区| 亚洲免费在线视频| 欧美日韩高清一区二区不卡| 视频在线观看一区| 2019国产精品| 国产.欧美.日韩| 亚洲乱码一区二区三区在线观看| 色www精品视频在线观看| 亚洲3atv精品一区二区三区| 91精品国产综合久久精品性色| 日韩影院免费视频| 久久天天做天天爱综合色| 成人性色生活片| 亚洲国产精品久久久久秋霞影院| 欧美电影在哪看比较好| 国内成人精品2018免费看| 亚洲欧洲三级电影| 欧美日本在线播放| 欧美最猛性xxxxx直播| 日本aⅴ免费视频一区二区三区| 日韩精品一区二区三区老鸭窝| 国产乱色国产精品免费视频| 最新日韩在线视频| 7777精品伊人久久久大香线蕉超级流畅 | 亚洲免费观看在线视频|