Panda3D
|
Defines the way an object appears in the presence of lighting. More...
#include "material.h"
Public Member Functions | |
Material (const string &name="") | |
Material (const Material ©) | |
void | clear_ambient () |
Removes the explicit ambient color from the material. | |
void | clear_diffuse () |
Removes the explicit diffuse color from the material. | |
void | clear_emission () |
Removes the explicit emission color from the material. | |
void | clear_specular () |
Removes the explicit specular color from the material. | |
int | compare_to (const Material &other) const |
Returns a number less than zero if this material sorts before the other one, greater than zero if it sorts after, or zero if they are equivalent. | |
virtual TypeHandle | force_init_type () |
const LColor & | get_ambient () const |
Returns the ambient color setting, if it has been set. | |
const LColor & | get_diffuse () const |
Returns the diffuse color setting, if it has been set. | |
const LColor & | get_emission () const |
Returns the emission color setting, if it has been set. | |
bool | get_local () const |
Returns the local viewer flag. | |
PN_stdfloat | get_shininess () const |
Returns the shininess exponent of the material. | |
const LColor & | get_specular () const |
Returns the specular color setting, if it has been set. | |
bool | get_twoside () const |
Returns the state of the two-sided lighting flag. | |
virtual TypeHandle | get_type () const |
bool | has_ambient () const |
Returns true if the ambient color has been explicitly set for this material, false otherwise. | |
bool | has_diffuse () const |
Returns true if the diffuse color has been explicitly set for this material, false otherwise. | |
bool | has_emission () const |
Returns true if the emission color has been explicitly set for this material, false otherwise. | |
bool | has_specular () const |
Returns true if the specular color has been explicitly set for this material, false otherwise. | |
bool | is_attrib_locked () const |
bool | operator!= (const Material &other) const |
bool | operator< (const Material &other) const |
void | operator= (const Material ©) |
bool | operator== (const Material &other) const |
void | output (ostream &out) const |
Outputs the Namable. | |
void | set_ambient (const LColor &color) |
Specifies the ambient color setting of the material. | |
void | set_attrib_lock () |
void | set_diffuse (const LColor &color) |
Specifies the diffuse color setting of the material. | |
void | set_emission (const LColor &color) |
Specifies the emission color setting of the material. | |
void | set_local (bool local) |
Sets the local viewer flag. | |
void | set_shininess (PN_stdfloat shininess) |
Sets the shininess exponent of the material. | |
void | set_specular (const LColor &color) |
Specifies the diffuse color setting of the material. | |
void | set_twoside (bool twoside) |
Set this true to enable two-sided lighting. | |
void | write (ostream &out, int indent) const |
virtual void | write_datagram (BamWriter *manager, Datagram &me) |
Function to write the important information in the particular object to a Datagram. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static Material * | get_default () |
Returns the default material. | |
static void | init_type () |
static void | register_with_read_factory () |
Factory method to generate a Material object. | |
Protected Member Functions | |
void | fillin (DatagramIterator &scan, BamReader *manager) |
Function that reads out of the datagram (or asks manager to read) all of the data that is needed to re-create this object and stores it in the appropiate place. | |
Static Protected Member Functions | |
static TypedWritable * | make_Material (const FactoryParams ¶ms) |
Factory method to generate a Material object. |
Defines the way an object appears in the presence of lighting.
A material is only necessary if lighting is to be enabled; otherwise, the material isn't used.
Definition at line 34 of file material.h.
void Material::clear_ambient | ( | ) | [inline] |
Removes the explicit ambient color from the material.
Definition at line 92 of file material.I.
void Material::clear_diffuse | ( | ) | [inline] |
Removes the explicit diffuse color from the material.
Definition at line 129 of file material.I.
void Material::clear_emission | ( | ) | [inline] |
Removes the explicit emission color from the material.
Definition at line 203 of file material.I.
void Material::clear_specular | ( | ) | [inline] |
Removes the explicit specular color from the material.
Definition at line 166 of file material.I.
int Material::compare_to | ( | const Material & | other | ) | const |
Returns a number less than zero if this material sorts before the other one, greater than zero if it sorts after, or zero if they are equivalent.
The sorting order is arbitrary and largely meaningless, except to differentiate different materials.
Definition at line 149 of file material.cxx.
References LVecBase4f::compare_to(), get_ambient(), get_diffuse(), get_emission(), get_shininess(), get_specular(), has_ambient(), has_diffuse(), has_emission(), and has_specular().
void Material::fillin | ( | DatagramIterator & | scan, |
BamReader * | manager | ||
) | [protected, virtual] |
Function that reads out of the datagram (or asks manager to read) all of the data that is needed to re-create this object and stores it in the appropiate place.
Reimplemented from TypedWritable.
Definition at line 276 of file material.cxx.
References DatagramIterator::get_int32(), DatagramIterator::get_stdfloat(), DatagramIterator::get_string(), and LVecBase4f::read_datagram().
Referenced by make_Material().
const LColor & Material::get_ambient | ( | ) | const [inline] |
Returns the ambient color setting, if it has been set.
Returns (0,0,0,0) if the ambient color has not been set.
Definition at line 82 of file material.I.
Referenced by ShaderGenerator::analyze_renderstate(), compare_to(), GraphicsStateGuardian::fetch_specified_part(), and output().
Material * Material::get_default | ( | ) | [inline, static] |
Returns the default material.
Definition at line 56 of file material.I.
Referenced by ShaderGenerator::analyze_renderstate().
const LColor & Material::get_diffuse | ( | ) | const [inline] |
Returns the diffuse color setting, if it has been set.
Returns (1,1,1,1) if the diffuse color has not been set.
Definition at line 119 of file material.I.
Referenced by ShaderGenerator::analyze_renderstate(), compare_to(), GraphicsStateGuardian::fetch_specified_part(), and output().
const LColor & Material::get_emission | ( | ) | const [inline] |
Returns the emission color setting, if it has been set.
Returns (0,0,0,0) if the emission color has not been set.
Definition at line 193 of file material.I.
Referenced by ShaderGenerator::analyze_renderstate(), compare_to(), GraphicsStateGuardian::fetch_specified_part(), and output().
bool Material::get_local | ( | ) | const [inline] |
Returns the local viewer flag.
Set set_local().
Definition at line 242 of file material.I.
Referenced by output().
PN_stdfloat Material::get_shininess | ( | ) | const [inline] |
Returns the shininess exponent of the material.
Definition at line 217 of file material.I.
Referenced by compare_to(), GraphicsStateGuardian::fetch_specified_part(), and output().
const LColor & Material::get_specular | ( | ) | const [inline] |
Returns the specular color setting, if it has been set.
Returns (0,0,0,0) if the specular color has not been set.
Definition at line 156 of file material.I.
Referenced by ShaderGenerator::analyze_renderstate(), compare_to(), GraphicsStateGuardian::fetch_specified_part(), and output().
bool Material::get_twoside | ( | ) | const [inline] |
Returns the state of the two-sided lighting flag.
See set_twoside().
Definition at line 274 of file material.I.
Referenced by output().
bool Material::has_ambient | ( | ) | const [inline] |
Returns true if the ambient color has been explicitly set for this material, false otherwise.
Definition at line 70 of file material.I.
Referenced by ShaderGenerator::analyze_renderstate(), compare_to(), and output().
bool Material::has_diffuse | ( | ) | const [inline] |
Returns true if the diffuse color has been explicitly set for this material, false otherwise.
Definition at line 107 of file material.I.
Referenced by ShaderGenerator::analyze_renderstate(), compare_to(), and output().
bool Material::has_emission | ( | ) | const [inline] |
Returns true if the emission color has been explicitly set for this material, false otherwise.
Definition at line 181 of file material.I.
Referenced by ShaderGenerator::analyze_renderstate(), compare_to(), and output().
bool Material::has_specular | ( | ) | const [inline] |
Returns true if the specular color has been explicitly set for this material, false otherwise.
Definition at line 144 of file material.I.
Referenced by ShaderGenerator::analyze_renderstate(), compare_to(), and output().
TypedWritable * Material::make_Material | ( | const FactoryParams & | params | ) | [static, protected] |
Factory method to generate a Material object.
Definition at line 257 of file material.cxx.
References fillin().
Referenced by register_with_read_factory().
void Material::output | ( | ostream & | out | ) | const |
Outputs the Namable.
This function simply writes the name to the output stream; most Namable derivatives will probably redefine this.
Reimplemented from Namable.
Definition at line 178 of file material.cxx.
References get_ambient(), get_diffuse(), get_emission(), get_local(), get_shininess(), get_specular(), get_twoside(), has_ambient(), has_diffuse(), has_emission(), and has_specular().
void Material::register_with_read_factory | ( | ) | [static] |
Factory method to generate a Material object.
Definition at line 230 of file material.cxx.
References BamReader::get_factory(), make_Material(), and Factory< Type >::register_factory().
void Material::set_ambient | ( | const LColor & | color | ) |
Specifies the ambient color setting of the material.
This will be the multiplied by any ambient lights in effect on the material to set its base color.
This is the color of the object as it appears in the absence of direct light.
If this is not set, the object color will be used.
Definition at line 55 of file material.cxx.
void Material::set_diffuse | ( | const LColor & | color | ) |
Specifies the diffuse color setting of the material.
This will be multiplied by any lights in effect on the material to get the color in the parts of the object illuminated by the lights.
This is the primary color of an object; the color of the object as it appears in direct light, in the absence of highlights.
If this is not set, the object color will be used.
Definition at line 80 of file material.cxx.
void Material::set_emission | ( | const LColor & | color | ) |
Specifies the emission color setting of the material.
This is the color of the object as it appears in the absence of any light whatsover, including ambient light. It is as if the object is glowing by this color (although of course it will not illuminate neighboring objects).
If this is not set, the object will not glow by its own light and will only appear visible in the presence of one or more lights.
Definition at line 129 of file material.cxx.
void Material::set_local | ( | bool | local | ) | [inline] |
Sets the local viewer flag.
Set this true to enable camera-relative specular highlights, or false to use orthogonal specular highlights. The default value is true. Applications that use orthogonal projection should specify false.
Definition at line 256 of file material.I.
void Material::set_shininess | ( | PN_stdfloat | shininess | ) | [inline] |
Sets the shininess exponent of the material.
This controls the size of the specular highlight spot. In general, larger number produce a smaller specular highlight, which makes the object appear shinier. Smaller numbers produce a larger highlight, which makes the object appear less shiny.
Definition at line 232 of file material.I.
void Material::set_specular | ( | const LColor & | color | ) |
Specifies the diffuse color setting of the material.
This will be multiplied by any lights in effect on the material to compute the color of specular highlights on the object.
This is the highlight color of an object: the color of small highlight reflections.
If this is not set, highlights will not appear.
Definition at line 104 of file material.cxx.
void Material::set_twoside | ( | bool | twoside | ) | [inline] |
Set this true to enable two-sided lighting.
When two-sided lighting is on, both sides of a polygon will be lit by this material. The default is for two-sided lighting to be off, in which case only the front surface is lit.
Definition at line 288 of file material.I.
Function to write the important information in the particular object to a Datagram.
Reimplemented from TypedWritable.
Definition at line 241 of file material.cxx.
References Datagram::add_int32(), Datagram::add_stdfloat(), Datagram::add_string(), and LVecBase4f::write_datagram().