Main Page   Modules   Alphabetical List   Data Structures   Data Fields  

RpMaterial
[Materials]


Modules

PlayStation 2

Data Structures

struct   RpMaterial

Typedefs

typedef RpMaterial *(*  RpMaterialCallBack )(RpMaterial *material, void *data)

Functions

void  RpMaterialSetFreeListCreateParams (RwInt32 blockSize, RwInt32 numBlocksToPrealloc)
RpMaterial RpMaterialCreate (void)
RwBool  RpMaterialDestroy (RpMaterial *material)
RpMaterial RpMaterialClone (RpMaterial *material)
RpMaterial RpMaterialAddRef (RpMaterial *material)
RpMaterial RpMaterialSetColor (RpMaterial *material, const RwRGBA *color)
const RwRGBA RpMaterialGetColor (const RpMaterial *material)
RpMaterial RpMaterialSetSurfaceProperties (RpMaterial *material, const RwSurfaceProperties *surfaceProperties)
const RwSurfaceProperties RpMaterialGetSurfaceProperties (const RpMaterial *material)
RpMaterial RpMaterialSetTexture (RpMaterial *material, RwTexture *texture)
RwTexture RpMaterialGetTexture (const RpMaterial *material)
RwInt32  RpMaterialRegisterPlugin (RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor constructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB)
RwInt32  RpMaterialRegisterPluginStream (RwUInt32 pluginID, RwPluginDataChunkReadCallBack readCB, RwPluginDataChunkWriteCallBack writeCB, RwPluginDataChunkGetSizeCallBack getSizeCB)
RwInt32  RpMaterialSetStreamAlwaysCallBack (RwUInt32 pluginID, RwPluginDataChunkAlwaysCallBack alwaysCB)
RwInt32  RpMaterialSetStreamRightsCallBack (RwUInt32 pluginID, RwPluginDataChunkRightsCallBack rightsCB)
RwInt32  RpMaterialGetPluginOffset (RwUInt32 pluginID)
RwBool  RpMaterialValidatePlugins (const RpMaterial *material)
RpMaterial RpMaterialStreamRead (RwStream *stream)
RwUInt32  RpMaterialStreamGetSize (const RpMaterial *material)
const RpMaterial RpMaterialStreamWrite (const RpMaterial *material, RwStream *stream)
RxPipeline RpMaterialSetDefaultPipeline (RxPipeline *pipeline)
RxPipeline RpMaterialGetDefaultPipeline (void)
RpMaterial RpMaterialSetPipeline (RpMaterial *material, RxPipeline *pipeline)
RpMaterial RpMaterialGetPipeline (RpMaterial *material, RxPipeline **pipeline)

Detailed Description

Handling surface materials Materials describe how things are to appear when rendered

RpMaterial Overview

Requirements

Overview

This object defines how the surface of a particular triangle in a model will look and react to lighting. Materials define color, texture, specularity, ambient reflectivity and diffusion. Materials also provide a hook into the PowerPipe mechanism, so you can attach your own rendering nodes on a per-material basis.

Further information is available in the Dynamic Models chapter of the User Guide.


Typedef Documentation

typedef RpMaterial*(* RpMaterialCallBack)(RpMaterial *material, void *data)
 

RpMaterialCallBack represents the function called from RpGeometryForAllMaterials and RpWorldForAllMaterials for all materials referenced by polygons in a given geometry. This function should return a pointer to the current material to indicate success. The callback may return NULL to terminate further callbacks on the materials.

Parameters:
material  Pointer to the current material
data  Pointer to developer-defined data structure.
Returns:
Pointer to the current material.

Function Documentation

RpMaterial* RpMaterialAddRef RpMaterial   material
 

RpMaterialAddRef is used to increment the reference count of the specified material. Use this function to indicate that a new object depends on the material's existence. This ensures that the material is not lost when other objects that use this material are destroyed.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

The world plugin must be attached before using this function.

