Tutorial 14c: Combining polygonal modeling with rules

To access the tutorials in CityEngine, click Help > Download Tutorials and Examples. After choosing a tutorial or example, the project is automatically downloaded and added to your workspace.

Use polygonal modeling and rules

Suppose you want to give all windows of this house a 3D frame.

House with flat texture

Currently, it’s just a flat texture. You could drag the frame out for every window, but this can be tedious. Also, the window texture does not adapt well when scaled. You may get some cuts in the windows.

Cuts in the windows

To conveniently place 3D windows, use a rule on the building.

  1. First, create a 3D window. Use the rectangle tool and drag it up.
    Rectangle tool used to create a 3D window
  2. Select the front face with the selection tool and assign the window texture with the texturing tool.
    Textured window created with the texturing tool
  3. Draw a few rectangles over the window frame with the rectangle tool. Drag them to create a 3D structure. Optionally, experiment with different structures.
  4. The window is finished.
    Arrow shows the direction of drag for the window rectangle
    To use it in a rule, you must export it first.
  5. Select the model, and choose File > Export models..
  6. Choose Wavefront OBJ and set the name to window.
  7. Make sure the folder is the tutorial/model folder.
  8. Click Finish.
    Export model to Wavefront OBJ
    Set location to the tutorial/model folder
  9. Now you can apply the rule.
  10. Select the house, and right-click Assign Rule File.
    Context menu for Assign Rule File
  11. Select rule.cga from the tutorial folder, and click generate.
  12. Note:

    This rule replaces all polygons with window textures with the 3D window. You can look at it and use it for your projects.

    All windows are now 3D shapes, and you can see the difference by switching the show/hide models toggle button.
    Windows with 3D shapes rule applied
    If you drag the window frame, it adapts much nicer.
    Drag the window frame to adjust
    You can also change global parameters.
  13. Bring up the Inspector window and select the house.
  14. Type values in the window parameters.
    Type values in the parameter to update all windows

    All the windows update automatically.