Well the addCameraFPS didnt help me very much, so I decided to write my own 3rd person camera that follows my player. Here is the code I used, I hope it helps:
Code: Select all
vector3df CCharacter::getRelativeCameraPosition(){
double rotationToCamera;
double distanceToCamera;
vector3df cameraPosition;
rotationToCamera = vRotation.Y - 180;
distanceToCamera = DISTANCE_TO_CAMERA;
cameraPosition.X = vPosition.X - sin(rotationToCamera*PI/180)*distanceToCamera;
cameraPosition.Z = vPosition.Z + cos(rotationToCamera*PI/180)*distanceToCamera;
cameraPosition.Y = vPosition.Y + distanceToCamera;
return cameraPosition;
}
What my code does is to first take the character position. I take the character's rotation (where he is looking at) and subtract 180 (because I want to use the angle directly behind the character as the base angle for where the camera is to be positioned). Then I have a distanceToCamera which is how far the camera must be positioned. Then using sin and cosine I figure out where the camera is positioned in the 3D world relative to the character.
So pretty much the variables mean:
- vPosition: Character Position
- rotationToCamera: where relative to the character the camera should be positioned (degrees in polar coordinates)
- distanceToCamera: how far along that rotation the camera should be positioned
If you need any clarification please ask.