Camera rotating around a pivot

Blitz3D Forums/Blitz3D Beginners Area/Camera rotating around a pivot

BlueWolf(Posted 2004) [#1]
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


mag.(Posted 2004) [#2]
Use PointEntity()


puki(Posted 2004) [#3]
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.


jfk EO-11110(Posted 2004) [#4]
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



Ross C(Posted 2004) [#5]
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. :)


Shambler(Posted 2004) [#6]
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



puki(Posted 2004) [#7]
I'm going to conceed - but I was sort of right - you can do it without the PointEntity in the main loop


puki(Posted 2004) [#8]
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


Ross C(Posted 2004) [#9]
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 :)


puki(Posted 2004) [#10]
I am such a doughnut! - Hey, but it visually works!


Ross C(Posted 2004) [#11]
Yeah :D


BlueWolf(Posted 2004) [#12]
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!


puki(Posted 2004) [#13]
Sorry "BlueWolf" - my way just 'visually' does it - I will be punished.


Ross C(Posted 2004) [#14]
Yeah, you will!

*takes off belt*

;)


puki(Posted 2004) [#15]
I was just trying to help in my usual bumbling way - don't beat me daddy, please.