Panda3D
Public Member Functions | Static Public Member Functions | List of all members
Material Class Reference

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. More...

Inheritance diagram for Material:
TypedWritableReferenceCount Namable TypedWritable ReferenceCount MemoryBase TypedObject MemoryBase MemoryBase

Public Member Functions

 __init__ (const Material copy)
 
 __init__ (str name)
 
 clearAmbient ()
 Removes the explicit ambient color from the material. More...
 
 clearDiffuse ()
 Removes the explicit diffuse color from the material. More...
 
 clearEmission ()
 Removes the explicit emission color from the material. More...
 
 clearSpecular ()
 Removes the explicit specular color from the material. More...
 
int compareTo (const Material other)
 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. More...
 
const LColor getAmbient ()
 Returns the ambient color setting, if it has been set. Returns (0,0,0,0) if the ambient color has not been set. More...
 
const LColor getDiffuse ()
 Returns the diffuse color setting, if it has been set. Returns (1,1,1,1) if the diffuse color has not been set. More...
 
const LColor getEmission ()
 Returns the emission color setting, if it has been set. Returns (0,0,0,0) if the emission color has not been set. More...
 
bool getLocal ()
 Returns the local viewer flag. Set set_local(). More...
 
float getShininess ()
 Returns the shininess exponent of the material. More...
 
const LColor getSpecular ()
 Returns the specular color setting, if it has been set. Returns (0,0,0,0) if the specular color has not been set. More...
 
bool getTwoside ()
 Returns the state of the two-sided lighting flag. See set_twoside(). More...
 
bool hasAmbient ()
 Returns true if the ambient color has been explicitly set for this material, false otherwise. More...
 
bool hasDiffuse ()
 Returns true if the diffuse color has been explicitly set for this material, false otherwise. More...
 
bool hasEmission ()
 Returns true if the emission color has been explicitly set for this material, false otherwise. More...
 
bool hasSpecular ()
 Returns true if the specular color has been explicitly set for this material, false otherwise. More...
 
bool isAttribLocked ()
 
bool operator!= (const Material other)
 
bool operator< (const Material other)
 
Material operator= (const Material copy)
 
