the goal is to make a procedural planet generator, the problem i am having is regarding the heightmap creation.
in short; i need to correct the spherical distortion of the map.
i have a lot of .png files containing different shapes with transparency, i paste them onto an image, wich is then used as a heighmap, to shape a sphere.
its very fast, and i think it looks pretty good, to me at least, as specialy when combined with something like perlin noise map.
kinda like spore's planets, -in a crude newb version of course
heres an example of how im pasting sprites to a map, might be a little messy:<
fullscreen=1
if fullscreen=1
set display mode desktop width(),desktop height(), 32, 1 : set window off
else
set display mode 800,600, 32, 1 : set window oN
endif
autocam off
backdrop on : color backdrop rgb(0,0,255)
sync on : sync rate 60 : set camera range 1, 100000
REM MAKE A RANDOM IMAGE AND USE IT AS SPRITE:
rem this is just to be used as a quick example
margin=10
create bitmap 1,200,200
lock pixels
for a=1 to 200
for b=1 to 200
if a>margin and a<200-margin and b>margin and b<200-margin
dot b,a,rgb(rnd(255),rnd(255),rnd(255))
else
dot b,a,rgb(0,0,0)
endif
next
next
unlock pixels
set image colorkey 0,0,0
get image 1,0,0,200,200
delete bitmap 1
sprite 1,0,0,1
rem hide sprite 1
REM CREATE BITMAP TO USE AS SPHERE/PLANET TEXTURE/HEIGHT-MAP:
rem set map resolution
map_res=1024
CREATE BITMAP 1,map_res,map_res
set current bitmap 1
lock pixels
REM PASTE SPRITES/HEIGHT IMAGES:
for a=1 to 20
x#=rnd(map_res)
y#=rnd(map_res)
rem -sprite height(1)+rnd(map_res+sprite height(1))
rem stretch sprite acording to distance from equator
warp#=(((map_res-(map_res/2))-y#)-(sprite height(1)/2))/(map_res)
REM CORRECT SPRITE PERSPECTIVE -DOES NOT WORK RIGHT?
rem sprites should be stretched at the poles, to match the sphere's distortion
set sprite texture coord 1,0,0+warp#,0 : rem top left
set sprite texture coord 1,1,1-warp#,0 : rem top right
rem set sprite texture coord 1,2,0-warp#,1 : rem bottom left
rem set sprite texture coord 1,3,1+warp#,1 : rem bottom right
rem test; make sprite "tinner" at the equator, to help correct the sphere distortion
stretch sprite 1,50+(100*abs(warp#)),100
paste sprite 1,x#,y#
rem paste again if close to edge -(paste on the opposite edge) to avoit seams
if x#>map_res-sprite width(1) then paste sprite 1,x#-map_res,y#
delete sprite 1
sprite 1,210,0,1
hide sprite 1
next
unlock pixels
get image 2,0,0,map_res,map_res
delete bitmap 1
rem MAKE A SPHERE OBJECT TO TEST IF TEXTURE FITS
make object sphere 1,500,50,50
texture object 1,2
set current bitmap 0
position camera 0,700,0,0
point camera 0,0,0,0
run=0
do
inc run
rem spin planet
rotate object 1,0,0,wrapvalue(run*0.5)
text 0,0,"FPS: "+str$(screen fps())+" key press: "+str$(scancode())
rem text 0,15," "+str$( )
REM UN-REM TO SEE THE MAP:
rem paste image 2,0,0
control camera using arrowkeys 0,1,1
sync
loop
i would like this work on-the-fly, and its quick to paste a sprite, but if i have to unlock pixel, set image, rotate object, grab image, make sprite, lock pixel, before pasting each sprite, to get the right perspective, i THINK it would be slow? havent tried, since it seems like a "clumsy" aproach?
but i dunno, i am a beginner at this whole thing