Panda3D
|
A CompassEffect causes a node to inherit its rotation (or pos or scale, if specified) from some other reference node in the graph, or more often from the root. More...
#include "compassEffect.h"
Public Types | |
enum | Properties { P_x = 0x001, P_y = 0x002, P_z = 0x004, P_pos = 0x007, P_rot = 0x008, P_sx = 0x010, P_sy = 0x020, P_sz = 0x040, P_scale = 0x070, P_all = 0x07f } |
Public Member Functions | |
virtual void | adjust_transform (CPT(TransformState)&net_transform, CPT(TransformState)&node_transform, PandaNode *node) const |
Performs some operation on the node's apparent net and/or local transforms. | |
virtual void | cull_callback (CullTraverser *trav, CullTraverserData &data, CPT(TransformState)&node_transform, CPT(RenderState)&node_state) const |
If has_cull_callback() returns true, this function will be called during the cull traversal to perform any additional operations that should be performed at cull time. | |
virtual TypeHandle | force_init_type () |
int | get_properties () const |
const NodePath & | get_reference () const |
Returns the reference node from which the CompassEffect inherits its transform. | |
virtual TypeHandle | get_type () const |
virtual bool | has_adjust_transform () const |
Should be overridden by derived classes to return true if adjust_transform() has been defined, and therefore the RenderEffect has some effect on the node's apparent local and net transforms. | |
virtual bool | has_cull_callback () const |
Should be overridden by derived classes to return true if cull_callback() has been defined. | |
virtual void | output (ostream &out) const |
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 | 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 (RenderEffect) make(const NodePath &reference |
static TypeHandle | get_class_type () |
static void | init_type () |
static void | register_with_read_factory () |
Tells the BamReader how to create objects of type CompassEffect. | |
Public Attributes | |
static int | properties = P_rot) |
Protected Member Functions | |
virtual int | compare_to_impl (const RenderEffect *other) const |
Intended to be overridden by derived CompassEffect types to return a unique number indicating whether this CompassEffect 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 CompassEffect. | |
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 CompassEffect is encountered in the Bam file. |
A CompassEffect causes a node to inherit its rotation (or pos or scale, if specified) from some other reference node in the graph, or more often from the root.
In its purest form, a CompassEffect is used to keep the node's rotation fixed relative to the top of the scene graph, despite other transforms that may exist above the node. Hence the name: the node behaves like a magnetic compass, always pointing in the same direction.
As an couple of generalizing extensions, the CompassEffect may also be set up to always orient its node according to some other reference node than the root of the scene graph. Furthermore, it may optionally adjust any of pos, rotation, or scale, instead of necessarily rotation; and it may adjust individual pos and scale components. (Rotation may not be adjusted on an individual component basis; that's just asking for trouble.)
Be careful when using the pos and scale modes. In these modes, it's possible for the CompassEffect to move its node far from its normal bounding volume, causing culling to fail. If this is an issue, you may need to explicitly set a large (or infinite) bounding volume on the effect node.
Definition at line 55 of file compassEffect.h.
void CompassEffect::adjust_transform | ( | CPT(TransformState)& | net_transform, |
CPT(TransformState)& | node_transform, | ||
PandaNode * | node | ||
) | const [virtual] |
Performs some operation on the node's apparent net and/or local transforms.
This will only be called if has_adjust_transform() is redefined to return true.
Both parameters are in/out. The original transforms will be passed in, and they may (or may not) be modified in-place by the RenderEffect.
Reimplemented from RenderEffect.
Definition at line 183 of file compassEffect.cxx.
References TransformState::get_pos(), TransformState::get_quat(), TransformState::get_scale(), TransformState::has_components(), and NodePath::is_empty().
Referenced by cull_callback().
int CompassEffect::compare_to_impl | ( | const RenderEffect * | other | ) | const [protected, virtual] |
Intended to be overridden by derived CompassEffect types to return a unique number indicating whether this CompassEffect is equivalent to the other one.
This should return 0 if the two CompassEffect 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 CompassEffect objects whose get_type() functions return the same.
Reimplemented from RenderEffect.
Definition at line 286 of file compassEffect.cxx.
References NodePath::compare_to().
void CompassEffect::cull_callback | ( | CullTraverser * | trav, |
CullTraverserData & | data, | ||
CPT(TransformState)& | node_transform, | ||
CPT(RenderState)& | node_state | ||
) | const [virtual] |
If has_cull_callback() returns true, this function will be called during the cull traversal to perform any additional operations that should be performed at cull time.
This may include additional manipulation of render state or additional visible/invisible decisions, or any other arbitrary operation.
At the time this function is called, the current node's transform and state have not yet been applied to the net_transform and net_state. This callback may modify the node_transform and node_state to apply an effective change to the render state at this level.
Reimplemented from RenderEffect.
Definition at line 134 of file compassEffect.cxx.
References adjust_transform(), CullTraverserData::get_net_transform(), and CullTraverserData::node().
void CompassEffect::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 CompassEffect.
Reimplemented from RenderEffect.
Definition at line 353 of file compassEffect.cxx.
References DatagramIterator::get_uint16().
Referenced by make_from_bam().
const NodePath & CompassEffect::get_reference | ( | ) | const [inline] |
Returns the reference node from which the CompassEffect inherits its transform.
If this is empty, it means the root of the scene graph.
Definition at line 35 of file compassEffect.I.
bool CompassEffect::has_adjust_transform | ( | ) | const [virtual] |
Should be overridden by derived classes to return true if adjust_transform() has been defined, and therefore the RenderEffect has some effect on the node's apparent local and net transforms.
Reimplemented from RenderEffect.
Definition at line 167 of file compassEffect.cxx.
bool CompassEffect::has_cull_callback | ( | ) | const [virtual] |
Should be overridden by derived classes to return true if cull_callback() has been defined.
Otherwise, returns false to indicate cull_callback() does not need to be called for this effect during the cull traversal.
Reimplemented from RenderEffect.
Definition at line 112 of file compassEffect.cxx.
TypedWritable * CompassEffect::make_from_bam | ( | const FactoryParams & | params | ) | [static, protected] |
This function is called by the BamReader's factory when a new object of type CompassEffect is encountered in the Bam file.
It should create the CompassEffect and extract its information from the file.
Definition at line 334 of file compassEffect.cxx.
References fillin().
Referenced by register_with_read_factory().
void CompassEffect::register_with_read_factory | ( | ) | [static] |
Tells the BamReader how to create objects of type CompassEffect.
Definition at line 307 of file compassEffect.cxx.
References BamReader::get_factory(), make_from_bam(), and Factory< Type >::register_factory().
bool CompassEffect::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 53 of file compassEffect.cxx.
void CompassEffect::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 318 of file compassEffect.cxx.
References Datagram::add_uint16().