3D Terrain
#8
I checked. it will work. You should record the depth data in the following way and it will be compatible with this.

I hope everything is understandable in the example! good luck !



Code: (Select All)
Dim Shared deep(4, 4)


deep(0, 0) = 10
deep(1, 0) = 20
deep(0, 1) = 30
deep(1, 1) = 40


'deep-array now
' 10 20 0 0 0
' 30 40 0 0 0
'  0  0 0 0 0
'  0  0 0 0 0
'  0  0 0 0 0


Print exact_deep(0, 0) '10
Print exact_deep(0.5, 0) 'between 10 and 20
Print exact_deep(.5, .5) 'between central 10,20,30,40 (central 25)




Function exact_deep (x, y)
    x1 = Int(x): x2 = x1 + 1: aposx = x - x1
    y1 = Int(y): y2 = y1 + 1: aposy = y - y1

    p1 = deep(x2, y1)
    p2 = deep(x1, y2)

    If aposx * aposx + aposy * aposy < (1 - aposx) * (1 - aposx) + (1 - aposy) * (1 - aposy) Then
        p0 = deep(x1, y1)
        q = p0 + aposx * (p1 - p0) + aposy * (p2 - p0)
    Else
        p3 = deep(x2, y2)
        q = p3 + (1 - aposy) * (p1 - p3) + (1 - aposx) * (p2 - p3)
    End If

    exact_deep = q

End Function
Reply


Messages In This Thread
3D Terrain - by james2464 - 01-08-2023, 09:24 PM
RE: 3D Terrain - by mnrvovrfc - 01-09-2023, 08:29 AM
RE: 3D Terrain - by james2464 - 01-09-2023, 05:13 PM
RE: 3D Terrain - by OldMoses - 01-09-2023, 12:12 PM
RE: 3D Terrain - by james2464 - 01-09-2023, 05:26 PM
RE: 3D Terrain - by OldMoses - 01-09-2023, 06:53 PM
RE: 3D Terrain - by james2464 - 01-09-2023, 08:17 PM
RE: 3D Terrain - by MasterGy - 01-09-2023, 03:24 PM
RE: 3D Terrain - by james2464 - 01-09-2023, 05:28 PM
RE: 3D Terrain - by MasterGy - 01-09-2023, 06:31 PM
RE: 3D Terrain - by james2464 - 01-09-2023, 06:40 PM
RE: 3D Terrain - by MasterGy - 01-09-2023, 06:56 PM
RE: 3D Terrain - by james2464 - 01-09-2023, 08:20 PM
RE: 3D Terrain - by james2464 - 01-10-2023, 06:30 PM
RE: 3D Terrain - by james2464 - 01-11-2023, 07:50 PM
RE: 3D Terrain - by bplus - 01-11-2023, 08:07 PM
RE: 3D Terrain - by james2464 - 01-11-2023, 08:46 PM
RE: 3D Terrain - by james2464 - 01-11-2023, 09:53 PM
RE: 3D Terrain - by bplus - 01-11-2023, 10:34 PM
RE: 3D Terrain - by james2464 - 01-11-2023, 11:51 PM
RE: 3D Terrain - by james2464 - 01-12-2023, 04:08 AM
RE: 3D Terrain - by bplus - 01-12-2023, 05:33 AM
RE: 3D Terrain - by james2464 - 01-12-2023, 04:34 PM
RE: 3D Terrain - by MasterGy - 01-12-2023, 04:57 PM
RE: 3D Terrain - by james2464 - 01-12-2023, 05:37 PM
RE: 3D Terrain - by OldMoses - 01-13-2023, 12:11 AM



Users browsing this thread: 8 Guest(s)