Texture on a textured terrain

Blitz3D Forums/Blitz3D Beginners Area/Texture on a textured terrain

That is right. And considering that a character is above the terrain all the time, simply parenting the sprite to the object might work.
I guess every method has it's disadvantages. Using a sprite doesn't allow for moving the vertices up and down separately. Using EntityOrder causes the terrain to be rendered below any characters. The multitexture solution works, but it takes far more memory than needed. And using a quad (preferrably with multiple subdivisions) will also need some tweaking to get it right, because the distance between the vertices should somehow match the vertices of the terrain. Otherwise some parts of the quad will still end up under the terrain.
;setup graphics
Graphics3D 800, 600, 0, 2
SetBuffer BackBuffer()

;create 1st texture
texture1 = CreateTexture(512, 512)
Cls
Color 0, 0, 255
For i = 0 To 512 Step 10
	Line i, 0, i, 512
	Line 0, i, 512, i
Next
CopyRect 0, 0, 512, 512, 0, 0, BackBuffer(), TextureBuffer(texture1)
ScaleTexture texture1, 512, 512

;create terrain
tw = 512 ;terrainwidth
terrain = CreateTerrain(tw);LoadTerrain("c:\_Xfiles\height44.bmp")
ScaleEntity terrain, 1, 10, 1
EntityTexture terrain, texture1


;create camera
camera = CreateCamera()
;CameraProjMode camera, 2
PositionEntity camera, tw/2, 500, tw/2
RotateEntity camera, 90, 0, 0

;create quad
mesh = CreateMesh()
surf = CreateSurface(mesh)
AddVertex surf, -1, -1, 0, 0, 0
AddVertex surf,  1, -1, 0, 1, 0
AddVertex surf,  1,  1, 0, 1, 1
AddVertex surf, -1,  1, 0, 0, 1
AddTriangle surf, 0, 1, 2
AddTriangle surf, 0, 2, 3
RotateMesh mesh, 90, 0, 0 
;ScaleMesh mesh, 10, 1, 10
FlipMesh mesh

camera2 = CreateCamera(mesh)
MoveEntity camera2, 0, 20, -50
HideEntity camera

;main loop
Repeat
	time = time + 1
	PositionEntity mesh, Cos(time) * 100 + tw/2, 0, Sin(time) * 100 + tw/2
	;calculate x/y position circle
	For t = 0 To 3
		TFormPoint VertexX(surf, t), VertexY(surf, t), VertexZ(surf, t), mesh, 0
		yy# = TerrainY(terrain, TFormedX(), TFormedY(), TFormedZ()) + 1
		TFormPoint TFormedX(), yy#, TFormedZ(), 0, mesh
		VertexCoords surf, t, TFormedX(), TFormedY(), TFormedZ()
	Next	
	
	;render
	RenderWorld()
	Flip
;until ESC is pressed
Until KeyHit(1)

End