Parameters:
material  Pointer to the material.
Returns:
Returns pointer to the material if successful or NULL if there is an error.
See also:
RpMaterialDestroy , RwTextureAddRef , RpWorldPluginAttach
RpMaterial* RpMaterialClone RpMaterial   material
 

RpMaterialClone is used to duplicate the specified material. This function creates and initializes a new material and copies the old materials's texture, color, pipeline, and surface properties to the new one. If there are any plug-ins registered with the material then the associated plugin data is also copied to the new material using the registered copy constructor function.

The world plugin must be attached before using this function.

Parameters:
material  Pointer to the material.
Returns:
Returns pointer to the new material if successful or NULL if there is an error.
See also:
RpMaterialCreate , RpMaterialRegisterPlugin , RpWorldPluginAttach
RpMaterial* RpMaterialCreate void   
 

RpMaterialCreate is used to create a new material. New materials have a default color of opaque white (red = green = blue = alpha = 255) and are untextured.

Note that the material is created with a reference count of one. Hence, it is the responsiblity of the application to destroy the material if it is no longer required.

The world plugin must be attached before using this function.

Returns:
Returns pointer to the new material if successful or NULL if there is an error.
See also:
RpMaterialDestroy , RpMaterialAddRef , RpMaterialSetColor , RpMaterialGetColor , RpMaterialSetTexture , RpMaterialGetTexture , RpWorldPluginAttach
RwBool RpMaterialDestroy RpMaterial   material
 

RpMaterialDestroy is used to destroy the specified material. Only materials with a reference count of zero are actually removed from the system. Reference counts greater than one indicate that this particular material is still being used by other geometries; in this situation, this function will only decrement the material's reference count. It is the application's responsibility to destroy the material if it is no longer required and it is not referenced by any geometries. This does not apply if the material was acquired by reading a geometry from a binary stream: destroying the geometry will also destroy the material it references.

The world plugin must be attached before using this function.

Parameters:
material  Pointer to the material
Returns:
Returns TRUE if successful or FALSE if there is an error
See also:
RpMaterialCreate , RpMaterialAddRef , RpWorldPluginAttach
const RwRGBA* RpMaterialGetColor const RpMaterial   material
 

RpMaterialGetColor is used to retrieve the specified material's color. Material colors are specified as RwUInt8 values in the range 0 to 255 in each color channel.

The default material color is opaque white (red = green = blue = alpha = 255).

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

The world plugin must be attached before using this function.

Parameters:
material  Pointer to the material.
Returns:
Returns pointer to a RwRGBA value equal to the material's color if successful or NULL if there is an error.
See also:
RpMaterialSetColor , RpMaterialSetTexture , RpMaterialGetTexture , RpWorldPluginAttach
RxPipeline* RpMaterialGetDefaultPipeline void   
 

RpMaterialGetDefaultPipeline retrieves the default pipeline for materials. This is the pipeline which will be used to render objects referencing a given material when that material's pipeline pointer is set to NULL.

The generic form of the default material pipeline is detailed in RpMaterialGetGenericPipeline and platform-specific versions in RpMaterialGetDefaultPipeline

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

The world plugin must be attached before using this function.

Returns:
Returns a pointer to the pipeline is successful, or NULL if there is an error.
See also:
RpAtomicGetGenericPipeline , RpAtomicGetDefaultPipeline , RpAtomicGetDefaultPipeline (platform-specific) , RpAtomicSetDefaultPipeline , RpAtomicGetPipeline , RpAtomicSetPipeline , RpMaterialGetPipeline , RpMaterialSetPipeline , RpMaterialGetGenericPipeline , RpMaterialSetDefaultPipeline , RpMaterialGetDefaultPipeline (platform-specific) , RpWorldGetSectorPipeline , RpWorldSetSectorPipeline , RpWorldSectorGetPipeline , RpWorldSectorSetPipeline , RpWorldGetGenericSectorPipeline , RpWorldGetDefaultSectorPipeline , RpWorldGetDefaultSectorPipeline (platform-specific) , RpWorldSetDefaultSectorPipeline
RpMaterial* RpMaterialGetPipeline RpMaterial   material,
RxPipeline **    pipeline
 

RpMaterialGetPipeline retrieves the pipeline for the specified material. This is the pipeline which will be used to render objects referencing the material. If the material's pipeline pointer is set to NULL, the default material pipeline will be used.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

The world plugin must be attached before using this function.

Parameters:
material  Pointer to the material.
pipeline  Pointer to receive the material's pipeline.
Returns:
Returns a pointer to the material is successful, or NULL if there is an error.
See also:
RpAtomicGetGenericPipeline , RpAtomicGetDefaultPipeline , RpAtomicGetDefaultPipeline (platform-specific) , RpAtomicGetPipeline , RpAtomicSetDefaultPipeline , RpAtomicSetPipeline , RpMaterialGetGenericPipeline , RpMaterialGetDefaultPipeline , RpMaterialGetDefaultPipeline (platform-specific) , RpMaterialSetDefaultPipeline , RpMaterialSetPipeline , RpWorldGetGenericSectorPipeline , RpWorldGetDefaultSectorPipeline , RpWorldGetDefaultSectorPipeline (platform-specific) , RpWorldGetSectorPipeline , RpWorldSectorGetPipeline , RpWorldSectorSetPipeline , RpWorldSetDefaultSectorPipeline , RpWorldSetSectorPipeline
RwInt32 RpMaterialGetPluginOffset RwUInt32    pluginID
 

RpMaterialGetPluginOffset is used to get the offset of a previously registered material plugin.

The world plugin must be attached before using this function.

Parameters:
pluginID  A RwUInt32 value equal to the plugin ID.
Returns:
Returns the data block offset if successful or -1 if the plugin is not registered.
See also:
RpMaterialRegisterPlugin , RpMaterialRegisterPluginStream , RpMaterialSetStreamAlwaysCallBack , RpMaterialValidatePlugins , RpWorldPluginAttach
const RwSurfaceProperties* RpMaterialGetSurfaceProperties const RpMaterial   material
 

RpMaterialGetSurfaceProperties is used to retrieve the surface lighting characteristics from the specified material. These surface properties define the ambient, diffuse and specular reflection coefficients for all surfaces within the geometry. The reflection coefficients are shared between all morph targets. Default values for the coefficients are defined as follows: 0.2 for the ambient, 0.6 for the diffuse and 0.6 for the specular.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

The world plugin must be attached before using this function.

Parameters:
material  Pointer to the RpMaterial structure.
Returns:
Returns a pointer to an RwSurfaceProperties structure filled with the surface properties information for the RpMaterial, or NULL if an error occurred.
See also:
RpMaterialSetSurfaceProperties , RpMaterialCreate , RpWorldPluginAttach
RwTexture* RpMaterialGetTexture const RpMaterial   material
 

RpMaterialGetTexture is used to retrieve the texture attached to the specified material.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

The world plugin must be attached before using this function.

Parameters:
material  Pointer to material.
Returns:
Returns pointer to the material's texture if successful or NULL if there is an error or if the material has no texture.
See also:
RpMaterialSetTexture , RpMaterialSetColor , RpMaterialGetColor , RpWorldPluginAttach
RwInt32 RpMaterialRegisterPlugin RwInt32    size,
RwUInt32    pluginID,
RwPluginObjectConstructor    constructCB,
RwPluginObjectDestructor    destructCB,
RwPluginObjectCopy    copyCB
 

RpMaterialRegisterPlugin is used to register a plugin and reserve some space within a material. This must happen after the engine has been initialized but before the engine is opened.

The world plugin must be attached before using this function.

