Code archives/3D Graphics - Mesh/RippleMesh ( )

This code has been declared by its author to be Public Domain code.

Download source code

RippleMesh ( ) by Rob2003
Not optimised, but fun to use.
;set up
Graphics3D 640,480,16,2
camera=CreateCamera()
PositionEntity camera,0,0,-3
light=CreateLight()
RotateEntity light,45,45,0

;any mesh with enough verts
mymesh = CreateSphere(12)
EntityShininess mymesh,1

While Not KeyHit(1)
	RippleMesh(mymesh,1,20,0.01)
	UpdateWorld
	RenderWorld
	Flip
Wend
End

;mesh is your mesh
;speed is how fast it ripples
;density is how fine the effect is (experiment to see how much of the mesh you affect)
;depth is how much it ripples

Function ripplemesh(mesh,speed#,density#,depth#)
	count=MilliSecs()*speed
	For scount=1 To CountSurfaces(mesh)
		surface = GetSurface(mesh,scount)
		numverts=CountVertices(surface)-1
		For i=0 To numverts
			a#=Cos(count+(i*density))*speed
			b#=Sin(count+(i*density))*speed
			c#=-b;Sin(count+(i*density))*speed
			nx#=VertexNX(surface,i)*depth
			ny#=VertexNY(surface,i)*depth
			nz#=VertexNZ(surface,i)*depth			
			x#=VertexX(surface,i)
			y#=VertexY(surface,i)
			z#=VertexZ(surface,i)		
			VertexCoords surface,i,x#+(a*nx),y#+(b*ny),z#+(c*nz)
		Next
	Next
End Function

Comments

erbbysam2005
insanly usefull


Robert Cummings2012
I just popped back to see how I did this :P Searching google for my OWN code.


Code Archives Forum