Code archives/3D Graphics - Effects/Highspeed distort

This code has been declared by its author to be Public Domain code.

Download source code

Highspeed distort by H. T. U.2008
Two months ago, I ran into a problem where a camera needed to be inside a character's collision radius but still get a good view of it's surroundings. I set CameraZoom to a value between 0 and 1. This increased the view but caused distortion. I still havn't solved that problem but used that technique to make this demo.
Graphics3D 640,480
SetBuffer BackBuffer()

camera=CreateCamera()
	PositionEntity camera,0,1,-5

light=CreateLight()

ship=CreateSphere()
	ScaleEntity ship,0.5,0.5,2

Dim back(1000)
	For a=1 To 1000
	back(a)=CreateSphere()
	PositionEntity back(a),Rand(-30,30),Rand(-30,30),Rand(-10,10000)
	EntityColor back(a),Rand(0,255),Rand(0,255),Rand(0,255)
Next

While Not KeyDown(1)

If KeyDown(200) speed#=speed#+0.1
If KeyDown(208) speed#=speed#-0.1
If KeyDown(13) Or KeyHit(78) amount#=amount#+0.1
If KeyDown(12) Or KeyHit(74) amount#=amount#-0.1


MoveEntity ship,0,0,speed#


If EntityZ(ship)>9000 PositionEntity ship,0,0,0
If EntityZ(ship)<-5 PositionEntity ship,0,0,9000

PositionEntity camera,EntityX(ship),EntityY(ship),EntityZ(ship)
MoveEntity camera,0,1,-5

CameraZoom camera,1/(amount#*speed#+1)

RenderWorld

Text  0,0,"Press + to increase distortion or - to decrease distortion (and zoom in).",False,False

Flip

Wend

End

Comments

Ace Killjoy2008
Nice.
I may be able to use this.


Nate the Great2008
I find the least distortion when I set zoom to 1.6


H. T. U.2008
Well, I kindof gave up and gave the camera collisions, not exactly what I wanted but it looks ok.

I still us this code for hyperfast spacecraft though.

P.S. A zoom of 1.6 is normal for human vision.


Code Archives Forum