CONST corr = 512 ''fish-eye correction in 3d formula
CONST y = 1 ''the y value of the plane
CONST res = 60 ''resolution of map
DIM map(-res TO res, -res TO res) AS INTEGER ''my height map
RANDOMIZE TIMER ''Need good random values for heightmap
FOR x = -res TO res
FOR x1 = -res TO res
map(x, x1) = (RND * 30) ''fill up map with rnd
NEXT x1
NEXT x
SCREEN 12 ''set screen to 640*480*16
LINE (0, 0)-(640, 270), 1, BF ''draw a sort of sky
FOR y1 = 241 TO 480 STEP 1 ''loop over scan lines
tz = y / ((y1 - 240) / corr) ''y map cord dirived from scanline
fz = ((tz - INT(tz)) / 3) + (1 / 3) ''should be the y spline fraction
iz = INT(tz) ''get integer part of map cord
FOR x = 0 TO 640 STEP 1 ''loop over x axis
tx = tz * ((x - 320) / corr) ''x map cord from screen x
f = ((tx - INT(tx)) / 3) + (1 / 3) ''? x spline fraction
i = INT(tx) ''integer part of x-map
IF tx >= -res AND tx <= res AND tz >= -res AND tz <= res THEN
''the next two lines are messy, but they should calculate
''a x and y spline respectively hx and hz
''they are then evend out and used as height correction
hx = (f ^ 3) * map(i - 1, iz) + 3 * (f * f) * (1 - f) * map(i, iz) + 3 * f * (1 - f) * (1 - f) * map(i + 1, iz) + (1 - f) * (1 - f) * (1 - f) * map(i + 2, iz)
hz = (fz ^ 3) * map(i, iz - 1) + 3 * (fz * fz) * (1 - fz) * map(i, iz) + 3 * fz * (1 - fz) * (1 - fz) * map(i, iz + 1) + (1 - fz) * (1 - fz) * (1 - fz) * map(i, iz + 2)
h = (hx + hz) * .5 ''even out
LINE (x, y1)-(x, y1 - h), h / 2 ''draw line
END IF
NEXT x
NEXT y1
end ''done
any sugestions? any one?
EOT MR Master
Ahem.. Listen to this:
I bet this subject got your attention...
Any way, I am having a slight problem with my code... It is in qbasic at the moment but that is just easy to try out stuff, I''ll port it to C or some other lang when I know excatly what I am doing and qbasic saves ya a lot of time compiling and so on.
Hummm... I am drifting of here...
As for my problem....
I have this small thing wich loops over the x and y axis and calculates the 3d position of that pixel given that the only thing visible is a plane at y=-1 so it only loops the ScreenResolution/2 +1 to last_scan_line. Then it takes from a height map, a height and draws a line from x,y to x,y-height.
This produces a landscape of planes. So I decided to add a sort of spline smoothing. This has sort of messed up... can any one tell me what is wrong... this can be ported to vb as well..
EOT MR Master
Should I port this to C to get any attention?
EOT MR Master
EOT MR Master
EOT MR Master
November 21, 2000 02:59 PM
quote: Original post by MR_MASTER
I bet this subject got your attention...
And I bet the first line lost it ...
November 22, 2000 11:11 PM
I did something very similar to that in QBasic, which makes the fact that I can''t make any sense out of your code all the more interesting.
Think the only question you should have asked is should I port it. Infact I think you knew the correct answer to that before asking
-----------------------------------------------
All messages are of my own personal opinion and
not meant to offend. But if they do - tough
Neuro.
-----------------------------------------------
All messages are of my own personal opinion and
not meant to offend. But if they do - tough
Neuro.
-----------------------------------------------All messages are of my own personal opinion and not meant to offend. But if they do - tough :)Neuro.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement