» Back To Index
Demoniak3D/LUA API : Materials handling library
The
HYP_Material library performs general operations on the scene materials.
HYP_Material.Create
HYP_Material.Destroy
HYP_Material.SetAmbient
HYP_Material.SetDiffuse
HYP_Material.SetDynamicFriction
HYP_Material.SetResilience
HYP_Material.SetSelfIllumination
HYP_Material.SetSpecular
HYP_Material.SetSpecularExp
HYP_Material.SetStaticFriction
HYP_Material.GetNumMaterials
HYP_Material.GetIdByIndex
HYP_Material.GetNameByIndex
HYP_Material.GetId
HYP_Material.GetName
HYP_Material.AttachTexture
HYP_Material.DetachTexture
HYP_Material.SetShaderProgram
HYP_Material.SetShaderProgramForAmbientPass
HYP_Material.GetTextureId
Create
Create allows to create a new material.
Syntax
id = HYP_Material.Create( name );
- name - [STR64] - name to be assigned to the new material.
- id - [INTEGER] - numerical identifier refering to the material.
Destroy
Destroy allows to destroy a material.
Syntax
id = HYP_Material.Destroy( name );
- name - [STR64] - name of the material.
- id - [INTEGER] - numerical identifier refering to the material.
SetDiffuse
SetDiffuse allows to change the value of the material diffuse reflexion coefficient passed as parameter.
Syntax
HYP_Material.SetDiffuse( name | id, r, g, b, a );
- name - [STR64] - name of the material as specified in the XML script by the "name" attribute.
- id - [INTEGER] - numerical identifier refering to the material.
- r - [CLAMPED_REAL] - red component of the color.
- g - [CLAMPED_REAL] - green component of the color.
- b - [CLAMPED_REAL] - blue component of the color.
- a - [CLAMPED_REAL] - alpha component of the color.
SetAmbient
SetAmbient allows to change the value of the material ambient reflexion coefficient passed as parameter.
Syntax
HYP_Material.SetAmbient( name | id, r, g, b, a );
- name - [STR64] - name of the material as specified in the XML script by the "name" attribute.
- id - [INTEGER] - numerical identifier refering to the material.
- r - [CLAMPED_REAL] - red component of the color.
- g - [CLAMPED_REAL] - green component of the color.
- b - [CLAMPED_REAL] - blue component of the color.
- a - [CLAMPED_REAL] - alpha component of the color.
SetSpecular
SetSpecular allows to change the value of the material specular reflexion coefficient passed as parameter.
Syntax
HYP_Material.SetSpecular( name | id, r, g, b, a );
- name - [STR64] - name of the material as specified in the XML script by the "name" attribute.
- id - [INTEGER] - numerical identifier refering to the material.
- r - [CLAMPED_REAL] - red component of the color.
- g - [CLAMPED_REAL] - green component of the color.
- b - [CLAMPED_REAL] - blue component of the color.
- a - [CLAMPED_REAL] - alpha component of the color.
SetSpecularExp
SetSpecularExp allows to change the value of the material exponential coefficient of the specular reflexion passed as parameter.
Syntax
HYP_Material.SetSpecularExp( name | id, exp );
- name - [STR64] - name of the material as specified in the XML script by the name attribute.
- id - [INTEGER] - numerical identifier refering to the material.
- exp - [REAL] - specular exponential coefficient.
SetSelfIllumination
SetSelfIllumination allows to change the value of the coefficient of car-illumination of material passed as parameter.
Syntax
HYP_Material.SetSelfIllumination( name | id, r, g, b, a );
- name - [STR64] - name of the material as specified in the XML script by the "name" attribute.
- id - [INTEGER] - numerical identifier refering to the material.
- r - [CLAMPED_REAL] - red component of the color.
- g - [CLAMPED_REAL] - green component of the color.
- b - [CLAMPED_REAL] - blue component of the color.
- a - [CLAMPED_REAL] - alpha component of the color.
SetResilience
SetResilience allows to change the rebound coefficient of the material.
Syntax
HYP_Material.SetResilience( name | id, resilience );
- name - [STR64] - name of the material as specified in the XML script by the "name" attribute.
- id - [INTEGER] - numerical identifier refering to the material.
- resilience - [REAL] - rebound coefficient of the material.
Remark
This function takes effect only if the physical engine (NovodeX Physics Engine) has been activated in
the scene node.
SetStaticFriction
SetStaticFriction allows to change the static friction coefficient of the material.
Syntax
HYP_Material.SetStaticFriction( name | id, friction );
- name - [STR64] - name of the material as specified in the XML script by the "name" attribute.
- id - [INTEGER] - numerical identifier refering to the material.
- friction - [REAL] - material friction coefficient.
Remark
This function takes effect only if the physical engine (NovodeX Physics Engine) has been activated
in the scene node.
SetDynamicFriction
SetDynamicFriction allows to change the dynamic friction coefficient of the material.
Syntax
HYP_Material.SetDynamicFriction( name | id, friction );
- name - [STR64] - name of the material as specified in the XML script by the "name" attribute.
- id - [INTEGER] - numerical identifier refering to the material.
- friction - [REAL] - material friction coefficient.
Remark
This function takes effect only if the physical engine (NovodeX Physics Engine) has been activated
in the scene node.
GetNumMaterials
GetNumMaterials returns the number of material listed among the material list of the scene at a given time.
Syntax
n = HYP_Material.GetNumMaterials();
- n - [INTEGER] - number of materials in the scene.
GetIdByIndex
GetIdByIndex allows to know the identifier of a material according to its position in the material list of the scene.
Syntax
id = HYP_Material.GetIdByIndex( index );
- index - [INTEGER] - material index in the material list of the scene.
- id - [INTEGER] - material identifier.
GetNameByIndex
GetNameByIndex allows to know the name of a material according to its position in the material list of the scene.
Syntax
name = HYP_Material.GetNameByIndex( index );
- index - [INTEGER] - material index in the material list of the scene.
- name - [STR64] - material name.
GetId
GetId allows to know the identifierof a material according to its name.
Syntax
id = HYP_Material.GetId( name );
- name - [STR64] - material nom.
- id - [INTEGER] - material identifier.
GetName
GetName allows to know the name of a material according to its identifier.
Syntax
name = HYP_Material.GetName( id );
- id - [INTEGER] - material identifier.
- name - [STR64] - material identifier.
AttachTexture
AttachTexture allows to attach a texture to a material.
Syntax
HYP_Material.AttachTexture( mat_name|mat_id, tex_name|tex_id, tu );
- mat_name - [STR64] - name of the material.
- mat_id - [INTEGER] - material identifier.
- tex_name - [STR128] - name of the texture.
- tex_id - [INTEGER] - texture identifier.
- tu - [INTEGER] - texture unit on which the texture has to be handled. Value ranging between 0 and 7.
DetachTexture
DetachTexture allows to detach a texture from a material.
Syntax
HYP_Material.DetachTexture( mat_name|mat_id, tex_name|tex_id, tu );
- mat_name - [STR64] - name of the material.
- mat_id - [INTEGER] - material identifier.
- tex_name - [STR128] - texture name.
- tex_id - [INTEGER] - texture identifier.
- tu - [INTEGER] - texture unit on which the texture has to be handled. Value ranging between 0 and 7.
SetShaderProgram
SetShaderProgram allows to attach a GLSL shader to a material.
Syntax
HYP_Material.SetShaderProgram( mat_name|mat_id, shader_name|shader_id );
- mat_name - [STR64] - material name .
- mat_id - [INTEGER] - material identifier.
- shader_name - [STR128] - shader name.
- shader_id - [INTEGER] - shader identifier.
SetShaderProgramForAmbientPass
SetShaderProgramForAmbientPass allows to attach a GLSL shader to a material. This shader will be
used for rendering the object during the ambiant pass imposed by the volumic shadow algorithm.
Syntax
HYP_Material.SetShaderProgramForAmbientPass( mat_name|mat_id,
shader_name|shader_id );
- mat_name - [STR64] - material name.
- mat_id - [INTEGER] - material identifier.
- shader_name - [STR128] - shader name.
- shader_id - [INTEGER] - shader identifier.
GetTextureId
GetTextureId allows to retrieve the texture identifier for a given texture unit.
Syntax
tid = HYP_Material.GetTextureId( mat_name|mat_id, texture_unit );
- mat_name - [STR64] - material name.
- mat_id - [INTEGER] - material identifier.
- texture_unit - [STR128] - texture unit
- tid - [INTEGER] - texture identifier for the texture attached to the specified texture unit.