|
Post by GuppyB on Jul 22, 2005 22:37:30 GMT -5
I was just fooling around and I liked how this came out...
' Ocean Wave Demo ' by GuppyB
Dim Wave#(44)(34) dim oldtick, dtime#, newtick dim degree# dim i,j const mult# = 1.0 / 32.0 dim texture dim fogcolor#(4) fogcolor#(0)=1.0:fogcolor#(1)=1.0:fogcolor#(2)=1.0:fogcolor#(3)=1.0
texture = LoadMipmapTexture ("Textures/water.bmp") if texture = 0 then print "Failed to load texture": end: endif
glEnable (GL_CULL_FACE) glEnable (GL_Texture_2d) oldtick = tickcount() degree# = 360.0 glEnable (GL_FOG) glFogf (GL_FOG_END, 30.0) glClearColor(1.0,1.0,1.0,0) glFogf (GL_FOG_MODE, GL_LINEAR) glFogfv (GL_FOG_Color, fogcolor# )
while true newtick = tickcount() dtime# = (newtick - oldtick) * 0.001 oldtick = newtick glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) glLoadIdentity() glBindTexture(GL_TEXTURE_2D,texture) glTranslatef(0.0,-3.0,-16.0) gosub drawWaves
SwapBuffers () degree# = degree# - (dtime# * 16.0) if degree# <= 0.0 then degree# = 360.0: endif wend drawWaves:
for i = 0 to 43 for j = 0 to 33 wave#(i)(j) = cosd(((mult# * 90.0) * i) + degree#)+ sind(((mult# * 90.0) * j)+ degree#) wave#(i)(j) = wave#(i)(j) + (cosd(((mult# * 180.0) * i) + ((mult# * 180.0) * j) + (degree#*2.0))/2.0) wave#(i)(j) = wave#(i)(j) + (cosd(((mult# * 360.0) * i) + ((mult# * 360.0) * j) + (degree#*4.0))/4.0) wave#(i)(j) = wave#(i)(j) + (cosd(((mult# * 720.0) * i) + (degree#*4.0))/4.0) next next for i = 0 to 42 for j = 0 to 32
glBegin(GL_quads) glTexCoord2f(0.0,0.0): glVertex3f((i)-22.0, wave#(i)(j) , (j)-17.0) glTexCoord2f(0.0,1.0): glVertex3f((i)-22.0, wave#(i)(j+1), (j)-16.0) glTexCoord2f(1.0,1.0): glVertex3f((i)-21.0, wave#(i+1)(j+1), (j)-16.0) glTexCoord2f(1.0,0.0): glVertex3f((i)-21.0, wave#(i+1)(j), (j)-17.0) glEnd()
next next
return
|
|
|
Post by Alan on Jul 23, 2005 6:18:20 GMT -5
wow, thats really good
dim texture, n# dim f_x, f_y, f_x2#, f_y2#, f_z#, f_y3#, f_y3a#, f_y3b# texture = loadtexture("Textures/r005.jpg") glEnable (GL_TEXTURE_2D) 'glEnable (GL_CULL_FACE)
glBindTexture(GL_TEXTURE_2D, texture) ' Select our texture
here: n# = n# + .04 glLoadIdentity() glTranslatef(32, -10, -64) for f_x = 1 to 32 gltranslatef(-64, 0, 2) for f_y = 1 to 32 f_x2# = (f_y * .03125) + .5 f_y2# = (f_x * .03125) + .5 f_z# = .5 - .015625 f_y3b# = f_y3a# f_y3a# = (sin((f_y * .5) + n#) + sin((f_y * .6) + (n# * .2)) + sin((f_y * .8) + (n# * .9))) gltranslatef(2, 0, 0) gosub face next next swapbuffers() glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) waittimer(10) goto here:
Face: glBegin(GL_QUADS) ' Front face f_y3# = f_y3b# glTexCoord2f(f_z# + f_x2#, f_z# + f_y2#): glVertex3f(-1, f_y3#, -1) ' Bottom left of the texture and quad f_y3# = f_y3a# glTexCoord2f((1 - f_z#) + f_x2#, f_z# + f_y2#): glVertex3f( 1, f_y3#, -1) ' Bottom right of the texture and quad glTexCoord2f((1 - f_z#) + f_x2#, (1 - f_z#) + f_y2#): glVertex3f( 1, f_y3#, 1) ' Top right of the texture and quad f_y3# = f_y3b# glTexCoord2f(f_z# + f_x2#, (1 - f_z#) + f_y2#): glVertex3f(-1, f_y3#, 1) ' Top left of the texture and quad glEnd() return
myne is not nearly as good but I thought Id post it here insted of make a new thread.
Thats really atmospheric though, and youve got it working in 2 directions.
Consider having black fog and a black background. Insted of white fog and a white background.
|
|
|
Post by GuppyB on Jul 23, 2005 9:02:10 GMT -5
The black fog/background makes the wave stand out better, but I'm still partial to the white because it's more atmospheric. I also changed the fog to an aqua blue and liked the results, just replace these two lines to read as below:
fogcolor#(0)=0.0:fogcolor#(1)=0.75:fogcolor#(2)=1.0:fogcolor#(3)=1.0
and
glClearColor(0.0,0.75,1.0,0.0)
I like the texture mapping on yours, and will probably fool around with mine a little more.
...G
|
|
|
Post by GuppyB on Jul 26, 2005 13:35:07 GMT -5
Something was bugging me about the wave and I finally realized what it was, the surface of the water wasn't moving. So this version adds that:
...G
' Ocean Wave Demo ' by GuppyB
Dim Wave#(44)(34) dim oldtick, dtime#, newtick dim degree# dim i,j const mult# = 1.0 / 32.0 dim texture dim surfacex#,surfacey# dim fogcolor#(4) fogcolor#(0)=0.0:fogcolor#(1)=0.75:fogcolor#(2)=1.0:fogcolor#(3)=1.0
texture = LoadMipmapTexture ("Textures/water.bmp") if texture = 0 then print "Failed to load texture": end: endif
glEnable (GL_CULL_FACE) glEnable (GL_Texture_2d) oldtick = tickcount() degree# = 360.0 glEnable (GL_FOG) glFogf (GL_FOG_END, 30.0) glClearColor(0.0,0.75,1.0,0.0) glFogf (GL_FOG_MODE, GL_LINEAR) glFogfv (GL_FOG_Color, fogcolor# )
while true newtick = tickcount() dtime# = (newtick - oldtick) * 0.001 oldtick = newtick glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) glLoadIdentity() glBindTexture(GL_TEXTURE_2D,texture) glTranslatef(0.0,-3.0,-16.0) gosub drawWaves
SwapBuffers () degree# = degree# - (dtime# * 16.0) if degree# <= 0.0 then degree# = 360.0: endif wend drawWaves:
for i = 0 to 43 for j = 0 to 33 wave#(i)(j) = cosd(((mult# * 90.0) * i) + degree#)+ sind(((mult# * 90.0) * j)+ degree#) wave#(i)(j) = wave#(i)(j) + (cosd(((mult# * 180.0) * i) + ((mult# * 180.0) * j) + (degree#*2.0))/2.0) wave#(i)(j) = wave#(i)(j) + (cosd(((mult# * 360.0) * i) + ((mult# * 360.0) * j) + (degree#*4.0))/4.0) wave#(i)(j) = wave#(i)(j) + (cosd(((mult# * 720.0) * i) + (degree#*4.0))/4.0) next next
surfacex# = surfacex# - (dtime# / 1.5 ) surfacey# = surfacey# - (dtime# / 1.5) if surfacex# <= 0.0 then surfacex# = surfacex# + 1.0:endif if surfacey# <= 0.0 then surfacey# = surfacey# + 1.0:endif for i = 0 to 42 for j = 0 to 32
glBegin(GL_quads) glTexCoord2f(surfacex#,surfacey#): glVertex3f((i)-22.0, wave#(i)(j) , (j)-17.0) glTexCoord2f(surfacex#,surfacey# + 1.0): glVertex3f((i)-22.0, wave#(i)(j+1), (j)-16.0) glTexCoord2f(surfacex# + 1.0,surfacey# + 1.0): glVertex3f((i)-21.0, wave#(i+1)(j+1), (j)-16.0) glTexCoord2f(surfacex# + 1.0,surfacey#): glVertex3f((i)-21.0, wave#(i+1)(j), (j)-17.0) glEnd()
next next
return
|
|
yuri
Newish
Posts: 15
|
Post by yuri on Jul 26, 2005 13:39:29 GMT -5
Each time better.
|
|
|
Post by jontm2010 on Jul 26, 2005 17:49:16 GMT -5
it'd make a cool screensaver, i like it
|
|
|
Post by GuppyB on Jul 27, 2005 12:47:23 GMT -5
Fog was bothering me, and that fact there was no background.... here's version 3 and I think I am finally pleased.
...G
' Ocean Wave Demo ' by GuppyB
Dim Wave#(44)(34) dim oldtick, dtime#, newtick dim degree# dim i,j const mult# = 1.0 / 32.0 dim texture, texture2 dim surfacex#,surfacey# dim fogcolor#(4) fogcolor#(0)=1.0:fogcolor#(1)=1.0:fogcolor#(2)=1.0:fogcolor#(3)=1.0
texture = LoadMipmapTexture ("Textures/water.bmp") if texture = 0 then print "Failed to load texture": end: endif
texture2 = LoadMipmapTexture ("Textures/r005.jpg") if texture2 = 0 then print "Failed to load texture": end: endif
glEnable (GL_CULL_FACE) glEnable (GL_Texture_2d) oldtick = tickcount() degree# = 360.0 glEnable (GL_FOG) glFogf (GL_FOG_END, 30.0) glClearColor(1.0,1.0,1.0,1.0) glFogf (GL_FOG_MODE, GL_LINEAR) glFogfv (GL_FOG_Color, fogcolor# )
while true newtick = tickcount() dtime# = (newtick - oldtick) * 0.001 oldtick = newtick glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) glLoadIdentity() glBindTexture(GL_TEXTURE_2D,texture) glTranslatef(0.0,-3.0,-16.0) gosub drawWaves glLoadIdentity() glBindTexture(GL_TEXTURE_2D,texture2) glTranslatef(0.0,0.0,-16.0) gosub DrawBackground
SwapBuffers () degree# = degree# - (dtime# * 16.0) if degree# <= 0.0 then degree# = 360.0: endif wend drawWaves:
for i = 0 to 43 for j = 0 to 33 wave#(i)(j) = cosd(((mult# * 90.0) * i) + degree#)+ sind(((mult# * 90.0) * j)+ degree#) wave#(i)(j) = wave#(i)(j) + (cosd(((mult# * 180.0) * i) + ((mult# * 180.0) * j) + (degree#*2.0))/2.0) wave#(i)(j) = wave#(i)(j) + (cosd(((mult# * 360.0) * i) + ((mult# * 360.0) * j) + (degree#*4.0))/4.0) wave#(i)(j) = wave#(i)(j) + (cosd(((mult# * 720.0) * i) + (degree#*4.0))/4.0) next next
surfacex# = surfacex# - (dtime# / 1.5 ) surfacey# = surfacey# - (dtime# / 1.5) if surfacex# <= 0.0 then surfacex# = surfacex# + 1.0:endif if surfacey# <= 0.0 then surfacey# = surfacey# + 1.0:endif for i = 0 to 42 for j = 0 to 32
glBegin(GL_quads) glTexCoord2f(surfacex#,surfacey#): glVertex3f((i)-22.0, wave#(i)(j) , (j)-17.0) glTexCoord2f(surfacex#,surfacey# + 1.0): glVertex3f((i)-22.0, wave#(i)(j+1), (j)-16.0) glTexCoord2f(surfacex# + 1.0,surfacey# + 1.0): glVertex3f((i)-21.0, wave#(i+1)(j+1), (j)-16.0) glTexCoord2f(surfacex# + 1.0,surfacey#): glVertex3f((i)-21.0, wave#(i+1)(j), (j)-17.0) glEnd()
next next
return
DrawBackground:
glBegin(GL_quads) glTexCoord2f(0.0,1.0): glVertex3f(-10.0, 8.0 ,3.0) glTexCoord2f(0.0,0.0): glVertex3f(-25.0,-6.0,-16.0) glTexCoord2f(1.0,0.0): glVertex3f(25.0,-6.0,-16.0) glTexCoord2f(1.0,1.0): glVertex3f(10.0,8.0,3.0) glEnd()
return
|
|
fenryl not logged in
Guest
|
Post by fenryl not logged in on Jul 27, 2005 13:06:27 GMT -5
geez... thats cool
|
|
|
Post by Guest on Aug 17, 2005 19:24:24 GMT -5
where's a texture
|
|
|
Post by guest on Aug 17, 2005 19:29:14 GMT -5
Oh i get it, cool. Stupid mixed-up directories.
|
|
|
Post by Richard West on Jan 15, 2006 0:48:17 GMT -5
|
|
|
Post by GuppyB on Jan 26, 2006 17:00:42 GMT -5
It's actually pretty simple, create a "standalone exe" and make sure that it is embedding the two source files. Then rename the file from "wave.exe" or whatever you call it to "wave.scr". Right click and "test" to make sure it is still working. The "esc" key will get you out of it (you would have to program in code to exit on mouse move or key hit, but that would be simple). Then right click and "Install" and it will appear in your screensaver list. Glad you enjoyed it.
...G
|
|
|
Post by HELP on Feb 1, 2006 10:20:45 GMT -5
it aint working for me.
|
|
|
Post by gaviero on Feb 1, 2006 14:19:18 GMT -5
Great work. I can't believe how little code was needed.
|
|
|
Post by Aldex on Apr 1, 2006 19:06:30 GMT -5
wow nice... i love it heh
|
|