March 08, 2021, 12:12:50 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
3D Graphics - Effects
»
[bb] RIPPLE EFFECT by Nate the Great [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bb] RIPPLE EFFECT by Nate the Great [ 1+ years ago ] (Read 708 times)
BlitzBot
Jr. Member
Posts: 1
[bb] RIPPLE EFFECT by Nate the Great [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:38 AM »
Title :
RIPPLE EFFECT
Author :
Nate the Great
Posted :
1+ years ago
Description :
This is a program I made that adds a ripple effect to pictures. I just thought this looked cool
Code :
Code: BlitzBasic
Graphics3D
1440
,
900
,
0
,
1
ShowPointer
(
)
tex =
LoadTexture
(
"desktoppic1.bmp"
)
;PUT YOUR PICTURE HERE
Type
ripples
Field
x#,y#,dist#
End Type
cam =
CreateCamera
(
)
TurnEntity
cam,
90
,
0
,
0
MoveEntity
cam,
0
,
0
,-
2.9
CameraZoom
cam,
5
lit =
CreateLight
(
)
TurnEntity
lit,
90
,
0
,
0
;135,0,0
square =
CreateMesh
(
)
EntityPickMode
square,
2
ripsurf =
CreateSurface
(
square
)
numverts =
50
Dim
verts
(
numverts,numverts
)
For
x# =
0
To
numverts
For
y# =
0
To
numverts
verts
(
x,y
)
=
AddVertex
(
ripsurf,x#/numverts-.5,
0
,y#/numverts-.5,x#/numverts,-y#/numverts+
1
)
Next
Next
For
y =
0
To
numverts-
1
For
x =
0
To
numverts-
1
AddTriangle
(
ripsurf,verts
(
x,y
)
,verts
(
x,y+
1
)
,verts
(
x+
1
,y
)
)
AddTriangle
(
ripsurf,verts
(
x+
1
,y+
1
)
,verts
(
x+
1
,y
)
,verts
(
x,y+
1
)
)
Next
Next
; We have a one-sided square with no normals defined. Now apply quick and dirty fix.
;EntityColor square,100,0,0
;EntityShininess square,1
;EntityAlpha square,.5
;VertexCoords(ripsurf,843,VertexX(ripsurf,843),.03,VertexZ(ripsurf,843))
TurnEntity
square,
0
,
0
,
0
EntityTexture
square,tex
While
Not
KeyDown
(
1
)
;TurnEntity square,1,0,0
If
MouseHit
(
1
)
Then
CameraPick
cam,
MouseX
(
)
,
MouseY
(
)
r.ripples =
New
ripples
rx# =
PickedX
(
)
ry# =
PickedZ
(
)
rdist# = .0001
EndIf
For
x =
0
To
numverts
For
y =
0
To
numverts
VertexCoords
(
ripsurf,verts
(
x,y
)
,
VertexX
(
ripsurf,verts
(
x,y
)
)
,
0
,
VertexZ
(
ripsurf,verts
(
x,y
)
)
)
Next
Next
For
r.ripples =
Each
ripples
For
x =
0
To
numverts
For
y =
0
To
numverts
dist# =
Sqr
(
(
VertexX
(
ripsurf,verts
(
x,y
)
)
- rx#
)
^
2
+
(
VertexZ
(
ripsurf,verts
(
x,y
)
)
- ry#
)
^
2
)
dif# =
Abs
(
rdist#-dist#
)
If
dif# < .04
Then
num = x*
40
+ y
VertexCoords
(
ripsurf,verts
(
x,y
)
,
VertexX
(
ripsurf,verts
(
x,y
)
)
,.04-dif#,
VertexZ
(
ripsurf,verts
(
x,y
)
)
)
EndIf
Next
Next
rdist# = rdist# + .005
If
rdist# =>
1.5
Then
Delete
r.ripples
EndIf
Next
UpdateNormals
square
UpdateWorld
(
)
RenderWorld
Oval
MouseX
(
)
-
5
,
MouseY
(
)
-
5
,
10
,
10
Flip
wend
Comments :
Nate the Great(Posted 1+ years ago)
oops sorry you may have to change the screen resolution and add your own picture instead of mine.
Stevie G(Posted 1+ years ago)
You've listed the code twice.
Nate the Great(Posted 1+ years ago)
oh... oops sorry it is fixed now
Zeotrope(Posted 1+ years ago)
Nice work nate.Works a treat!
Nate the Great(Posted 1+ years ago)
Thanks... I think I may try to use it in a very low poly game for effects like when there is an explosion... so far it works well in game, but it causes a significant slowdown from 100 fps to 50 fps but it is worth it for me.
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
3D Graphics - Effects
»
[bb] RIPPLE EFFECT by Nate the Great [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal