simple camera prob

Started by
2 comments, last by skz_ 19 years, 7 months ago
Hey everyone This is my first post here :) I'm no good at math so you most certainly know more about this than me :( okay I'm trying to take two moving objects and place the camera at the exact center of both of them -20 units on the z axis and still be able to see both objects through the camera at all times i know there is a simple solution to this! but i thought maybe you might be able to give me some advice on this thanks for your help
Advertisement
well find the distance between them divide that by two and place thats the center position....but then again you might have to bring the camera back so that you can see both objects as they move away from each other
Vector Up(0, 1, 0);Vector Centre = (Obj2.Pos + Obj1.Pos) / 2;Vector Extent = (Obj2.Pos - Obj1.Pos) / 2;Vector Dir    = Extent.Cross(Up);Dir.Normalise();float e  = Extent.Magnitude();distance = e / tan(DegreesToRadians(Camera.FiendOfViewAngle / 2));Camera.Position  = Centre + Dir * distance;Camera.Direction = -Dir;Camera.Up        = Up;

Everything is better with Metal.

thank you :)

This topic is closed to new replies.

Advertisement