Camera rotating around a pivot
Blitz3D Forums/Blitz3D Beginners Area/Camera rotating around a pivot
I have toyed around with it a bit but once again I am stuck :/ How can you rotate an object(ie the camera) while still keeping the view on another object(the pivot or 0,0,0 in world space) So basically a kind of orbiting effect.
any help is appreciated,
Thanks
Use PointEntity()
PointEntity() - You don't need to use it in the main loop though (just in case you are or were going to) - Once you've set the pointing up, just TurnEntity (for example) the camera pivot.
puki huh?
as far as I know you will HAVE to point the camera to the object every loop. At least this is the easiest way.
while not keydown(1)
a#(a#+1) mod 360
positionentity camera, sin(a#)*20, 0, cos(a#)*20
pointentity camera,center_object
renderworld()
flip
wend
Yeah, PointEntity must be called every loop. PointEntity just points an entity at an Entity's position. It's basically a rotation command. If the entity being pointed at moves, the camera will remain at it's rotation. :)
Another option is
Create a pivot where you want the camera to be looking.
Look=CreatePivot()
Entity point the camera at it, then parent the camera to it.
PointEntity Camera,Look
EntityParent Camera,Look
Turnentity the pivot now makes the camera orbit around it.
Turnentity Look,0,0.1,0
I'm going to conceed - but I was sort of right - you can do it without the PointEntity in the main loop
This is how I have found to do it - it's kind of cheap (it isn't technically orbiting as such) - I know, but the PointEntity isn't called in the main loop:
Graphics3D 800,600,16
SetBuffer BackBuffer()
cpiv=CreatePivot()
camera=CreateCamera(cpiv)
PositionEntity camera,0,-4,0
block=CreateCube()
PointEntity camera,block
While Not KeyHit(1)
TurnEntity cpiv,0,0,0.5
UpdateWorld
RenderWorld
Flip
Wend
Forget the PositionMesh that I had in there, I've edited it out - it wasn't meant to be there
Puki, try moving the block to co-ords (-5,0,0). It won't point at it. Only reason it's pointing at it, is cause thats the centre that the camera is rotating round :)
I am such a doughnut! - Hey, but it visually works!
Yeah :D
as far as I know you will HAVE to point the camera to the object every loop
ahh.. that would be my problem :) Thanks for all the help!
Sorry "BlueWolf" - my way just 'visually' does it - I will be punished.
Yeah, you will!
*takes off belt*
;)
I was just trying to help in my usual bumbling way - don't beat me daddy, please.