Parameters:
size  A RwInt32 value equal to the size of the memory block to reserve.
pluginID  A RwInt32 value equal to the plugin ID (must be unique; used to identify binary chunks).
constructCB  Constructor for the plugin data block.
destructCB  Destructor for the plugin data block.
copyCB  Copy constructor for the plugin data block.
Returns:
Returns a RwInt32 value equal to the byte offset within the material of memory reserved for this plugin or a negative value if there is an error.
See also:
RpMaterialValidatePlugins , RpMaterialRegisterPluginStream , RpMaterialSetStreamAlwaysCallBack , RpMaterialGetPluginOffset , RpWorldPluginAttach
RwInt32 RpMaterialRegisterPluginStream RwUInt32    pluginID,
RwPluginDataChunkReadCallBack    readCB,
RwPluginDataChunkWriteCallBack    writeCB,
RwPluginDataChunkGetSizeCallBack    getSizeCB
 

RpMaterialRegisterPluginStream is used to associate a set of binary stream functionality with a previously registered material plugin.

The world plugin must be attached before using this function.

Parameters:
pluginID  A RwInt32 value equal to the plugin ID (must be unique; used to identify binary chunks).
readCB  Callback used when a chunk is read that is identified as being for this plugin.
writeCB  Callback used when a chunk should be written out for this plugin.
getSizeCB  Callback used to determine the binary stream size required for this plugin (return negative to suppress chunk writing).
Returns:
Returns a RwInt32 value equal to the byte offset within the material of memory reserved for this plugin or a negative value if there is an error.
See also:
RpMaterialSetStreamAlwaysCallBack , RpMaterialValidatePlugins , RpMaterialRegisterPlugin , RpMaterialGetPluginOffset , RpWorldPluginAttach
RpMaterial* RpMaterialSetColor RpMaterial   material,
const RwRGBA   color
 

RpMaterialSetColor is used to specify the color of the given material. Material colors are specified as RwUInt8 values in the range 0 to 255 in each color channel.

The default material color is opaque white (red = green = blue = alpha = 255).

To use material colors the rpGEOMETRYMODULATEMATERIALCOLOR flag needs to be set (see RpGeometryFlag). If a model is exported with material color 255, 255, 255, 255 the rpGEOMETRYMODULATEMATERIALCOLOR flag is not set and the material color will not be used.

The rpGEOMETRYMODULATEMATERIALCOLOR flag is set when creating a world. For more information about material colors, refer to the Dynamic Models User Guide chapter.

Note:
This function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.
The world plugin must be attached before using this function.
Parameters:
material  Pointer to material.
color  Pointer to RwRGBA value equal to the material color.
Returns:
Returns pointer to the material if successful or NULL if there is an error.
See also:
RpMaterialGetColor , RpMaterialSetTexture , RpMaterialGetTexture , RpWorldPluginAttach
RxPipeline* RpMaterialSetDefaultPipeline RxPipeline   pipeline
 

RpMaterialSetDefaultPipeline determines the default pipeline for materials. This is the pipeline which will be used to render objects referencing a given material when that material's pipeline pointer is set to NULL.

If the parameter is NULL, the default default material pipeline is reinstated.

The world plugin must be attached before using this function.

Parameters:
pipeline  Pointer to the pipeline or NULL.
Returns:
Returns a pointer to the pipeline is successful, or NULL if there is an error.
See also:
RpAtomicGetGenericPipeline , RpAtomicGetDefaultPipeline , RpAtomicGetDefaultPipeline (platform-specific) , RpAtomicGetPipeline , RpAtomicSetDefaultPipeline , RpAtomicSetPipeline , RpMaterialGetGenericPipeline , RpMaterialGetDefaultPipeline , RpMaterialGetDefaultPipeline (platform-specific) , RpMaterialGetPipeline , RpMaterialSetPipeline , RpWorldGetGenericSectorPipeline , RpWorldGetDefaultSectorPipeline , RpWorldGetDefaultSectorPipeline (platform-specific) , RpWorldGetSectorPipeline , RpWorldSectorGetPipeline , RpWorldSectorSetPipeline , RpWorldSetDefaultSectorPipeline , RpWorldSetSectorPipeline
void RpMaterialSetFreeListCreateParams RwInt32    blockSize,
RwInt32    numBlocksToPrealloc
 

