blitz terrain texture tiling question

Blitz3D Forums/Blitz3D Programming/blitz terrain texture tiling question

is it possible? and if so... how?
I'm talking about applying tiled textures to a internal blitz command loadterrain() blitz terrain.
I decided I want to update my shadow library to have towl meshes for terrains... (but have the same projection method I use)... So I started creating a terrain editor... but then my process became halted when I noticed I don't have a clue about tiling a terrain with textures...
If someone can help, that would be great!
also, is there a function that anyone has created for saving a terrain as a *.bmp heightmap?
Both these things would really help.
(Oh, and I know I don't need these things for terrain shadows... but after playing days of Morrowwind, I decided I want to start trying to use the blitz terrain commands in games... face it, it has a great LOD system!)

to control texture tiling use scaletexture ie.

;Load terrain
terrain=LoadTerrain("terrain1.bmp")
TerrainDetail terrain,4000,True
ScaleEntity terrain,1,10,1
grasstex=LoadTexture("terrain1grass.jpg")
ScaleTexture grasstex,32,32
EntityTexture terrain,grasstex,0,1


I think he means painting different textures on different parts of the terrain and saving the output.

I have tried that, but I couldn't get it to work. The only way I succeeded was placing a few terrains on top of each other, each with (1) a tilemap (2) a alphamap. I stretched the alphamap out over the entire terrain, so it has a low resolution and I kept the tilemap small, to give detail.
Later on, I've made a single terrain with (1) a colormap and (2) a detail map, in greyscale. The idea was to suggest a tiled terrain using different colors.
Maybe you can combine both methods, but instead of using a 2nd terrain, use a few mesh terrains here and there that fit exactly on the blitz terrain. On these smaller mesh terrains you can apply alpha, so they blend into the 'background' terrain.

iamdaman13: Yuppers, that's exactly what I meant.

B32: that's what I'm doing now... a colormap and a detailmap. I guess it gets the job done

I think I'll stick to this for now

Well, I think that is the best way. However, you could easily make a mesh that fits on a terrain using TerrainY(). First, design the add-on for the terrain in a 3d editor as a flat shape. Then, in blitz, loop through all the vertices and place them on the terrain.
Here is the code from my attempt, it loads the same terrain three times.
;---------------------------------------------------------------------------------code by bram32bit--

	;old face normals (for function SmootlyAlign..)
	Global oldnx#, oldny#, oldnz#
	
	;Graphics size and width.
	Graphics3D 800,600,0,2		
	SetBuffer BackBuffer()
	
;-------------------------------------TRACK SETUP----------------------------------------------------
		
	If FileType("height_map2.bmp") <> 1 Then MakeHeightMap("height_map.bmp")
	
	;create terrains
	track = LoadTerrain("height_map.bmp")
	track2 = LoadTerrain("height_map.bmp")
	track3 = LoadTerrain("height_map.bmp")

	;green color
	tex2 = TCreateTexture($00FF00)
	;alpha map
	tex = LoadTexture("height_map.bmp", 2)
	
	;black squares
	tex4 = LoadTexture("height_map.bmp")
	
	;alpha map2
	tex5 = LoadTexture("height_map.bmp", 2)
	PositionTexture tex5, 0.5, 0.5
	;red color
	tex6 = TCreateTexture($FF0000)

	DeleteFile "height_map.bmp"
	
	;assign textures terrain 1
	EntityTexture track, tex2, 0, 1 ;green color
	EntityTexture track, tex, 0, 0  ;alpha map
	;assign texture terrain 2
	EntityTexture track2, tex4
	;assign textures terrain3
	EntityTexture track3, tex6, 0, 1 ;red color
	EntityTexture track3, tex5, 0, 0  ;alpha map

	;place terrain1	
	ScaleEntity track, 10, 100, 10
	PositionEntity track, -256, -100, -256
	EntityPickMode track, 2
	
	;place terrain2
	ScaleEntity track2, 10, 100, 10
	PositionEntity track2, -256, -101, -256

	;place terrain3
	ScaleEntity track3, 10, 100, 10
	PositionEntity track3, -256, -101, -256
	
	;scale textures
	ScaleTexture tex, 512, 512
	ScaleTexture tex4, 10, 10	
	ScaleTexture tex5, 512, 512

	;force alpha blending
	EntityFX track, 32
	EntityFX track3, 32
		
;--------------------------------SETUP CAR----------------------------------------------------------
	
	;pivot is the parent of the camera
	c_pivot = CreatePivot()
	PositionEntity c_pivot, 0, 150, 0
	
;-------------------------------------CAMERA SETUP--------------------------------------------------
	
	;set up camera
	camera = CreateCamera(c_pivot)
	CameraZoom camera, 0.7
	CameraClsColor camera, 0, 0, 255
	PositionEntity camera, 0, 0, 0
;	CameraFogColor camera, 0, 0, 255
;	CameraFogMode camera, 1
	
;-------------------------------------MAIN LOOP------------------------------------------------------
	While Not(KeyHit(1))
	
		PositionTexture tex, MilliSecs() * 0.0001, 0.5
	
		;keys to turn <- ->
		If KeyDown(203) Then TurnEntity c_pivot, 0, +1, 0
		If KeyDown(205) Then TurnEntity c_pivot, 0, -1, 0
		If KeyDown(200) Then MoveEntity c_pivot, 0, 0, +5
		If KeyDown(208) Then MoveEntity c_pivot, 0, 0, -5

		;Q/W		
		If KeyHit(16) Then HideEntity track
		If KeyHit(17) Then ShowEntity track

		;E/R
		If KeyHit(18) Then HideEntity track2
		If KeyHit(19) Then ShowEntity track2

		;T/Y
		If KeyHit(20) Then HideEntity track3
		If KeyHit(21) Then ShowEntity track3

				
		UpdateWorld
		RenderWorld
		
		Color 255, 255, 255
		Text 0, 0, "Press cursor keys to move .. "
		Text 0, 20, "Use Q/W/E/R/T/Y to show hide different terrains"
				
		Flip False
	
	Wend
	
	End
	
;-----------------------------------------SmootlyAlignToVector()-------------------------------------
	;this function applies aligntovector gradually ..
	Function SmoothlyAlignToVector(obj, nx#, ny#, nz#, mode )
		oldnx# = (oldnx# * 0.9 + nx# * 0.1)
		oldny# = (oldny# * 0.9 + ny# * 0.1)
		oldnz# = (oldnz# * 0.9 + nz# * 0.1)
		AlignToVector obj, oldnx, oldny, oldnz, mode
	End Function
	
;----------------------------------------MakeHeightMap()---------------------------------------------
	;make a heighmap
	Function MakeHeightMap(ff$)
		image = CreateImage(512, 512)
		oldbuffer = GraphicsBuffer()
		SetBuffer ImageBuffer(image)
		LockBuffer ImageBuffer(image)
		For i = 0 To 511
		For j = 0 To 511
		c = Cos(i * 4) * Sin(j * 4) * 127 + 128
		WritePixelFast i, j, c * 65536 + c * 256 + c 
		Next
		Next
		UnlockBuffer ImageBuffer(image)
		SetBuffer oldbuffer
		SaveImage image, ff$
		FreeImage image
End Function

Function TCreateTexture%(col%)
	oldbuffer% = GraphicsBuffer()
	tex = CreateTexture(64, 64)
	SetBuffer TextureBuffer(tex)
	Color 0, 0, col
	Rect 0, 0, 64, 64
	SetBuffer oldbuffer
	Return tex
End Function