Why aren't these dynamic shadows UV-mapping right?

Blitz3D Forums/Blitz3D Programming/Why aren't these dynamic shadows UV-mapping right?

Edit:

FIXED!

STRIPPED-DOWN DYNAMIC SHADOW EXAMPLE

Graphics3D 640,480,16,2 
SetBuffer BackBuffer() 

cam=CreateCamera() 
CameraRange cam,1,10000 
MoveEntity cam,0,20,-40 

m=CreateCube();LoadMesh("swat.3ds")
ScaleMesh m,1,10,1
PositionEntity m,0,8,0

EntityColor m,100,100,100 
l=CreateLight() 

b=CreateCube() 
ScaleMesh b,20,1,20 
PositionEntity b,0,-1,0 
EntityParent m,b 

t=CreateTexture(256,256) 
EntityTexture b,t 

shadowcam=CreateCamera()

While Not KeyHit(1) 

	HideEntity cam
	ShowEntity shadowcam
	PositionEntity shadowcam,30,30,0 
	PointEntity shadowcam,m 
	RotateEntity shadowcam,EntityPitch(shadowcam),EntityYaw(shadowcam),0 
	CameraViewport shadowcam,0,0,256,256 
	CameraClsColor shadowcam,255,255,255 
	EntityAlpha b,0.1 
	RenderWorld

	ShowEntity cam

	CopyRect 0,0,256,256,0,0,BackBuffer(),TextureBuffer(t) 
	EntityAlpha b,1 
	For s=1 To CountSurfaces(b) 
	surf=GetSurface(b,s) 
	For v=0 To CountVertices(surf)-1 
		r#=64
		TFormPoint VertexX(surf,v),VertexY(surf,v),VertexZ(surf,v),b,shadowcam
		VertexTexCoords surf,v,TFormedX()/r+0.5,1-(TFormedY()/r+.5)
		Next 
	Next 
	HideEntity shadowcam

TurnEntity b,0,1,0
RenderWorld
CopyRect 0,0,256,256,0,0,TextureBuffer(t),BackBuffer() 

Flip 
Wend 
End