RpMaterialSetFreeListCreateParams allows the developer to specify how many RpMaterial s to preallocate space for. Call before RwEngineInit.

Parameters:
blockSize  number of entries per freelist block.
numBlocksToPrealloc  number of blocks to allocate on RwFreeListCreateAndPreallocateSpace.
See also:
RwFreeList
RpMaterial* RpMaterialSetPipeline RpMaterial   material,
RxPipeline   pipeline
 

RpMaterialSetPipeline determines the pipeline for the specified material. This is the pipeline which will be used to render objects referencing the material. If the material's pipeline pointer is set to NULL, the default material pipeline will be used.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

The world plugin must be attached before using this function.

Parameters:
material  Pointer to the material.
pipeline  Pointer to the pipeline.
Returns:
Returns a pointer to the material is successful, or NULL if there is an error.
See also:
RpAtomicGetGenericPipeline , RpAtomicGetDefaultPipeline , RpAtomicGetDefaultPipeline (platform-specific) , RpAtomicGetPipeline , RpAtomicSetDefaultPipeline , RpAtomicSetPipeline , RpMaterialGetGenericPipeline , RpMaterialGetDefaultPipeline , RpMaterialGetDefaultPipeline (platform-specific) , RpMaterialGetPipeline , RpMaterialSetDefaultPipeline , RpWorldGetGenericSectorPipeline , RpWorldGetDefaultSectorPipeline , RpWorldGetDefaultSectorPipeline (platform-specific) , RpWorldGetSectorPipeline , RpWorldSectorGetPipeline , RpWorldSectorSetPipeline , RpWorldSetDefaultSectorPipeline , RpWorldSetSectorPipeline
RwInt32 RpMaterialSetStreamAlwaysCallBack RwUInt32    pluginID,
RwPluginDataChunkAlwaysCallBack    alwaysCB
 

RpMaterialSetStreamAlwaysCallBack is used to associate a binary stream callback with a previously registered material plugin. This callback is called for all plugins after stream data reading has completed.

The world plugin must be attached before using this function.

Parameters:
pluginID  A RwInt32 value equal to the plugin ID (must be unique; used to identify binary chunks).
alwaysCB  Callback used when object base and plugin data reading is complete.
Returns:
Returns a RwInt32 value equal to the byte offset within the material of memory reserved for this plugin or a negative value if there is an error.
See also:
RpMaterialRegisterPluginStream , RpMaterialValidatePlugins , RpMaterialRegisterPlugin , RpMaterialGetPluginOffset , RpWorldPluginAttach
RwInt32 RpMaterialSetStreamRightsCallBack RwUInt32    pluginID,
RwPluginDataChunkRightsCallBack    rightsCB
 

RpMaterialSetStreamRightsCallBack is used to associate a binary stream callback with a previously registered plugin. This callback is called for the plugin whose rights are asserted on the read material. Rights are asserted if the material had an attached pipeline with a plugin id when it was streamed.

The world plugin must be attached before using this function.

Parameters:
pluginID  A RwInt32 value equal to the plugin ID (must be unique; used to identify binary chunks).
rightsCB  Callback used when object base and plugin data reading is complete.
Returns:
Returns a RwInt32 value equal to the byte offset within the material of memory reserved for this plugin or a negative value if there is an error.
See also:
RpMaterialRegisterPluginStream , RpMaterialValidatePlugins , RpMaterialRegisterPlugin , RpMaterialGetPluginOffset , RpWorldPluginAttach
RpMaterial* RpMaterialSetSurfaceProperties RpMaterial   material,
const RwSurfaceProperties   surfaceProperties
 

RpMaterialSetSurfaceProperties is used to modify the surface lighting characteristics of the specified material. These surface properties define the ambient, diffuse and specular reflection coefficients for all surfaces within the geometry. The reflection coefficients are shared between all morph targets. Default values for the coefficients are defined as follows: 0.2 for the ambient, 0.6 for the diffuse and 0.6 for the specular.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

