15 #include "planeNode.h"
16 #include "geometricBoundingVolume.h"
17 #include "bamWriter.h"
18 #include "bamReader.h"
20 #include "datagramIterator.h"
21 #include "geomVertexWriter.h"
22 #include "geomVertexData.h"
23 #include "geomLines.h"
25 #include "cullableObject.h"
26 #include "cullHandler.h"
27 #include "boundingPlane.h"
40 return new CData(*
this);
49 void PlaneNode::CData::
51 _plane.write_datagram(dg);
61 void PlaneNode::CData::
63 _plane.read_datagram(scan);
72 PlaneNode(
const string &name,
const LPlane &plane) :
80 set_overall_hidden(
true);
93 _priority(copy._priority),
94 _clip_effect(copy._clip_effect),
105 output(ostream &out)
const {
106 PandaNode::output(out);
134 cdata->_plane = cdata->_plane * mat;
135 cdata->_front_viz = NULL;
136 cdata->_back_viz = NULL;
171 data.get_internal_transform(trav));
203 int &internal_vertices,
205 Thread *current_thread)
const {
206 CDStageReader cdata(_cycler, pipeline_stage, current_thread);
208 internal_vertices = 0;
219 CDLockedReader cdata(_cycler);
223 const Lens *lens = trav->get_scene()->get_lens();
224 LPlane eye_plane = cdata->_plane * data.get_modelview_transform(trav)->get_mat();
225 bool front = (eye_plane.dist_to_plane(lens->
get_nodal_point()) >= 0.0f);
227 if (cdata->_front_viz != (
Geom *)NULL) {
228 return front ? cdata->_front_viz : cdata->_back_viz;
231 if (pgraph_cat.is_debug()) {
233 <<
"Recomputing viz for " << *
this <<
"\n";
236 CDWriter cdataw(_cycler, cdata,
false);
237 const LPlane &plane = cdataw->_plane;
240 (get_name(), GeomVertexFormat::get_v3cp(),
Geom::UH_static);
247 if (fabs(plane[0]) > fabs(plane[1])) {
249 if (fabs(plane[0]) > fabs(plane[2])) {
260 if (fabs(plane[1]) > fabs(plane[2])) {
271 static const int num_segs = 10;
272 a *= cdataw->_viz_scale / (num_segs * 2);
273 b *= cdataw->_viz_scale / (num_segs * 2);
275 for (
int x = -num_segs; x <= num_segs; ++x) {
276 vertex.add_data3(plane.project(a * x - b * num_segs));
277 vertex.add_data3(plane.project(a * x + b * num_segs));
278 lines->add_next_vertices(2);
279 lines->close_primitive();
281 for (
int y = -num_segs; y <= num_segs; ++y) {
282 vertex.add_data3(plane.project(b * y - a * num_segs));
283 vertex.add_data3(plane.project(b * y + a * num_segs));
284 lines->add_next_vertices(2);
285 lines->close_primitive();
288 cdataw->_front_viz =
new Geom(vdata->set_color(
LColor(1.0f, 1.0f, 0.0f, 1.0f)));
289 cdataw->_front_viz->add_primitive(lines);
291 cdataw->_back_viz =
new Geom(vdata->set_color(
LColor(0.4, 0.4, 0.0f, 1.0f)));
292 cdataw->_back_viz->add_primitive(lines);
294 return front ? cdataw->_front_viz : cdataw->_back_viz;
336 parse_params(params, scan, manager);
337 node->fillin(scan, manager);
351 PandaNode::fillin(scan, manager);
static void register_with_read_factory()
Tells the BamReader how to create objects of type PlaneNode.
A basic node of the scene graph or data graph.
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data)
This function will be called during the cull traversal to perform any additional operations that shou...
void add_uint8(PN_uint8 value)
Adds an unsigned 8-bit integer to the datagram.
A base class for any number of different kinds of lenses, linear and otherwise.
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 is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
void read_cdata(DatagramIterator &scan, PipelineCyclerBase &cycler)
Reads in the indicated CycleData object.
A single page of data maintained by a PipelineCycler.
Base class for objects that can be written to and read from Bam files.
void write_cdata(Datagram &packet, const PipelineCyclerBase &cycler)
Writes out the indicated CycleData object.
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 ...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
PN_int32 get_int32()
Extracts a signed 32-bit integer.
PN_uint8 get_uint8()
Extracts an unsigned 8-bit integer.
This funny bounding volume is an infinite plane that divides space into two regions: the part behind ...
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so...
The smallest atom of cull.
This is a 4-by-4 transform matrix.
virtual void record_object(CullableObject *object, const CullTraverser *traverser)
This callback function is intended to be overridden by a derived class.
CullHandler * get_cull_handler() const
Returns the object that will receive the culled Geoms.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
const LPlane & get_plane() const
Returns the plane represented by the PlaneNode.
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
Defines a series of disconnected line segments.
This is the base class for all three-component vectors and points.
virtual bool is_renderable() const
Returns true if there is some value to visiting this particular node during the cull traversal for an...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
A thread; that is, a lightweight process.
virtual PandaNode * make_copy() const
Returns a newly-allocated Node that is a shallow copy of this one.
void add_int32(PN_int32 value)
Adds a signed 32-bit integer to the datagram.
A class to retrieve the individual data elements previously stored in a Datagram. ...
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
TypeHandle is the identifier used to differentiate C++ class types.
This is a sequence number that increments monotonically.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
LPoint3 get_nodal_point() const
Returns the center point of the lens: the point from which the lens is viewing.
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so...
A node that contains a plane.