30 make(
const LVector3 &up_vector,
bool eye_relative,
31 bool axial_rotate, PN_stdfloat offset,
const NodePath &look_at,
32 const LPoint3 &look_at_point,
bool fixed_depth) {
34 effect->_up_vector = up_vector;
35 effect->_eye_relative = eye_relative;
36 effect->_axial_rotate = axial_rotate;
37 effect->_offset = offset;
38 effect->_look_at = look_at;
39 effect->_look_at_point = look_at_point;
40 effect->_fixed_depth = fixed_depth;
42 return return_new(effect);
60 prepare_flatten_transform(
const TransformState *net_transform)
const {
63 return net_transform->set_hpr(LVecBase3(0, 0, 0));
69 void BillboardEffect::
70 output(std::ostream &out)
const {
71 out << get_type() <<
":";
80 if (!_up_vector.almost_equal(LVector3::up())) {
81 out <<
" up " << _up_vector;
87 out <<
" depth " << -_offset;
88 }
else if (_offset != 0.0f) {
89 out <<
" offset " << _offset;
92 out <<
" look at " << _look_at;
94 if (!_look_at_point.almost_equal(LPoint3(0.0f, 0.0f, 0.0f))) {
95 out <<
" look at point " << _look_at_point;
106 bool BillboardEffect::
107 has_cull_callback()
const {
123 void BillboardEffect::
127 CPT(
TransformState) modelview_transform = data.get_modelview_transform(trav);
128 if (modelview_transform->is_singular()) {
135 CPT(
TransformState) camera_transform = TransformState::make_identity();
143 compute_billboard(node_transform, modelview_transform, camera_transform);
151 bool BillboardEffect::
152 has_adjust_transform()
const {
167 void BillboardEffect::
178 CPT(
TransformState) camera_transform = _look_at.get_net_transform();
180 compute_billboard(node_transform, net_transform, camera_transform);
196 int BillboardEffect::
199 DCAST_INTO_R(ta, other, 0);
201 if (_axial_rotate != ta->_axial_rotate) {
202 return (
int)_axial_rotate - (int)ta->_axial_rotate;
204 if (_eye_relative != ta->_eye_relative) {
205 return (
int)_eye_relative - (int)ta->_eye_relative;
207 if (_fixed_depth != ta->_fixed_depth) {
208 return (
int)_fixed_depth - (int)ta->_fixed_depth;
210 if (_offset != ta->_offset) {
211 return _offset < ta->_offset ? -1 : 1;
213 int compare = _up_vector.compare_to(ta->_up_vector);
221 compare = _look_at_point.compare_to(ta->_look_at_point);
234 void BillboardEffect::
245 node_transform = node_transform->set_pos(LPoint3(0.0f, 0.0f, 0.0f));
248 net_transform->compose(translate)->invert_compose(camera_transform);
249 if (!rel_transform->has_mat()) {
254 const LMatrix4 &rel_mat = rel_transform->
get_mat();
257 LVector3 camera_pos, up;
265 up = _up_vector * rel_mat;
266 camera_pos = LVector3::forward() * rel_mat;
270 camera_pos = -(_look_at_point * rel_mat);
276 heads_up(rotate, camera_pos, up);
278 look_at(rotate, camera_pos, up);
283 if (_offset != 0.0f || _fixed_depth) {
284 LVector3 translate(rel_mat(3, 0), rel_mat(3, 1), rel_mat(3, 2));
287 pos = translate / rel_mat(3, 3);
291 translate.normalize();
292 translate *= _offset;
293 rotate.set_row(3, pos + translate);
296 node_transform = translate->compose(TransformState::make_mat(rotate))->compose(node_transform);
302 void BillboardEffect::
303 register_with_read_factory() {
316 _up_vector.write_datagram(dg);
320 _look_at_point.write_datagram(dg);
355 effect->fillin(scan, manager);
364 void BillboardEffect::
366 RenderEffect::fillin(scan, manager);
369 _up_vector.read_datagram(scan);
373 _look_at_point.read_datagram(scan);
376 _look_at.
fillin(scan, manager);
379 _fixed_depth =
false;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CPT(RenderEffect) BillboardEffect
Constructs a new BillboardEffect object with the indicated properties.
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...
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being written.
Indicates that geometry at this node should automatically rotate to face the camera,...
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
bool is_off() const
Returns true if the BillboardEffect is an 'off' BillboardEffect, indicating that it does not enable b...
virtual bool safe_to_transform() const
Returns true if it is generally safe to transform this particular kind of RenderEffect by calling the...
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,...
const TransformState * get_camera_transform() const
Returns the position of the camera relative to the starting node.
A class to retrieve the individual data elements previously stored in a Datagram.
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
bool get_bool()
Extracts a boolean value.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
void add_bool(bool value)
Adds a boolean value to the datagram.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
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 BamFil...
bool is_empty() const
Returns true if the NodePath contains no nodes.
int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
int compare_to(const NodePath &other) const
Returns a number less than zero if this NodePath sorts before the other one, greater than zero if it ...
void write_datagram(BamWriter *manager, Datagram &dg) const
Writes the contents of this object to the datagram for shipping out to a Bam file.
A basic node of the scene graph or data graph.
This is the base class for a number of special render effects that may be set on scene graph nodes to...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
TypeHandle is the identifier used to differentiate C++ class types.
Base class for objects that can be written to and read from Bam files.
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().
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.