Mechanism Viewer Tutorial

NameLocation
Mechanism Viewer<Vortex Studio Installation Folder>\tutorials\MechanismViewer

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

This application is meant to run as a standalone Vortex application. To use it as a simulator node, it must be expanded to support network.

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

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

It shows how to implements keyboard listeners extensions to enable functionalities based on key pressed at runtime. The functionality shown are

  • Record and playback
  • Key frames
  • Camera/lighting tools

Application

As this is a standalone application, the main function will register this tutorials extensions.

For reusability, the extension's code should be moved to a separate plugin, see the Keyboard tutorials for an example.

The application support 3 commands line arguments:

  • --config: 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 body creates a VxApplication, load a setup file or add some basic extensions and module. The setup will be saved as defaultConfig_MechanismViewer.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 adds a some IKeyboard extension to enable some extra functionality.

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

Classes

These are implementation of VxSim::IKeyboardThe interface IKeyboard is managed by the graphics module. Furthermore, in order to be used, a 3d window must have focus and simulation must be running.

RecorderKeyboardListener

It shows how to interact with the Kinematic Recorder API to implement record and playback of a simulation

KeyFrameListListener

It shows how to interact with the Key Frame Manager API to implement key frames. This can be used to reset simulation to a given point.

CameraKeyboardListener

It shows how to interact with Display extension to switch the current view shown by a 3d view.

It also show how to turn on and off the default light added during the application's creation.


See Integrating Vortex Studio using the SDK -Making an Application for more details about making a Vortex Application

See Keyboard Extension Tutorial for an example of a keyboard extension plugin

See Vortex Studio SDK - Adding User Controls for example on controlling the Vortex Application, including Record and playback.

See Vortex Studio SDK Advanced - Key Frames to learn more about Keyframes


Using the tutorial

  1. Open Tutorials solution
  2. Set Mechanism as the active project.
  3. Compile the project.
  4. The code is fully documented explaining each step.
  5. Run the executable.
    1. Provide a content file using argument –content
    2. A setup file can be provided with --config.
      1. If none is provided, one will be created to provide minimal functionality. 
        1. It will be saved as defaultConfig_MechanismViewer.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 simapp process.
    3. Provide argument --light to turn on the default light.
  6. If the setup provides a main 3d view, the content should be visible.
    1. Click in the window to ensure it has focus.
    2. Use the keyboard to activate some functionality
      1. See each extension code for the key binding of each functionality and how to use it. 
      2. Record and playback
        1. First record the simulation
        2. Once you have enough material recorded, you would need at least a few seconds for this tutorial to be useful, go into play mode 
        3. You can move forward and back by 60 frames.
        4. Stop when you are done to return to the simulation
      3. Keyframes
        1. While the application is running, you can save keyframes
        2. As the application runs, you can load previously saved keyframes to reset the simulation.
      4. Camera controls
        1. You can cycle the display extension in the content loaded
        2. You can turn on or off the default light.
  7. To go into detail, debug the project and follow the code execution step by step.