Have any of you guys done or is there a script out there that will generate a torus (not just the collition but the geometry aswell). I'm trying to draw the orbits of the planets in the solar system and I think a torus might be exactly what I need, the problem with importing it from Maya is that I need tori of diferent radius but when I scale, the thickness of the torus also increases.
thanks for the script steffen, StarManta, I haven't tried the line renderer much, but would it be easy to make it draw circles or ellipses?
attache the script to a gameobject. set the segmentRadius, tubeRadius, segments and tubes in the editor. If you push the play button the turos woud be created. if you need a wizard i can write you one.
Thanks Steffen, I got it working, but when I get close to the torus or at certain angles it becomes invisible, any clue why? I looked at the code and didn't see anything that could produce this behavior.
I was thinking that's the problem, but why would the torus disapear completely, usually when things get clipped by the camera planes just part of the mesh gets clipped, not the whole thing, that's what has me soo confused...
The script doesn't assign any normals as far as I can see. If I remember correctly, Unity assigns a (0, 0, 1) normal by default to each vertex (same as Vector3.forward), which will make the shading go wrong. All faces will be shaded exactly the same and the lightness will depend on the angle between the light source and the object. Since you are doing a planetary motion thing, would I be right in thinking your background colour is black? Your torus would appear black (and therefore invisible against the background) if it were rotated to face exactly away from the light source. Unless you want the shaded, tube-like effect of the torus then it probably would be best to use a LineRenderer for this task. Wikipedia has a page with the equations for drawing an ellipse - the parametric version is probably the easiest way to generate the verts for the LineRenderer and also to plot the path to animate the motion of the planets.
You could try putting in a Mesh.RecalculateNormals(); line in there (probably near RecalculateBounds(). --Eric
Inserting mesh.RecalculateNormals(); just below RecalculateBounds(); worked for me. Thx for the nice script.
Hi, Guys. This is an old post, but I think it is still important. The script to create the ring is very useful. Congratulations. I've made some changes to possiblity to manipulate the ring's parameters outside the script. I hope it helps.
Thanks for the scripts, Steffen and thieberson! I started simplifying them earlier though and they ended up with 30+ fewer lines of code. xD I'm pretty sure they'll run faster, but they're definitely at least smaller and less memory intensive. Both simplified scripts are in the zip. I did verify myself that the end result is the exact same for the default parameters, but let me know if there are any problems in either of them!
Hey there, I'd just like to add my thanks to everybody here for making my life so much easier today! In the off chance it'll be useful to anybody else searching around, I've made a Playmaker action based on what's already been done here: http://hutonggames.com/playmakerforum/index.php?topic=11786.0 Cheers, Nick
Hey everyone, I really needed a torus shape in my current project, and I stumbled upon this script. After trying it out I was still not satisfied. I was looking for something that would allow me to create a torus like any other basic shape such as a cube, sphere, or capsule. After some tinkering using the scripts provided in the zip posted by zoller27osu, I have made a fully functional editor script for this exact purpose. Optimization It might not be as optimized as it used to be. I welcome anyone to take a look at my edits and improve on it. How to use To create a torus, go to the menu at top of the Unity window: 1. GameObject 2. 3D Object 3. Torus Other info This script collection has a README file attached that explains how to use it.