1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include "chai3d.h"
void CreateWorld(cWorld* world, cCamera* camera, cLight* light,cGenericObject* rootlabels)
{
// Intialization of world
world = new cWorld();
world->setBackgroundColor(0.0, 0.0, 0.0);
camera = new cCamera(world);
world->addChild(camera);
camera->set( cVector3d (0.5, 0.0, 0.0), // camera position (eye)
cVector3d (0.0, 0.0, 0.0), // lookat position (target)
cVector3d (0.0, 0.0, 1.0)); // direction of the "up" vector
camera->setClippingPlanes(0.01, 10.0);
// create a light source and attach it to the camera
light = new cLight(world);
camera->addChild(light); // attach light to camera
light->setEnabled(true); // enable light source
light->setPos(cVector3d( 2.0, 0.5, 1.0)); // position the light source
light->setDir(cVector3d(-2.0, 0.5, 1.0)); // define the direction of the light beam
// create a node on which we will attach small labels that display the
// position of each haptic device
rootlabels = new cGenericObject();
camera->m_front_2Dscene.addChild(rootlabels);
// create a small label as title
cLabel* titleLabel = new cLabel();
rootlabels->addChild(titleLabel);
// define its position, color and string message
titleLabel->setPos(0, 30, 0);
titleLabel->m_fontColor.set(1.0, 1.0, 1.0);
titleLabel->m_string = "Haptic Device Pos [mm]:";
//exit (0);
}
|