Panda3D
|
This is a special kind of attribute that instructs the graphics driver to apply an offset or bias to the generated depth values for rendered polygons, before they are written to the depth buffer. More...
#include "depthOffsetAttrib.h"
Public Member Functions | |
virtual TypeHandle | force_init_type () |
int | get_offset () const |
Returns the depth offset represented by this attrib. | |
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(int offset |
static | CPT (RenderAttrib) make_default() |
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 DepthOffsetAttrib. | |
Protected Member Functions | |
virtual int | compare_to_impl (const RenderAttrib *other) const |
Intended to be overridden by derived DepthOffsetAttrib types to return a unique number indicating whether this DepthOffsetAttrib is equivalent to the other one. | |
virtual | CPT (RenderAttrib) invert_compose_impl(const RenderAttrib *other) const |
virtual | CPT (RenderAttrib) compose_impl(const RenderAttrib *other) 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 DepthOffsetAttrib. | |
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 TypedWritable * | make_from_bam (const FactoryParams ¶ms) |
This function is called by the BamReader's factory when a new object of type DepthOffsetAttrib is encountered in the Bam file. |
This is a special kind of attribute that instructs the graphics driver to apply an offset or bias to the generated depth values for rendered polygons, before they are written to the depth buffer.
This can be used to shift polygons forward slightly, to resolve depth conflicts. The cull traverser may optionally use this, for instance, to implement decals. However, driver support for this feature seems to be spotty, so use with caution.
The bias is always an integer number, and each integer increment represents the smallest possible increment in Z that is sufficient to completely resolve two coplanar polygons. Positive numbers are closer towards the camera.
Nested DepthOffsetAttrib values accumulate; that is, a DepthOffsetAttrib with a value of 1 beneath another DepthOffsetAttrib with a value of 2 presents a net offset of 3. (A DepthOffsetAttrib will not, however, combine with any other DepthOffsetAttribs with a lower override parameter.) The net value should probably not exceed 16 or drop below 0 for maximum portability.
Definition at line 53 of file depthOffsetAttrib.h.
int DepthOffsetAttrib::compare_to_impl | ( | const RenderAttrib * | other | ) | const [protected, virtual] |
Intended to be overridden by derived DepthOffsetAttrib types to return a unique number indicating whether this DepthOffsetAttrib is equivalent to the other one.
This should return 0 if the two DepthOffsetAttrib 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 DepthOffsetAttrib objects whose get_type() functions return the same.
Reimplemented from RenderAttrib.
Definition at line 77 of file depthOffsetAttrib.cxx.
void DepthOffsetAttrib::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 DepthOffsetAttrib.
Reimplemented from RenderAttrib.
Definition at line 198 of file depthOffsetAttrib.cxx.
References DatagramIterator::get_int32().
Referenced by make_from_bam().
size_t DepthOffsetAttrib::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 94 of file depthOffsetAttrib.cxx.
References integer_hash< Key, Compare >::add_hash().
int DepthOffsetAttrib::get_offset | ( | ) | const [inline] |
Returns the depth offset represented by this attrib.
Definition at line 34 of file depthOffsetAttrib.I.
Referenced by NodePath::get_depth_offset().
TypedWritable * DepthOffsetAttrib::make_from_bam | ( | const FactoryParams & | params | ) | [static, protected] |
This function is called by the BamReader's factory when a new object of type DepthOffsetAttrib is encountered in the Bam file.
It should create the DepthOffsetAttrib and extract its information from the file.
Definition at line 179 of file depthOffsetAttrib.cxx.
References fillin().
Referenced by register_with_read_factory().
void DepthOffsetAttrib::register_with_read_factory | ( | ) | [static] |
Tells the BamReader how to create objects of type DepthOffsetAttrib.
Definition at line 153 of file depthOffsetAttrib.cxx.
References BamReader::get_factory(), make_from_bam(), and Factory< Type >::register_factory().
Writes the contents of this object to the datagram for shipping out to a Bam file.
Reimplemented from RenderAttrib.
Definition at line 164 of file depthOffsetAttrib.cxx.
References Datagram::add_int32().