I don't think it is good idea looking at this code since it has no comments and variables names are like "a", "h" or "v"... It would be hard to understand also because it has got other functionalities...
ZbfZ, I give you some code how to rotate a camera around an object using the mouse... Just use it if you don't understand the sample project. Kurt is right, try to rewrite this code so you will understand how it works...
(this code is for a resolution of 640*480
, but you may change the resolution, if you make the necessary changes)
// for mouse informations
int mouseX, mouseY;
// variables for object position
float objectX, objectY, objectZ;
// variables for view angles
float viewAngleX=0, viewAngleY=0; // don't need angle Z
// variables for camera position
float camX, camY, camZ;
// cam distance
float distance = 100; // 100 is default value, but you may change it
////#### IN YOUR MAIN LOOP ####////
mouseX = dbMouseX();
mouseY = dbMouseY();
// note : do these 3 operations in your loop only if your object is likely to move
objectX = dbObjectPositionX();
objectY = dbObjectPositionY();
objectZ = dbObjectPositionZ();
// computing view angles (320 is half of 640, 240 is half of 480)
viewAngleY += (320 - mouseX);
viewAngleX += (240 - mouseY);
// protection
if (viewAngleX > 89.99f) viewAngleX = 89.99f;
if (viewAngleX < -89.99f) viewAngleX = -89.99f;
// computing camera position (basic maths)
camX = distance * dbCos(viewAngleX) * dbCos(viewAngleY) + objectX;
camY = distance * dbSin(viewAngleX) + objectY;
camZ = distance * dbCos(viewAngleX) * dbSin(viewAngleY) + objectZ;
// positionning and pointing the camera
dbPositionCamera(camX, camY, camZ);
dbPointCamera(objectX, objectY, objectZ);