blitz terrain texture tiling question

Blitz3D Forums/Blitz3D Programming/blitz terrain texture tiling question

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

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