15 #include "sheetNode.h" 16 #include "cullTraverser.h" 17 #include "cullTraverserData.h" 18 #include "cullableObject.h" 19 #include "cullHandler.h" 20 #include "bamWriter.h" 21 #include "bamReader.h" 23 #include "datagramIterator.h" 24 #include "pStatTimer.h" 26 #include "geomTristrips.h" 27 #include "geomVertexWriter.h" 28 #include "boundingSphere.h" 29 #include "colorAttrib.h" 30 #include "renderState.h" 43 return new CData(*
this);
52 void SheetNode::CData::
66 void SheetNode::CData::
79 SheetNode(
const string &name) :
160 render_sheet(trav, data, result);
189 output(ostream &out)
const {
190 PandaNode::output(out);
193 out <<
" " << *surface;
195 out <<
" (no surface)";
205 write(ostream &out,
int indent_level)
const {
206 PandaNode::write(out, indent_level);
209 indent(out, indent_level + 2) << *surface <<
"\n";
211 indent(out, indent_level + 2) <<
"(no surface)\n";
227 do_recompute_bounds(rel_to, pipeline_stage, current_thread);
228 mark_internal_bounds_stale(current_thread);
241 int &internal_vertices,
243 Thread *current_thread)
const {
248 internal_bounds = bounds;
249 internal_vertices = 0;
258 do_recompute_bounds(
const NodePath &rel_to,
int pipeline_stage,
259 Thread *current_thread)
const {
273 DCAST_INTO_R(gbv, bound, bound);
274 gbv->
around(&verts[0], &verts[0] + verts.size());
295 CPT(GeomVertexFormat) format;
296 if (use_vertex_color) {
297 format = GeomVertexFormat::get_v3n3cpt2();
299 format = GeomVertexFormat::get_v3n3t2();
302 (
"sheet", format, Geom::UH_stream);
303 int expected_num_vertices = num_u_segments * (num_u_verts + 1) * num_v_segments * num_v_verts;
304 vdata->reserve_num_rows(expected_num_vertices);
311 for (
int ui = 0; ui < num_u_segments; ui++) {
312 for (
int uni = 0; uni <= num_u_verts; uni++) {
313 PN_stdfloat u0 = (PN_stdfloat)uni / (PN_stdfloat)num_u_verts;
316 for (
int vi = 0; vi < num_v_segments; vi++) {
317 for (
int vni = 0; vni < num_v_verts; vni++) {
318 PN_stdfloat v = (PN_stdfloat)vni / (PN_stdfloat)(num_v_verts - 1);
329 if (use_vertex_color) {
338 nassertv(vdata->get_num_rows() == expected_num_vertices);
342 int expected_num_tristrips = num_u_segments * num_u_verts * num_v_segments;
343 int expected_verts_per_tristrip = num_v_verts * 2;
345 int expected_prim_vertices = (expected_num_tristrips - 1) * (expected_verts_per_tristrip + strip->get_num_unused_vertices_per_primitive()) + expected_verts_per_tristrip;
347 strip->reserve_num_vertices(expected_prim_vertices);
349 int verts_per_row = num_v_segments * num_v_verts;
351 for (
int ui = 0; ui < num_u_segments; ui++) {
352 for (
int uni = 0; uni < num_u_verts; uni++) {
353 int row_start_index = ((ui * (num_u_verts + 1)) + uni) * verts_per_row;
355 for (
int vi = 0; vi < num_v_segments; vi++) {
356 for (
int vni = 0; vni < num_v_verts; vni++) {
357 int vert_index_0 = row_start_index + (vi * num_v_verts) + vni;
358 int vert_index_1 = vert_index_0 + verts_per_row;
359 strip->add_vertex(vert_index_0);
360 strip->add_vertex(vert_index_1);
362 strip->close_primitive();
366 nassertv(strip->get_num_vertices() == expected_prim_vertices);
369 geom->add_primitive(strip);
372 if (use_vertex_color) {
373 state = state->add_attrib(ColorAttrib::make_vertex());
378 data.get_internal_transform(trav));
419 parse_params(params, scan, manager);
420 node->fillin(scan, manager);
434 PandaNode::fillin(scan, manager);
virtual bool safe_to_transform() const
Returns true if it is generally safe to transform this particular kind of Node by calling the xform()...
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...
CullHandler * get_cull_handler() const
Returns the object that will receive the culled Geoms.
PN_stdfloat get_segment_v(int vi, PN_stdfloat v) const
Accepts a v value in the range [0, 1], and assumed to be relative to the indicated segment (as in eva...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
virtual PandaNode * make_copy() const
Returns a newly-allocated Node that is a shallow copy of this one.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
int get_pipeline_stage() const
Returns the Pipeline stage number associated with this thread.
void read_cdata(DatagramIterator &scan, PipelineCyclerBase &cycler)
Reads in the indicated CycleData object.
This defines a bounding sphere, consisting of a center and a radius.
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.
void add_data2(PN_stdfloat x, PN_stdfloat y)
Sets the write row to a particular 2-component value, and advances the write row. ...
void skip_pointer(DatagramIterator &scan)
Reads and discards a pointer value from the Bam file.
int get_num_u_subdiv() const
Returns the number of subdivisions per cubic segment to draw in the U direction.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
NurbsSurfaceEvaluator * get_surface() const
Returns the surface represented by the SheetNode.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Defines a series of triangle strips.
A lightweight class that can be used to automatically start and stop a PStatCollector around a sectio...
PN_stdfloat get_segment_u(int ui, PN_stdfloat u) const
Accepts a u value in the range [0, 1], and assumed to be relative to the indicated segment (as in eva...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
int get_num_v_segments() const
Returns the number of piecewise continuous segments within the surface in the V direction.
This class is an abstraction for evaluating NURBS surfaces.
void add_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w)
Sets the write row to a particular 4-component value, and advances the write row. ...
virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data)
This function will be called during the cull traversal to perform any additional operations that shou...
static Thread * get_current_thread()
Returns a pointer to the currently-executing Thread object.
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
A lightweight class that represents a single element that may be timed and/or counted via stats...
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
NodePath get_node_path() const
Constructs and returns an actual NodePath that represents the same path we have just traversed...
This class draws a visible representation of the NURBS surface stored in its NurbsSurfaceEvaluator.
The smallest atom of cull.
virtual void record_object(CullableObject *object, const CullTraverser *traverser)
This callback function is intended to be overridden by a derived class.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
The result of a NurbsSurfaceEvaluator.
A container for geometry primitives.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
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. ...
void eval_segment_point(int ui, int vi, PN_stdfloat u, PN_stdfloat v, LVecBase3 &point) const
Evaluates the point on the surface corresponding to the indicated value in parametric time within the...
int get_num_u_segments() const
Returns the number of piecewise continuous segments within the surface in the U direction.
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.
This is the base class for all three-component vectors and points.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
void eval_segment_normal(int ui, int vi, PN_stdfloat u, PN_stdfloat v, LVecBase3 &normal) const
As eval_segment_point, but computes the normal to the surface at the indicated point.
static void register_with_read_factory()
Tells the BamReader how to create objects of type SheetNode.
A thread; that is, a lightweight process.
virtual bool is_renderable() const
Returns true if there is some value to visiting this particular node during the cull traversal for an...
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
int get_num_v_subdiv() const
Returns the number of subdivisions per cubic segment to draw in the V direction.
void reset_bound(const NodePath &rel_to)
Recomputes the bounding volume.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
bool around(const GeometricBoundingVolume **first, const GeometricBoundingVolume **last)
Resets the volume to enclose only the volumes indicated.
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...
void eval_segment_extended_points(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d, PN_stdfloat result[], int num_values) const
Simultaneously performs eval_extended_point on a contiguous sequence of dimensions.
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
bool get_use_vertex_color() const
Returns the "use vertex color" flag.