Zoning

Blitz3D Forums/Blitz3D Programming/Zoning

Baystep Productions(Posted 2005) [#1]
How do you create a color zone map. Like retrieving what section of the map you are in based after a colored image. Mainly in the case of terrains.


Baystep Productions(Posted 2005) [#2]
And great, now I need a terrain generator to make square shaped segments.


solitaire(Posted 2005) [#3]
Maybe this can help you.
http://www.blitzbase.de/_mapeditor/usa_home.htm


octothorpe(Posted 2005) [#4]
Wow. I'm completely unable to figure out what a "color zone map" is. Maybe it's because I was eating some of the red mushrooms.


Baystep Productions(Posted 2005) [#5]
VoidRPG uses one. It an image like a colormap, or a light map for terrains, but instead it uses solid color sections to define "zones".

And I need to figure out how I can use this. To find out which zone an entity is in on the terrain.


Baystep Productions(Posted 2005) [#6]
Oh and the map editor is a 2D Platform Level Mapper. Thanks for trying. But I neede a terrain engine to make a well, terrain. But instead of the natural triangle shaps included. I need them to be cubes and to move uniformaly. As in a grid.


Baystep Productions(Posted 2005) [#7]
Okay, I got something down, but I need some help with speed optimization. really need help.

Function ZN_Init(mapn$)
	zn_zone=LoadImage(mapn$)
	zn_size=ImageWidth(zn_zone)
	zn_tex=LoadTexture(mapn$)
End Function

Function ZN_Update(ent=-1)
	DrawImage(zn_zone,0,0)			;The current zone image
	If ent=-1
		ent=zn_ent					;A default parameter
	EndIf
	tx=EntityX(ent)*10;/100			This is the x times map scale.
	tz=EntityZ(ent)*10;/100
	If tx<=zn_size And ty<=zn_size	;If in area
		GetColor tx,tz
		zn_r=ColorRed()
		zn_g=ColorGreen()
		zn_b=ColorBlue()
		;Tolerence Function
		zn_r=(zn_r/128)*128			;Get a solid color. Either 0/128/255. Needs to be fixed
		zn_g=(zn_g/128)*128			;Gives bad output
		zn_b=(zn_b/128)*128
		thisclr$=ZN_GetColor$(zn_r,zn_g,zn_b)	;A Function to return the color name.
		If thisclr$="darkgreen"					; 0 128 0
			zn_inzone=1
		Else If thisclr$="darkred"				; 128 0 0
			zn_inzone=3
		Else If thisclr$="grey"					; 128 128 128
			zn_inzone=2
		Else
			zn_inzone=0							;No zone
		EndIf
	EndIf
	zn_x=tx							;Debug out image position
	zn_y=tz
	Color 255,255,255
	;RuntimeError zn_r+","+zn_g+","+zn_b
End Function

Function ZN_DrawZone(znum=1,ent=-1,size=1)
	SetBuffer ImageBuffer(zn_zone)
	If ent=-1
		ent=zn_ent
	EndIf
	tx=EntityX(ent)*10;/100
	tz=EntityZ(ent)*10;/100
	Select znum
		Case 1					;Get zone number
			Color 255,0,0
			For x=tx-(size/2) To size*2
			  For y=tz-(size/2) To size*2
				Plot x,y		;Draw a box based on zone and size
			  Next
			Next
	End Select
	SetBuffer TextureBuffer(zn_tex)	;Set to terrain texture
	DrawImage zn_zone,0,0			;Copy zone image to texture
	SetBuffer BackBuffer()			;Back to the game
End Function



octothorpe(Posted 2005) [#8]
I'd like to help you but I don't understand you.


Baystep Productions(Posted 2005) [#9]
Whats not to understand? Okay, this function takes where the suplied entity is and finds the respective pixel on the supplied image. It then returns the color of that pixel and that determines the "ZONE" # it is in. Okay, but in the second function, all the building entities will change the supplied image based on there positions. So this means, if your close to a building you are in it's players zone. Like property lines. And what I am doing is displaying this supplied image as a texture for the ground.


Ross C(Posted 2005) [#10]
There is a function in the archives, to find the U and V of a texture, based on an xy position on a polygon. I dunno if that's any use. It's by Birdie or fredborg.


Baystep Productions(Posted 2005) [#11]
Hmm, that might be useful later.