Jump to content


moving particles in a conical spiral manner


6 replies to this topic

#1 empy_85

    New Member

  • Members
  • Pip
  • 4 posts

Posted 14 March 2011 - 07:45 PM

hi there,
i m trying to move particles in a conical spiral path from top to bottom which some thing looks like a tornado... in c++

so kindly help me in with a solution

cheers,
emphy

#2 alphadog

    DevMaster Staff

  • Moderators
  • 1716 posts

Posted 14 March 2011 - 08:05 PM

You have two problems. One, how to calculate a spiral path along a cone, and two, learning steering/flocking algorithms. The first is to simply write a function f(x,y,z) that behaves like an Archimedes spiral or some such. See Wikipedia for the math behind different spirals. Then, the right algorithm would allow you to move particles along the path. See http://www.red3d.com/cwr/boids/ as an example for the flocking of birds.

Of course, one should mention that tornadoes do not follow a single 3D spiral...
Hyperbole is, like, the absolute best, most wonderful thing ever! However, you'd be an idiot to not think dogmatism is always bad.

#3 Reedbeta

    DevMaster Staff

  • Administrators
  • 5311 posts
  • LocationSanta Clara, CA

Posted 14 March 2011 - 08:07 PM

1. Make the particles rotate around a circle (x = cos(theta), y = sin(theta), where theta is an angle that increases at a certain speed)
2. Make the circle get larger over time by scaling x and y.
3. Make the circle move up along the Z axis over time.
reedbeta.com - developer blog, OpenGL demos, and other projects

#4 TheNut

    Senior Member

  • Moderators
  • 1701 posts
  • LocationCyberspace

Posted 14 March 2011 - 09:37 PM

Here I am writing a lengthy reply about how to construct great looking tornadoes, but then looking at the OP question I realize Reed pretty much answered it...

/me back to work.
http://www.nutty.ca - Being a nut has its advantages.

#5 rouncer

    Senior Member

  • Members
  • PipPipPipPip
  • 2725 posts

Posted 15 March 2011 - 11:43 AM

Are you making rpg spell effects or what? ;)
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

#6 empy_85

    New Member

  • Members
  • Pip
  • 4 posts

Posted 15 March 2011 - 09:10 PM

no rouncer its a tornado effect

#7 TheNut

    Senior Member

  • Moderators
  • 1701 posts
  • LocationCyberspace

Posted 21 March 2011 - 05:41 AM

I was doing some more WebGL work and thought it would be interesting to do a tornado effect, so I came up with this.

Posted Image
Clicky-click


I believe the effect here closely mimics how things were done in Sacrifice and Giants: Citizen Kabuto. I'm using a Bezier curve to construct and animate the funnel. I didn't have any decent textures on hand to emit a particle cloud around the funnel (which would give it a nice puffy look), so you could say it's a naked twister ;)

I used 4 control points, which allows the tornado to bend in interesting ways. The screenshot below is an example I created in Blender. This curve has only 3 control points.

Posted Image

You can use the middle and ground points to control the twist and curve of the tornado, simulating ground wind.

You calculate the mesh by using a tubing algorithm (which primarily uses Reed's circular formula). The tubing algorithm is exactly how you would construct a cylinder. You construct multiple circles at each level in the curve. You can add as many levels as you want for more resolution, and each circle can have any number of points. Using the direction vector of the curve, you construct a circle around that point and then connect its edges with the next circle you will create in the curve. Each control point contains a radius, which defines the size of the tube at that point. You linearly interpolate that radius as you move along the curve. So in the example above, the ground point has a radius of 2, the middle has a radius of 5, and the top has a radius of 10.

The wireframe should look something like this.
Posted Image

Now all you have to do is write logic to move the tornado around. Due to the nature of Bezier curves and how the 3D meshes are constructed, you can also animate the birth of a tornado. You can display the top portion of the funnel and slowly build on it until it connects with the ground. Freebie effect.

On another note, this same algorithm can be used to generate trees.
http://www.nutty.ca - Being a nut has its advantages.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users