from direct.showutil.Rope import Rope
This class defines a NURBS curve whose control vertices are defined based on points relative to one or more nodes in space, so that the “rope” will animate as the nodes move around. It uses the C++ RopeNode class to achieve fancy rendering effects like thick lines built from triangle strips.
Returns a list of len points, evenly distributed in parametric space on the rope, in the coordinate space of the Rope itself.
Recomputes the curve after its properties have changed. Normally it is not necessary for the user to call this directly.
setup(self, order, verts, knots=None)¶
This must be called to define the shape of the curve initially, and may be called again as needed to adjust the curve’s properties.
order must be either 1, 2, 3, or 4, and is one more than the degree of the curve; most NURBS curves are order 4.
verts is a list of (NodePath, point) tuples, defining the control vertices of the curve. For each control vertex, the NodePath may refer to an arbitrary node in the scene graph, indicating the point should be interpreted in the coordinate space of that node (and it will automatically move when the node is moved), or it may be the empty NodePath or None to indicate the point should be interpreted in the coordinate space of the Rope itself. Each point value may be either a 3-tuple or a 4-tuple (or a VBase3 or VBase4). If it is a 3-component vector, it represents a 3-d point in space; a 4-component vector represents a point in 4-d homogeneous space; that is to say, a 3-d point and an additional weight factor (which should have been multiplied into the x y z components).
verts may be a list of dictionaries instead of a list of tuples. In this case, each vertex dictionary may have any of the following elements:
‘node’ : the NodePath indicating the coordinate space ‘point’ : the 3-D point relative to the node; default (0, 0, 0) ‘color’ : the color of the vertex, default (1, 1, 1, 1) ‘thickness’ : the thickness at the vertex, default 1
In order to enable the per-vertex color or thickness, you must call rope.ropeNode.setUseVertexColor(1) or rope.ropeNode.setUseVertexThickness(1).
knots is optional. If specified, it should be a list of floats, and should be of length len(verts) + order. If it is omitted, a default knot string is generated that consists of the first (order - 1) and last (order - 1) values the same, and the intermediate values incrementing by 1.