Panda3D
|
This class draws a visible representation of the NURBS curve stored in its NurbsCurveEvaluator. More...
#include "ropeNode.h"
Classes | |
class | CData |
class | CurveVertex |
Public Types | |
enum | NormalMode { NM_none, NM_vertex } |
enum | RenderMode { RM_thread, RM_tape, RM_billboard, RM_tube } |
enum | UVMode { UV_none, UV_parametric, UV_distance, UV_distance2 } |
Public Member Functions | |
RopeNode (const string &name) | |
void | clear_matrix () |
Resets the node's matrix to identity. | |
virtual bool | cull_callback (CullTraverser *trav, CullTraverserData &data) |
This function will be called during the cull traversal to perform any additional operations that should be performed at cull time. | |
virtual TypeHandle | force_init_type () |
NurbsCurveEvaluator * | get_curve () const |
Returns the curve represented by the RopeNode. | |
const LMatrix4 & | get_matrix () const |
Returns the optional matrix which is used to transform each control vertex after it has been transformed into the RopeNode's coordinate space, but before the polygon vertices are generated. | |
NormalMode | get_normal_mode () const |
Returns the kind of normals to generate for the rope. | |
int | get_num_slices () const |
Returns the number of radial subdivisions to make if RenderMode is RM_tube. | |
int | get_num_subdiv () const |
Returns the number of subdivisions per cubic segment to draw. | |
RenderMode | get_render_mode () const |
Returns the method used to render the rope. | |
PN_stdfloat | get_thickness () const |
Returns the thickness of the rope. | |
const LVector3 & | get_tube_up () const |
Returns the normal vector used to control the "top" of the curve, when RenderMode is RM_tube. | |
virtual TypeHandle | get_type () const |
bool | get_use_vertex_color () const |
Returns the "use vertex color" flag. | |
bool | get_use_vertex_thickness () const |
Returns the "use vertex thickness" flag. | |
bool | get_uv_direction () const |
Returns true if the rope runs down the U coordinate of the texture, or false if it runs down the V coordinate. | |
UVMode | get_uv_mode () const |
Returns the algorithm to use to generate UV's for the rope. | |
PN_stdfloat | get_uv_scale () const |
Returns the scaling factor to apply to generated UV's for the rope. | |
bool | has_matrix () const |
Returns true if the node has a matrix set, false otherwise. | |
virtual bool | is_renderable () const |
Returns true if there is some value to visiting this particular node during the cull traversal for any camera, false otherwise. | |
virtual PandaNode * | make_copy () const |
Returns a newly-allocated Node that is a shallow copy of this one. | |
virtual void | output (ostream &out) const |
Outputs the Namable. | |
void | reset_bound (const NodePath &rel_to) |
Recomputes the bounding volume. | |
virtual bool | safe_to_transform () const |
Returns true if it is generally safe to transform this particular kind of Node by calling the xform() method, false otherwise. | |
void | set_curve (NurbsCurveEvaluator *curve) |
Sets the particular curve represented by the RopeNode. | |
void | set_matrix (const LMatrix4 &matrix) |
Specifies an optional matrix which is used to transform each control vertex after it has been transformed into the RopeNode's coordinate space, but before the polygon vertices are generated. | |
void | set_normal_mode (NormalMode normal_mode) |
Specifies the kind of normals to generate for the rope. | |
void | set_num_slices (int num_slices) |
Specifies the number of radial subdivisions to make if RenderMode is RM_tube. | |
void | set_num_subdiv (int num_subdiv) |
Specifies the number of subdivisions per cubic segment (that is, per unique knot value) to draw in a fixed uniform tesselation of the curve. | |
void | set_render_mode (RenderMode render_mode) |
Specifies the method used to render the rope. | |
void | set_thickness (PN_stdfloat thickness) |
Specifies the thickness of the rope, in pixels or in spatial units, depending on the render mode. | |
void | set_tube_up (const LVector3 &tube_up) |
Specifies a normal vector, generally perpendicular to the main axis of the starting point of the curve, that controls the "top" of the curve, when RenderMode is RM_tube. | |
void | set_use_vertex_color (bool flag) |
Sets the "use vertex color" flag. | |
void | set_use_vertex_thickness (bool flag) |
Sets the "use vertex thickness" flag. | |
void | set_uv_direction (bool u_dominant) |
Specify true to vary the U coordinate down the length of the rope, or false to vary the V coordinate. | |
void | set_uv_mode (UVMode uv_mode) |
Specifies the algorithm to use to generate UV's for the rope. | |
void | set_uv_scale (PN_stdfloat scale) |
Specifies an additional scaling factor to apply to generated UV's along the rope. | |
virtual void | write (ostream &out, int indent_level=0) const |
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 Public Member Functions | |
static TypeHandle | get_class_type () |
static int | get_vertex_color_dimension () |
Returns the numeric extended dimension in which the color components should be found. | |
static int | get_vertex_thickness_dimension () |
Returns the numeric extended dimension in which the thickness component should be found. | |
static void | init_type () |
static void | register_with_read_factory () |
Tells the BamReader how to create objects of type RopeNode. | |
Protected Member Functions | |
RopeNode (const RopeNode ©) | |
virtual void | compute_internal_bounds (CPT(BoundingVolume)&internal_bounds, int &internal_vertices, int pipeline_stage, Thread *current_thread) const |
Called when needed to recompute the node's _internal_bound object. | |
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 BamFile for the new RopeNode. | |
Static Protected Member Functions | |
static TypedWritable * | make_from_bam (const FactoryParams ¶ms) |
This function is called by the BamReader's factory when a new object of type RopeNode is encountered in the Bam file. |
This class draws a visible representation of the NURBS curve stored in its NurbsCurveEvaluator.
It automatically recomputes the curve every frame.
This is not related to NurbsCurve, CubicCurveseg or any of the ParametricCurve-derived objects in this module. It is a completely parallel implementation of NURBS curves, and will probably eventually replace the whole ParametricCurve class hierarchy.
Definition at line 38 of file ropeNode.h.
void RopeNode::clear_matrix | ( | ) | [inline] |
Resets the node's matrix to identity.
See set_matrix().
Definition at line 443 of file ropeNode.I.
References LMatrix4f::ident_mat().
void RopeNode::compute_internal_bounds | ( | CPT(BoundingVolume)& | internal_bounds, |
int & | internal_vertices, | ||
int | pipeline_stage, | ||
Thread * | current_thread | ||
) | const [protected, virtual] |
Called when needed to recompute the node's _internal_bound object.
Nodes that contain anything of substance should redefine this to do the right thing.
Reimplemented from PandaNode.
Definition at line 257 of file ropeNode.cxx.
bool RopeNode::cull_callback | ( | CullTraverser * | trav, |
CullTraverserData & | data | ||
) | [virtual] |
This function will be called during the cull traversal to perform any additional operations that should be performed at cull time.
This may include additional manipulation of render state or additional visible/invisible decisions, or any other arbitrary operation.
Note that this function will *not* be called unless set_cull_callback() is called in the constructor of the derived class. It is necessary to call set_cull_callback() to indicated that we require cull_callback() to be called.
By the time this function is called, the node has already passed the bounding-volume test for the viewing frustum, and the node's transform and state have already been applied to the indicated CullTraverserData object.
The return value is true if this node should be visible, or false if it should be culled.
Reimplemented from PandaNode.
Definition at line 150 of file ropeNode.cxx.
References WorkingNodePath::get_node_path().
void RopeNode::fillin | ( | DatagramIterator & | scan, |
BamReader * | manager | ||
) | [protected, virtual] |
This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new RopeNode.
Reimplemented from PandaNode.
Definition at line 984 of file ropeNode.cxx.
References PiecewiseCurve::fillin(), and BamReader::read_cdata().
Referenced by make_from_bam().
NurbsCurveEvaluator * RopeNode::get_curve | ( | ) | const [inline] |
Returns the curve represented by the RopeNode.
Definition at line 81 of file ropeNode.I.
const LMatrix4 & RopeNode::get_matrix | ( | ) | const [inline] |
Returns the optional matrix which is used to transform each control vertex after it has been transformed into the RopeNode's coordinate space, but before the polygon vertices are generated.
Definition at line 470 of file ropeNode.I.
RopeNode::NormalMode RopeNode::get_normal_mode | ( | ) | const [inline] |
Returns the kind of normals to generate for the rope.
This is only applicable when the RenderMode is set to RM_tube.
Definition at line 208 of file ropeNode.I.
int RopeNode::get_num_slices | ( | ) | const [inline] |
Returns the number of radial subdivisions to make if RenderMode is RM_tube.
It is ignored in the other render modes. See set_num_slices().
Definition at line 343 of file ropeNode.I.
int RopeNode::get_num_subdiv | ( | ) | const [inline] |
Returns the number of subdivisions per cubic segment to draw.
See set_num_subdiv().
Definition at line 310 of file ropeNode.I.
RopeNode::RenderMode RopeNode::get_render_mode | ( | ) | const [inline] |
Returns the method used to render the rope.
See set_render_mode().
Definition at line 106 of file ropeNode.I.
PN_stdfloat RopeNode::get_thickness | ( | ) | const [inline] |
const LVector3 & RopeNode::get_tube_up | ( | ) | const [inline] |
Returns the normal vector used to control the "top" of the curve, when RenderMode is RM_tube.
See set_tube_up().
Definition at line 239 of file ropeNode.I.
bool RopeNode::get_use_vertex_color | ( | ) | const [inline] |
Returns the "use vertex color" flag.
Definition at line 269 of file ropeNode.I.
bool RopeNode::get_use_vertex_thickness | ( | ) | const [inline] |
Returns the "use vertex thickness" flag.
See set_use_vertex_thickness().
Definition at line 375 of file ropeNode.I.
bool RopeNode::get_uv_direction | ( | ) | const [inline] |
Returns true if the rope runs down the U coordinate of the texture, or false if it runs down the V coordinate.
Definition at line 155 of file ropeNode.I.
RopeNode::UVMode RopeNode::get_uv_mode | ( | ) | const [inline] |
Returns the algorithm to use to generate UV's for the rope.
Definition at line 130 of file ropeNode.I.
PN_stdfloat RopeNode::get_uv_scale | ( | ) | const [inline] |
Returns the scaling factor to apply to generated UV's for the rope.
Definition at line 181 of file ropeNode.I.
int RopeNode::get_vertex_color_dimension | ( | ) | [inline, static] |
Returns the numeric extended dimension in which the color components should be found.
See NurbsCurveEvaluator::set_extended_vertex().
The color components will be expected at (n, n + 1, n + 2, n + 3).
Definition at line 285 of file ropeNode.I.
int RopeNode::get_vertex_thickness_dimension | ( | ) | [inline, static] |
Returns the numeric extended dimension in which the thickness component should be found.
See NurbsCurveEvaluator::set_extended_vertex().
Definition at line 388 of file ropeNode.I.
bool RopeNode::has_matrix | ( | ) | const [inline] |
Returns true if the node has a matrix set, false otherwise.
See set_matrix().
Definition at line 456 of file ropeNode.I.
bool RopeNode::is_renderable | ( | ) | const [virtual] |
Returns true if there is some value to visiting this particular node during the cull traversal for any camera, false otherwise.
This will be used to optimize the result of get_net_draw_show_mask(), so that any subtrees that contain only nodes for which is_renderable() is false need not be visited.
Reimplemented from PandaNode.
Definition at line 201 of file ropeNode.cxx.
PandaNode * RopeNode::make_copy | ( | ) | const [virtual] |
TypedWritable * RopeNode::make_from_bam | ( | const FactoryParams & | params | ) | [static, protected] |
void RopeNode::output | ( | ostream & | out | ) | const [virtual] |
Outputs the Namable.
This function simply writes the name to the output stream; most Namable derivatives will probably redefine this.
Reimplemented from PandaNode.
Definition at line 211 of file ropeNode.cxx.
References PandaNode::output().
void RopeNode::register_with_read_factory | ( | ) | [static] |
Tells the BamReader how to create objects of type RopeNode.
Reimplemented from PandaNode.
Definition at line 940 of file ropeNode.cxx.
References BamReader::get_factory(), PandaNode::make_from_bam(), and Factory< Type >::register_factory().
void RopeNode::reset_bound | ( | const NodePath & | rel_to | ) |
Recomputes the bounding volume.
This is normally called automatically, but it must occasionally be called explicitly when the curve has changed properties outside of this node's knowledge.
Definition at line 241 of file ropeNode.cxx.
References Thread::get_current_thread(), Thread::get_pipeline_stage(), and PandaNode::mark_internal_bounds_stale().
bool RopeNode::safe_to_transform | ( | ) | const [virtual] |
void RopeNode::set_curve | ( | NurbsCurveEvaluator * | curve | ) | [inline] |
Sets the particular curve represented by the RopeNode.
Definition at line 70 of file ropeNode.I.
void RopeNode::set_matrix | ( | const LMatrix4 & | matrix | ) | [inline] |
Specifies an optional matrix which is used to transform each control vertex after it has been transformed into the RopeNode's coordinate space, but before the polygon vertices are generated.
Definition at line 430 of file ropeNode.I.
void RopeNode::set_normal_mode | ( | RopeNode::NormalMode | normal_mode | ) | [inline] |
Specifies the kind of normals to generate for the rope.
This is only applicable when the RenderMode is set to RM_tube; in the other render modes, normals are never generated.
Definition at line 195 of file ropeNode.I.
void RopeNode::set_num_slices | ( | int | num_slices | ) | [inline] |
Specifies the number of radial subdivisions to make if RenderMode is RM_tube.
It is ignored in the other render modes.
Increasing this number increases the roundness of a cross-section of the tube. The minimum value for a dimensional tube is 3; setting it to 2 will get you a thin piece of tape (which is similar to RM_billboard, except it won't rotate to face the camera).
Definition at line 329 of file ropeNode.I.
void RopeNode::set_num_subdiv | ( | int | num_subdiv | ) | [inline] |
Specifies the number of subdivisions per cubic segment (that is, per unique knot value) to draw in a fixed uniform tesselation of the curve.
Definition at line 297 of file ropeNode.I.
void RopeNode::set_render_mode | ( | RopeNode::RenderMode | render_mode | ) | [inline] |
Specifies the method used to render the rope.
The simplest is RM_thread, which just draws a one-pixel line segment.
Definition at line 94 of file ropeNode.I.
void RopeNode::set_thickness | ( | PN_stdfloat | thickness | ) | [inline] |
Specifies the thickness of the rope, in pixels or in spatial units, depending on the render mode.
See set_render_mode().
The thickness may also be specified on a per-vertex basis. See set_use_vertex_thickness().
Definition at line 403 of file ropeNode.I.
void RopeNode::set_tube_up | ( | const LVector3 & | tube_up | ) | [inline] |
Specifies a normal vector, generally perpendicular to the main axis of the starting point of the curve, that controls the "top" of the curve, when RenderMode is RM_tube.
This is used to orient the vertices that make up the tube. If this vector is too nearly parallel with the starting direction of the curve, there may be a tendency for the whole tube to gimble-lock around its primary axis.
Definition at line 226 of file ropeNode.I.
void RopeNode::set_use_vertex_color | ( | bool | flag | ) | [inline] |
Sets the "use vertex color" flag.
When this is true, the R, G, B, A vertex color is assumed to be stored as the dimensions n + 0, n + 1, n + 2, n + 3, respectively, of the extended vertex values, where n is the value returned by get_vertex_color_dimension(). Use NurbsCurveEvaluator::set_extended_vertex() to set these values.
Definition at line 257 of file ropeNode.I.
void RopeNode::set_use_vertex_thickness | ( | bool | flag | ) | [inline] |
Sets the "use vertex thickness" flag.
When this is true, the vertex thickness is assumed to be stored as the dimension get_vertex_thickness_dimension(), of the extended vertex values. Use NurbsCurveEvaluator::set_extended_vertex() to set these values.
In this mode, the overall thickness is also applied as a scale to the vertex thickness. Not all render modes support vertex thickness.
Definition at line 363 of file ropeNode.I.
void RopeNode::set_uv_direction | ( | bool | u_dominant | ) | [inline] |
Specify true to vary the U coordinate down the length of the rope, or false to vary the V coordinate.
Definition at line 142 of file ropeNode.I.
void RopeNode::set_uv_mode | ( | RopeNode::UVMode | uv_mode | ) | [inline] |
Specifies the algorithm to use to generate UV's for the rope.
Definition at line 118 of file ropeNode.I.
void RopeNode::set_uv_scale | ( | PN_stdfloat | uv_scale | ) | [inline] |
Specifies an additional scaling factor to apply to generated UV's along the rope.
This scale factor is applied in whichever direction is along the rope, as specified by set_uv_direction().
Definition at line 169 of file ropeNode.I.
Writes the contents of this object to the datagram for shipping out to a Bam file.
Reimplemented from PandaNode.
Definition at line 951 of file ropeNode.cxx.
References BamWriter::write_cdata(), and PiecewiseCurve::write_datagram().