[vtkusers] zoom in rendering scene don't work

Stephan Theisen StephanTheisen at gmx.de
Fri Mar 25 12:03:53 EST 2005


Hi Guys!

I have the following Problem: I used the volumepro hardware to render a
volume. That works fine and without any problem. i can interact with the
volume like rotate or translate. But If I try to zoom the volume it don't
work. After that I tryed the vtkVolumeRayCastMapper and here it works.
But I need the support of the VolumePro hardware. So can Anybody say what is
wrong here in my program:

public void mouseDragged(MouseEvent e) {
        if (ren.VisibleActorCount() == 0) return;
        int x = e.getX();
        int y = e.getY();
        // rotate
        if (this.InteractionMode == 1) {
            cam.Azimuth(lastX - x);
            cam.Elevation(y - lastY);
            cam.OrthogonalizeViewUp();
            resetCameraClippingRange();
            if (this.LightFollowCamera == 1) {
                lgt.SetPosition(cam.GetPosition());
                lgt.SetFocalPoint(cam.GetFocalPoint());
            }
        }
        // translate
        if (this.InteractionMode == 2) {
            double  FPoint[];
            double  PPoint[];
            double  APoint[] = new double[3];
            double  RPoint[];
            double focalDepth;
            
            // get the current focal point and position
            FPoint = cam.GetFocalPoint();
            PPoint = cam.GetPosition();
            
            // calculate the focal depth since we'll be using it a lot
            ren.SetWorldPoint(FPoint[0],FPoint[1],FPoint[2],1.0);
            ren.WorldToDisplay();
            focalDepth = ren.GetDisplayPoint()[2];
            
            APoint[0] = rw.GetSize()[0]/2.0 + (x - lastX);
            APoint[1] = rw.GetSize()[1]/2.0 - (y - lastY);
            APoint[2] = focalDepth;
            ren.SetDisplayPoint(APoint);
            ren.DisplayToWorld();
            RPoint = ren.GetWorldPoint();
            if (RPoint[3] != 0.0) {
                RPoint[0] = RPoint[0]/RPoint[3];
                RPoint[1] = RPoint[1]/RPoint[3];
                RPoint[2] = RPoint[2]/RPoint[3];
            }
            
        /*
         * Compute a translation vector, moving everything 1/2
         * the distance to the cursor. (Arbitrary scale factor)
         */
            cam.SetFocalPoint(
            (FPoint[0]-RPoint[0])/2.0 + FPoint[0],
            (FPoint[1]-RPoint[1])/2.0 + FPoint[1],
            (FPoint[2]-RPoint[2])/2.0 + FPoint[2]);
            cam.SetPosition(
            (FPoint[0]-RPoint[0])/2.0 + PPoint[0],
            (FPoint[1]-RPoint[1])/2.0 + PPoint[1],
            (FPoint[2]-RPoint[2])/2.0 + PPoint[2]);
            resetCameraClippingRange();
        }
        // zoom
        if (this.InteractionMode == 3) {
            double zoomFactor;
            double clippingRange[];
            
            zoomFactor = Math.pow(1.02,(y - lastY));
            if (cam.GetParallelProjection() == 1) {
                cam.SetParallelScale(cam.GetParallelScale()/zoomFactor);
            }
            else {
                cam.Dolly(zoomFactor);
                resetCameraClippingRange();
            }
        }
        lastX = x;
        lastY = y;
        this.Render();
    }

Thanks in advance

Stephan

-- 
Sparen beginnt mit GMX DSL: http://www.gmx.net/de/go/dsl



More information about the vtkusers mailing list