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.

DarkBASIC Professional Discussion / Wanting to know if this can be done with DBPro

Author
Message
i lyke pineconez
15
Years of Service
User Offline
Joined: 16th Aug 2010
Location:
Posted: 23rd Mar 2011 08:14 Edited at: 23rd Mar 2011 08:16
Basically, say I have an image, the background is completely black, and on it are 2D boxes, which are filled in completely white. Is there any way I could go about using this image to create cubes in 3D space, placed and rotated so that they match the image? They would all be the same height. I have an example image attached.

I dont really know if a heightmap-like image could be used to define where cubes should be placed, especially in DBPro, so I just want to ask if anyone thinks this is possible? If not, does anyone know of a way I could go about getting the same effect?
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 23rd Mar 2011 10:52
Do i get it right, you want to analize a bitmap for automated polygon creation?

Well technically very possible, but the part you could use for the analizing can be tricky.

I would suggest to have 3 colors in the bitmap, completey black, white and some kind of gray. Black is still the background, white is a visual reference where the poly's are going to be created, and at the corners you manually put gray dots, so the program will know where to put the vertices.

After that the only real challenge is to figure out in what order you need to make those vertices.

Technically speaking you will need either Plain Object creation in connection with Vertexdata commands. Or memblock object making.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 23rd Mar 2011 13:10
Here`s an example that use a zone of 100*40 pixels to make something like you want. You can load an image and do the same, but bigger the image slower the FPS`S . I hope it can help



Read you soon.

I'm not a grumpy grandpa
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 23rd Mar 2011 13:44
Analysing an image and placing cubes is quite straightforward, however rotation might be tricky. I wouldn't rely on detecting the rotation on a box, because that would be quite unreliable. Have the boxes on an image, but then have a 1 pixel centre point, and another pixel showing the facing direction, in different colours. So you might have a box on your image, with a red pixel in the middle showing the centre point, and a green pixel inside the box still, but showing the rotation angle. That way, you find a non-black pixel, then find the red centre pixel, and scan the box for the green pixel, then work out the angle between the red and green dots, which is your object angle.

To load up an image and add cubes though, maybe something like this:

If bitmap exist(1)=1 then delete bitmap 1
load bitmap "map.bmp",1
set current bitmap 1
obj=100
for y=0 to bitmap height(1)-1
for x=0 to bitmap width(1)-1
c=point(x,y)
if rgbb(c)>0
make object cube obj,1
position object obj,x,0.5,y
inc obj,1
endif
next x
next y
set current bitmap 0

Health, Ammo, and bacon and eggs!
i lyke pineconez
15
Years of Service
User Offline
Joined: 16th Aug 2010
Location:
Posted: 24th Mar 2011 02:19
Awesome to hear. Wasn't sure how I would go about analyzing the pixels of an image, but it looks pretty easy.

I think I am going to be forced to use the vertexdata commands, because it requires the least modifications to the image itself, plus that may also assist in me later making some of the boxes hollow like buildings.

Thanks to all for your help, Definately going to use it!

Login to post a reply

Server time is: 2026-07-17 12:04:29
Your offset time is: 2026-07-17 12:04:29