Whirlpool effect

Blitz3D Forums/Blitz3D Programming/Whirlpool effect

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Cool!
There's another one here but I can't remember the author of this code. Possibly FredBorg(?)
Use this image for a nice effect:

; Vortex demo.
; Creates custom cone.  Apex of cone <===> center of texture.
; Oriented so apex is on z+ axis, interior of cone is visible.

Graphics3D 640, 480

tx = LoadTexture("vortex2.jpg") ; image should be square, perhaps 256 x 256.
VortexCone = createVortexCone(24,32) ; try different heights
EntityTexture VortexCone, tx
EntityFX VortexCone, 1 ; full bright

cam = CreateCamera( )
PositionEntity cam, 0,0,-3
CameraZoom cam, 3.8 ; zoom >= 3.8 fills the screen

While Not KeyDown(1)
 TurnEntity VortexCone, 0,0, -.26
 RenderWorld : Flip
Wend
End

Function CreateVortexCone(segments=24,height=1)
 Local n, m,s, a#,t#, u#,v# 
 m=CreateMesh()
 s=CreateSurface(m)
 a=360.0/segments
 ; First two vertices are apex and one point on the base.
 AddVertex s,0,0,height,0.5,0.5     ; vertex 0
 AddVertex s,Cos(t),Sin(t),0,1,0.5  ; vertex 1
 For n=2 To segments
  t=t+a : u=(1+Cos(t))/2 : v=(1-Sin(t))/2
  AddVertex s,Cos(t),Sin(t),0,u,v  ; vertex n
  AddTriangle s,0,n,n-1
 Next 
 AddTriangle s,0,1,n-1
 Return m
End Function