当前位置: 首页>>代码示例>>C++>>正文


C++ cVector3d::set方法代码示例

本文整理汇总了C++中cVector3d::set方法的典型用法代码示例。如果您正苦于以下问题:C++ cVector3d::set方法的具体用法?C++ cVector3d::set怎么用?C++ cVector3d::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cVector3d的用法示例。


在下文中一共展示了cVector3d::set方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getPosition

//===========================================================================
int cVirtualDevice::getPosition(cVector3d& a_position)
{
    if (!m_systemReady)
    {
        a_position.set(0, 0, 0);
        return (-1);
    }

    double x,y,z;
    x = (double)(*m_pDevice).PosX;
    y = (double)(*m_pDevice).PosY;
    z = (double)(*m_pDevice).PosZ;
    a_position.set(x, y, z);

    return (0);
}
开发者ID:flair2005,项目名称:chai3d,代码行数:17,代码来源:CVirtualDevice.cpp

示例2: getPosition

//===========================================================================
int cPhantomDevice::getPosition(cVector3d& a_position)
{
    // check if drivers are installed
    if (!m_driverInstalled) return (-1);

    double x,y,z;
    int error = hdPhantomGetPosition(m_deviceID, &x, &y, &z);
    a_position.set(x, y, z);
    estimateLinearVelocity(a_position);
    return (error);
}
开发者ID:oostlander,项目名称:chai,代码行数:12,代码来源:CPhantomDevices.cpp

示例3: getForce

//===========================================================================
int cVirtualDevice::getForce(cVector3d& a_force)
{
    if (!m_systemReady)
    {
        a_force.set(0,0,0);
        return (-1);
    }

    a_force.x = ((*m_pDevice).ForceX);
    a_force.y = ((*m_pDevice).ForceY);
    a_force.z = ((*m_pDevice).ForceZ);

    return (0);
}
开发者ID:flair2005,项目名称:chai3d,代码行数:15,代码来源:CVirtualDevice.cpp

示例4: getPosition

//===========================================================================
int cHydraDevice::getPosition(cVector3d& a_position)
{
    //std::cout << "get pos";
    /************************************************************************
        STEP 7:
        Here you may implement code which reads the position (X,Y,Z) from
        your haptic device. Read the values from your device and modify
        the local variable (x,y,z) accordingly.
        If the operation fails return an error code such as -1 for instance.

        Note:
        For consistency, units must be in meters.
        If your device is located in front of you, the x-axis is pointing
        towards you (the operator). The y-axis points towards your right
        hand side and the z-axis points up towards the sky. 

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

    int error = 0;
    double x,y,z;

    // *** INSERT YOUR CODE HERE, MODIFY CODE BELLOW ACCORDINGLY ***

    sixenseAllControllerData acd;
    sixenseGetAllNewestData( &acd );


    y = acd.controllers[a_deviceNumber].pos[0] / 1000.0f;
    z = acd.controllers[a_deviceNumber].pos[1] / 1000.0f - 0.3;
    x = acd.controllers[a_deviceNumber].pos[2] / 1000.0f - 0.3;


    // offset
    cMatrix3d r;
    getRotation(r);
    cVector3d v(-0.08,0,0);
    v = r * v;




    // store new position values
    a_position.set(x+v.x(), y+v.y(), z+v.z());

    // estimate linear velocity
    estimateLinearVelocity(a_position);

    // exit
    return (error);
}
开发者ID:ChellaVignesh,项目名称:ros_haptics,代码行数:51,代码来源:CHydraDevice.cpp

示例5: getPosition

//==============================================================================
bool cMyCustomDevice::getPosition(cVector3d& a_position)
{
    ////////////////////////////////////////////////////////////////////////////
    /*
        STEP 7:

        Here you shall implement code that reads the position (X,Y,Z) from
        your haptic device. Read the values from your device and modify
        the local variable (x,y,z) accordingly.
        If the operation fails return an C_ERROR, C_SUCCESS otherwise

        Note:
        For consistency, units must be in meters.
        If your device is located in front of you, the x-axis is pointing
        towards you (the operator). The y-axis points towards your right
        hand side and the z-axis points up towards the sky. 
    */
    ////////////////////////////////////////////////////////////////////////////

    bool result = C_SUCCESS;
    double x,y,z;

    // *** INSERT YOUR CODE HERE, MODIFY CODE BELLOW ACCORDINGLY ***

    x = 0.0;    // x = getMyDevicePositionX()
    y = 0.0;    // y = getMyDevicePositionY()
    z = 0.0;    // z = getMyDevicePositionZ()

    // store new position values
    a_position.set(x, y, z);

    // estimate linear velocity
    estimateLinearVelocity(a_position);

    // exit
    return (result);
}
开发者ID:WoodenHaptics,项目名称:woody-experimental,代码行数:38,代码来源:CMyCustomDevice.cpp

示例6: getPosition

//===========================================================================
int cMyCustomDevice::getPosition(cVector3d& a_position)
{
 
    /************************************************************************
        STEP 7:
        Here you may implement code which reads the position (X,Y,Z) from
        your haptic device. Read the values from your device and modify
        the local variable (x,y,z) accordingly.
        If the operation fails return an error code such as -1 for instance.

        Note:
        For consistency, units must be in meters.
        If your device is located in front of you, the x-axis is pointing
        towards you (the operator). The y-axis points towards your right
        hand side and the z-axis points up towards the sky. 

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

    int error = 0;
    double x,y,z;

    // *** INSERT YOUR CODE HERE, MODIFY CODE BELLOW ACCORDINGLY ***

    x = 0.0;    // x = getMyDevicePositionX()
    y = 0.0;    // y = getMyDevicePositionY()
    z = 0.0;    // z = getMyDevicePositionZ()

    // store new position values
    a_position.set(x, y, z);

    // estimate linear velocity
    estimateLinearVelocity(a_position);

    // exit
    return (error);
}
开发者ID:ChellaVignesh,项目名称:ros_haptics,代码行数:37,代码来源:CMyCustomDevice.cpp

示例7: main

int main(int argc, char* argv[])
{
    // display pretty message
    printf ("\n");
    printf ("  ===================================\n");
    printf ("  CHAI 3D\n");
    printf ("  Earth Demo\n");
    printf ("  Copyright 2006\n");
    printf ("  ===================================\n");
    printf ("\n");

    // create a new world
    world = new cWorld();

    // set background color
    world->setBackgroundColor(0.2f,0.2f,0.2f);

    // create a camera
    camera = new cCamera(world);
    world->addChild(camera);

    // create a torus like shape
    object = new cShapeSphere(0.18);
    world->addChild(object);

    // set material stiffness of object
    object->m_material.setStiffness(200.0);
    
    object->m_material.m_ambient.set(0.3, 0.3, 0.3);
    object->m_material.m_diffuse.set(0.8, 0.8, 0.8);
    object->m_material.m_specular.set(1.0, 1.0, 1.0);
    object->m_material.setShininess(100);

    // let's project a world map onto the sphere
    cTexture2D* texture = new cTexture2D();
    texture->loadFromFile("./resources/images/earth.bmp");
    texture->setEnvironmentMode(GL_MODULATE);
    object->m_texture = texture;

    // initialize the object's rotational velocity
    rotVelocity.set(0,0,0.001);

    // position a camera
    camera->set( cVector3d (1.0, 0.0, 0.0),
                 cVector3d (0.0, 0.0, 0.0),
                 cVector3d (0.0, 0.0, 1.0));

    // set the near and far clipping planes of the camera
    camera->setClippingPlanes(0.01, 10.0);

    // Create a light source and attach it to the camera
    light = new cLight(world);
    light->setEnabled(true);
    light->setPos(cVector3d(2,0.5,1));
    light->setDir(cVector3d(-2,0.5,1));
    camera->addChild(light);

    // load a little chai bitmap logo which will located at the bottom of the screen
    logo = new cBitmap();
    logo->m_image.loadFromFile("./resources/images/chai3d.bmp");
    logo->setPos(10,10,0);
    camera->m_front_2Dscene.addChild(logo);

    // we replace the backround color of the logo (black) with a transparent color.
    // we also enable transparency
    logo->m_image.replace(cColorb(0,0,0), cColorb(0,0,0,0));
    logo->enableTransparency(true);

    // create a cursor and add it to the world.
    cursor = new cMeta3dofPointer(world, 0);
    world->addChild(cursor);
    cursor->setPos(0.0, 0.0, 0.0);

    // set up a nice-looking workspace for the cursor so it fits nicely with our
    // cube models we will be builing
    cursor->setWorkspace(1.0,1.0,1.0);

    // set the diameter of the ball representing the cursor
    cursor->setRadius(0.01);

    // set up the device
    cursor->initialize();

    // open communication to the device
    cursor->start();

    // start haptic timer callback
    timer.set(0, hapticsLoop, NULL);

    // initialize the GLUT windows
    glutInit(&argc, argv);
    glutInitWindowSize(512, 512);
    glutInitWindowPosition(0, 0);
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
    glutCreateWindow(argv[0]);
    glutDisplayFunc(draw);
    glutKeyboardFunc(key);
    glutReshapeFunc(rezizeWindow);
    glutSetWindowTitle("CHAI 3D");

//.........这里部分代码省略.........
开发者ID:remis,项目名称:chai3d,代码行数:101,代码来源:main.cpp


注:本文中的cVector3d::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。