Mechanism Viewer Tutorial (Python 3)

NameLocation
Mechanism Viewer<Vortex Studio Installation Folder>\tutorials\Python\Vortex\PyMechanismViewer\MechanismViewer.py

This tutorial provide an example of creating a custom Vortex, akin to simapp.exe in python.

This application is meant to run as a standalone Vortex application.

It shows how to create a simple VxApplication and load content.

It also shows how to create an application setup in code.

It is the python 3 equivalent of the C++ Mechanism Viewer Tutorial without the additional keyboard extensions. These extensions cannot be written in python but they could be moved to a plugin and added to a setup.

Application

The application support 4 commands line arguments:

  • --help : explains how to use it
  • --setup: The setup file for the application. If none is provided, one is created.
  • --content: Content (scene, mechanism etc) to load. The user is invited to use a scene from the demo scenes package.
    • Some mechanism can also be used, but a terrain must be provided of the object will fall forever.
  • --light: Turn on a default light added at startup. Some content does not provide lighting

The main function creates a VxApplication, load a setup file or add some basic extensions and module. The setup will be saved as defaultConfig_PyMechanismViewer.vxc for reuse in the same folder of the executable.

It adds the callback to trigger the application to end when 3d windows are closed.

It adds a default Ambient white light to the simulator.

It then loads the content and run the application until closed.


See Vortex Studio SDK Advanced - Creating an Application for more details about making a Vortex Application

See Vortex Studio SDK - Python 3 Scripting for more details about using Python.

Using the tutorial

  1. For more information about the arguments, call the script with argument --help
  2. Run the script with the following:
    1. Provide a content file using argument –content, if none is provided, you will run an empty simulator.
    2. A setup file can be provided with --setup.
      1. If none is provided, one will be created to provide minimal functionality. 
        1. It will be saved as defaultConfig_PyMechanismViewer.vxc in the same folder of the executable. Use the editor to inspect it.
      2. A good example would be to provide <Vortex Studio Installation Folder>\resources\config\simapp.vxc, which is a good example for a standalone Vortex process.
    3. Add --light to turn on the default light
  3. If the setup provide a main 3d view, the content should be visible.
  4. To go into detail, debug the project and follow the code execution step by step.