Ignore:
Timestamp:
01/08/19 10:13:03 (3 years ago)
Author:
Sanahuja Guillaume
Message:

draw vrpn axis in simulator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairSimulator/src/VisualizationCamera.cpp

    r70 r286  
    3131using namespace core;
    3232using namespace scene;
     33using namespace video;
    3334
    3435namespace flair {
     
    4041  LMouseKey = false;
    4142
    42    // camera
     43  // camera for visualization
    4344  camera = getGui()->getSceneManager()->addCameraSceneNode();
    4445  camera->setAspectRatio(getGui()->getAspectRatio()); // on force a cause du view port
     
    4849
    4950  getGui()->pimpl_->AddVisualizationCamera(this);
     51 
     52  // camera to draw axis, in a new dedicated scene manager
     53  axis_scenemanager=getGui()->getSceneManager()->createNewSceneManager();
     54  axis_camera = axis_scenemanager->addCameraSceneNode();
     55  axis_camera->setAspectRatio(1);  // same as texture ratio, TODO: get it from texture in renderAxisToTexture
     56  axis_camera->setUpVector(vector3df(0, 0, 1));
     57  axis_camera->setFOV(PI / 2.5f);
     58  axis_scenemanager->setActiveCamera(axis_camera);
     59  prendre en compte le yaw monde/optitrack (rotation de axis_scenemanager?)
     60  IAnimatedMesh* arrowMeshRed = axis_scenemanager->addArrowMesh( "x_axisArrow",video::SColor(255, 255, 0, 0),video::SColor(255, 255, 0, 0));
     61  nodeX = axis_scenemanager->addMeshSceneNode(arrowMeshRed);
     62  nodeX->setMaterialFlag(video::EMF_LIGHTING, false);
     63  nodeX->setRotation(vector3df(0,0,-90));
     64  nodeX->setScale(vector3df(1,3,1));
     65 
     66  IAnimatedMesh* arrowMeshGreen = axis_scenemanager->addArrowMesh( "y_axisArrow",video::SColor(255, 0, 255, 0),video::SColor(255, 0, 255, 0));
     67  nodeY = axis_scenemanager->addMeshSceneNode(arrowMeshGreen);
     68  nodeY->setMaterialFlag(video::EMF_LIGHTING, false);
     69  nodeY->setScale(vector3df(1,3,1));
     70 
     71  IAnimatedMesh* arrowMeshBlue = axis_scenemanager->addArrowMesh( "z_axisArrow",video::SColor(255, 0, 0, 255),video::SColor(255, 0, 0, 255));
     72  nodeZ = axis_scenemanager->addMeshSceneNode(arrowMeshBlue);
     73  nodeZ->setMaterialFlag(video::EMF_LIGHTING, false);
     74  nodeZ->setRotation(vector3df(-90,0,0));//irrlicht is left handed, draw a right handed axis
     75  nodeZ->setScale(vector3df(1,3,1));
    5076}
    5177
    5278VisualizationCamera::~VisualizationCamera() {}
     79
     80void VisualizationCamera::renderAxisToTexture(ITexture* texture) {
     81  //put axis at a "normalized" distance
     82  vector3df direction=camera->getTarget()-camera->getPosition();
     83  direction.normalize();
     84  nodeX->setPosition(camera->getPosition()+direction*6);
     85  nodeY->setPosition(camera->getPosition()+direction*6);
     86  nodeZ->setPosition(camera->getPosition()+direction*6);
     87
     88  axis_camera->setPosition(camera->getPosition());
     89  axis_camera->setRotation(camera->getRotation());
     90  axis_camera->setTarget(camera->getTarget());
     91 
     92  axis_scenemanager->getVideoDriver()->setRenderTarget(texture, true, true, SColor(0,0,0,0));
     93  axis_scenemanager->drawAll();
     94  axis_scenemanager->getVideoDriver()->setRenderTarget(0, true, true, 0);
     95}
    5396
    5497std::string VisualizationCamera::getName(void) {
Note: See TracChangeset for help on using the changeset viewer.