Patch Lab (setPatchPtPos)

What's Happening

A patch looks just like a plane, but has its own set of s, t coordinates which correspond to a grid of points on the patch. This allows you to change the position of these points individually, as well as specify properties (color, texture, material) for each of the "tiles" on the patch.

Grab the blue control points (which of course don't appear on an actual patch) with your mouse and drag them up or down. To view your patch from different angles, press the left and right bracket [ ] keys. Press "Reset Patch" to reset the point positions and "Update Normals" to call the updateNormals() method of the patch model, which will correct the patch definition so that lighting falls on it properly.

This patch was created using the command model = WTScene.createPatch( 5, 5, 1, 1, 0, 0 ). The first two parameters are the number of points you want in the patch for the s and t directions, respectively. The second two parameters are the distance between each point in the s and t directions, respectively. The last two parameters specify the world x and z points (respectively) at which you want you patch's "upper left" corner, or s = 0 and t = 0, to be located. By default the patch is created at y = 0.

In this lab, when you drag a control point, the setPatchPtPos() method of the WTModel object is used: model.setPatchPtPos( s, t, x, y, z ), where s and t specify a point on your patch and x, y, and z are the world coordinates of where you want that patch point to be located.

Key Methods Used

WT::createPatch, WTModel::setPatchPtPos

Points to Remember