camera to rotate around object

Blitz3D Forums/Blitz3D Programming/camera to rotate around object

Grovesy(Posted 2005) [#1]
I have a camera set up so that it is always looking at an entity from a 45 degree (ish) angle.

I want to be able to make it so that the user can use the left or right arrow keys to rotate the camera (view) around this entity. Therefore the camera height and distance from the emtity remain the same.

How would I go about doing this? Could I somehow create a large pivot point around the entity and attach the camera to the outside of that?

Any help would be great.


Shambler(Posted 2005) [#2]
Just create a normal pivot where you want the camera to look at and then parent the camera to it.

Then, rotating the pivot will make the camera rotate around the object as you require.

Graphics3D 800,600,32

look=CreatePivot()
cam=CreateCamera()
PositionEntity cam,0,10,-10
PointEntity cam,look
EntityParent cam,look


cube=CreateCube()
cube2=CreateCube()
PositionEntity cube2,0,0,10

While Not KeyHit(1)


If KeyDown(203) Then TurnEntity look,0,-1,0
If KeyDown(205) Then TurnEntity look,0,1,0
RenderWorld()
Flip 

Wend 



Grovesy(Posted 2005) [#3]
Brilliant, Thanks very much Shambler, its much appreciated.