2
votes

I'm creating a simulator coded in python and based on ODE (Open Dynamics Engine). For visualization I chose VTK.

For every object in the simulation, I create a corresponding source (e.g. vtkCubeSource), mapper and actor. I am able to show objects correctly and update them as the simulation runs.

I want to add axes to have a point of reference and to show the direction of each axis. Doing that I realized that, by default, X and Z are in the plane of the screen and Y points outwards. In my program I have a different convention.

I've been able to display axes in 2 ways:

1) Image

axes = vtk.vtkAxes()
axesMapper = vtk.vtkPolyDataMapper()
axesMapper.SetInputConnection(axes.GetOutputPort())
axesActor = vtk.vtkActor()
axesActor.SetMapper(axesMapper)
axesActor.GetProperty().SetLineWidth(4)

2) Image (colors do not match with the first case)

axesActor = vtk.vtkAxesActor()
axesActor.AxisLabelsOn()
axesActor.SetShaftTypeToCylinder()
axesActor.SetCylinderRadius(0.05)

In the second one, the user is allowed to set many parameters related to how the axis are displayed. In the first one, I only managed to set the line width but nothing else.

So, my questions are:

  • Which is the correct way to define and display axes in a 3D scene? I just want them in a fixed position and orientation.
  • How can I set a different convention for the axes orientation, both for their display and the general visualization?
1

1 Answers

1
votes

Well, if you do not mess with objects' transformation matrix for display purposes, it could probably be sufficient to just put your camera into a different position while using axes approach 2. The easy methods to adjust your camera position are: Pitch(), Azimuth() and Roll().

If you mess with object transforms, then apply the same transform to the axes.


Dženan Zukić kindly answered this question in [email protected] mail list. http://www.vtk.org/pipermail/vtkusers/2011-November/119990.html