formZ SDK | 5.0 API Reference | Project | Modeling | Rendering | Render Materials

# fz_rmtl_get_obj_col_rndr_txr

Description

Renders the color shaders of all faces of an object into a single texture. The object is unfolded and then rendered from a top view. The uv coordinates of each topological point (segment's start point) are returned in the optional uv_coords array. If passed in as non NULL, the array must be allocated to the number of items which is equal to the number of facetted segments of the object.
The texture map can be returned in a memory buffer of bytes or can be written to an image file. To return the texture map in memory, the bytes parameter must be passed as non NULL and the bytes storage must be allocated by calling code to res * res * 3 bytes if do_alpha is FALSE or res * res * 4 bytes if do_alpha is TRUE. Pixel color is stored as unsigned char r g b components. i.e. 255, 255, 255 is white, 0, 0, 0 is black. Pixels are stored in row major order with the top left pixel of the texture in the first three bytes. To write the texture map to file, the floc parameter must be passed as non NULL and must contain a valid file name and file directory. The format reference id parameter, ffmt_id, must identify a file format that is capable of writing a bitmap image.
The rendered texture for each face does actually not show the shape of the face but coveres the entire bounding rectangle of the face. This is done to avoid color bleeding artifacts when using MIP mapping and summation table sampling techniques. In order to capture the shape of the face in the texture, the do_alpha argument needs to be set to TRUE. When this is done, the shape of the face is rendered into the aplha channel of the texture, where a pixel covered by the face is on (255) and a true background pixels is off (0).
Note, that the texture contains all effects of the color shaders properly. This includes decals, solid texture and random patterns.

Plugin Prototype

fzrt_error_td fz_rmtl_get_obj_col_rndr_txr(

fzrt_int | windex,
fz_objt_ptr | objt,
fzrt_int | res,
unsigned char * | bytes,
fzrt_floc_ptr | floc,
fz_ffmt_ref_td | ffmt_id,
fzrt_boolean | do_alpha,
fz_xy_td * | uv_coords )

Parameters

windex [Input]

project window index

objt [Input]

the object, whose color shaders to render into the texture map

res [Input]

The (horizontal and vertical) resolution of the square texture.

bytes [Input, Optional]

byte storage for the texture. IMPORTANT : it is the calling code's responsibility to allcoate at least res * res * 3 bytes.

floc [Input, Optional]

texture map file locator

ffmt_id [Input, Optional]

The file format reference id.

do_alpha [Input]

If set to TRUE, the outline of the rendered faces is included in the aplha channel of the texture.

uv_coords [Result, Optional]

storage for the uv coordinates, which place each topological point (segment start point) of the object at the proper position in the texture.

Returns

Error codes

Availability

6.0.0.0

Function Set

fz_rmtl_fset

Defined in

fz_rmtl_api.h