Hi Haimi,
well, these are tough questions, especially as I fear that the current game code, as-is, needs some nontrivial changes to support this (one of the reasons why I plan to revise and improve it).
A side question ahead: Are you familiar with
Git?
I'm currently toying with it and plan to migrate the Cafu Subversion repository to it sometime during this year, and it would be a nice tool to (possibly collaboratively) develop a "3rd person view" branch.
Git however, in its full depth, is not exactly easy to learn, so it's okay if for 3rd person view we proceed without it as well.
Well, the pure
rendering of a 3rd person model in the HumanPlayer code should not be terribly difficult.
How it is done technically you can see e.g. in the CompanyBot code and in almost any non-player character entity code.
More difficult will it be to create a proper mental "model" for the 3rd person view:
For example, at this time, all entities can only have state as described in
struct EntityStateT
. With 3rd person view, if it was all to be built into the
EntHumanPlayerT
class, we had not only to store the position, orientation, etc. of the "true", first-person camera, but also the position and orientation of the 3rd person model.
One (relatively easy) way for avoiding this is changing the core engine to render the world not from the viewpoint of the local human player entity, but from a given distance.
A second option that just occurred to me but that I haven't fully thought-out would be to keep the 3rd person entity entirely separate from the human player "camera". That is, loosely speaking, these changes might achieve a similar effect:
- the human player entity code would render no own body(parts), but remain responsible for the (fly/orbit-mode) camera where the world is rendered from,
- the CompanyBot would be copied and made to act or "mimic" / "carry out" the humay player entities intentions.
Then this would work as if the Company Bot was an "allied" character, but (made to) feel like the human players own character.
For example, if the human player fires, it would only carry the state "I'm firing", but take no own action. Instead, the modified CompanyBot would figure out that "its" human player wants to fire, and carry out the fire action itself.
As all this might involve client-server communications until the CompanyBot does something, it might turn out to suffer from internet latency. On the plus side, it would keep the camera and the character very independent of each other: E.g. the camera could take a detour at any time in mid game, then return to the 3rd person character, which might be interesting in it's own right.
But as said above, I've not fully thought this out...
Finally, 3rd person view has been discussed before, please see this thread, which also has technical details and source code:
http://www.cafu.de/forum/viewtopic.php?f=8&t=760
I'm happy to help you in this regard, and it would be wonderful if we could eventually change Cafu to have optional 3rd person view built-in by default...