creating toroidal meshes/objects

I originally started a thread with this title in the forum models but have been asked to raise the topic here because it is more appropriate.
(Incidentally I tried to get the thread transferred but could not find an administrator!)

Here was the questions as originally put:

I am a complete beginner with Blender. I have gotten into it because I want to create quite a number of toroidal meshes & objects. I wonder if someone with experience could help me choose an appropriate method for creating them.

I think I can define what I want to do but have no idea how to go about it!! Here is my explanation. I want to:

  1. Establish horizontal and vertical paths to define the central axis for building each toroidal mesh and object.

2 Define along the paths changing diameters for the toroidal object to be built around the central axis.

  1. Define along the paths changes to lighting to be applied

  2. It would be great if there were a way of doing this by creating a script - all ideas encouragement appreciated.

Subsequently I was asked for some more detail and added the following:

hank you for your helpful contribution.

Sorry I do not have a sketch but I will try and describe my target in a little more detail.

I feel you are pointing in the right direction for my purposes because the models do lend themselves to mathematical description. However when the model is fully described it needs to be converted into a reasonably fine mesh.

Toroidal object is, in their basic form can be described as a continuous circular tunnel - rather like a bagel (which is in reality not normally a circular but an elptical. The toroidal objects that I want to build are continuous solids or tunnels which maintain an open space around them! If you could get inside the “tunnel” there would be no way out. You can only go round and round within the continuous walls.

So the basic model is a tube following a path that loops back upon itself where the end joins back onto the beginning! In its most simple form the path of the toroid is defined by changes to its x & y axes whilst the z axis remains constant (e.g. a bagel). However for my purposes I also need to be able to change the z dimension. So the first step is to define a path (the toroidal path) in xyz dimensions and deduce a linear path index which can provide a reference for the second step.

In its most simple form “the tube” has the same diameter for its whole length and its outer shape is circular. However one may want the outer shape to take some other geometric form e.g. an ovoid (bagel like) when its outer shape is described by an eliptical path at an angle to the path of the toroid, or triangular where the outer shape might be described by three other paths each of which is defined by an angle and distance from the path of the toroid. However these dimensions will need to change along the toroidal path.

This leads me to the second step which is to be able to define the outer shape relative to the toroidal path and modify those dimensions by reference to a linear path index.

The third step would be to create a mesh and then manipulate that mesh to create additional features.

I then see the linear path index being used to control lighting and other tools.

At some stage I need to map photographic images to the surfaces.

I hope this explains what I want to achieve in a little more detail.

Ricky Blender then added:

I responded with:

Ricky suggested

So following up Ricky’s suggestion can any point me in the right direction.

I’ve not had time to properly read your post, but there is a tool to create a torus mesh. SpaceKEY -> Add -> Mesh -> Torus.

This actually runs a Python script called that can be found in the .blender/scripts folder. You might be able to use this script as a base for your own script and edit it to include the functionality that you need.

Detail can be added at the time the mesh is created or by using a subsurf modifier or through multires.

Hope this helps.

It does and sounds sensible. Hopefully I will be able to understand it.

Unfortunately the code is not well documented but as it is quite short I should be able to get my head around it. Looking at the code has helped and it made me rethink the problem. My goal at this stage is to define an approach that has a reasonably good chance of succeeding!!! is based on the assumption that the toroids it builds are a whole objects described in free space. Whereas I need to construct toroidal forms in which every element has to be defined by reference to a path. This tells me I cannot start with building toroidal forms until I have a path to refer to.

I have so far identified the project requires at least 7 working modes:

  1. scripts that can define and shape a path that links back to its starting point [ some mathematical models to generate basic shapes and control minimum and maximum degrees of proximity and separation of path elements in xyz space would be valuable]

  2. scripts that iteratively index the path (distance as proportion along the path expressed as a 32bit floating point # between >0 & <1 should do)

  3. scripts that generate path shape changes by reference to the index and map the directional changes to the index.

  4. scripts that define the shape of the toroidal form at every iteration and can do so by referencing the index and the directional changes at each point.

  5. creating a mesh from the shape.

  6. as you suggest detail modelling using subsurf or multires.

  7. surface mapping

Comments welcome

check here:
there’s a few toroid examples.

can you show a pic of what you want to do

would be easier to advice !


This is really difficult because the approach is not for a particular object but an object of type. So I am going to ask you to use your imagination by using analogy to describe the process I envisage.

STAGE ONE: Create the toroidal path:

First imagine taking a piece of string of dimension zero and length n (this will represent the toroidal path) and unravelling it in space. Magically everywhere you go the length you leave behind stays exactly where you let it go. You can create any path you choose and there are only three rules.

  1. The string must not touch against itself anywhere along its length.
  2. The end must join seamlessly to its start.
  3. You do not have to decide how long it is going to be until you finish.

Now mark the join.

You now have a toroidal path of length 1

STAGE TWO Create an index
Index the path proportionate to its length so that every point along it can be represented by a 32bit floating point number in the range 0-1. Call this “the index.”

You now have a toroidal path (your string) and can use the index to identify every point along the path. The index provides an association between an indexed position on the path and a position in xyz space. Both the index and xyz position are unique in our model.

STAGE THREE Fine tune the path
We now need to be able to fine tune the way the string rests in space. It would be great if we could move it about create curves and turns in a way that satisfies creative imagination. As it is moved, lengthened/shortened the index system needs to keep up with the changes we make. The string is always of length 1 because we are only interested in proportion and not actual dimension!! So we need tools that create curves/angles etc.

STAGE FOUR - Here comes the fun bit.
Using the index as a reference we start to build a model around the path. It is rather like building a boat-- lets erect a lot of frames first. At any point we choose we create two dimensional shapes which have the path at their centre points.
The rules are simple.

  1. Define the shape
  2. Place its centre point on the path ('the action point").
  3. Choose an algorythm to determine the direction (the active direction") in which the path is travelling in xyz space at the action point.
  4. Choose angles for the xy, xz & yz planes and place the shape relative to the active direction. We will call these “frames”.
    Go back to 1 and repeat as often as you wish.

STAGE FIVE: Build a mesh that connects the frames. Now we have a toroidal shape to play with.

STAGE 6; Do any subsurfing or multires we need

STAGE 7; Map to the surface.

It all sounds simple but the challenge is that every movement of the path or alteration to it will have repercussions on every other component. Every alteration to the frames will alter the mesh etc. It has to start from the path and the shape possibilities are infinite.

That is why I feel a drawing does not help… this needs to be imagined as an abstract concept until the modelling tool has been built.

My skill does not lie in python - I am primarily a photographer and an image maker so forgive me please if my way of expressing things does not meet your expectations.

Thank you for partaking and listening



It seems to me that using a bezier curve with a bevel object and a taper object might achieve most of what you want to do. One ommision from the existing tool is you are limited to only one shape with which to create the toroid.

Check out the section “Bevel and Taper Objects” on this page.

I’ve used this before and found it useful, but tricky to set up. Your proposal seems to be far more usable and the addition of functionality to change the shape of the bevel object would be useful for creating novel tunnel sections, for example.

Perhaps the implementation of this existing tool could provide inspiration for your proposal.

Thanks for your observation I am studying the Bezier & taper right now. You have indeed been inspirational and stimulated an idea for a valuable tool left out of the 7 stages.

A set of of scripts to create additional paths (lets call them “toroidal framework paths”) defining, in mathematical terms, a relationship for the toroidal framework paths, which is relative to the toroidal path. Each toroidal framework path would run between any two indexed points on the toroidal path. A minimum of three toroidal framework paths would be required between each pair of indexed points to generate a sectional toroidal framework as a basis for the mesh to be built in STAGE 5.

This would open an opportunity to create infinite twisting/waving/ expanding-contracting spirals and other forms capable of definition by mathematical formulae. Such a script needs methods to incorporate user defined mathematical routines (for generating the toroidal framework paths) and accept input for user defined index points that set the start and finish points for their creation along the toroidal path.

I am uncertain how one would deal with mesh creation where there are gaps in the mesh along the path – maybe this is an opportunity to revisit the draft, go back a couple of STAGES and think about introducing a default toroidal mesh (“auto-mesh”) to be built automatically after STAGE 1.

I am wondering if it would it be possible to devise an auto-mesh with the ability to meld itself onto section of mesh introduced into the model at a later stage.

This inclines me to the notion that a default mesh should be build on circular 2d objects centred on the toroidal path and at right angles to its path. The circle would need to be of a diameter fractionally less than 50% of the minimum gap to be maintained between toroidal paths. This would create a default tunnel shaped toroid. I would think that minimum gap might be best expressed as a proportion of the length of the toroidal path to facilitate scaling!!

This means envisaging two mesh building STAGES. Auto-mesh after STAGE ONE followed by a modification of the auto-mesh at STAGE 5 which incorporate the changes for those sections in the model where sectional toroidal frameworks have been introduced at STAGE 4A.

How is this coming along. Am I being clear?


I am going to be cheeky here.

Just wondering if there are any python gurus out there who might be sufficiently interested to volunteer to work communally with me on this on the strict understanding
(a) that I am a total ignoramus as far as python is concerned but am a fussy tester!!!.
(b) it must be open source

I think it could be done one module at a time.
Any volunteers for stage one?


just ot understand more about it

cause this looks like a big model with 100,000 of verticies?

can you give an idea on how many frames or index size we’are talking here and size ?

do you want this to be in real time ?

and just to know more about it

does it represent somethng physical real or just a sort of sci fi tunnel?

is this going to be a movie or just some realitme simulation?

and how to you intend to feed the new index location or rotation ?

Good luck

Yes you are right. I think there is no point in attempting this without planning for scaleability.

My inclination is towards having a database interface for the tool. I understand python has a good interface to mysql and other db’s. That way it becomes (almost) infinitely scaleable.

I would have thought frame building should be in realtime but mesh building should be switchable to either realtime or to be done when frame building is complete. That way users will be able to make an appropriate choice dependednt upon ram/processor configuration.

I see no reason why it cannot be used for both.

I can see how a movie maker could make good use of this tool. For me the use is to generate multiple still frames but I could see others using it for purposes such as building worlds for gamers where characters inhabit complex toroidal structures!

Not being a python person nor a sufficiently experienced in the inner workings of blender I am passing on this question for the moment-- not certain what you mean. Any chance of expanding on the problem so I can get my head around it?

I would like to continue the process of defining the objectives and hopefully engaging a few people who could help bring the concept to fruition when we have sufficient clarity.

Thanks for your interest


I’d kinda like to help out on this. It would be a great level designer for a tunnel based space shooter idea I’ve had in the planning stage for a while. I’ve tried the method of tunnel creation using curves and a bevel object but found the results nearly impossible to uv texture. I eventually fell back on creating a straight section of tunnel that was uv mapped and using duplicate and curve deform to create my tunnels, but this method is quite limited.

Support for splitting the toroidal structure down separate paths would be essential for this (think a figure of 8 dual torus), but I think this would be a relatively minor addition to the feature set of this project. Welding the toroidal meshes in a sensible way would be a challenge, but with the other functionality (and having implemented a way to weld toroidal meshes based on different source shapes along the length of the toroid) it should be fairly simple.

Unfortunately I’m engaged in a few other projects at the moment (all of which seem to be somehow related to the space shooter… I wonder if my subconscious is trying to tell me something?). If I can just get my head round hierarchies of quaternion rotations then I’d clear up a large amount of time in my schedule. Making progress and taking baby steps towards a solution, but it’s not a fast process. I’ve been messing with this for a few months and I’m so close to a final implementation that I keep getting distracted by the possibilities that will be available when it’s done.

Just for information, I’m a complete amateur who likes to mess about with code and 3d.


do you have a small sample file script python to do a little piece extrude along path showing how to

using the curve and bevel object

i’v been looking for a sample script like that for a while and did not find anything at all

would apprecaite if you could dig up a little sample of this script
would be interested in learning how to do that


@RickyBlender: Unfortunately, I couldn’t find any script that did this either. I don’t think that it is possible to use the curve and bevel object by script. I was having to define and apply the bevel object by hand. I was also having to go through a laborious duplicate, translate, duplicate, translate, etc… procedure by hand to create a tunnel using the curve deform modifier.

I believe that in Blender 2.5, the auto-generated python API defined by RNA will create Python bindings to tools such as the curve deform and the curve/bevel object/taper object. I’m really looking forward to trying my hand at creating some mesh editing and parametric mesh generation scripts when tools are accessible from Python.

Even simple tools that would be very useful such as triangulating a mesh and flipping normals are not currently available from Python as far as I can tell. I would love to be proved wrong in this. It is possible to recreate these tools in a script form, but they perform slower than the C code that runs when you use a Blender tool from the editor.