This python script (perhaps faithfully) emulates a good old sample C++ code "WdgSample.cpp" included in each trueSpace tSxAPI SDK.
Fig.1. A widget generated near a textured object.
The cuboid (colored yellow and green) is a widget generated by the script. User can roll the texture (i.e. change offset) interactively by dragging a yellow face, and can scale the texture (i.e. change number of repeat) by green.
Fig.2. Scaled texture
Fig.3. Rolled texture
The script registers some functions written in itself as callback functions for widgets in order to catch user events (selection, dragging, hovering, etc.) as with the original C++ sample code, and generates a message box to pause the main flow in order to end itself.
Fig.4. Structure of the callback functions
Please compare the script with the original SDK sample C++ code and read classes defined in ptsxpydef1.py to understand hierarchical callbacks if needed.
Note
(1) Original issues
The original API sample C++ code does not respond to every situation. This script inherits that, and tS often crashes as in the C++ sample.
(2) Blocking by the message box
While the message box is living (in the back side of tS), some user operations to tS (e.g. Render Scene, selecting a shader, terminating tS, etc.) are blocked. Please keep in mind that till you close the box.
Widget sample emulation (2021)
- 3DfromNULL
- Site Admin
- Posts: 45
- Joined: 2018-Jul-13 9:35
Widget sample emulation (2021)
- Attachments
-
- widget1a.py
- script file
- (22.06 KiB) Downloaded 1916 times