Go to the documentation of this file.
54 OccluderNode(
const std::string &name) :
59 set_overall_hidden(
true);
60 set_double_sided(
false);
61 set_min_coverage(0.0);
62 set_vertices(LPoint3::rfu(-1.0, 0.0, -1.0),
63 LPoint3::rfu(1.0, 0.0, -1.0),
64 LPoint3::rfu(1.0, 0.0, 1.0),
65 LPoint3::rfu(-1.0, 0.0, 1.0));
74 _double_sided(copy._double_sided),
75 _min_coverage(copy._min_coverage),
76 _vertices(copy._vertices)
111 xform(
const LMatrix4 &mat) {
112 nassertv(!mat.is_nan());
114 for (Vertices::iterator vi = _vertices.begin();
115 vi != _vertices.end();
144 new CullableObject(get_occluder_viz(trav, data), get_occluder_viz_state(trav, data),
145 data.get_internal_transform(trav));
149 nassertr(_frame_viz !=
nullptr,
false);
152 data.get_internal_transform(trav));
177 output(std::ostream &out)
const {
178 PandaNode::output(out);
188 int &internal_vertices,
190 Thread *current_thread)
const {
197 if (!_vertices.empty()) {
198 const LPoint3 *vertices_begin = &_vertices[0];
199 const LPoint3 *vertices_end = vertices_begin + _vertices.size();
200 gbv->
around(vertices_begin, vertices_end);
203 internal_bounds = bound;
204 internal_vertices = 0;
213 if (_occluder_viz ==
nullptr) {
214 nassertr(_vertices.size() == 4,
nullptr);
216 if (pgraph_cat.is_debug()) {
218 <<
"Recomputing viz for " << *
this <<
"\n";
225 LPlane plane(_vertices[0], _vertices[1], _vertices[2]);
226 LVector3 poly_normal = plane.get_normal();
248 triangles->add_vertices(0, 1, 2);
249 triangles->close_primitive();
250 triangles->add_vertices(0, 2, 3);
251 triangles->close_primitive();
253 _occluder_viz =
new Geom(vdata);
254 _occluder_viz->add_primitive(triangles);
257 lines->add_vertices(0, 1, 2, 3);
258 lines->add_vertex(0);
259 lines->close_primitive();
261 _frame_viz =
new Geom(vdata);
262 _frame_viz->add_primitive(lines);
265 return _occluder_viz;
273 if (_viz_tex ==
nullptr) {
276 _viz_tex =
new Texture(
"occluder_viz");
277 _viz_tex->setup_2d_texture(2, 2, Texture::T_unsigned_byte, Texture::F_luminance);
279 image.set_data(
"\x20\x80\x80\x20");
280 _viz_tex->set_ram_image(image);
281 _viz_tex->set_minfilter(SamplerState::FT_nearest);
282 _viz_tex->set_magfilter(SamplerState::FT_nearest);
286 if (viz_state ==
nullptr) {
287 viz_state = RenderState::make
288 (ColorAttrib::make_flat(LVecBase4(1.0f, 1.0f, 1.0f, 0.5f)),
289 TransparencyAttrib::make(TransparencyAttrib::M_alpha),
290 DepthOffsetAttrib::make(),
291 TextureAttrib::make(_viz_tex));
292 viz_state = viz_state->adjust_all_priorities(1);
297 state = viz_state->set_attrib(CullFaceAttrib::make(CullFaceAttrib::M_cull_none), 1);
299 state = viz_state->set_attrib(CullFaceAttrib::make(CullFaceAttrib::M_cull_clockwise), 1);
302 return state->compose(viz_state);
311 if (viz_state ==
nullptr) {
312 viz_state = RenderState::make
313 (ColorAttrib::make_flat(LVecBase4(0.0f, 0.0f, 0.0f, 1.0f)),
314 TextureAttrib::make_off());
315 viz_state = viz_state->adjust_all_priorities(1);
318 return data._state->compose(viz_state);
338 for (Vertices::const_iterator vi = _vertices.begin();
339 vi != _vertices.end();
341 (*vi).write_datagram(dg);
368 node->fillin(scan, manager);
379 PandaNode::fillin(scan, manager);
383 _vertices.reserve(num_vertices);
384 for (
int i = 0; i < num_vertices; i++) {
386 vertex.read_datagram(scan);
387 _vertices.push_back(vertex);
A container for geometry primitives.
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.
uint16_t get_uint16()
Extracts an unsigned 16-bit integer.
The smallest atom of cull.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
This defines a bounding sphere, consisting of a center and a radius.
virtual bool preserve_name() const
Returns true if the node's name has extrinsic meaning and must be preserved across a flatten operatio...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A class to retrieve the individual data elements previously stored in a Datagram.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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().
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
A node in the scene graph that can hold an occluder polygon, which must be a rectangle.
void add_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Sets the write row to a particular 3-component value, and advances the write row.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Defines a series of line strips.
virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data)
This function will be called during the cull traversal to perform any additional operations that shou...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Base class for objects that can be written to and read from Bam files.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
virtual PandaNode * make_copy() const
Returns a newly-allocated Node that is a shallow copy of this one.
void add_uint16(uint16_t value)
Adds an unsigned 16-bit integer to the datagram.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
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 record_object(CullableObject *object, const CullTraverser *traverser)
This callback function is intended to be overridden by a derived class.
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this node by the indicated matrix, if it means anything to do so.
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
CPT(RenderState) OccluderNode
Returns the RenderState to apply to the visualization.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_data2(PN_stdfloat x, PN_stdfloat y)
Sets the write row to a particular 2-component value, and advances the write row.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
Defines a series of disconnected triangles.
virtual bool is_renderable() const
Returns true if there is some value to visiting this particular node during the cull traversal for an...
static void register_with_read_factory()
Tells the BamReader how to create objects of type OccluderNode.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool around(const GeometricBoundingVolume **first, const GeometricBoundingVolume **last)
Resets the volume to enclose only the volumes indicated.
is_double_sided
Is this occluder double-sided.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void output(std::ostream &out) const
Writes a brief description of the node to the indicated output stream.
PT(Geom) OccluderNode
Returns a Geom that represents the visualization of the OccluderNode, as seen from the front.
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A basic node of the scene graph or data graph.
A thread; that is, a lightweight process.
CullHandler * get_cull_handler() const
Returns the object that will receive the culled Geoms.
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,...