Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

BillboardEffect Class Reference

Indicates that geometry at this node should automatically rotate to face the camera, or any other arbitrary node. More...

#include <billboardEffect.h>

Inheritance diagram for BillboardEffect:

RenderEffect TypedWritableReferenceCount TypedWritable ReferenceCount TypedObject List of all members.

Public Member Functions

bool is_off () const
 Returns true if the BillboardEffect is an 'off' BillboardEffect, indicating that it does not enable billboarding.

const LVector3f & get_up_vector () const
 Returns the up vector in effect for this billboard.

bool get_eye_relative () const
 Returns true if this billboard interprets the up vector relative to the camera, or false if it is relative to the world.

bool get_axial_rotate () const
 Returns true if this billboard rotates only around the axis of the up vector, or false if it rotates freely in three dimensions.

float get_offset () const
 Returns the distance toward the camera (or the look_at_point) the billboard is moved towards, after rotating.

const NodePathget_look_at () const
 Returns the node this billboard will rotate to look towards.

const LPoint3f & get_look_at_point () const
 Returns the point, relative to the look_at node, towards which the billboard will rotate.

virtual bool safe_to_transform () const
 Returns true if it is generally safe to transform this particular kind of RenderEffect by calling the xform() method, false otherwise.

virtual void output (ostream &out) const
ConstPointerTo< TransformStatedo_billboard (const TransformState *net_transform, const TransformState *camera_transform) const
 Computes the appropriate transform to apply to the billboarded geometry, given its current net transform, and the camera's inverse net transform.

virtual void write_datagram (BamWriter *manager, Datagram &dg)
 Writes the contents of this object to the datagram for shipping out to a Bam file.

virtual TypeHandle get_type () const
virtual TypeHandle force_init_type ()
int compare_to (const RenderEffect &other) const
 Provides an arbitrary ordering among all unique RenderEffects, so we can store the essentially different ones in a big set and throw away the rest.

virtual bool safe_to_combine () const
 Returns true if this kind of effect can safely be combined with sibling nodes that share the exact same effect, or false if this is not a good idea.

virtual ConstPointerTo< RenderEffectxform (const LMatrix4f &mat) const
 Returns a new RenderEffect transformed by the indicated matrix.

virtual void write (ostream &out, int indent_level) const
virtual void finalize ()
 Method to ensure that any necessary clean up tasks that have to be performed by this object are performed.

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

int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.

bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type.

bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly.

int get_ref_count () const
 Returns the current reference count.

int ref () const
 Explicitly increments the reference count.

int unref () const
 Explicitly decrements the reference count.

void test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus.


Static Public Member Functions

ConstPointerTo< RenderEffectmake (const LVector3f &up_vector, bool eye_relative, bool axial_rotate, float offset, const NodePath &look_at, const LPoint3f &look_at_point)
 Constructs a new BillboardEffect object with the indicated properties.

ConstPointerTo< RenderEffectmake_axis ()
ConstPointerTo< RenderEffectmake_point_eye ()
ConstPointerTo< RenderEffectmake_point_world ()
void register_with_read_factory ()
 Tells the BamReader how to create objects of type BillboardEffect.

TypeHandle get_class_type ()
void init_type ()
TypedWritablechange_this (TypedWritable *old_ptr, BamReader *manager)
 Called immediately after complete_pointers(), this gives the object a chance to adjust its own pointer if desired.


Static Public Attributes

TypedWritable *const Null = (TypedWritable*)0L

Protected Member Functions

virtual int compare_to_impl (const RenderEffect *other) const
 Intended to be overridden by derived BillboardEffect types to return a unique number indicating whether this BillboardEffect is equivalent to the other one.

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


Static Protected Member Functions

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

ConstPointerTo< RenderEffectreturn_new (RenderEffect *effect)
 This function is used by derived RenderEffect types to share a common RenderEffect pointer for all equivalent RenderEffect objects.

TypedWritablenew_from_bam (RenderEffect *effect, BamReader *manager)

Private Member Functions

 BillboardEffect ()
 Use BillboardEffect::make() to construct a new BillboardEffect object.


Private Attributes

bool _off
LVector3f _up_vector
bool _eye_relative
bool _axial_rotate
float _offset
NodePath _look_at
LPoint3f _look_at_point

Static Private Attributes

TypeHandle _type_handle

Detailed Description

Indicates that geometry at this node should automatically rotate to face the camera, or any other arbitrary node.

Definition at line 42 of file billboardEffect.h.


Constructor & Destructor Documentation

BillboardEffect::BillboardEffect  )  [inline, private]
 

