45 minutes ago, Josheir said:So, the view for the ball is determined and used for the previous terrain model too?
If you're asking whether you'd use the same view transform for both the terrain and the ball, the answer is probably yes.
In a simple environment, typically there will be a single projection transform and a single view transform. Sometimes you can have multiple projection/view transforms, e.g. for picture-in-picture effects, UI elements, specialized first-person elements like a player's hands or held items, etc. But in a typical simple scene you'd have one projection transform, one view transform, and N world transforms, for some arbitrary value N. (I think this has all been touched on in various forms by others previously.)
I don't know if this'll help, but here's an attempt at a graph showing what we're talking about:
projection transform
|
view transform
|
-----------------------------------------------------
| | |
world transform world transform world transform
(e.g. terrain) (e.g. ball) (etc.)
In practice the world transforms can be arbitrary hierarchies, but we're just keeping it simple here.
Your focus in this thread seems to be on how to come up with an appropriate view transform, and there have been various suggestions made about that.
As has been pointed out, a view transform is typically the inverse of a world transform. It's the inverse because its purpose is not to transform geometry from local to world space, but rather to transform geometry from world to local space (that is, to camera space). So-called 'look at' functions hide these details from you in that they build a world-to-local transform for you given (usually) a position, a target, and reference up vector.
I would say that using a 'look at' function would probably be the easiest way for you to build an appropriate view transform. You know what the world up vector is, and you know what the target is (the ball position). That leaves only the camera position that you need to compute. (This isn't the only way to go about it, but I think it's a fairly straightforward way.)
I can't tell you exactly how to compute the camera position because at this point I'm still not entirely clear on what behavior you want. There have been various suggestions though, so I suspect the answer is somewhere in this thread. In any case, whatever behavior you're after, computing the camera position should only require a little vector math and/or trig (for the basic behavior at least).