5.4 Using Prototypes with the Scene Tree
Several prototype examples are packaged with Webots. Instances of these prototypes can be added to the simulation with the Scene Tree buttons. Note that currently the Scene Tree allows the instantiation but not the definition of prototypes. Prototype definitions must be created or modified manually in .proto files.
5.4.1 Prototype Directories
In order to make a prototype available to Webots, the complete prototype definition must be placed in a .proto file. Each .proto file can contain the definition for only one prototype, and each file must be saved under the name <prototypeName>.proto, where prototypeName is the name of the prototype as specified after the PROTO keyword (case-sensitive). For example the above TwoColorChair prototype must be saved in a file name TwoColorChair.proto.
The .proto file should be placed in the protos subdirectory of the current project directory. By definition, the current project directory is the parent directory of the worlds directory that contains the currently opened .wbt file. The figure 5.2 shows where .proto files are stored in a project directory.

Figure 5.2: Prototypes directory in a project directory structure
Note that inside the protos directory, the number of subdirectories and their names is free. The user can assign directory names for practical classification reasons; but the names do not influence how prototypes are searched. The whole subdirectory tree is always searched recursively.
In addition to the current project directory, Webots does also manage a default project directory. This directory is structurally similar to the current project directory (see above) but it is located inside Webots distribution. In the default project directory there is also a protos subdirectory that provides Webots standard prototypes. These standard prototypes should normally not be modified by the user. Note that .proto files will be searched first in the current project directory and then in the default project directory.
5.4.2 Add a Node Dialog
If a prototype is saved in a file with proper name and location, it should become visible in the Add a node dialog that can be invoked from the Scene Tree. In the dialog, the prototypes are organized using the same directory hierarchy found in the project's and Webots's protos folders. However this dialog shows a prototype only if its base type is suitable for the chosen insertion point. For example, a prototype whose base type is Material cannot be inserted in a boundingObject field. In figure 5.3 you can see how the TwoColorChair prototype appears in the dialog. Note that, the dialog's text pane is automatically filled with any comment placed at the beginning of the .proto file.

Figure 5.3: Adding an instance of the TwoColorChair prototype
Icons can be used to better illustrate prototypes. A prototype icon must be stored in a 128 x 128 pixels .png file. The file name must correspond to that of the prototype plus the .png extension and it must be stored in the icons subdirectory of the protos directory (see figure 5.2). Note that it is possible to create the .png files directly with Webots's menu File > Take Screenshot.... Then the image should be cropped or resized to 128 x 128 pixels using an image editor.
5.4.3 Using Prototype Instances
If you hit the Add button, the prototype instance is added to the Scene Tree. In the Scene Tree, prototype instances are represented with a different color than built-in nodes (see figure 5.4). Prototype fields can be manipulated exactly like built-in node fields.

Figure 5.4: Scene Tree with two instances of the TwoColorChair prototype