Mimicking MacOS Genie effect on Windows

Started by
0 comments, last by lucky9999 2 years, 3 months ago

Hello,

What I want to achieve with Jack Hoxley's code is to eliminate the Y offset from the code, now, the patch always bends into the screen or out of the screen, how do I avoid that from happening? This function simply calculates the Y value which you may assume is pointing towards me (out of the screen), when I set the Ys to zeros, nothing changed to the patches. When I set the z's to zero's, it screwed up everything.

Private Function CubicSurface(X As Single, Y As Single, PatchData As CubicTerrainPatch) As Single

'bounds checking:

If X > 1# Then X = 1#

If X < 0# Then X = 0#

If Y > 1# Then Y = 1#

If Y < 0# Then Y = 0#

'variables:

Dim X_3 As Single

Dim X_2 As Single

Dim Y_3 As Single

Dim Y_2 As Single

'A = 1-X

Dim A As Single

Dim A_2 As Single

Dim A_3 As Single

'B = 1-Y

Dim B As Single

Dim B_2 As Single

Dim B_3 As Single

'cache common values:

X_3 = X * X * X

X_2 = X * X

Y_3 = Y * Y * Y

Y_2 = Y * Y

A = 1 - X

A_2 = A * A

A_3 = A * A * A

B = 1 - Y

B_2 = B * B

B_3 = B * B * B

'Calculate the final value:

CubicSurface = (PatchData.Data(0, 0) * X_3 * Y_3) + (PatchData.Data(1, 0) * X_3 * Y_2 * B) + (PatchData.Data(2, 0) * 4 * X_3 * B_2 * Y) + (PatchData.Data(3, 0) * X_3 * B_3) + _

(PatchData.Data(0, 1) * 2 * X_2 * A * Y_3) + (PatchData.Data(1, 1) * 4 * X_2 * Y_2 * A * B) + (PatchData.Data(2, 1) * 8 * X_2 * A_2 * Y * B_2) + (PatchData.Data(3, 1) * 2 * B_3 * X_2 * A) + _

(PatchData.Data(0, 2) * 4 * X * A_2 * Y_3) + (PatchData.Data(1, 2) * 8 * X * A_2 * Y * B) + (PatchData.Data(2, 2) * 16 * X * A_2 * Y * B_2) + (PatchData.Data(3, 2) * 4 * X * A_2 * B_3) + _

(PatchData.Data(0, 3) * A_3 * Y_3) + (PatchData.Data(1, 3) * 2 * A_3 * Y_2 * B) + (PatchData.Data(2, 3) * 4 * Y * B_2 * A_3) + (PatchData.Data(3, 3) * A_3 * B_3)

End Function

This topic is closed to new replies.

Advertisement