The world plugin must be attached before using this function.

Parameters:
material  * Pointer to the material.
surfaceProperties  * Pointer to a RwSurfaceProperties value specifying the new surface reflection coefficients.
Returns:
Returns a pointer to the geometry if successful or NULL if there is an error.
See also:
RpMaterialGetSurfaceProperties , RpMaterialCreate , RpWorldPluginAttach
RpMaterial* RpMaterialSetTexture RpMaterial   material,
RwTexture   texture
 

RpMaterialSetTexture is used to specify a texture for the given material. If the material already posesses a texture the old texture is destroyed before the new one is attached to the material.

The world plugin must be attached before using this function.

Parameters:
material  Pointer to material.
texture  Pointer to texture.
Returns:
Returns pointer to the material if successful or NULL if there is an error.
See also:
RpMaterialGetTexture , RpMaterialSetColor , RpMaterialGetColor , RwTextureRead , RwTextureCreate , RwTextureDestroy , RpWorldPluginAttach
RwUInt32 RpMaterialStreamGetSize const RpMaterial   material
 

RpMaterialStreamGetSize is used to determine the size in bytes of the binary representation of the specified material. This is used in the binary chunk header to indicate the size of the material chunk. The size does not include the size of the chunk header.

The world plugin must be attached before using this function.

Parameters:
material  Pointer to the material.
Returns:
Returns a RwUInt32 value equal to the chunk size of the material in bytes if successful or zero if there is an error.
See also:
RpMaterialStreamRead , RpMaterialStreamWrite , RpWorldPluginAttach
RpMaterial* RpMaterialStreamRead RwStream   stream
 

RpMaterialStreamRead is used to read a material from the specified binary stream. Prior to this function call a binary material chunk must have been found in the stream.

The world plugin must be attached before using this function.

The sequence to locate and read a material from a binary stream connected to a disk file is as follows:

   RwStream *stream;
   RpMaterial *NewMaterial;
  
   stream = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMREAD, "mybinary.xxx");
   if( stream )
   {
       if( RwStreamFindChunk(stream, rwID_MATERIAL, NULL, NULL) )
       {
           NewMaterial = RpMaterialStreamRead(stream);
       }
   
       RwStreamClose(stream, NULL);
   }
Parameters:
stream  Pointer to the binary stream.
Returns:
Returns pointer to the material if successful or NULL if there is an error.
See also:
RpMaterialStreamGetSize , RpMaterialStreamWrite , RwStreamOpen , RwStreamClose , RwStreamFindChunk , RpWorldPluginAttach
const RpMaterial* RpMaterialStreamWrite const RpMaterial   material,
RwStream   stream
 

RpMaterialStreamWrite is used to write the specified material to the given binary stream. The stream must have been opened prior to this function call.

The world plugin must be attached before using this function.

Parameters:
material  Pointer to the material.
stream  Pointer to the binary stream.
Returns:
Returns pointer to the material if successful or NULL if there is an error.
See also:
RpMaterialStreamGetSize , RpMaterialStreamRead , RwStreamOpen , RwStreamClose , RpWorldPluginAttach
RwBool RpMaterialValidatePlugins const RpMaterial   material
 

RpMaterialValidatePlugins validates the plugin memory allocated within the specified material. This function is useful for determining where memory trampling may be occuring within an application.

This function only returns a meaningful response under a debug library.

The world plugin must be attached before using this function.

Parameters:
material  Pointer to the material to validate.
Returns:
Returns TRUE is the material data is valid or FALSE if there is an error or if the material data has become corrupt.
See also:
RpMaterialRegisterPlugin , RpMaterialRegisterPluginStream , RpWorldPluginAttach

Criterion Software © 1993-2003 Criterion Software Limited. All rights reserved. Built Tue Apr 22 12:46:17 2003. Send Feedback
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)