Page 1 of 1

Widget sample emulation (2021)

Posted: 2021-Apr-11 2:09
by 3DfromNULL
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 to understand hierarchical callbacks if needed.


(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.

Image Image
Image Image Image Image Image