Panda3D
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  */
27 class EXPCL_PANDA_PGRAPH BillboardEffect : public RenderEffect {
28 private:
29  INLINE BillboardEffect();
30 
31 PUBLISHED:
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 
52 public:
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 
67 protected:
68  virtual int compare_to_impl(const RenderEffect *other) const;
69 
70 private:
71  void compute_billboard(CPT(TransformState) &node_transform,
72  const TransformState *net_transform,
73  const TransformState *camera_transform) const;
74 
75 private:
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 
85 public:
86  static void register_with_read_factory();
87  virtual void write_datagram(BamWriter *manager, Datagram &dg);
89  BamReader *manager);
90 
91 protected:
92  static TypedWritable *make_from_bam(const FactoryParams &params);
93  void fillin(DatagramIterator &scan, BamReader *manager);
94 
95 public:
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 
109 private:
110  static TypeHandle _type_handle;
111 };
112 
113 #include "billboardEffect.I"
114 
115 #endif
nodePath.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
RenderEffect
This is the base class for a number of special render effects that may be set on scene graph nodes to...
Definition: renderEffect.h:48
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition: datagramIterator.h:27
TypedWritable::complete_pointers
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().
Definition: typedWritable.cxx:81
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
BamWriter
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
CullTraverser
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
Definition: cullTraverser.h:45
RenderEffect::safe_to_transform
virtual bool safe_to_transform() const
Returns true if it is generally safe to transform this particular kind of RenderEffect by calling the...
Definition: renderEffect.cxx:68
BillboardEffect
Indicates that geometry at this node should automatically rotate to face the camera,...
Definition: billboardEffect.h:27
TypedWritable
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
RenderState
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:47
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
TransformState
Indicates a coordinate-system transform on vertices.
Definition: transformState.h:54
luse.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CullTraverserData
This collects together the pieces of data that are accumulated for each node while walking the scene ...
Definition: cullTraverserData.h:40
plist
This is our own Panda specialization on the default STL list.
Definition: plist.h:35
RenderEffect::write_datagram
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: renderEffect.cxx:283
NodePath
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:159
renderEffect.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
billboardEffect.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PandaNode
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64