Use BillboardEffect::make() to construct a new BillboardEffect object.

Definition at line 34 of file billboardEffect.I.

References INLINE, and make().


Member Function Documentation

TypedWritable * RenderEffect::change_this TypedWritable old_ptr,
BamReader manager
[static, inherited]
 

Called immediately after complete_pointers(), this gives the object a chance to adjust its own pointer if desired.

Most objects don't change pointers after completion, but some need to.

Once this function has been called, the old pointer will no longer be accessed.

Definition at line 294 of file renderEffect.cxx.

int RenderEffect::compare_to const RenderEffect other  )  const [inline, inherited]
 

Provides an arbitrary ordering among all unique RenderEffects, so we can store the essentially different ones in a big set and throw away the rest.

This method is not needed outside of the RenderEffect class because all equivalent RenderEffect objects are guaranteed to share the same pointer; thus, a pointer comparison is always sufficient.

Definition at line 46 of file renderEffect.I.

int BillboardEffect::compare_to_impl const RenderEffect other  )  const [protected, virtual]
 

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

This should return 0 if the two BillboardEffect 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 BillboardEffect objects whose get_type() functions return the same.

Reimplemented from RenderEffect.

Definition at line 204 of file billboardEffect.cxx.

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

int TypedWritable::complete_pointers TypedWritable **  p_list,
BamReader manager
[virtual, inherited]
 

Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().

Returns the number of pointers processed.

This is the callback function that is made by the BamReader at some later point, after all of the required pointers have been filled in. It is necessary because there might be forward references in a bam file; when we call read_pointer() in fillin(), the object may not have been read from the file yet, so we do not have a pointer available at that time. Thus, instead of returning a pointer, read_pointer() simply reserves a later callback. This function provides that callback. The calling object is responsible for keeping track of the number of times it called read_pointer() and extracting the same number of pointers out of the supplied vector, and storing them appropriately within the object.

Reimplemented in AnimBundleNode, AnimGroup, PartBundleNode, PartGroup, Character, CharacterJoint, CollisionNode, GeomSprite, PiecewiseCurve, ClipPlaneAttrib, FogAttrib, LensNode, LightAttrib, MaterialAttrib, RenderEffects, RenderState, TextureAttrib, Person, and Child.

Definition at line 94 of file typedWritable.cxx.

Referenced by RenderState::do_invert_compose().

ConstPointerTo< TransformState > BillboardEffect::do_billboard const TransformState net_transform,
const TransformState camera_transform
const
 

Computes the appropriate transform to apply to the billboarded geometry, given its current net transform, and the camera's inverse net transform.

Definition at line 125 of file billboardEffect.cxx.

References _up_vector.

void BillboardEffect::fillin DatagramIterator scan,
BamReader manager
[protected]
 

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

Reimplemented from RenderEffect.

Definition at line 311 of file billboardEffect.cxx.

void RenderEffect::finalize void   )  [virtual, inherited]
 

Method to ensure that any necessary clean up tasks that have to be performed by this object are performed.

Reimplemented from TypedWritable.

Definition at line 325 of file renderEffect.cxx.

virtual TypeHandle BillboardEffect::force_init_type void   )  [inline, virtual]
 

Reimplemented from RenderEffect.

Definition at line 104 of file billboardEffect.h.

bool BillboardEffect::get_axial_rotate  )  const [inline]
 

Returns true if this billboard rotates only around the axis of the up vector, or false if it rotates freely in three dimensions.

Definition at line 154 of file billboardEffect.I.

TypeHandle BillboardEffect::get_class_type void   )  [inline, static]
 

Reimplemented from RenderEffect.

Definition at line 93 of file billboardEffect.h.

References RenderEffect::get_class_type().

Referenced by compare_to_impl().

bool BillboardEffect::get_eye_relative  )  const [inline]
 

Returns true if this billboard interprets the up vector relative to the camera, or false if it is relative to the world.

Definition at line 137 of file billboardEffect.I.

References _look_at, and INLINE.

const NodePath & BillboardEffect::get_look_at  )  const [inline]
 

Returns the node this billboard will rotate to look towards.

If this is empty, it means the billboard will rotate towards the current camera node, wherever that might be.

Definition at line 192 of file billboardEffect.I.

const LPoint3f & BillboardEffect::get_look_at_point  )  const [inline]
 

Returns the point, relative to the look_at node, towards which the billboard will rotate.

Normally this is (0, 0, 0).

Definition at line 209 of file billboardEffect.I.

float BillboardEffect::get_offset  )  const [inline]
 

