Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / DOES ANYONE KNOW ANY HEIGHTMAP FUNCTIONS FOR DBC?????!!!

Author
Message
Zotoast
20
Years of Service
User Offline
Joined: 24th Oct 2004
Location: southside of mt everest,its warmer there
Posted: 13th Dec 2004 05:15
Hi, does anyone have know any heightmap functions for DBC, just sumtin where u can get the tone of each pixel of an image and then putting that value onto a matrix tile?

"Well, if he dies it'll teach him not to do it again." - Me
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 13th Dec 2004 06:25
YOU COULD TRY USING THE POINT COMMAND TO GET A PIXEL COLOUR ON YOUR SCREEN!!!!!!!!! HOWEVER THIS WOULD RUN SLOW, so its best to pre calculate the height values and store them in an array or something.


Mattman
21
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 13th Dec 2004 08:57
You will need DBCenhanced. Then go to the darkbasic classic board and read the latest thread about memblock matrixes

Song of the whenever i feel like updating it....
Whatever Happened, The Strokes
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 14th Dec 2004 03:40
If you dont have the enhancement pack, you could use the point command to load the data into an array, then save that data out to a file. Then use that file for your games instead of the image.

"eureka" - Archimedes
Zotoast
20
Years of Service
User Offline
Joined: 24th Oct 2004
Location: southside of mt everest,its warmer there
Posted: 14th Dec 2004 03:44
hey, i found sumtin on the internet, and it does the heightmap function, but mine aint enhanced, if u wanna see it here you go....

`Heightmap code

set display mode 1024,768,32
sync on
sync rate 1000
backdrop on
color backdrop rgb(0,200,255)
set camera range 1,5000
fog on
fog distance 7000
fog color rgb(0,200,255)
hide mouse
set ambient light 100

`arrays
dim hmap(1)

getheightbmp("hmap.bmp")

load image "texture.bmp",100
make matrix 1,5000,5000,70,70
prepare matrix texture 1,100,1,1
for x=1 to 70
for z=1 to 70
set matrix height 1,x,z,hmap(x,z)*3
next z
next x

update matrix 1

camspeed#=10

do

set cursor 10,10
print "FPS: ",screen FPS()

rem Crude way to fix mouse pointer (hide this and run again)
position mouse 320,240

camf#=0
camx#=wrapvalue(camx#-mousemovey()*0.4)
camy#=wrapvalue(camy#+mousemovex()*0.4)
acamx#=curveangle(camx#,acamx#,2.5)
acamy#=curveangle(camy#,acamy#,2.5)
rotate camera acamx#,acamy#,0
if mouseclick()=1 then camf#=camf#+camspeed#
if mouseclick()=2 then camf#=camf#-camspeed#
if leftkey()=1 then camy#=wrapvalue(camy#-3.0)
if rightkey()=1 then camy#=wrapvalue(camy#+3.0)
if upkey()=1 then camx#=wrapvalue(camx#+3.0)
if downkey()=1 then camx#=wrapvalue(camx#-3.0)
if shiftkey()=1 then camf#=camf#+camspeed#
if controlkey()=1 then camf#=camf#-camspeed#
if camf#<>0 then move camera camf#

x#=camera position x()
y#=camera position y()
z#=camera position z()
yg#=get ground height(1,x#,z#)+10
if y#<yg#
position camera x#,yg#,z#
else
position camera x#,y#,z#
endif

rem Update screen
sync
loop

function getheightbmp(file$)

`this function only gets information from a 24-bit bitmap
`so make sure you save it as one

open to read 1,file$
`--------------------
`decode the header
`The info contained here is not usefull.
read byte 1,notusefull
read byte 1,notusefull
read long 1,notusefull
read long 1,notusefull
read long 1,notusefull
read long 1,notusefull

`--------------------
`Get Bitmap Width
read long 1,BmpWidth
`Get Bitmap Height
read long 1,BmpHeight
`--------------------

read word 1,notusefull

`--------------------
`Get BitDepth
read word 1,BitDepth
`--------------------

`The info contained here is not usefull.
read long 1,notusefull
read long 1,notusefull
read long 1,notusefull
read long 1,notusefull
read long 1,notusefull
read long 1,notusefull
`--------------------
`error check only if bitdepth=24
if BitDepth=24

ypos=BmpHeight

` Calculate If bmp required Padding

bmpwidth#=bmpwidth
evenwidth1#=(BmpWidth#*3)/4
evenwidth2=(BmpWidth*3)/4
padlen=0
if evenwidth1#<>evenwidth2
evenwidth1#=evenwidth1#-evenwidth2
padlen=4-(evenwidth1#*4)
endif

`-------------------------------------------
`create the hmap array
dim hmap(bmpwidth,bmpheight)
`-------------------------------------------


`Get color info
For Ylp=1 to BmpHeight
for Xlp=1 to Bmpwidth

`Read color values
read byte 1,blue
read byte 1,Green
read byte 1,red

`enter color info into height array
hmap(xlp,ypos)=(blue+green+red)/3

next Xlp

dec Ypos
`Padding
if padlen<>0
for padlp=1 to padlen
read byte 1,padbyte
next padlp
endif

next Ylp
endif

close file 1

endfunction



=======================

i added better controls and stuff

"Well, if he dies it'll teach him not to do it again." - Me
Monty87
20
Years of Service
User Offline
Joined: 8th Dec 2003
Location: not very deep in the west country, eng
Posted: 19th Dec 2004 07:16
no sane person knows about heightmaps, only madmen and geniuses; oh and most of the people in this forum other than me.

Monty
Monty87
20
Years of Service
User Offline
Joined: 8th Dec 2003
Location: not very deep in the west country, eng
Posted: 19th Dec 2004 07:18
a very small section of the world population i think you will agree, not including the madmen [INSERT OH-SO-CLEVER LEFT-WING POLITCAL STATEMENT ABOUT WORLD LEADER OF YOU NATIONAL PREFERENCE! HERE].

Monty
Mr Underhill
21
Years of Service
User Offline
Joined: 23rd Apr 2003
Location: The Forgotten Worlds...
Posted: 19th Dec 2004 08:03 Edited at: 19th Dec 2004 08:15
{EDIT} Uhhh...never mind...sorry...

Quote: "A kilobyte is 1024 bytes, not 1028.
I mean.... not.. that i.... new that already.... i figured... maybe... CRUD! IM A NERD! -Ion Stream"

I feel your pain, man. Wait...pain?!
Zotoast
20
Years of Service
User Offline
Joined: 24th Oct 2004
Location: southside of mt everest,its warmer there
Posted: 19th Dec 2004 19:19
Monty are u mocking me?

"Well, if he dies it'll teach him not to do it again." - Me
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Dec 2004 08:57
if its really important that you create heightmaps from bitmaps without using memblocks, then i'll try and write a routine that reads bitmaps in that way. I just need a document that tells me the bitmap structure

"eureka" - Archimedes
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 22nd Dec 2004 20:41
does that mean u want me to send u the heightmap?

"Well, if he dies, it'll teach him not to do it again." - Me

Login to post a reply

Server time is: 2024-11-27 16:34:25
Your offset time is: 2024-11-27 16:34:25