Rope texture?

Can a Rope be textured?
I cant seem to get it to work.

texture = loader.loadTexture('tex.png')
rope.setTexture(texture, 1)
#rope.setTexGen(TextureStage.getDefault(), TexGenAttrib.MPointSprite)
tex = loader.loadTexture('models/iron.jpg')
ropeNode = RopeNode('name')
ropeNP = render.attachNewNode(ropeNode)

Sorry, but I because of the nature of the textures, I need to render it as geomlines, not solid geometry.

GeomLines, of course, can only display a 1-by-N texture. TexGenAttrib.MPointSprite doesn’t make sense on a GeomLine either. But you can use ropeNode.setUvMode() to make the rope generate one-dimensional UV’s for you and then apply the one-dimensional texture of your choice.


I thought geomlines could display a 2d texture, if you set the tickness that is. GeomPoints do this to render sprites, so I thought why not. Would be great for effects such as lazers. I could use ordinary billboards, but that would be alot faster I’m guessing.

Nope. Nice guess, but GeomLines can’t do that. You’ll need to use polygons if you want textures to go across the width of the line. Try one of the other RM render modes, for instance RMBillboard or RMTube. They’re designed for exactly that purpose.

Also note that GeomLines aren’t particularly fast to render anyway. Polygons are generally faster, because the hardware doesn’t actually support thick lines–your driver has to simulate this, either by creating polygons on the fly or by rendering the entire line in software.


What I meant by fast is that with ordinary billboards the node is rotated to face the camera, I think this means that each ‘segment’ has to be a separate geom and having only few of such ropes with ten or twenty segments can already be a performance issue, not in a demo, but in a real game with other geoms perhaps.

Right, actually implementing a rope with a series of billboards would require many individual Geoms and be ridiculously expensive. But RMBillboard doesn’t do that; it animates the individual vertices instead, kind of like a particle system does. It’s not free, but it’s not too expensive, especially for a reasonably small number of vertices.


Then it might actually work for me.

Unlrelated, could I use RMBillboard on other things than Ropes?

No, these are the render implementations for RopeNode.

So would I need to reimplement that if I just used a node consisting of geomlines? Or is there another way?

Another way to do what? You’re not being very specific here. Of course there are many ways to draw something that looks like a laser beam.

But in terms of making a thick “line” which is actually a polygon whose vertices rotate towards the camera, you can either use RopeNode, or maybe MeshDrawer does this sort of thing too, or you can make up your own implementation.