wavvy ocean

Blitz3D Forums/Blitz3D Programming/wavvy ocean

Akat(Posted 2003) [#1]
hi guys...

anyone know how to code a big wavy ocean and a boat (or a cube) floating on it - imagine a demo from an implementation of 'SINBAD the movie'

- actually i try to convert it into a plugin within Max or Maya... so dull code will be fine..


RexRhino(Posted 2003) [#2]
Try taking a terrain, and manipulating each point on a terrain with a sine wav function over time. All the wavy water type stuff done in blitz that I have seen used something similiar.

You could make your own mesh I guess, but the LOD of the terrain would make it a lot nicer.


Akat(Posted 2003) [#3]
what about the floating cube? the simulation quite real like u can see in reactor water for 3DMAX


poopla(Posted 2003) [#4]
A terrain is a good idea for detail levels, but a semi high poly mesh would be faster I believe.


IPete2(Posted 2003) [#5]
Akat,

someone did a boat on a strecth of water demo - was it Open DNA? Check out Reda's stuff, possibly in the archives?

I'll check my pc - I have a store of older stuff for this kind of occasion!

IPete2.


Akat(Posted 2003) [#6]
huh.. Open DNA already Close DNA right?... i had a lil' of them but didnt notice 'this' demo...

btw, can u put the link here?


GfK(Posted 2003) [#7]
Try this. No sourcecode tho - I think the author got the code for the water out of the blitzcoder archives. You might want to ask him bout it.


Shambler(Posted 2003) [#8]
Heres a simple demo to get you started



Type water
Field mesh
Field surf
Field size
Field wavedensity
Field wavespeed
End Type

Graphics3D 800,600,32
SetBuffer BackBuffer()
WireFrame True

camera=CreateCamera()
look=CreatePivot()
PositionEntity camera,50,10,10
PositionEntity look,50,0,25
PointEntity camera,look

;createwater meshsize,wavedensity,wavespeed
createwater(100,10,10)

While Not KeyHit(1)
updatewater(MilliSecs())
RenderWorld

Text 0,0,"Simple non random wave motion"
Flip
Wend

Function createwater(s,wd,ws)

w.water=New water
w\size=s
w\wavedensity=wd
w\wavespeed=ws
w\mesh=CreateMesh()
w\surf=CreateSurface(w\mesh)
v=0
For x=0 To w\size
For z=0 To w\size
AddVertex w\surf,x,0,z, x,z,0.5
v=v+1
Next
Next
zs=w\size+1
zm=w\size-1
rd=0
For z=0 To zm 
For v=0 To w\size-1
AddTriangle w\surf,rd+v,rd+v+1,rd+v+1+w\size
AddTriangle w\surf,rd+v+1+w\size,rd+v+1,rd+v+w\size+2
Next
rd=rd+zs
Next
UpdateNormals(w\mesh)
EntityColor w\mesh,150,200,255
End Function

Function updatewater(move)
For w.water=Each water
v=0
For x=0 To w\size
For z=0 To w\size
h#=(Sin(w\wavedensity*x+move/w\wavespeed)+Cos(w\wavedensity*z+move/w\wavespeed))
VertexCoords w\surf,v,x,h#,z
v=v+1
Next
Next
Next
End Function




IPete2(Posted 2003) [#9]
Akat,

Right m8! Got the demo I was talking about (or at least one of them).

This one has a couple of balls/bouys in the water, the red one floats I think.

Not sure who is the author.

http://www.smartscreenuk.com/water.zip

IPete2.


TartanTangerine (was Indiepath)(Posted 2003) [#10]
Have a look at the one I put together. The original code was from OpenDNA - I've optimised it and added the boat etc...

http://www.blitzcoder.com/cgi-bin/showcase/showcase_showentry.pl?id=flynn07282003184232&comments=no


IPete2(Posted 2003) [#11]
Flynn,

Top man! Ta!

IPete2.


Akat(Posted 2003) [#12]
whoa Flynn... great! just what i needed - i'll optimize it and try to convert it into C/C++ code to suit Maya mel script - i'll let u know if i'm done...