Пример #1
0
void
VisWinLighting::UpdateLightPositions()
{
    if (mediator.GetMode() == WINMODE_3D)
    {
        //
        //  Get the camera's distance from the focal point.
        //
        vtkCamera *cam = mediator.GetCanvas()->GetActiveCamera();
        double cpos[3], cfoc[3], proj[3], projLen = 0.;

        cam->GetPosition(cpos);
        cam->GetFocalPoint(cfoc);
        proj[0] = cpos[0] - cfoc[0];
        proj[1] = cpos[1] - cfoc[1];
        proj[2] = cpos[2] - cfoc[2];
        int i; 
        for (i = 0; i < 3; i++)
        {
             projLen += (proj[i] * proj[i]);
        }
        projLen = sqrt(projLen);

        //
        //  VisIt lights have a unit vector direction, pointing
        //  from the light's position to the focal point.  We need
        //  to use the inverse vector in determing the position 
        //  in world coordinates.  We want to position the light
        //  so that vtk passes a unit vector for the light direction
        //  along the (inverse) direction vector to OpenGL.
        //
        double pos[3];
        avtLight aLight;
        for (i = 0; i < MAX_LIGHTS ; i++)
        {
            aLight = avtlights.Light(i);
            if (aLight.type == CAMERA)
            {
                lights[i]->SetPosition(-aLight.direction[0],
                                       -aLight.direction[1],
                                       -aLight.direction[2]);
                lights[i]->SetFocalPoint(0, 0, 0);
            }
            else 
            {
                pos[0] = cfoc[0] - aLight.direction[0] / projLen; 
                pos[1] = cfoc[1] - aLight.direction[1] / projLen; 
                pos[2] = cfoc[2] - aLight.direction[2] / projLen; 
                lights[i]->SetPosition(pos);
                lights[i]->SetFocalPoint(cfoc);
            }
        }
    }
    else 
    {
        InitDefaultLight();
    }
}
Пример #2
0
VisWinLighting::VisWinLighting(VisWindowColleagueProxy &p) : VisWinColleague(p)
{
    vtkRenderer *canvas = mediator.GetCanvas();

    for (int i = 0 ; i < MAX_LIGHTS ; i++)
    {
        lights[i] = vtkLight::New();
        canvas->AddLight(lights[i]);
    }

    InitDefaultLight();
}
Пример #3
0
void
VisWinLighting::Stop3DMode()
{
    InitDefaultLight();
}
Пример #4
0
Light::Light()
{
	InitDefaultLight();
}