15 #include "compassEffect.h"
16 #include "cullTraverserData.h"
17 #include "config_pgraph.h"
19 #include "bamReader.h"
20 #include "bamWriter.h"
22 #include "datagramIterator.h"
38 make(const
NodePath &reference,
int properties) {
40 effect->_reference = reference;
41 effect->_properties = (properties & P_all);
42 return return_new(effect);
63 output(ostream &out)
const {
64 out << get_type() <<
":";
65 if (_properties == 0) {
68 if ((_properties & P_pos) == P_pos) {
71 if ((_properties & P_x) != 0) {
74 if ((_properties & P_y) != 0) {
77 if ((_properties & P_z) != 0) {
81 if ((_properties & P_rot) != 0) {
84 if ((_properties & P_scale) == P_scale) {
87 if ((_properties & P_sx) != 0) {
90 if ((_properties & P_sy) != 0) {
93 if ((_properties & P_sz) != 0) {
98 out <<
" reference " << _reference;
135 CPT(TransformState) &node_transform,
137 if (_properties == 0) {
142 CPT(TransformState) true_net_transform = data.get_net_transform(trav);
143 CPT(TransformState) want_net_transform = true_net_transform;
148 CPT(TransformState) compass_transform =
149 true_net_transform->invert_compose(want_net_transform);
155 node_transform = compass_transform->compose(node_transform);
168 return (_properties != 0);
184 CPT(TransformState) &node_transform,
186 if (_properties == 0) {
194 CPT(TransformState) ref_transform;
196 ref_transform = TransformState::make_identity();
198 ref_transform = _reference.get_net_transform();
205 CPT(TransformState) want_net_transform;
206 if (_properties == P_all) {
208 want_net_transform = ref_transform;
213 LVecBase3 want_pos = net_transform->get_pos();
214 const LVecBase3 &ref_pos = ref_transform->get_pos();
215 if ((_properties & P_x) != 0) {
216 want_pos[0] = ref_pos[0];
218 if ((_properties & P_y) != 0) {
219 want_pos[1] = ref_pos[1];
221 if ((_properties & P_z) != 0) {
222 want_pos[2] = ref_pos[2];
225 if ((_properties & ~P_pos) == 0) {
227 want_net_transform = net_transform->set_pos(want_pos);
229 }
else if ((_properties & (P_rot | P_scale)) == (P_rot | P_scale)) {
231 want_net_transform = ref_transform->set_pos(want_pos);
236 if (!net_transform->has_components() ||
237 !ref_transform->has_components()) {
240 want_net_transform = ref_transform->set_pos(want_pos);
245 if ((_properties & P_rot) != 0) {
246 want_quat = ref_transform->get_quat();
249 LVecBase3 want_scale = net_transform->get_scale();
250 const LVecBase3 &ref_scale = ref_transform->get_scale();
251 if ((_properties & P_sx) != 0) {
252 want_scale[0] = ref_scale[0];
254 if ((_properties & P_sy) != 0) {
255 want_scale[1] = ref_scale[1];
257 if ((_properties & P_sz) != 0) {
258 want_scale[2] = ref_scale[2];
262 TransformState::make_pos_quat_scale(want_pos, want_quat, want_scale);
267 net_transform = want_net_transform;
288 DCAST_INTO_R(ta, other, 0);
290 if (_properties != ta->_properties) {
291 return _properties - ta->_properties;
293 int compare = _reference.
compare_to(ta->_reference);
339 parse_params(params, scan, manager);
340 effect->fillin(scan, manager);
354 RenderEffect::fillin(scan, manager);
A basic node of the scene graph or data graph.
This is the base class for all three-component vectors and points.
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 ...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Base class for objects that can be written to and read from Bam files.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
PandaNode * node() const
Returns the node traversed to so far.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
This is the base class for a number of special render effects that may be set on scene graph nodes to...
PN_uint16 get_uint16()
Extracts an unsigned 16-bit integer.
virtual bool has_adjust_transform() const
Should be overridden by derived classes to return true if adjust_transform() has been defined...
virtual bool has_cull_callback() const
Should be overridden by derived classes to return true if cull_callback() has been defined...
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.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
virtual bool safe_to_transform() const
Returns true if it is generally safe to transform this particular kind of RenderEffect by calling the...
static void register_with_read_factory()
Tells the BamReader how to create objects of type CompassEffect.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
void add_uint16(PN_uint16 value)
Adds an unsigned 16-bit integer to the 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.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
This is the base quaternion class.
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_empty() const
Returns true if the NodePath contains no nodes.
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 perfor...
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
A CompassEffect causes a node to inherit its rotation (or pos or scale, if specified) from some other...
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...