Jump to content


Photo

Commandos BEL - VOL file - How do I handle depth sorting and rendering in a map?


  • Please log in to reply
11 replies to this topic

#1 Sinc

Sinc
  • Members
  • 19 posts

Posted 17 July 2015 - 12:07 PM

Hi,

 

I'm trying to programmatically render the BEL map using the VOL file and am running into some problems in the rendering.

 

1. I am sure I'm missing details on the depth sorting algorithm and the order of drawing items. So far I just do a rudimentary sort by centroY and draw :(

2. I'm noticing weird spots of unpainted areas that are not covered in the vol file.

 

I'd appreciate help or tips from any one who has experience with this. 


Edited by Sinc, 17 July 2015 - 08:47 PM.


#2 Sinc

Sinc
  • Members
  • 19 posts

Posted 18 July 2015 - 04:12 PM

I've managed to get it working now... 

 

Just sharing some tips/info for others who might want to do something similar...

 

1. The MAPAxxxx.VOL contains all the information needed to render a map. This includes a list of all polygons, and the necessary TILEs along with x,y, offsetX and offsetY information. The sprite names refer to the resource BMP/RLE files in the appropriate WAD file.

 

2. The POLY called "BASE" contains all the tiles that form the ground, while all the other tiles are objects like buildings etc which are drawn on top of the "BASE" poly. To render the map correctly, I first drew the BASE poly tiles, then drew all the remaining POLY tiles on top.

 

3. Tiles with a "-" in front are hidden (typically ruins/destroyed buildings), and are only displayed when the building is destroyed. Tiles with an S in front are typically shadow tiles. Tiles with the name MAR0DST are mid-river/water tiles. 

 

4. TILES sometimes have a flipX/flipY and offsetX/offsetY along with width/height which might be different from the height/width of the sprite images in the WAD file. In such cases, we need to flip the sprite appropriately, and repeat/offset the images as necessary... Some details on how to interpret this data is over here - https://sites.google...?attredirects=0

 

Hope this helps others and saves them some research effort... :)

 

 

 



#3 Salvadorc17

Salvadorc17

    title available

  • Members
  • 507 posts
  • Location:Colombia
  • Projects:Destination Norway

Posted 19 July 2015 - 09:08 PM

Yes, this seems a must see work, share with us when you have something to show...



#4 Sinc

Sinc
  • Members
  • 19 posts

Posted 23 September 2015 - 04:24 AM

I've made considerable progress in my project but I've run into a slight snag.
 
When drawing the polygons, one or two seem to still getting drawn in the wrong order. 
 
This one is for the Rocks and the walls

{"type":"POLY","name":"NONAME","centreX":439,"centreY":2752,"centreZ":0,"height":68,"vertices":[{"x":71,"y":91},{"x":-117,"y":-97},{"x":-88,"y":-106},{"x":90,"y":72}],"tiles":[{"x":324,"y":1672,"width":73,"height":82,"offsetX":0,"offsetY":0,"brightness":0,"sprite":"MURO0000"},{"x":397,"y":1674,"width":69,"height":124,"offsetX":0,"offsetY":0,"brightness":0,"sprite":"MURO0001"},{"x":466,"y":1719,"width":73,"height":109,"offsetX":0,"offsetY":0,"brightness":0,"sprite":"MURO0002"}]},
 
{"type":"POLY","name":"NONAME","centreX":325,"centreY":2743,"centreZ":0,"height":86,"vertices":[{"x":-45,"y":-69},{"x":-4,"y":-88},{"x":73,"y":-10},{"x":65,"y":58},{"x":32,"y":87},{"x":-1,"y":80},{"x":-47,"y":35},{"x":-75,"y":-27}],"tiles":[{"x":248,"y":1660,"width":161,"height":164,"offsetX":0,"offsetY":0,"brightness":0,"sprite":"ROC10011","flipX":true}]},

 
I sort by centreY, and then centreX while drawing, then draw the items in descending order. However the rocks seem to have a centreY lower than the wall, but it looks like it needs to be drawn after the wall...
8NX0211.jpg
 
Would you know what I am missing here??
 
If there is a cleaner implementation of depth sorting while drawing?

I briefly read in http://forums.revora...ed/#entry917062that there is some kind of bounding box used to figure out drawing order....

Any help would be appreciated :)

#5 Salvadorc17

