November 28, 2020, 02:05:10 PM

Author Topic: [bb] Highspeed distort by H. T. U. [ 1+ years ago ]  (Read 498 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Highspeed distort by H. T. U. [ 1+ years ago ]
« on: June 29, 2017, 12:28:39 AM »
Title : Highspeed distort
Author : H. T. U.
Posted : 1+ years ago

Description : 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.

Code :
Code: BlitzBasic
  1. Graphics3D 640,480
  2. SetBuffer BackBuffer()
  3.  
  4. camera=CreateCamera()
  5.         PositionEntity camera,0,1,-5
  6.  
  7. light=CreateLight()
  8.  
  9. ship=CreateSphere()
  10.         ScaleEntity ship,0.5,0.5,2
  11.  
  12. Dim back(1000)
  13.         For a=1 To 1000
  14.         back(a)=CreateSphere()
  15.         PositionEntity back(a),Rand(-30,30),Rand(-30,30),Rand(-10,10000)
  16.         EntityColor back(a),Rand(0,255),Rand(0,255),Rand(0,255)
  17. Next
  18.  
  19. While Not KeyDown(1)
  20.  
  21. If KeyDown(200) speed#=speed#+0.1
  22. If KeyDown(208) speed#=speed#-0.1
  23. If KeyDown(13) Or KeyHit(78) amount#=amount#+0.1
  24. If KeyDown(12) Or KeyHit(74) amount#=amount#-0.1
  25.  
  26.  
  27. MoveEntity ship,0,0,speed#
  28.  
  29.  
  30. If EntityZ(ship)>9000 PositionEntity ship,0,0,0
  31. If EntityZ(ship)<-5 PositionEntity ship,0,0,9000
  32.  
  33. PositionEntity camera,EntityX(ship),EntityY(ship),EntityZ(ship)
  34. MoveEntity camera,0,1,-5
  35.  
  36. CameraZoom camera,1/(amount#*speed#+1)
  37.  
  38. RenderWorld
  39.  
  40. Text  0,0,"Press + to increase distortion or - to decrease distortion (and zoom in).",False,False
  41.  
  42. Flip
  43.  
  44. Wend
  45.  
  46. End


Comments :


Ace Killjoy(Posted 1+ years ago)

 Nice.I may be able to use this.


Nate the Great(Posted 1+ years ago)

 I find the least distortion when I set zoom to 1.6


H. T. U.(Posted 1+ years ago)

 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.


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal