Flexible cylinder

I originally posted this question in the pipeline- but I think it may be better in the scripting issues section.
I have a cylindrical model that I’ve created procedurally. The model is composed of stacked rings, each ring has 8 vertices. I’ve procedurally created triangles to connect the rings. Is there a way to move the rings while maintaining the polygon connections to its neighbor rings? I want to be able to dynamically create bends in the cylindrical model. Can I parent a ring to a dummy node, and move the dummy node around? The trouble is that the cylindrical model is one node. I want to maintain the polygon connections but be able to dynamically change the rings positions.

I’m pretty sure this is possible somehow, I’m not sure the best way to implement it.

I’ve looked at using joints but this would make a type of snake - when you bend/displace one part it bends the rest of the cylinder. I want to be able to simply deform the cylinder dynamically.

I’m really not sure what you’re asking for, precisely, or why joints aren’t a satisfactory solution.

The bottom line is, a GeomNode is only one node. So any vertices that are attached to the GeomNode are always rendered in the coordinate space of that one node. You can move that node with scene graph operations, but then you will be moving all of its vertices as a unit.

If you want the vertices to move relative to each other, then you have to move the vertices through some mechanism other than through scene graph operations.

The use of joints is the most common way to achieve this. In fact, it’s possible to set up joints to follow nodes, so that you can move a particular node, and then the vertices of your geometry will follow those motions (even though the vertices are not directly parented to the node). This sounds to me like precisely what you’re asking for.

Another common way to achieve this is with the RopeNode, which can model a cylinder and move the vertices automatically along with the nodes that you specify. In this case, you don’t create the cylinder; you let the RopeNode do it for you. But it creates a snake-like tube, which is what you say you don’t want (but then I don’t understand what it is you do want).

If neither of the above suffices, then you need to use some other mechanism to move the vertices. Probably this will involve computing the appropriate transformation yourself and rewriting the vertices using a GeomVertexRewriter. If you have many vertices, this may be too slow to do in Python, but it’s well-suited for C++.


Thanks for the reply. As I read through your answer I think I’m not understanding the scene graph very well.

In my scenario, I’m procedurally drawing a tube/cylinder composed of stacked rings made of 8 vertices each. All I want to be able to do is to move a ring within that stack without moving the other rings. I want to move the vertices but maintain the polygon connections between the rings. During the generation phase my script makes a separate Geom and GeomNode or each ring- those GeomNodes are parented to a node that represents the entire tube. Can I just manipulate that Geom or GeomNode? That won’t cause problems with the polygon rendering?

Thanks again.

The problem in your idea is “maintain the polygon connection between the rings”. See, if you’re creating a separate GeomNode for each ring, then there isn’t really a polygon connection between the rings; there are only vertices in two different rings that happen to be in the same position. But when you move one of the rings, you will move all of its vertices by the same amount, and thus the vertices will no longer be in the same position.

If you want to move the ring without moving some of its vertices, so that the vertices remain in the same position as the vertices in the ring below, “maintaining the polygon connection”, then what it means is that you must move the ring, and then adjust those vertices by the inverse movement, so that they remain in the same position in world space.

This is, incidentally, what a joint does.


Ok, so how do I attached joint to a procedurally generated geomnode? I looked through the manual and it seems to mostly talk about controlling joints placed by modeling software.

Yes, it is hard to do. Joints are complex beasts. The easiest way is to create the geometry by creating an egg file dynamically, and then load the egg file. You can create the egg file in-memory using Python print statements, or using the EggData interface. (Assuming it really needs to be dynamic, of course–if it’s just the same cylinder you’re creating every time, you’re probably better off creating the egg file once, and just loading the same egg file over and over.)

But creating a dynamic egg file isn’t the fastest way to create geometry. If you really want to use the GeomVertexData et al interfaces to create joint-animated geometry, you have to do it the hard way. There was a longish thread here where Anon was asking a similar question recently.