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. More... | |
void | clear_diffuse () |
Removes the explicit diffuse color from the material. More... | |
void | clear_emission () |
Removes the explicit emission color from the material. More... | |
void | clear_specular () |
Removes the explicit specular color from the material. More... | |
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. More... | |
virtual TypeHandle | force_init_type () |
const LColor & | get_ambient () const |
Returns the ambient color setting, if it has been set. More... | |
const LColor & | get_diffuse () const |
Returns the diffuse color setting, if it has been set. More... | |
const LColor & | get_emission () const |
Returns the emission color setting, if it has been set. More... | |
bool | get_local () const |
Returns the local viewer flag. More... | |
PN_stdfloat | get_shininess () const |
Returns the shininess exponent of the material. More... | |
const LColor & | get_specular () const |
Returns the specular color setting, if it has been set. More... | |
bool | get_twoside () const |
Returns the state of the two-sided lighting flag. More... | |
virtual TypeHandle | get_type () const |
bool | has_ambient () const |
Returns true if the ambient color has been explicitly set for this material, false otherwise. More... | |
bool | has_diffuse () const |
Returns true if the diffuse color has been explicitly set for this material, false otherwise. More... | |
bool | has_emission () const |
Returns true if the emission color has been explicitly set for this material, false otherwise. More... | |
bool | has_specular () const |
Returns true if the specular color has been explicitly set for this material, false otherwise. More... | |
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 |
void | set_ambient (const LColor &color) |
Specifies the ambient color setting of the material. More... | |
void | set_attrib_lock () |
void | set_diffuse (const LColor &color) |
Specifies the diffuse color setting of the material. More... | |
void | set_emission (const LColor &color) |
Specifies the emission color setting of the material. More... | |
void | set_local (bool local) |
Sets the local viewer flag. More... | |
void | set_shininess (PN_stdfloat shininess) |
Sets the shininess exponent of the material. More... | |
void | set_specular (const LColor &color) |
Specifies the diffuse color setting of the material. More... | |
void | set_twoside (bool twoside) |
Set this true to enable two-sided lighting. More... | |
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. More... | |
![]() | |
TypedWritableReferenceCount (const TypedWritableReferenceCount ©) | |
virtual ReferenceCount * | as_reference_count () |
Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type. More... | |
void | operator= (const TypedWritableReferenceCount ©) |
![]() | |
TypedWritable (const TypedWritable ©) | |
virtual int | complete_pointers (TypedWritable **p_list, BamReader *manager) |
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin(). More... | |
string | encode_to_bam_stream () const |
Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a string string. More... | |
bool | encode_to_bam_stream (string &data, BamWriter *writer=NULL) const |
Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. More... | |
virtual void | finalize (BamReader *manager) |
Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed. More... | |
UpdateSeq | get_bam_modified () const |
Returns the current bam_modified counter. More... | |
void | mark_bam_modified () |
Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. More... | |
void | operator= (const TypedWritable ©) |
virtual bool | require_fully_complete () const |
Some objects require all of their nested pointers to have been completed before the objects themselves can be completed. More... | |
virtual void | update_bam_nested (BamWriter *manager) |
Called by the BamWriter when this object has not itself been modified recently, but it should check its nested objects for updates. More... | |
![]() | |
TypedObject (const TypedObject ©) | |
TypedObject * | as_typed_object () |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
const TypedObject * | as_typed_object () const |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
int | get_best_parent_from_Set (const std::set< int > &) const |
int | get_type_index () const |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More... | |
bool | is_exact_type (TypeHandle handle) const |
Returns true if the current object is the indicated type exactly. More... | |
bool | is_of_type (TypeHandle handle) const |
Returns true if the current object is or derives from the indicated type. More... | |
void | operator= (const TypedObject ©) |
![]() | |
int | get_ref_count () const |
Returns the current reference count. More... | |
WeakReferenceList * | get_weak_list () const |
Returns the WeakReferenceList associated with this ReferenceCount object. More... | |
bool | has_weak_list () const |
Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More... | |
void | local_object () |
This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More... | |
void | ref () const |
Explicitly increments the reference count. More... | |
bool | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. More... | |
bool | test_ref_count_nonzero () const |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More... | |
virtual bool | unref () const |
Explicitly decrements the reference count. More... | |
void | weak_ref (WeakPointerToVoid *ptv) |
Adds the indicated PointerToVoid as a weak reference to this object. More... | |
void | weak_unref (WeakPointerToVoid *ptv) |
Removes the indicated PointerToVoid as a weak reference to this object. More... | |
![]() | |
Namable (const string &initial_name="") | |
Namable (const Namable ©) | |
void | clear_name () |
Resets the Namable's name to empty. More... | |
const string & | get_name () const |
bool | has_name () const |
Returns true if the Namable has a nonempty name set, false if the name is empty. More... | |
Namable & | operator= (const Namable &other) |
void | output (ostream &out) const |
Outputs the Namable. More... | |
void | set_name (const string &name) |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static Material * | get_default () |
Returns the default material. More... | |
static void | init_type () |
static void | register_with_read_factory () |
Factory method to generate a Material object. More... | |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
static | PT (TypedWritableReferenceCount) decode_from_bam_stream(const string &data |
![]() | |
static bool | decode_raw_from_bam_stream (TypedWritable *&ptr, ReferenceCount *&ref_ptr, const string &data, BamReader *reader=NULL) |
Reads the string created by a previous call to encode_to_bam_stream(), and extracts the single object on that string. More... | |
static TypeHandle | get_class_type () |
static void | init_type () |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
This function is declared non-inline to work around a compiler bug in g++ 2.96. More... | |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
Additional Inherited Members | |
![]() | |
static BamReader * | reader = NULL) |
![]() | |
static TypedWritable *const | Null = (TypedWritable*)0L |
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.
|
inline |
Removes the explicit ambient color from the material.
Definition at line 92 of file material.I.
References has_diffuse().
Referenced by get_ambient().
|
inline |
Removes the explicit diffuse color from the material.
Definition at line 129 of file material.I.
References has_specular().
Referenced by get_diffuse().
|
inline |
Removes the explicit emission color from the material.
Definition at line 203 of file material.I.
References get_shininess().
Referenced by get_emission().
|
inline |
Removes the explicit specular color from the material.
Definition at line 166 of file material.I.
References has_emission().
Referenced by get_specular().
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_local(), get_shininess(), get_specular(), get_twoside(), has_ambient(), has_diffuse(), has_emission(), has_specular(), and register_with_read_factory().
Referenced by set_emission(), and set_twoside().
|
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.
References clear_ambient().
Referenced by EggSaver::add_node(), TinyGraphicsStateGuardian::bind_light(), compare_to(), GraphicsStateGuardian::fetch_specified_part(), DXGraphicsStateGuardian9::get_index_type(), has_ambient(), and ShaderGenerator::~ShaderGenerator().
|
inlinestatic |
Returns the default material.
Definition at line 56 of file material.I.
References has_ambient().
Referenced by ShaderGenerator::~ShaderGenerator().
|
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.
References clear_diffuse().
Referenced by EggSaver::add_node(), TinyGraphicsStateGuardian::bind_light(), compare_to(), GraphicsStateGuardian::fetch_specified_part(), DXGraphicsStateGuardian9::get_index_type(), has_diffuse(), and ShaderGenerator::~ShaderGenerator().
|
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.
References clear_emission().
Referenced by EggSaver::add_node(), TinyGraphicsStateGuardian::bind_light(), compare_to(), GraphicsStateGuardian::fetch_specified_part(), DXGraphicsStateGuardian9::get_index_type(), has_emission(), and ShaderGenerator::~ShaderGenerator().
|
inline |
Returns the local viewer flag.
Set set_local().
Definition at line 242 of file material.I.
References set_local().
Referenced by EggSaver::add_node(), compare_to(), DXGraphicsStateGuardian9::get_index_type(), set_shininess(), and ShaderGenerator::~ShaderGenerator().
|
inline |
Returns the shininess exponent of the material.
Definition at line 217 of file material.I.
References set_shininess().
Referenced by EggSaver::add_node(), TinyGraphicsStateGuardian::bind_light(), clear_emission(), compare_to(), GraphicsStateGuardian::fetch_specified_part(), and DXGraphicsStateGuardian9::get_index_type().
|
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.
References clear_specular().
Referenced by EggSaver::add_node(), TinyGraphicsStateGuardian::bind_light(), compare_to(), GraphicsStateGuardian::fetch_specified_part(), DXGraphicsStateGuardian9::get_index_type(), has_specular(), and ShaderGenerator::~ShaderGenerator().
|
inline |
Returns the state of the two-sided lighting flag.
See set_twoside().
Definition at line 274 of file material.I.
References set_twoside().
Referenced by compare_to(), and set_local().
|
inline |
Returns true if the ambient color has been explicitly set for this material, false otherwise.
Definition at line 70 of file material.I.
References get_ambient().
Referenced by EggSaver::add_node(), TinyGraphicsStateGuardian::bind_light(), compare_to(), get_default(), DXGraphicsStateGuardian9::get_index_type(), and ShaderGenerator::~ShaderGenerator().
|
inline |
Returns true if the diffuse color has been explicitly set for this material, false otherwise.
Definition at line 107 of file material.I.
References get_diffuse().
Referenced by EggSaver::add_node(), TinyGraphicsStateGuardian::bind_light(), clear_ambient(), compare_to(), DXGraphicsStateGuardian9::get_index_type(), and ShaderGenerator::~ShaderGenerator().
|
inline |
Returns true if the emission color has been explicitly set for this material, false otherwise.
Definition at line 181 of file material.I.
References get_emission().
Referenced by EggSaver::add_node(), clear_specular(), compare_to(), and ShaderGenerator::~ShaderGenerator().
|
inline |
Returns true if the specular color has been explicitly set for this material, false otherwise.
Definition at line 144 of file material.I.
References get_specular().
Referenced by EggSaver::add_node(), clear_diffuse(), compare_to(), DXGraphicsStateGuardian9::get_index_type(), and ShaderGenerator::~ShaderGenerator().
|
static |
Factory method to generate a Material object.
Definition at line 230 of file material.cxx.
References BamReader::get_factory(), Factory< Type >::register_factory(), and write_datagram().
Referenced by compare_to().
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.
References set_diffuse().
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.
References set_specular().
Referenced by AssimpLoader::build_graph(), and set_ambient().
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.
References compare_to().
Referenced by set_specular().
|
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.
References get_twoside().
Referenced by get_local().
|
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.
References get_local().
Referenced by get_shininess().
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.
References set_emission().
Referenced by set_diffuse().
|
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.
References compare_to().
Referenced by get_twoside().
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(), DatagramIterator::get_int32(), DatagramIterator::get_stdfloat(), DatagramIterator::get_string(), LVecBase4f::read_datagram(), and LVecBase4f::write_datagram().
Referenced by register_with_read_factory().