March 06, 2021, 05:25:10 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
Like stats
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
3D Graphics - Maths
»
[bb] Calc terrain height - Ideal for terrain tool by KimoTech [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bb] Calc terrain height - Ideal for terrain tool by KimoTech [ 1+ years ago ] (Read 775 times)
BlitzBot
Jr. Member
Posts: 1
Total likes: 0
[bb] Calc terrain height - Ideal for terrain tool by KimoTech [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:41 AM »
Title :
Calc terrain height - Ideal for terrain tool
Author :
KimoTech
Posted :
1+ years ago
Description :
Uses Cos#() to calc the vertex/terrain height for ex. a mountain. Ideal if u want to make a terrain tool for modifying the terrain with smooth mountains.
Code :
Code: BlitzBasic
;GetHeight#( center x of mountain, center z of mountain, vertex/terrain-seg x to calc, vertex/terrain-seg z to calc, mountain radius )
Function
GetHeight#
(
cx#,cz#,px#,pz#,r#
)
If
PointDistance#
(
cx#,
0
,cz#,px#,
0
,pz#
)
<r#
Then
Return
-
Cos
#
(
(
PointDistance#
(
cx#,
0
,cz#,px#,
0
,pz#
)
/ r#
)
*
180
)
-
1
End Function
Function
PointDistance#
(
X1#,Y1#,Z1#,X2#,Y2#,Z2#
)
dx# = X1 - X2:dy# = Y1 - Y2:dz# = Z1 - Z2
Return
Sqr
(
dx*dx + dy*dy + dz*dz
)
End Function
;Example:
Graphics
800
,
600
Repeat
Cls
For
z=
0
To
600
Plot
z,GetHeight
(
200
,
0
,z,
0
,
300
)
*
MouseZ
(
)
+
400
Next
Flip
Until
KeyHit
(
1
)
End
Comments :
none...
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
3D Graphics - Maths
»
[bb] Calc terrain height - Ideal for terrain tool by KimoTech [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal