[vtkusers] Camera orientations

Karin Faulhaber faulhaber at ipf.uni-karlsruhe.de
Mon Sep 17 04:35:17 EDT 2001


Hi Rob, 

if I got it right you want to have a view on your data from one of the
coordinate axes? Have a look at what I did (in Java), maybe it's what
you need.

Karin


------------

    public void actionPerformed(ActionEvent ae) {
	vtkCamera cam = this.getRenderer().GetActiveCamera();
	double[] fp = cam.GetFocalPoint();
	double[] pos = cam.GetPosition();
	double distance = Math.sqrt(
				    (fp[0]-pos[0])*(fp[0]-pos[0])+
				    (fp[1]-pos[1])*(fp[1]-pos[1])+
				    (fp[2]-pos[2])*(fp[2]-pos[2])
				    );

	Object source = ae.getSource();

	if (source == VisuMain.downButton) {
	    cam.SetPosition(fp[0], fp[1], fp[2]+distance);
	    cam.SetViewUp(0,1,0);
	}

	if (source == VisuMain.westButton) {
	    cam.SetPosition(fp[0]+distance, fp[1], fp[2]);
	    cam.SetViewUp(0,0,1);
	}

	if (source == VisuMain.eastButton) {
	    cam.SetPosition(fp[0]-distance, fp[1], fp[2]);
	    cam.SetViewUp(0,0,1);
	}

	if (source == VisuMain.southButton) {
	    cam.SetPosition(fp[0], fp[1]+distance, fp[2]);
	    cam.SetViewUp(0,0,1);
	}

	if (source == VisuMain.northButton) {
	    cam.SetPosition(fp[0], fp[1]-distance, fp[2]);
	    cam.SetViewUp(0,0,1);
	}
    }



More information about the vtkusers mailing list