Returns the distance toward the camera (or the look_at_point) the billboard is moved towards, after rotating.

This can be used to ensure the billboard is not obscured by nearby geometry.

Definition at line 173 of file billboardEffect.I.

int ReferenceCount::get_ref_count  )  const [inline, inherited]
 

Returns the current reference count.

Definition at line 183 of file referenceCount.I.

Referenced by RenderState::determine_bin_index(), RenderEffects::determine_show_bounds(), FontPool::ns_garbage_collect(), TexturePool::ns_garbage_collect(), MaterialPool::ns_get_material(), and TexturePool::ns_release_texture().

virtual TypeHandle BillboardEffect::get_type void   )  const [inline, virtual]
 

Reimplemented from RenderEffect.

Definition at line 101 of file billboardEffect.h.

int TypedObject::get_type_index  )  const [inline, inherited]
 

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

Definition at line 71 of file typedObject.I.

References TypeHandle::get_name(), TypedObject::get_type(), and INLINE.

const LVector3f & BillboardEffect::get_up_vector  )  const [inline]
 

Returns the up vector in effect for this billboard.

Definition at line 120 of file billboardEffect.I.

References _offset, and INLINE.

void BillboardEffect::init_type void   )  [inline, static]
 

Reimplemented from RenderEffect.

Definition at line 96 of file billboardEffect.h.

References RenderEffect::get_class_type(), and RenderEffect::init_type().

bool TypedObject::is_exact_type TypeHandle  handle  )  const [inline, inherited]
 

Returns true if the current object is the indicated type exactly.

Definition at line 101 of file typedObject.I.

Referenced by PT(), and CollisionNode::xform().

bool TypedObject::is_of_type TypeHandle  handle  )  const [inline, inherited]
 

Returns true if the current object is or derives from the indicated type.

Definition at line 86 of file typedObject.I.

Referenced by EggMaterialCollection::collapse_equivalent_materials(), EggTextureCollection::collapse_equivalent_textures(), DeferredNodeProperty::compose(), AnimBundleMaker::create_s_channel(), CharacterMaker::create_slider(), ProjectionScreen::cull_callback(), DataNode::define_output(), EggNode::determine_draw_order(), CharacterMaker::egg_to_index(), EggGroupUniquifier::EggGroupUniquifier(), EggPoolUniquifier::EggPoolUniquifier(), EggGroupNode::find_textures(), StaticTextFont::get_glyph(), EggMaterialCollection::insert_materials(), EggTextureCollection::insert_textures(), CharacterJoint::make_copy(), PT(), EggGroupNode::r_flatten_transforms(), EggGroupNode::r_transform_vertices(), EggGroupNode::recompute_polygon_normals(), CollisionLevelState::reserve(), PandaFramework::reset_frame_rate(), PandaFramework::set_texture(), EggGroupNode::steal_children(), and DataGraphTraverser::traverse().

bool BillboardEffect::is_off  )  const [inline]
 

Returns true if the BillboardEffect is an 'off' BillboardEffect, indicating that it does not enable billboarding.

This kind of BillboardEffect isn't particularly useful and isn't normally created or stored in the graph; it might be implicitly discovered as the result of a NodePath::get_rel_state().

Definition at line 107 of file billboardEffect.I.

References _axial_rotate, and INLINE.

ConstPointerTo< RenderEffect > BillboardEffect::make const LVector3f &  up_vector,
bool  eye_relative,
bool  axial_rotate,
float  offset,
const NodePath look_at,
const LPoint3f &  look_at_point
[static]
 

Constructs a new BillboardEffect object with the indicated properties.

Definition at line 43 of file billboardEffect.cxx.

References look_at().

Referenced by BillboardEffect(), and NodePath::has_fog().

ConstPointerTo< RenderEffect > BillboardEffect::make_axis  )  [inline, static]
 

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

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

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

Definition at line 287 of file billboardEffect.cxx.

Referenced by compare_to_impl().

ConstPointerTo< RenderEffect > BillboardEffect::make_point_eye  )  [inline, static]
 

ConstPointerTo< RenderEffect > BillboardEffect::make_point_world  )  [inline, static]
 

TypedWritable* RenderEffect::new_from_bam RenderEffect effect,
BamReader manager
[static, protected, inherited]
 

void BillboardEffect::output ostream &  out  )  const [virtual]
 

Reimplemented from RenderEffect.

Definition at line 83 of file billboardEffect.cxx.

int ReferenceCount::ref  )  const [inline, inherited]
 

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.

This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

The return value is the new reference count.

Definition at line 225 of file referenceCount.I.

