Panda3D
billboardEffect.h
1 // Filename: billboardEffect.h
2 // Created by: drose (14Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef BILLBOARDEFFECT_H
16 #define BILLBOARDEFFECT_H
17 
18 #include "pandabase.h"
19 
20 #include "renderEffect.h"
21 #include "luse.h"
22 #include "nodePath.h"
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : BillboardEffect
26 // Description : Indicates that geometry at this node should
27 // automatically rotate to face the camera, or any other
28 // arbitrary node.
29 ////////////////////////////////////////////////////////////////////
30 class EXPCL_PANDA_PGRAPH BillboardEffect : public RenderEffect {
31 private:
32  INLINE BillboardEffect();
33 
34 PUBLISHED:
35  static CPT(RenderEffect) make(const LVector3 &up_vector,
36  bool eye_relative,
37  bool axial_rotate,
38  PN_stdfloat offset,
39  const NodePath &look_at,
40  const LPoint3 &look_at_point);
41  INLINE static CPT(RenderEffect) make_axis();
42  INLINE static CPT(RenderEffect) make_point_eye();
43  INLINE static CPT(RenderEffect) make_point_world();
44 
45  INLINE bool is_off() const;
46  INLINE const LVector3 &get_up_vector() const;
47  INLINE bool get_eye_relative() const;
48  INLINE bool get_axial_rotate() const;
49  INLINE PN_stdfloat get_offset() const;
50  INLINE const NodePath &get_look_at() const;
51  INLINE const LPoint3 &get_look_at_point() const;
52 
53 public:
54  virtual bool safe_to_transform() const;
55  virtual CPT(TransformState) prepare_flatten_transform(const TransformState *net_transform) const;
56  virtual void output(ostream &out) const;
57 
58  virtual bool has_cull_callback() const;
59  virtual void cull_callback(CullTraverser *trav, CullTraverserData &data,
60  CPT(TransformState) &node_transform,
61  CPT(RenderState) &node_state) const;
62 
63  virtual bool has_adjust_transform() const;
64  virtual void adjust_transform(CPT(TransformState) &net_transform,
65  CPT(TransformState) &node_transform,
66  PandaNode *node) const;
67 
68 protected:
69  virtual int compare_to_impl(const RenderEffect *other) const;
70 
71 private:
72  void compute_billboard(CPT(TransformState) &node_transform,
73  const TransformState *net_transform,
74  const TransformState *camera_transform) const;
75 
76 private:
77  bool _off;
78  LVector3 _up_vector;
79  bool _eye_relative;
80  bool _axial_rotate;
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);
88 
89 protected:
90  static TypedWritable *make_from_bam(const FactoryParams &params);
91  void fillin(DatagramIterator &scan, BamReader *manager);
92 
93 public:
94  static TypeHandle get_class_type() {
95  return _type_handle;
96  }
97  static void init_type() {
98  RenderEffect::init_type();
99  register_type(_type_handle, "BillboardEffect",
100  RenderEffect::get_class_type());
101  }
102  virtual TypeHandle get_type() const {
103  return get_class_type();
104  }
105  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
106 
107 private:
108  static TypeHandle _type_handle;
109 };
110 
111 #include "billboardEffect.I"
112 
113 #endif
114 
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
This is the base class for a number of special render effects that may be set on scene graph nodes to...
Definition: renderEffect.h:56
Indicates that geometry at this node should automatically rotate to face the camera, or any other arbitrary node.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
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 write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
Definition: cullTraverser.h:48