Clothing

Clothing is added to a figure once the figures pose has been calculated. The costume (or outfit) is specified by assigning a series of clothing generator files to the ppCostumeItems array within an outfit file (e.g. 'ppoutfit1.inc'). Once the POV-Person macros have built the figure, each of these clothing generator files is called in turn to generate a costume element. Control variables specified in the outfit file are used by the clothing macros to control aspects of the clothing. For example, the ppTopTexture control variable allows you to specify the texture to be applied to the shirt defined by the 'ppshirts1.inc' clothing generator file and the ppShirtWaistHeight control variable is used to specify the height of the bottom of the waist band of the shirt above the hips.

How clothing files work

The POV-Person clothing generator uses a layered design. This layered approach enables the clothing generator macros to be used for types of figure other than just the 'human001' figure. So if, in the future an alien anatomy is defined, the same clothing macros can be used with that, based upon body parts that may or may not map to those of the 'human001' figure.

A figure-specific macro takes body parts from the figure definition and assigns them to variables that can then be used by a more generic macro to generate an item of clothing. For the 'human001' figure, the file 'pphuman001accessories.inc' contains a series of figure-specific macros that take body part definitions, their positions and orientations from the 'human001' figure definition matrices and assigns them to sets of variables that are subsequently used as the basis for creating items of clothing. Each item of clothing is then generated using a macro defined in it's own file.

This is most easily understood by following through what happens when you specify an item of clothing in an outfit file.

The file 'ppoutfit1.inc' is one of the control files that you can specify as a parameter on the call to the ppFigure macro.

Within this file you will see that there are three clothing files assigned to the ppCostumeItems array. Each results in an item of clothing being added to the figure. Following this are a series of control variables that influence the type of clothing. In this case a few simple control variables are used. The first two indicate that both boots should be drawn, the third indicates the length of the trousers. A whole range of other control variables can be used with these items of clothing (for an example, take a look at the 'ppsantaoutfit.inc' file which adjusts the textures and dimensions of several items of clothing). Nevertheless, in the 'ppoutfit1.inc' file only these three control variables are set and the remainder are left and take on their default values.

The clothing files each contain a macro definition that will be used to create an item of clothing and add it to the figure. Each macro definition is followed by a call-back to a macro that sets a series of variables before calling the clothing macro defined in the original file. So the 'ppshirts1.inc' file includes a definition of the ppShirtGenerator macro which, when called will define a shirt based upon a set of body part definitions. Once the macro has been defined (but not run), it calls the ppTop macro from the figure-specific file (in this case the 'pphuman001accessories.inc' file). The ppTop macro uses figure-specific knowledge and sets the values of variables and objects, giving them names that are not figure-specific (but are specific to the ppShirtGenerator macro). The ppTop macro then runs the ppShirtGenerator macro.

Clothing definition macros, like the ppShirtGenerator macro, create clothing that is in-place relative to the figure and therefore takes some account of the bends at the joints, wrapping the clothing surface seamlessly around those joints. As a consequence of being defined in-place, the items of clothing do not need to be transformed once they have been defined, they simply need to be added to the figure by calling the ppAddBodyPart macro. This is performed as one of the last tasks of the ppShirtGenerator macro.

To improve performance, the number of slices and segments used for each patch of clothing is kept relatively small. If you find that the clothing doesn't wrap around joints correctly or doesn't take account of bulges in the anatomy, you can increase the number of points scanned to attempt to alleviate the problems.

Adding new clothing files

To add your own clothing definition macro based upon an existing set of body part definitions you can simply add a clothing file. For example, if you copy the file 'ppshirts1.inc' to a file called 'mybodyarmour.inc' you can replace the SDL within your new copy of the 'ppShirtGenerator' macro to generate body armour on the upper body of the figure. To add your newly defined item of clothing to a figure you simply add it's file name to the ppCostumeItems array in an 'outfit' file. For example you could copy the 'ppoutfit1.inc' file to a file called 'myarmouroutfit.inc' and remove 'ppshirts1.inc' from the ppCostumeItems array, replacing it with 'mybodyarmour.inc'.

If you need to make different body parts available to your clothing macro you will need to also add a figure-specific macro to the figure specific file (e.g. the 'pphuman001accessories.inc' file). You could, for example add a 'myWholeBody' macro into the 'pphuman001accessories.inc' file that declares variables and objects that you want to use in your 'mybodyarmour.inc' file. You then would update the macro call at the bottom of your 'mybodyarmour.inc' file to call your 'myWholeBody' macro instead of calling the ppTop macro. Your 'myWholeBody' macro would then call-back your 'ppShirtGenerator' macro once the variables and objects you need have been declared. You could also optionaly rename the 'ppShirtGenerator' macro and the call to it from your 'myWholeBody' macro.

If you find the techniques used by the existing clothing definition macros don't do what you want, you also have the option of placing whatever SDL you like within your own clothing definition macro. Essentially so long as the item you define is added to the figure by calling the ppAddBodyPart macro at the end of the clothes definition macro, then you can do whatever you want in order to define a costume item. So you can create a new clothing definition macro that could simply call a macro you already have. For example, if you have a macro to generate a diving helmet, you can then scale, orientate and translate that object into the position of the head, then call the ppAddBodyPart macro to add it to the figure.

The position of a body part is stored in the 'ppBodyPartListPosition[]' array, so to retrieve the position of the head you can use 'ppBodyPartListPosition[ppHeadRef]' the calculated orientation of a body part is stored in the 'ppBodyPartListOrientation[]' array. So if you have assigned a diving helmet to the variable 'myDivingHelmet' you can align it with the head by specifying:

    #declare myDivingHelmet = object {myDivingHelmet rotate ppBodyPartListOrientation[ppHeadRef] translate ppBodyPartListPosition[ppHeadRef]}

The Clothing Macros

It is possible to add costume items to a figure that do not depend upon the anatomy of the figure. For example, you could define a sword and simply add it to the figure at the position of the hand, or a skateboard and attach it to the figures foot. However, most items of clothing depend heavily upon the anatomy of the figure. POV-Person therefore provides a number of macros to help generate clothing that follows the contours of body parts.

A clothing definition macro will usually take a series of body parts and scan combinations of those body parts. A two dimensional array is used to store positions representing the surface of the material. The ppLimbScan macro can be called to scan an object and assign surface positions to an array. The ppAddOffSetToArray macro can be used to add an offset to those positions based on either a linear displacement or based upon a texture (or a combination of the two). For example, you can make a bumpy surface some distance from the surface of the original object (the skin).

There are other useful POV-Person macros that help you to manipulate clothing surfaces, for example the ppStitchArrays macro that patches one array so that it joins seamlessly with another. For a complete list see Section 7 Macro Reference - Clothing Macros.