Ah sorry, I guess you are not using Halo's code then. Have a look in the 3d samples folder under halo and meshfx.
Anyway this is the wrapvalue function he uses...
Edit... Well although that is elegant, it still has some issues so I am looking to improve it, particularly when lo is negative and hi is positive or hi or lo are large numbers. I can't currently figure out how to modify it though so here is an alternative
Here is another amended and more simplified version of the ripple function.
In fact as this is pretty cylinder specific we can change it to deal with the end caps.
In fact I now see you are probably using the ripplemesh code on the archives, which is very much a different kettle of fish. I guess you could do something like that with a seamed mesh, but you will have to preprocess the mesh information to capture verts into a list of some sort and ensure coincident verts receive identical transforms, unless of course you can otherwise ensure that verts with the same X Y and Z will receive the same transform, which is something to ponder.
Anyway this is the wrapvalue function he uses...
;==================== Function wrapvalue#(value#,lo#,hi#) i=Floor(value/(hi-lo)) r#=i*(hi-lo) Return (value-r)+lo End Function
Edit... Well although that is elegant, it still has some issues so I am looking to improve it, particularly when lo is negative and hi is positive or hi or lo are large numbers. I can't currently figure out how to modify it though so here is an alternative
Function wrapvalue#(value#,low#,high#) If value<low Then value=high-(low-value) Mod (high-low) If value>=high Then value=low+(value-high) Mod (high-low) Return value End Function
Here is another amended and more simplified version of the ripple function.
; Halo's ripple mesh code modified for use with Todd Riggins Segmented cylinder. ;========================================================== Function ripple(mesh,omesh,depth#=0.1,speed#=0.1,freq#=200) Local k,surf,surf2,index,add#,pos#,newx#,newy#,newz#,time=MilliSecs() And $FFFFFF For k=1 To CountSurfaces(mesh) surf=GetSurface(mesh,k) surf2=GetSurface(omesh,k) For index=0 To CountVertices(surf)-1 newy#=VertexY(surf2,index) pos#=newy*freq add#=Sin(wrapvalue(pos+time*speed,0,360))*depth newx#=VertexX(surf2,index)+add*VertexNX(surf2,index) newz#=VertexZ(surf2,index)+add*VertexNZ(surf2,index) VertexCoords surf,index,newx,newy,newz Next Next UpdateNormals mesh End Function
In fact as this is pretty cylinder specific we can change it to deal with the end caps.
; Halo's ripple mesh code modified for use with Todd Riggins Segmented cylinder. ;========================================================== Function ripple(mesh,omesh,depth#=0.1,speed#=0.1,freq#=200) Local k,surf,surf2,index,add#,pos#,newx#,newy#,newz#,mag# Local time=MilliSecs() And $FFFFFF For k=1 To CountSurfaces(mesh) surf=GetSurface(mesh,k) surf2=GetSurface(omesh,k) verts=CountVertices(surf)-1 For index=0 To verts newx = VertexX(surf2,index) newy = VertexY(surf2,index) newz = VertexZ(surf2,index) pos = newy * freq add = Sin(wrapvalue(pos+time*speed,0,360)) * depth mag = Sqr(newx*newx+newz*newz) newx = newx + add * newx * mag newz = newz + add * newz * mag VertexCoords surf,index,newx,newy,newz Next Next UpdateNormals mesh End Function
In fact I now see you are probably using the ripplemesh code on the archives, which is very much a different kettle of fish. I guess you could do something like that with a seamed mesh, but you will have to preprocess the mesh information to capture verts into a list of some sort and ensure coincident verts receive identical transforms, unless of course you can otherwise ensure that verts with the same X Y and Z will receive the same transform, which is something to ponder.