ok, i had extrude the Wobble Code From the Demo
You can Find , a simple scene with the Wobble Mesh
and the code
I'll try to comment code, but not for All.. if you want more explain , ask me..
Ps: Of course there are no Hdr shader in this scene..
Set Display mode 1024,768,32
set window on
sync ON
sync rate 60
color backdrop 0,0
MaxCorde as integer = 20
Type ParamCorde
WobbleAngle as float
OldWobbleAngle as float
WobbleScale as float
WobbleMag as float
WobbleSpeed as float
ENDTYPE
dim Wob(maxcorde) as Paramcorde
Numcorde = 5000 `` 1 to maxcorde (default 20)
for i=1 to maxcorde
wob(i).WobbleAngle=0
wob(i).OldWobbleAngle=-0.1
wob(i).WobbleScale=1.0+(rnd(40)/10)
wob(i).WobbleMag=0.09
wob(i).WobbleSpeed=10.0+(rnd(10))
load object "data/3d/corde_96.3ds",Numcorde+i
set object diffuse Numcorde+i,rgb(rnd(255),rnd(255),rnd(255))
position object Numcorde+i,rnd(30)-15,rnd(30)-15,rnd(30)-5
rotate object Numcorde+i,rnd(360),0,0
next i
do
fps# = screen fps()
if fps#>0 then dt#=1/fps# else dt#=1/60.0
for i=1 to maxcorde
WobbleObject(Numcorde+i,i,dt#)
position object Numcorde+i,object position x(Numcorde+i),object position y(Numcorde+i),object position z(Numcorde+i)-0.1
if object position z(Numcorde+i)<camera position z()
position object Numcorde+i,rnd(30)-15,rnd(30)-15,rnd(30)-5
endif
next i
sync
loop
`#########################################################################################################
function WobbleObject(object as dword,Numbercorde,dt as float)
local x as dword
local PosX as float
local PosY as float
local PosZ as float
local Temp as float
lock vertexdata for limb object,1
for x = 0 to get vertexdata vertex count()
`Get vertex position
PosX = get vertexdata position x(x)
PosY = get vertexdata position y(x)
PosZ = get vertexdata position z(x)
`If mesh has been deformed previously
if wob(Numbercorde).OldWobbleAngle >= 0
`Find displacement of vertex depending on old angle and height of vertex
Temp = 1.0/(1.0-sin(wob(Numbercorde).OldWobbleAngle+(PosX/wob(Numbercorde).WobbleScale)*360)*wob(Numbercorde).WobbleMag)
`Scale vertex pos
PosY = get vertexdata position y(x)*Temp
rem PosZ = get vertexdata position z(x)*Temp
endif
`Find new displacement of vertex depending on angle and height of vertex
Temp = (1.0-(sin(wob(Numbercorde).WobbleAngle+(PosX/wob(Numbercorde).WobbleScale)*360)*wob(Numbercorde).WobbleMag))
`Scale vertex pos
PosY = PosY*Temp
rem PosZ = PosZ*Temp
`Set the position of vertex
set vertexdata position x,PosX,PosY,PosZ
next x
unlock vertexdata
`Store old angle and increase angle
wob(Numbercorde).OldWobbleAngle = wob(Numbercorde).WobbleAngle
wob(Numbercorde).WobbleAngle = wrapvalue(wob(Numbercorde).WobbleAngle+wob(Numbercorde).WobbleSpeed*dt/0.01)
endfunction