Salvadorc17

    title available

  • Members
  • 507 posts
  • Location:Colombia
  • Projects:Destination Norway

Posted 29 September 2015 - 09:18 PM

Yours is different from original, which algorithm youre using? Youre missing height offset??



#6 Sinc

Sinc
  • Members
  • 19 posts

Posted 30 September 2015 - 03:20 PM

Yours is different from original, which algorithm youre using? Youre missing height offset??

 

For the tile drawing, I used a very simple painters algorithm (sort all items in vol file by centroY and then by centroX), and then paint from back to front.... While that works in most places, there are occasional bugs like I pointed out in the screen shot...

 

How is the height offset used? I have no access to the original algorithm and am doing everything from scratch on my own :(



#7 Salvadorc17

Salvadorc17

    title available

  • Members
  • 507 posts
  • Location:Colombia
  • Projects:Destination Norway

Posted 30 September 2015 - 07:46 PM

How is the height offset used? I have no access to the original algorithm and am doing everything from scratch on my own :(


Is used for objects ,that are supposed to be draw with different heights (like RAMPS (POLYRAMPA), see original VOL file example.

	POLY "NONAME",943,2191,81,123,4,1			;Nombre,CentroX,CentroY,CentroZ,Altura,#vertices,#Tiles
	POINT		-22,-28				;Coord. X, Coord. Y
	POINT		30,28				;Coord. X, Coord. Y
	POINT		24,33				;Coord. X, Coord. Y
	POINT		-27,-19				;Coord. X, Coord. Y
	EXTRAINFO		0,0,0,0,0,0,0,0                 ;Extra Info Bytes
	TILE         916,1238,  54, 132,   1,   0, 0,"CAS50001.RLE","   "
	POLYRAMPA "NONAME",975,624,91,0,30,4,1			;Nombre,CentroX,CentroY,CentroZ,Altura,AlturaOff,#vertices,#Tiles
	POINT		-24,15				;Coord. X, Coord. Y
	POINT		-24,-24				;Coord. X, Coord. Y
	POINT		29,-16				;Coord. X, Coord. Y
	POINT		27,24				;Coord. X, Coord. Y
	EXTRAINFO		0,0,0,0,0,0,0,0                 ;Extra Info Bytes
	TILE         951, 302,  61,  32,   0,   0, 0,"ESQU0005.RLE","   

Edited by Salvadorc17, 30 September 2015 - 07:46 PM.


#8 herbert3000

herbert3000

    Guilty Until Proven Innocent

  • Division Admins
  • 593 posts
  • Location:Austria
  • Division:Commandos HQ
  • Job:Division Admin

Posted 06 October 2015 - 04:27 PM

I think something like this could work:

At first create a bounding box for every polygon (minX, minY, maxX, maxY)

if the bounding boxes of two polygons intersect each other:
check if one polygon is on top of another
if A.z >= (B.z + B.height) then A is on top of B
else if B.z >= (A.z + A.height) then B is on top of A
else check the edges of the polygons (see image)

edges.png

it's required that the points of an edge are sorted,

the start point of an edge is always the point with the lower x

 



#9 Sinc

Sinc
  • Members
  • 19 posts

Posted 07 October 2015 - 04:28 PM

I think something like this could work:


Thanks... I'll try and tweak my algorithm and see if it fixes the bugs...

Appreciate the help... Hopefully I'll have a working demo soon :)

#10 Salvadorc17

Salvadorc17

    title available

  • Members
  • 507 posts
  • Location:Colombia
  • Projects:Destination Norway

Posted 22 October 2015 - 07:34 PM

Thanks... I'll try and tweak my algorithm and see if it fixes the bugs...

Appreciate the help... Hopefully I'll have a working demo soon :)


Still working, on this, you have achieved to complete vol parsing??

#11 Sinc

Sinc
  • Members
  • 19 posts

Posted 31 October 2015 - 07:29 PM

Check out some screenshots and updates here... https://www.facebook...ishankarfanpage



#12 Salvadorc17

Salvadorc17

    title available

  • Members
  • 507 posts
  • Location:Colombia
  • Projects:Destination Norway

Posted 31 October 2015 - 08:24 PM

Check out some screenshots and updates here... https://www.facebook...ishankarfanpage

Screenshoots looks cool, based from those, youre making the commandos Behind Enemy Lines version, wil lbe good to see if also will compatible with the expansion features..






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users