Question

I am trying to reset the 3D object to its original view (something orthogonal, sagital, say) after its interaction.

Here is my code how I try to reset, unsuccessful though:

private vtkAxesActor axes;
private vtkOrientationMarkerWidget widget;

public void ResetView()
        {
          //  axes.InitPathTraversal();
            if (axes != null)
            {
                if (axes.GetUserMatrix() != null)
                    axes.GetUserMatrix().Identity();
                axes.GetMatrix().Identity();
                axes.SetOrigin(0,0,0);
                axes.SetOrientation(0, 0, 0);
                axes.SetScale(1, 1, 1);
                axes.SetPosition(0, 0, 0);
            }

            if (widget != null)
            {
                widget.SetOrientationMarker(axes);
            }


            ForceWindowToRender();
        }

How should I do this? Thanks a lot.

Was it helpful?

Solution

private vtkCamera camera;    
camera.SetPosition(DoubleArrayToIntPtr(defaultCamPos));
camera.SetViewUp(DoubleArrayToIntPtr(defaultCamViewup));
camera.SetFocalPoint(DoubleArrayToIntPtr(defaultCamFocus));

You need to adjust the focal point, position, and orientation to your senario of course (refer to VTK manual for coordinate system), but that is basically how I set up my 3D rendered object to its default view after the object being rotated and shifted.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top