Panda3D
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions

ColorAttrib Class Reference

Indicates what color should be applied to renderable geometry. More...

#include "colorAttrib.h"

Inheritance diagram for ColorAttrib:
RenderAttrib TypedWritableReferenceCount TypedWritable ReferenceCount TypedObject MemoryBase MemoryBase

List of all members.

Public Types

enum  Type { T_vertex, T_flat, T_off }

Public Member Functions

virtual TypeHandle force_init_type ()
const LColorget_color () const
 If the type is T_flat or T_off, this returns the color that will be applied to geometry.
Type get_color_type () const
 Returns the type of color specified by this ColorAttrib.
virtual int get_slot () const
virtual TypeHandle get_type () const
virtual void output (ostream &out) const
virtual void write_datagram (BamWriter *manager, Datagram &dg)
 Writes the contents of this object to the datagram for shipping out to a Bam file.

Static Public Member Functions

static CPT (RenderAttrib) make_vertex()
static CPT (RenderAttrib) make_flat(const LColor &color)
static CPT (RenderAttrib) make_default()
static CPT (RenderAttrib) make_off()
static int get_class_slot ()
static TypeHandle get_class_type ()
static void init_type ()
static void register_with_read_factory ()
 Tells the BamReader how to create objects of type ColorAttrib.

Protected Member Functions

virtual int compare_to_impl (const RenderAttrib *other) const
 Intended to be overridden by derived ColorAttrib types to return a unique number indicating whether this ColorAttrib is equivalent to the other one.
virtual CPT (RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const
void fillin (DatagramIterator &scan, BamReader *manager)
 This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new ColorAttrib.
virtual size_t get_hash_impl () const
 Intended to be overridden by derived RenderAttrib types to return a unique hash for these particular properties.

Static Protected Member Functions

static TypedWritablemake_from_bam (const FactoryParams &params)
 This function is called by the BamReader's factory when a new object of type ColorAttrib is encountered in the Bam file.

Detailed Description

Indicates what color should be applied to renderable geometry.

Definition at line 30 of file colorAttrib.h.


Member Function Documentation

int ColorAttrib::compare_to_impl ( const RenderAttrib other) const [protected, virtual]

Intended to be overridden by derived ColorAttrib types to return a unique number indicating whether this ColorAttrib is equivalent to the other one.

This should return 0 if the two ColorAttrib objects are equivalent, a number less than zero if this one should be sorted before the other one, and a number greater than zero otherwise.

This will only be called with two ColorAttrib objects whose get_type() functions return the same.

Reimplemented from RenderAttrib.

Definition at line 124 of file colorAttrib.cxx.

References LVecBase4f::compare_to().

void ColorAttrib::fillin ( DatagramIterator scan,
BamReader manager 
) [protected, virtual]

This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new ColorAttrib.

Reimplemented from RenderAttrib.

Definition at line 251 of file colorAttrib.cxx.

References DatagramIterator::get_int8(), and LVecBase4f::read_datagram().

Referenced by make_from_bam().

const LColor & ColorAttrib::get_color ( ) const [inline]

If the type is T_flat or T_off, this returns the color that will be applied to geometry.

If the type is T_vertex, this is meaningless.

Definition at line 58 of file colorAttrib.I.

Referenced by TextNode::apply_attribs_to_vertices(), GraphicsStateGuardian::do_issue_color(), GraphicsStateGuardian::fetch_specified_part(), NodePath::get_color(), PolylightNode::get_color_scenegraph(), GeomTransformer::make_compatible_state(), and CLerpNodePathInterval::priv_step().

ColorAttrib::Type ColorAttrib::get_color_type ( ) const [inline]

Returns the type of color specified by this ColorAttrib.

The options are:

T_vertex - use the vertex color specified in the geometry itself.

T_flat - use the color specified in this ColorAttrib for all geometry. You can get this color via get_color().

T_off - use the color white.

Definition at line 46 of file colorAttrib.I.

Referenced by ShaderGenerator::analyze_renderstate(), TextNode::apply_attribs_to_vertices(), GraphicsStateGuardian::do_issue_color(), GraphicsStateGuardian::fetch_specified_part(), NodePath::get_color(), PolylightNode::get_color_scenegraph(), GeomTransformer::make_compatible_state(), and CLerpNodePathInterval::priv_step().

size_t ColorAttrib::get_hash_impl ( ) const [protected, virtual]

Intended to be overridden by derived RenderAttrib types to return a unique hash for these particular properties.

RenderAttribs that compare the same with compare_to_impl(), above, should return the same hash; RenderAttribs that compare differently should return a different hash.

Reimplemented from RenderAttrib.

Definition at line 147 of file colorAttrib.cxx.

References LVecBase4f::add_hash(), and integer_hash< Key, Compare >::add_hash().

TypedWritable * ColorAttrib::make_from_bam ( const FactoryParams params) [static, protected]

This function is called by the BamReader's factory when a new object of type ColorAttrib is encountered in the Bam file.

It should create the ColorAttrib and extract its information from the file.

Definition at line 232 of file colorAttrib.cxx.

References fillin(), and LVecBase4f::zero().

Referenced by register_with_read_factory().

void ColorAttrib::register_with_read_factory ( ) [static]

Tells the BamReader how to create objects of type ColorAttrib.

Definition at line 205 of file colorAttrib.cxx.

References BamReader::get_factory(), make_from_bam(), and Factory< Type >::register_factory().

void ColorAttrib::write_datagram ( BamWriter manager,
Datagram dg 
) [virtual]

Writes the contents of this object to the datagram for shipping out to a Bam file.

Reimplemented from RenderAttrib.

Definition at line 216 of file colorAttrib.cxx.

References Datagram::add_int8(), and LVecBase4f::write_datagram().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations