Panda3D
Loading...
Searching...
No Matches
billboardEffect.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file billboardEffect.h
10 * @author drose
11 * @date 2002-03-14
12 */
13
14#ifndef BILLBOARDEFFECT_H
15#define BILLBOARDEFFECT_H
16
17#include "pandabase.h"
18
19#include "renderEffect.h"
20#include "luse.h"
21#include "nodePath.h"
22
23/**
24 * Indicates that geometry at this node should automatically rotate to face
25 * the camera, or any other arbitrary node.
26 */
27class EXPCL_PANDA_PGRAPH BillboardEffect : public RenderEffect {
28private:
29 INLINE BillboardEffect();
30
31PUBLISHED:
32 static CPT(RenderEffect) make(const LVector3 &up_vector,
33 bool eye_relative,
34 bool axial_rotate,
35 PN_stdfloat offset,
36 const NodePath &look_at,
37 const LPoint3 &look_at_point,
38 bool fixed_depth = false);
39 INLINE static CPT(RenderEffect) make_axis();
40 INLINE static CPT(RenderEffect) make_point_eye();
41 INLINE static CPT(RenderEffect) make_point_world();
42
43 INLINE bool is_off() const;
44 INLINE const LVector3 &get_up_vector() const;
45 INLINE bool get_eye_relative() const;
46 INLINE bool get_axial_rotate() const;
47 INLINE bool get_fixed_depth() const;
48 INLINE PN_stdfloat get_offset() const;
49 INLINE const NodePath &get_look_at() const;
50 INLINE const LPoint3 &get_look_at_point() const;
51
52public:
53 virtual bool safe_to_transform() const;
54 virtual CPT(TransformState) prepare_flatten_transform(const TransformState *net_transform) const;
55 virtual void output(std::ostream &out) const;
56
57 virtual bool has_cull_callback() const;
58 virtual void cull_callback(CullTraverser *trav, CullTraverserData &data,
59 CPT(TransformState) &node_transform,
60 CPT(RenderState) &node_state) const;
61
62 virtual bool has_adjust_transform() const;
63 virtual void adjust_transform(CPT(TransformState) &net_transform,
64 CPT(TransformState) &node_transform,
65 const PandaNode *node) const;
66
67protected:
68 virtual int compare_to_impl(const RenderEffect *other) const;
69
70private:
71 void compute_billboard(CPT(TransformState) &node_transform,
72 const TransformState *net_transform,
73 const TransformState *camera_transform) const;
74
75private:
76 bool _off;
77 bool _eye_relative;
78 bool _axial_rotate;
79 bool _fixed_depth;
80 LVector3 _up_vector;
81 PN_stdfloat _offset;
82 NodePath _look_at;
83 LPoint3 _look_at_point;
84
85public:
86 static void register_with_read_factory();
87 virtual void write_datagram(BamWriter *manager, Datagram &dg);
88 virtual int complete_pointers(TypedWritable **plist,
89 BamReader *manager);
90
91protected:
92 static TypedWritable *make_from_bam(const FactoryParams &params);
93 void fillin(DatagramIterator &scan, BamReader *manager);
94
95public:
96 static TypeHandle get_class_type() {
97 return _type_handle;
98 }
99 static void init_type() {
100 RenderEffect::init_type();
101 register_type(_type_handle, "BillboardEffect",
102 RenderEffect::get_class_type());
103 }
104 virtual TypeHandle get_type() const {
105 return get_class_type();
106 }
107 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
108
109private:
110 static TypeHandle _type_handle;
111};
112
113#include "billboardEffect.I"
114
115#endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
static ConstPointerTo< RenderEffect > make(const LVector3 &up_vector, bool eye_relative, bool axial_rotate, PN_stdfloat offset, const NodePath &look_at, const LPoint3 &look_at_point, bool fixed_depth=false)
Constructs a new BillboardEffect object with the indicated properties.
const NodePath & get_look_at() const
Returns the node this billboard will rotate to look towards.
bool get_eye_relative() const
Returns true if this billboard interprets the up vector relative to the camera, or false if it is rel...
const LPoint3 & get_look_at_point() const
Returns the point, relative to the look_at node, towards which the billboard will rotate.
static void register_with_read_factory()
Tells the BamReader how to create objects of type BillboardEffect.
bool is_off() const
Returns true if the BillboardEffect is an 'off' BillboardEffect, indicating that it does not enable b...
bool get_axial_rotate() const
Returns true if this billboard rotates only around the axis of the up vector, or false if it rotates ...
PN_stdfloat get_offset() const
Returns the distance toward the camera (or the look_at_point) the billboard is moved towards,...
const LVector3 & get_up_vector() const
Returns the up vector in effect for this billboard.
bool get_fixed_depth() const
Returns true if this billboard always appears at a fixed distance from the camera.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
An instance of this class is passed to the Factory when requesting it to do its business and construc...
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition nodePath.h:159
A basic node of the scene graph or data graph.
Definition pandaNode.h:65
virtual bool has_adjust_transform() const
Should be overridden by derived classes to return true if adjust_transform() has been defined,...
virtual bool safe_to_transform() const
Returns true if it is generally safe to transform this particular kind of RenderEffect by calling the...
virtual void adjust_transform(ConstPointerTo< TransformState > &net_transform, ConstPointerTo< TransformState > &node_transform, const PandaNode *node) const
Performs some operation on the node's apparent net and/or local transforms.
virtual ConstPointerTo< TransformState > prepare_flatten_transform(const TransformState *net_transform) const
Preprocesses the accumulated transform that is about to be applied to (or through) this node due to a...
virtual bool has_cull_callback() const
Should be overridden by derived classes to return true if cull_callback() has been defined.
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 void cull_callback(CullTraverser *trav, CullTraverserData &data, ConstPointerTo< TransformState > &node_transform, ConstPointerTo< RenderState > &node_state) const
If has_cull_callback() returns true, this function will be called during the cull traversal to perfor...
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition renderState.h:47
Indicates a coordinate-system transform on vertices.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
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().
This is our own Panda specialization on the default STL list.
Definition plist.h:35
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.