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