Widget sample emulation (2021)

Author's sample script, wroks, hints.
Post Reply
User avatar
3DfromNULL
Site Admin
Posts: 45
Joined: 2018-Jul-13 9:35

Widget sample emulation (2021)

Post by 3DfromNULL »

This python script (perhaps faithfully) emulates a good old sample C++ code "WdgSample.cpp" included in each trueSpace tSxAPI SDK.

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

Image
Fig.2. Scaled texture

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

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

Image Image
Image Image Image Image Image
Attachments
widget1a.py
script file
(22.06 KiB) Downloaded 581 times
Post Reply