Smart Cam Problems

Blitz3D Forums/Blitz3D Programming/Smart Cam Problems

Hey Stevie, just an update. I've managed to get things working a bit. Still got some tinkering to do to tie up loose ends and whatnot, but I think its licked. I just flew to the outer reaches of Pluto with the resolution set pretty high and the jittering was gone.

Here is the code I got that someone else may find of use if the previous link should come up dead. Huge HUGE thanks to Andy!

Function housekeeping()
		
	;Call this function from your main loop as often as you need it
	;		to "Normalize" your environment. This is used to keep your environment
	;		moving while you remain the center of the universe and not suffer
	;		from the loss of floating point accuracy and weird effects from moving
	;		too far from 0,0,0 location. Rather than using controls to move the 
	;		player, use them to move all your stuff around them!
	;'Camera' should be your "player" pivot
	;'MasterPivot' is the pivot your universe is tied to. Or you can run a loop
	;		to move all your entities if they arent tied to a single pivot. 
	;HUGE thanks to Andy at Blitzcoder for this function.

	fieldsize#=2000
	mmx = 0.0
	mmy = 0.0
	mmz = 0.0 
	
	If EntityX(Camera,True)>fieldsize Then
	PositionEntity Camera,EntityX(Camera,True)-fieldsize,EntityY(Camera,True),EntityZ(Camera,True)
	mmx = -fieldsize : mmy = 0.0 : mmz = 0.0 
	MoveEntity MasterPivot,mmx,mmy,mmz
	EndIf

	If EntityZ(Camera,True)>fieldsize Then
	PositionEntity Camera,EntityX(Camera,True),EntityY(Camera,True),EntityZ(Camera,True)-fieldsize
	mmx = 0.0 : mmy = 0.0 : mmz = -fieldsize
	MoveEntity MasterPivot,mmx,mmy,mmz
	EndIf

	If EntityX(Camera,True)<-fieldsize Then
	PositionEntity Camera,EntityX(Camera,True)+fieldsize,EntityY(Camera,True),EntityZ(Camera,True)
	mmx = fieldsize : mmy = 0.0 : mmz = 0.0
MoveEntity MasterPivot,mmx,mmy,mmz
	EndIf

	If EntityZ(Camera,True)<-fieldsize Then
	PositionEntity Camera,EntityX(Camera,True),EntityY(Camera,True),EntityZ(Camera,True)+fieldsize
	mmx = 0.0 : mmy = 0.0 : mmz = fieldsize
	MoveEntity MasterPivot,mmx,mmy,mmz
	EndIf

End Function ;housekeeping