Script tg_reference_box.py

Started by Kevin Kipper, January 06, 2025, 07:20:43 PM

Previous topic - Next topic

Kevin Kipper

Here's yet another of my workflow admissions.  I've been using Terragen's built-in Landmark feature for so long it's become second nature.  I use it so much that the first script I wrote "all by myself" was to add a Landmark object to the project for me; via Terragen's remote procedure call (RPC) feature.  Heck, I even blogged about it ...twice. 

Pop quiz #1: How many mouse clicks does it take to add a blue Landmark object about the size of a human at the origin of the project?  Answer: about 18
Pop quiz #2: How many mouse clicks to do the same with a script?  Answer: about 2

You can still get that script by the way.

Enter Terragen 4.7 and the introduction of a new object class, the Bounding box. Like the Landmark object this type of object won't render.  Its primary purpose is to define a volumetric area, and one very practical usage of this is to isolate and export selected portions of a cloud layer at different resolutions.  Think VDB assets.

But there's another use for the Bounding box which has started to threaten my beloved Landmark workflow.  At first I found myself adding a Bounding box to the project, changing its size, placement and colour parameters as needed in order to help visualize areas of the terrain I wanted to export as a heightfield.  Did you know that you can copy the xyz coordinates from a Bounding box's Scale parameter and paste them into the xz Position coordinates of a Heightfield generate node?  Pretty spiffy that.  But even after a few days of doing that I was ready to make a script.

Here's the UI for the first script I wrote to add a Bounding box to a project. 

tg_add_bbox_UI.JPG

After using the script for months I was thinking about sharing it with you guys, but then I realized the script was only being used for one specific purpose, and not tapping into what the Bounding box fully offered.  So I came up with the idea of a Reference box, something that's more malleable and can be used as a proxy object to reflect many sizes of objects.  Here is the current UI.

tg_reference_box_GUI.jpg

Radio buttons and a "Size modifier" parameter control the size of the reference box.  There's check buttons to flatten the box or align it on its base.  You can rotate it too.  The Reference box's position is based on the origin of the project or valid coordinates in the clipboard.  To get those coordinates just right click in the 3D Preview and select "Copy Coordinates".  If it gets too crazy there are buttons to reset the size modifier and rotation parameters.  There's a Preset menu with a handful of fun sized values for creating reference boxes the size of a human, the Eiffel Tower, Mount Everest, and of course Olympus Mons.

Clicking one of the colourful boxes will add a reference box to the project with that preview colour.  There's a check button to automatically give the reference box node a more descriptive name.

Finally, there's a few other buttons to hide, show, or remove all the Bounding box objects in the project, and to clear the contents of the clipboard.

This script is now included with the redmaw-tg-toolkit repository.
 
Click the link below for download and installation information for the entire toolkit.
https://github.com/RedMawVFX/redmaw-tg-toolkit

Or, click the link below to go directly to the tg-reference-box folder in the toolkit.
https://github.com/RedMawVFX/redmaw-tg-toolkit/tree/main/scripts/tg-reference-box