Ignore:
Timestamp:
Jun 12, 2013, 2:51:11 AM (11 years ago)
Author:
ldelgass
Message:

Improvements to 3D shapes in vtkvis. Add preliminary, experimental grouping.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/vtkvis/Renderer.cpp

    r3680 r3683  
    2020#include <vtkCamera.h>
    2121#include <vtkLight.h>
     22#include <vtkLightCollection.h>
    2223#include <vtkCoordinate.h>
    2324#include <vtkTransform.h>
     
    124125    //_renderer->SetAmbient(.2, .2, .2);
    125126
     127    _renderer->AutomaticLightCreationOff();
     128
    126129    vtkSmartPointer<vtkLight> headlight = vtkSmartPointer<vtkLight>::New();
    127130    headlight->SetLightTypeToHeadlight();
     
    130133    //headlight->SetAmbientColor(1, 1, 1);
    131134    _renderer->AddLight(headlight);
     135
    132136    vtkSmartPointer<vtkLight> skylight = vtkSmartPointer<vtkLight>::New();
    133137    skylight->SetLightTypeToCameraLight();
     
    138142    //skylight->SetAmbientColor(1, 1, 1);
    139143    _renderer->AddLight(skylight);
     144
    140145    _renderer->LightFollowCameraOn();
    141146    _renderWindow = vtkSmartPointer<vtkRenderWindow>::New();
     
    31773182    mergeGraphicsObjectBounds<Disk>(bounds, onlyVisible);
    31783183    mergeGraphicsObjectBounds<Glyphs>(bounds, onlyVisible);
     3184    mergeGraphicsObjectBounds<Group>(bounds, onlyVisible);
    31793185    mergeGraphicsObjectBounds<HeightMap>(bounds, onlyVisible);
    31803186    mergeGraphicsObjectBounds<LIC>(bounds, onlyVisible);
     
    38183824}
    38193825
     3826int Renderer::addLight(float pos[3])
     3827{
     3828    vtkSmartPointer<vtkLight> light = vtkSmartPointer<vtkLight>::New();
     3829    light->SetLightTypeToCameraLight();
     3830    light->SetPosition(pos[0], pos[1], pos[2]);
     3831    light->SetFocalPoint(0, 0, 0);
     3832    light->PositionalOff();
     3833    _renderer->AddLight(light);
     3834    _needsRedraw = true;
     3835    return (_renderer->GetLights()->GetNumberOfItems()-1);
     3836}
     3837
     3838vtkLight *Renderer::getLight(int lightIdx)
     3839{
     3840    vtkLightCollection *lights = _renderer->GetLights();
     3841    if (lights->GetNumberOfItems() < lightIdx+1)
     3842        return NULL;
     3843    lights->InitTraversal();
     3844    vtkLight *light = NULL;
     3845    int i = 0;
     3846    do {
     3847        light = lights->GetNextItem();
     3848    } while (i++ < lightIdx);
     3849    return light;
     3850}
     3851
     3852void Renderer::setLightSwitch(int lightIdx, bool state)
     3853{
     3854    vtkLight *light = getLight(lightIdx);
     3855    if (light == NULL) {
     3856        ERROR("Unknown light %d", lightIdx);
     3857        return;
     3858    }
     3859    light->SetSwitch((state ? 1 : 0));
     3860    _needsRedraw = true;
     3861}
     3862
    38203863/**
    38213864 * \brief Initialize the camera zoom region to include the bounding volume given
Note: See TracChangeset for help on using the changeset viewer.