bool operator== (const Material other)
 
 output (Ostream out)
 
 setAmbient (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. More...
 
 setAttribLock ()
 
 setDiffuse (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. More...
 
 setEmission (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). More...
 
 setLocal (bool local)
 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. More...
 
 setShininess (float shininess)
 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. More...
 
 setSpecular (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. More...
 
 setTwoside (bool twoside)
 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. More...
 
 write (Ostream out, int indent)
 
- Public Member Functions inherited from TypedWritable
object __reduce__ ()
 
object __reduce_persist__ (object pickler)
 
str encodeToBamStream ()
 Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a string string. Returns empty string on failure. More...
 
bool encodeToBamStream (String data, BamWriter writer)
 Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. Returns true on success, false on failure. More...
 
UpdateSeq getBamModified ()
 Returns the current bam_modified counter. This counter is normally incremented automatically whenever the object is modified. More...
 
 markBamModified ()
 Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. This should normally not need to be called by user code; it should be called internally when the object has been changed in a way that legitimately requires its retransmission to any connected clients. More...
 
- Public Member Functions inherited from TypedObject
TypeHandle getType ()
 Derived classes should override this function to return get_class_type(). More...
 
int getTypeIndex ()
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. This is equivalent to get_type().get_index(). More...
 
bool isExactType (TypeHandle handle)
 Returns true if the current object is the indicated type exactly. More...
 
bool isOfType (TypeHandle handle)
 Returns true if the current object is or derives from the indicated type. More...
 
- Public Member Functions inherited from ReferenceCount
int getRefCount ()
 Returns the current reference count. More...
 
 ref ()
 Explicitly increments the reference count. User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically. More...
 
bool testRefCountIntegrity ()
 Does some easy checks to make sure that the reference count isn't completely bogus. Returns true if ok, false otherwise. More...
 
bool testRefCountNonzero ()
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. Returns true if ok, false otherwise. More...
 
bool unref ()
 Explicitly decrements the reference count. Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic.) However, see the helper function unref_delete(). More...
 
- Public Member Functions inherited from Namable
 __init__ (const Namable copy)
 
 __init__ (str initial_name)
 
 clearName ()
 Resets the Namable's name to empty. More...
 
str getName ()
 
bool hasName ()
 Returns true if the Namable has a nonempty name set, false if the name is empty. More...
 
Namable operator= (const Namable other)
 
 output (Ostream out)
 Outputs the Namable. This function simply writes the name to the output stream; most Namable derivatives will probably redefine this. More...
 
 setName (str name)
 

Static Public Member Functions

static TypeHandle getClassType ()
 
static Material getDefault ()
 Returns the default material. More...
 
- Static Public Member Functions inherited from TypedWritableReferenceCount
static TypedWritableReferenceCount decodeFromBamStream (str data, BamReader reader)
 Reads the string created by a previous call to encode_to_bam_stream(), and extracts and returns the single object on that string. Returns NULL on error. More...
 
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedWritable
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from Namable
static TypeHandle getClassType ()
 

Detailed Description

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.

Member Function Documentation

◆ __init__() [1/2]

__init__ ( const Material  copy)

◆ __init__() [2/2]

__init__ ( str  name)

◆ clearAmbient()

clearAmbient ( )

Removes the explicit ambient color from the material.

◆ clearDiffuse()

clearDiffuse ( )

Removes the explicit diffuse color from the material.

◆ clearEmission()

clearEmission ( )

Removes the explicit emission color from the material.

◆ clearSpecular()

clearSpecular ( )

Removes the explicit specular color from the material.

◆ compareTo()

int compareTo ( const Material  other)

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.

◆ getAmbient()

const LColor getAmbient ( )

Returns the ambient color setting, if it has been set. Returns (0,0,0,0) if the ambient color has not been set.

◆ getClassType()

static TypeHandle getClassType ( )
static

◆ getDefault()

static Material getDefault ( )
static

Returns the default material.

◆ getDiffuse()

const LColor getDiffuse ( )

Returns the diffuse color setting, if it has been set. Returns (1,1,1,1) if the diffuse color has not been set.

◆ getEmission()

const LColor getEmission ( )

Returns the emission color setting, if it has been set. Returns (0,0,0,0) if the emission color has not been set.

◆ getLocal()

bool getLocal ( )

Returns the local viewer flag. Set set_local().

◆ getShininess()

float getShininess ( )

Returns the shininess exponent of the material.

◆ getSpecular()

const LColor getSpecular ( )

Returns the specular color setting, if it has been set. Returns (0,0,0,0) if the specular color has not been set.

◆ getTwoside()

bool getTwoside ( )

Returns the state of the two-sided lighting flag. See set_twoside().

◆ hasAmbient()

bool hasAmbient ( )

Returns true if the ambient color has been explicitly set for this material, false otherwise.

◆ hasDiffuse()

bool hasDiffuse ( )

Returns true if the diffuse color has been explicitly set for this material, false otherwise.

◆ hasEmission()

bool hasEmission ( )

Returns true if the emission color has been explicitly set for this material, false otherwise.

◆ hasSpecular()

bool hasSpecular ( )

Returns true if the specular color has been explicitly set for this material, false otherwise.

◆ isAttribLocked()

bool isAttribLocked ( )

◆ operator!=()

bool operator!= ( const Material  other)

◆ operator<()

bool operator< ( const Material  other)

◆ operator=()

Material operator= ( const Material  copy)

◆ operator==()

bool operator== ( const Material  other)

◆ output()

output ( Ostream  out)

◆ setAmbient()

setAmbient ( 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.

◆ setAttribLock()

setAttribLock ( )

◆ setDiffuse()

setDiffuse ( 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.

◆ setEmission()

setEmission ( 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.

◆ setLocal()

setLocal ( bool  local)

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.

◆ setShininess()

setShininess ( float  shininess)

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.

◆ setSpecular()

setSpecular ( 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.

◆ setTwoside()

setTwoside ( bool  twoside)

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.

◆ write()

write ( Ostream  out,
int  indent 
)