EntityBox and ScaleEntity

Blitz3D Forums/Blitz3D Beginners Area/EntityBox and ScaleEntity

Thanks b32 - that function was very useful. I have now managed to get further progress by stretching the cubes along a different plane before specifying both EntityBox and EntityRadius:

Graphics3D 1024,768,32,2
SetBuffer BackBuffer()
Color 255,255,255

Const OBJ_LENSE=1
Const OBJ_FLOOR=2
Const OBJ_Train=3

Local BallastTexture=0
Local FPS
Local FPS_Chkpt=MilliSecs()
Local FPS_Count
Local ObjHandle=0
Local ObjType=0
Local TrainSel=-1

Dim Train(2)

Collisions OBJ_LENSE,OBJ_FLOOR,2,1
Collisions OBJ_Train,OBJ_Train,3,2

; setup entities
light=CreateLight()
Camera=CreateCamera()
PositionEntity Camera,0,6,-16
RotateEntity Camera,15.0,0,0
EntityType Camera,OBJ_LENSE
ground=CreatePlane()
EntityColor ground, 34,53,123
EntityType ground,OBJ_FLOOR

For k=0 To 2
	Train(k)=CreateCube()
	ScaleEntity Train(k),4,0.5,0.5
	EntityBox Train(k),-4,-0.5,-0.5,8,1,1
	EntityRadius Train(k),4,0.5
	PositionEntity Train(k),10,1,k*3
	EntityPickMode Train(k),3
	EntityType Train(k),OBJ_Train
Next

While Not KeyDown(1)
	; check for selection
	If MouseHit(1) Then
		For k=0 To 2
			EntityColor Train(k),255,255,255
		Next
		TrainSel=-1
		ObjType=0
		ObjHandle=CameraPick(Camera,MouseX(),MouseY())
		If ObjHandle<>0 Then
			ObjType=GetEntityType(ObjHandle)
			If ObjType=OBJ_Train Then
				For k=0 To 2
					If Train(k)=ObjHandle Then
						TrainSel=k
						Exit
					EndIf
				Next
				EntityColor PickedEntity(),255,255,0
			EndIf
		EndIf
	EndIf
	; check for move/rotate
	If KeyDown(42) Then ; LEFTSHIFT
		If KeyDown(200) Then
			MoveEntity Camera,0,0,0.1
		ElseIf KeyDown(208) Then
			MoveEntity Camera,0,0,-0.1
		ElseIf KeyDown(203) Then
			MoveEntity Camera,-0.1,0,0
		ElseIf KeyDown(205) Then
			MoveEntity Camera,0.1,0,0
		EndIf
	ElseIf KeyDown(29) Then ; LEFT CTRL
		If KeyDown(200) Then
			MoveEntity Camera,0,0.1,0
		ElseIf KeyDown(208) Then
			MoveEntity Camera,0,-0.1,0
		ElseIf KeyDown(203) Then
			MoveEntity Camera,-0.1,0,0
		ElseIf KeyDown(205) Then
			MoveEntity Camera,0.1,0,0
		EndIf
	ElseIf TrainSel>-1 Then
		If KeyDown(200) Then
			If KeyDown(203) Then
				TurnEntity Train(TrainSel),0,1.0,0
			EndIf
			If KeyDown(205) Then
				TurnEntity Train(TrainSel),0,-1.0,0
			EndIf
			MoveEntity Train(TrainSel),-0.1,0,0
		EndIf
	EndIf
	; update screen
	UpdateWorld
	RenderWorld
	FPS_Count=FPS_Count+1
	If MilliSecs()-FPS_Chkpt>=1000
		FPS_Chkpt=MilliSecs()
		FPS=FPS_Count
		FPS_Count=0
	EndIf
	Text 0,0,"FPS: "+FPS
	If TrainSel>-1 Then
		Text 0,12,"Entity Handle:"+Train(TrainSel)
		Text 0,24,"Entity Collision:"+EntityCollided(Train(TrainSel),OBJ_TRAIN)
	EndIf
	Flip
Wend

For k=0 To 2
	FreeEntity Train(k)
Next
End


However - EntityRadius seems to ignore the optional y_radius parameter and use the x_radius value for both instead. If you run the above code and move the middle "train" clear of the others, then move the others the same distance, both glide outwards as they slide round the middle train's y_radius boundary. This is no good to me since I need trains to run on adjacent tracks - which Blitz3D will currently prevent me doing since its collision detection will halt the trains if the tracks are close together.

I see in the forums that this y_radius behaviour was once thought to be a possible bug. I am now using v1.98 and can find nothing in the versions.txt to indicate this was fixed.

Does anyone know if this has ever been confirmed as a bug and if so whether a fix was issued?