Referenced by ClientDevice::ClientDevice(), EggGroupNode::find_textures(), EggGroupNode::r_apply_texmats(), EggGroupNode::r_flatten_transforms(), and EggGroupNode::reverse_vertex_ordering().

void BillboardEffect::register_with_read_factory void   )  [static]
 

Tells the BamReader how to create objects of type BillboardEffect.

Definition at line 243 of file billboardEffect.cxx.

ConstPointerTo< RenderEffect > RenderEffect::return_new RenderEffect effect  )  [static, protected, inherited]
 

This function is used by derived RenderEffect types to share a common RenderEffect pointer for all equivalent RenderEffect objects.

The make() function of the derived type should create a new RenderEffect and pass it through return_new(), which will either save the pointer and return it unchanged (if this is the first similar such object) or delete it and return an equivalent pointer (if there was already a similar object saved).

Definition at line 201 of file renderEffect.cxx.

References TypedWritable::write_datagram().

bool RenderEffect::safe_to_combine  )  const [virtual, inherited]
 

Returns true if this kind of effect can safely be combined with sibling nodes that share the exact same effect, or false if this is not a good idea.

Reimplemented in DecalEffect, and ShowBoundsEffect.

Definition at line 129 of file renderEffect.cxx.

References indent().

bool BillboardEffect::safe_to_transform  )  const [virtual]
 

Returns true if it is generally safe to transform this particular kind of RenderEffect by calling the xform() method, false otherwise.

Reimplemented from RenderEffect.

Definition at line 70 of file billboardEffect.cxx.

void ReferenceCount::test_ref_count_integrity  )  const [inline, inherited]
 

Does some easy checks to make sure that the reference count isn't completely bogus.

Definition at line 328 of file referenceCount.I.

References INLINE.

Referenced by EggNode::determine_bin(), and ReferenceCount::~ReferenceCount().

int ReferenceCount::unref  )  const [inline, inherited]
 

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; plus, we don't have a virtual destructor anyway.) However, see the helper function unref_delete().

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.

This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

The return value is the new reference count.

Definition at line 293 of file referenceCount.I.

References INLINE.

Referenced by RenderState::determine_bin_index(), and RenderEffects::determine_show_bounds().

void RenderEffect::write ostream &  out,
int  indent_level
const [virtual, inherited]
 

Definition at line 170 of file renderEffect.cxx.

void BillboardEffect::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 RenderEffect.

Definition at line 258 of file billboardEffect.cxx.

References _axial_rotate, _eye_relative, _look_at_point, _off, _offset, _up_vector, RenderEffect::fillin(), DatagramIterator::get_bool(), and DatagramIterator::get_float32().

ConstPointerTo< RenderEffect > RenderEffect::xform const LMatrix4f &  mat  )  const [virtual, inherited]
 

Returns a new RenderEffect transformed by the indicated matrix.

Definition at line 144 of file renderEffect.cxx.

References nassertr, and NULL.


Member Data Documentation

bool BillboardEffect::_axial_rotate [private]
 

Definition at line 79 of file billboardEffect.h.

Referenced by is_off(), and write_datagram().

bool BillboardEffect::_eye_relative [private]
 

Definition at line 78 of file billboardEffect.h.

Referenced by write_datagram().

NodePath BillboardEffect::_look_at [private]
 

Definition at line 81 of file billboardEffect.h.

Referenced by get_eye_relative().

LPoint3f BillboardEffect::_look_at_point [private]
 

Definition at line 82 of file billboardEffect.h.

Referenced by write_datagram().

bool BillboardEffect::_off [private]
 

Definition at line 76 of file billboardEffect.h.

Referenced by write_datagram().

float BillboardEffect::_offset [private]
 

Definition at line 80 of file billboardEffect.h.

Referenced by get_up_vector(), and write_datagram().

TypeHandle BillboardEffect::_type_handle [static, private]
 

Reimplemented from RenderEffect.

Definition at line 30 of file billboardEffect.cxx.

LVector3f BillboardEffect::_up_vector [private]
 

Definition at line 77 of file billboardEffect.h.

Referenced by do_billboard(), and write_datagram().

TypedWritable *const TypedWritable::Null = (TypedWritable*)0L [static, inherited]
 

Definition at line 25 of file typedWritable.cxx.

Referenced by Child::complete_pointers(), Parent::complete_pointers(), Person::complete_pointers(), LoaderFileTypeBam::get_extension(), PartGroup::pick_channel_index(), BamReader::read_pointer(), and AnimGroup::write_datagram().


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:47:43 2003 for Panda by doxygen1.3