本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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");
//.........这里部分代码省略.........