Manipulating Sub-parts

Any model sub-part that has a transform node associated with it can have it's tranform (position, orientation, and scale) changed. Certain commands that affect appearance (e.g. alpha, visibility, texture) can be applied to other types of scene graph nodes. The objective in this section is to set up the model for a script that:

  • Animates the car moving while the wheels rotate
  • Toggles the visibility of the trees and car
  • Cycles through various ground textures

In order to get a handle to a sub-part via the script, it’s name in the scene graph must be known. Although the original names of the tree and car sub-parts can be used directly in the script, they will be renamed them here so they are shorter and easier to remember.

Enter ‘IPÊ_AMARELO’ in the search bar, click on the first search result, and change the group node name in the scenegraph to ‘tree1’:

Repeat this for the second ‘IPÊ_AMARELO’ search result and change the name to ‘tree2’ in the scenegraph.

Enter ‘bentley’ in the search bar, click on the search result, and change the group node name in the scenegraph to ‘car’:

Next, the transform nodes for the wheels will be given unique names. Type 'wheel' into the search bar. Each of the wheels has been given the same name in SketchUp:

Click on the first wheel result and rename the transform node directly above it to ‘wheel1’:

Repeat this for each of the other wheels giving them the names ‘wheel2’, ‘wheel3’, and ‘wheel4’

Next, in order to swap out the grass texture in the script, the geometry associated with it must have a name. Close the search results to increase the viewer area. Click anywhere on the grass and change the material name in the scenegraph to ‘grass’:

Run the 'house_subparts.py' script to see some different ways model sub-parts can be manipulated in the script:

  • Press 1 to move the car forward
  • Press 2 to move the car back
  • Press 3 to toggle the visibility of the tree and car
  • Use the texture panel to change the ground texture

Turning off the visibility of the trees and car will substantially reduce the scene's drawable count. Depending on the system specs this may have a noticeable effect on the frame rate. With the script running, press F4 twice to display all the render stats. Navigate backwards so the entire house scene is within view. Press '3' to toggle the objects and notice how the render stats are affected:

Notes:

  • For the purposes of this tutorial, the car was used to show how sub-parts can be transformed. In many cases, especially when applying more complex transformations, it's easier to export the sub-part as it's own distinct model
  • In Vizard, textures can only be applied or swapped on geometry with texture coordinates. Geometry that has color applied in SketchUp but no texture will not have texture coordinates.


Back: Sky Models