#include <HMaterialLibrary.h>
Public Types | |
enum | Read_Flags { Read_Flags_Default = 0x0000, Prefer_Embedded = 0x0001, Prefer_Highest_Resolution = 0x0002 } |
see documentation on HMaterialLibrary::Read_Flags More... | |
enum | Write_Flags { Write_Flags_Default = 0x0000, Embedded = 0x0001 } |
Public Member Functions | |
bool | ApplyMaterial (const char *name) |
bool | ApplyStyles () |
bool | CloneMaterial (const char *old_material_name, char *new_material_name) |
bool | Compile (const char *name) |
int | CountFromType (const char *type) |
bool | EnsureEnvironmentInitialized (const char *name) |
bool | EnsureMaterialInitialized (const char *name) |
bool | FindReferencedMaterials (HC_KEY segment_tree, char *list, int list_size) |
const char * | GetContainerSegment () const |
const char * | GetCurrentEnvironment (char *buffer=0, int buffer_length=-1) |
const char * | GetEnvironmentList (char *buffer=0, int buffer_length=-1) |
const char * | GetMaterialList (char *buffer=0, int buffer_length=-1) |
Read_Flags | GetReadFlags () |
see documentation on HMaterialLibrary::Read_Flags | |
bool | GetTweakableByIndex (const char *material_name, int index, char *tweakable_name, char *type) |
bool | GetTweakableByName (const char *material_name, char const *tweakable_name, int *index, char *type) |
bool | GetTweakableDefaults (const char *material_name, int index, float *vals) |
bool | GetTweakablesCount (const char *material_name, int *count) |
Write_Flags | GetWriteFlags () |
see documentation on HMaterialLibrary::Write_Flags | |
bool | InitRead (int version) |
bool | InitWrite (const char *list, int *size) |
bool | IsValidEnvironment (const char *name) const |
bool | IsValidMaterial (const char *name) const |
TK_Status | ParseBuffer (char const *buffer, int size) |
bool | RegisterMaterials (const wchar_t *directory) |
bool | RegisterMaterials (const char *directory) |
bool | ReloadMaterial (const char *name) |
bool | RenameMaterial (const char *old_material_name, const char *new_material_name) |
bool | SetEnvironment (const char *name) |
void | SetReadFlags (Read_Flags flags) |
void | SetWriteFlags (Write_Flags flags) |
bool | Tweak (const char *material_name, int index, float val0, float val1=0, float val2=0, float val3=0) |
bool | Tweak (const char *material_name, int index, const float *vals) |
Protected Member Functions | |
bool | Compile (const char *name, void alter *bufferlist) |
virtual void | Error (const char *message, int severity=1) |
const char * | FindValidMaterial (const char *name) const |
bool | GetShaderSource (const char *material_name, char *shader_source, char *options=0) |
bool | GetTweakablesString (const char *material_name, char *string) |
bool | Initialize (const char *name, bool environment=false) |
Protected Attributes | |
const char * | m_CurrentEnvironment |
the name of the environment most recently set with SetEnvironment | |
HC_KEY | m_CurrentEnvironmentKey |
the currently active environment | |
struct vhash_s * | m_EnvironmentHash |
maps environment names to the compiled material hsf file from which it came | |
const char * | m_EnvironmentList |
the environment list | |
const wchar_t * | m_MaterialDirectory |
see documentation on HMaterialLibrary::Write_Flags | |
struct vhash_s * | m_MaterialHash |
maps material names to the compiled material hsf file from which it came | |
const char * | m_MaterialList |
the material list | |
HC_KEY | m_MaterialSegmentKey |
the segment containing the materials and environments | |
Read_Flags | m_ReadFlags |
see documentation on HMaterialLibrary::Read_Flags | |
Write_Flags | m_WriteFlags |
see documentation on HMaterialLibrary::Write_Flags | |
Friends | |
class | HTK_Material_Composite |
class | HTK_One_Material |
see documentation on HMaterialLibrary::Read_Flags
options for file import
options for file export
Read_Flags_Default | use textures in the HMaterialLibrary in preference to any that are embedded in the data |
Prefer_Embedded | keep the embedded material if there is a name conflict between existing and embedded one |
Prefer_Highest_Resolution | keep the one with the highest resolution if there is a name conflict between existing and embedded one |
bool HMaterialLibrary::ApplyMaterial | ( | const char * | name | ) |
Applies all of the attributes of the given material to the currently open segment. Initializes the material if necessary by pulling the resources (DAT, shader and images) from disk.
name | UTF8-encoded name as passed back from GetMaterialList() |
bool HMaterialLibrary::ApplyStyles | ( | ) |
After materials are registered, something in the model's ancestry needs to be styled by the materials segment, so that any and all name definitions are made available. We suggest the scene key, but really we can use anything from which the model inherits attributes provided it is in the same subwindow as the model. This function applies the library styles to the current segment.
bool HMaterialLibrary::CloneMaterial | ( | const char * | old_material_name, | |
char * | new_material_name | |||
) |
creates a copy of a material with a new name.
old_material_name | the material to be copied | |
new_material_name | the new material name. It will be the old material name plus a suffix guaranteed not to conflict with any materials yet defined, starting with "+1". |
bool HMaterialLibrary::Compile | ( | const char * | name, | |
void alter * | bufferlist | |||
) | [protected] |
name | the name of the material be compiled. | |
bufferlist | a vlist of SerializationNode objects onto which the compile results should be appended |
bool HMaterialLibrary::Compile | ( | const char * | name | ) |
name | the material name to be compiled. |
int HMaterialLibrary::CountFromType | ( | const char * | type | ) |
A utility to determine the number of floating point values required to store the data for a given type.
type | must be one of: "float", "float2", "float3", "float4" |
bool HMaterialLibrary::EnsureEnvironmentInitialized | ( | const char * | name | ) |
Checks whether the environment has already been initialized, and calls through to Initialize if it has not.
name | the material name |
bool HMaterialLibrary::EnsureMaterialInitialized | ( | const char * | name | ) |
Checks whether the material has already been initialized, and calls through to Initialize if it has not.
name | the material name |
virtual void HMaterialLibrary::Error | ( | const char * | message, | |
int | severity = 1 | |||
) | [protected, virtual] |
Reports an error.
message | the string to be shown to the user | |
severity | warning = 1, error = 2, fatal error = 3 |
const char* HMaterialLibrary::FindValidMaterial | ( | const char * | name | ) | const [protected] |
name | the name of the material to search for. |
const char* HMaterialLibrary::GetContainerSegment | ( | ) | const |
returns the name of the root segment under which resources are stored.
const char* HMaterialLibrary::GetEnvironmentList | ( | char * | buffer = 0 , |
|
int | buffer_length = -1 | |||
) |
const char* HMaterialLibrary::GetMaterialList | ( | char * | buffer = 0 , |
|
int | buffer_length = -1 | |||
) |
buffer | The buffer to write the results into. If non-NULL, it will also be returned back to the user. | |
buffer_length | The maximum number of characters to write into buffer. If less than or equal to zero, the caller is assumed to have allocated sufficient space to hold all contents. |
bool HMaterialLibrary::GetShaderSource | ( | const char * | material_name, | |
char * | shader_source, | |||
char * | options = 0 | |||
) | [protected] |
Pulls the shader source for a given material out of the material segment, using Show_Shader()
material_name | the material name | |
shader_source | hlsl/glsl shader source code. returned to user. | |
options | defaults to NULL, but if specified, a buffer in which to put the options associated with a material's shader definition. |
bool HMaterialLibrary::GetTweakableByIndex | ( | const char * | material_name, | |
int | index, | |||
char * | tweakable_name, | |||
char * | type | |||
) |
Tweakables can be identified by a combination of material name and index.
material_name | the material name | |
index | the tweakable index (0-based offset from the start of the comma-delimited tweakables string in the material's DAT file). | |
tweakable_name | the name of the tweakable, returned to user (e.g. for GUI labels) | |
type | the tweakable type. Possible values are float, float2, float3 and float4 |
bool HMaterialLibrary::GetTweakableByName | ( | const char * | material_name, | |
char const * | tweakable_name, | |||
int * | index, | |||
char * | type | |||
) |
Tweakables can be identified by a combination of material name and tweakable name.
material_name | the material name | |
tweakable_name | the name of the tweakable | |
index | the tweakable index, returned to user. | |
type | the tweakable type. Possible values are float, float2, float3 and float4 |
bool HMaterialLibrary::GetTweakableDefaults | ( | const char * | material_name, | |
int | index, | |||
float * | vals | |||
) |
pulls the initializer for a tweakable (specified by material_name and index) and returns the values to the user.
material_name | the material name | |
the | tweakable index (0-based offset from the start of the comma-delimited tweakables string in the material's DAT file). | |
vals | a pointer to up to 4 float values (depending on the type as returned by GetTweakable()) to be returned to the user currently specified in the hlsl code. |
bool HMaterialLibrary::GetTweakablesCount | ( | const char * | material_name, | |
int * | count | |||
) |
Allows the user to show the number of tweakables.
material_name | the material name | |
the | number of materials. |
bool HMaterialLibrary::GetTweakablesString | ( | const char * | material_name, | |
char * | string | |||
) | [protected] |
Pulls the comma-separated list of tweakables for a given material out of the material segment's user data.
material_name | the material name | |
string | the list of tweakables, returned to the caller |
bool HMaterialLibrary::Initialize | ( | const char * | name, | |
bool | environment = false | |||
) | [protected] |
Loads resources from disk to populate material attributes
name | the material name | |
environment | indicates whether the data will be used as an environment (which should contain texture definitions but no color settings). |
bool HMaterialLibrary::IsValidEnvironment | ( | const char * | name | ) | const |
name | the name of the environment to search for. |
bool HMaterialLibrary::IsValidMaterial | ( | const char * | name | ) | const |
name | the name of the material to search for. |
bool HMaterialLibrary::RegisterMaterials | ( | const wchar_t * | directory | ) |
Scans the given directory path and records the names of materials it discovers.
directory | the location on disk of the materials |
bool HMaterialLibrary::RegisterMaterials | ( | const char * | directory | ) |
Scans the given directory path and records the names of materials it discovers. Also creates a style link from the materials segment to the segment that is currently open. This function should be called from somewhere above the model in the model's path, but materials_segment does not necessarily need to be in the models path.
directory | the location on disk of the materials |
bool HMaterialLibrary::ReloadMaterial | ( | const char * | name | ) |
Refresh the material from disk. Note that any new materials that were cloned will not be affected.
name | the material name |
bool HMaterialLibrary::RenameMaterial | ( | const char * | old_material_name, | |
const char * | new_material_name | |||
) |
creates a copy of a material with a new name.
old_material_name | the material to be copied | |
new_material_name | the new material name. |
bool HMaterialLibrary::SetEnvironment | ( | const char * | name | ) |
An environment typically contains a cube map, and specifies the colors that are picked up by reflective materials and optionally the color of the window background
name | the environment to set |
bool HMaterialLibrary::Tweak | ( | const char * | material_name, | |
int | index, | |||
float | val0, | |||
float | val1 = 0 , |
|||
float | val2 = 0 , |
|||
float | val3 = 0 | |||
) |
a convenience wrapper around Tweak (const char *, int, const float *)
material_name | the material name | |
the | tweakable index (0-based offset from the start of the comma-delimited tweakables string in the material's DAT file). | |
val0 | the first value injected into the hlsl code. | |
val1 | the second value injected into the hlsl code (if applicable, depending on the tweakable's type). | |
val2 | the third value injected into the hlsl code (if applicable, depending on the tweakable's type). | |
val3 | the fourth value injected into the hlsl code (if applicable, depending on the tweakable's type). |
bool HMaterialLibrary::Tweak | ( | const char * | material_name, | |
int | index, | |||
const float * | vals | |||
) |
pulls the initializer for a tweakable (specified by material_name and index) and replaces the values with values specified by the user.
material_name | the material name | |
the | tweakable index (0-based offset from the start of the comma-delimited tweakables string in the material's DAT file). | |
vals | a pointer to up to 4 float values (depending on the type as returned by GetTweakable()) to be injected into the hlsl code. |
const wchar_t* HMaterialLibrary::m_MaterialDirectory [protected] |
see documentation on HMaterialLibrary::Write_Flags
the path to the materials and environments on disk