Besides that, i tried to rotate around point using this logic, all i know is that you can mix y angle with z angle. What affect the value to that 2 angles isnt that important, lets say up down left right keys.
This is what i know:
x = dbCos(az) * d * dbSin(ay);
Ok, to move in x or -x direction you need cos of z angle, like in "standard" 2D xy plane, and if you move in z direction sure it wil affect the x. Like i first post the problem. No problem here.
y = dbSin(az) * d;
Elevation up down, like in XY plane sine is taken from z angle, standard stuff. No problem here.
z = dbCos(az) * d * dbCos(ay);
Z depth value is XZ movement where cosine of y angle gives Z++ and Z--,
Problem here: how come that cosine of az has a role in z movement?
And with all that the there is a glitch with the 90* degrees. What am i not seeing here. Here is the complete code, please check it out:
#include "DarkGDK.h"
float az = 0; //angle of z axis: gives standard y(sin) elevation, and x(cos) left right movement on XY plane
float ay = 0; //angle of y axis: (left right keys), sine of y gives values to left/right movement on XZ plane
float d = 400; //radius
float x = 0;
float y = 0;
float z = -500; //position of camera default view
void forum(){
if(dbUpKey()) az = dbWrapValue (az + 1); //angle z
if(dbDownKey()) az = dbWrapValue (az - 1);
if(dbLeftKey()) ay = dbWrapValue (ay + 1); //angle y maximum sine of y(1) gives right movement or y(-1) left.
if(dbRightKey()) ay = dbWrapValue (ay - 1);
x = dbCos(az) * d * dbSin(ay); //to move in x and -x directions, combining "standard" angle z cosine (like in 2D XY PLANE) and XZ sine (left right movement, driving car example)
y = dbSin(az) * d; //elevation up down, like in XY plane sine is taken from z angle, standard stuff
z = dbCos(az) * d * dbCos(ay); //z depth value is XZ movement where cosine of y angle gives Z++ and Z--,
//how come that cosine of az has a role in it.
dbPositionCamera( x, y, z );
dbPointCamera ( 0, 0, 0 );
}
void DrawCoord(){
dbMakeObjectBox(100, 5,5,5); //just a object that should represent z direction
dbPositionObject(100, 0,0, 50);
dbMakeObjectSphere(101, 5); //just a object that should represent x direction
dbPositionObject(101, 50, 0, 0);
}
void debuginfo(){
dbSetCursor(0,0);
dbPrint("az:"); dbPrint(dbStr(dbWrapValue(az)));
dbPrint("ay:"); dbPrint(dbStr(dbWrapValue(ay)));
dbPrint("x:"); dbPrint(dbStr(x));
dbPrint("y:"); dbPrint(dbStr(y));
dbPrint("z:"); dbPrint(dbStr(z));
}
void DarkGDK ( void ) {
dbSyncOn ( );
dbMakeObjectBox(2, 20, 20, 20);
dbMakeMatrix(1, 20000, 20000, 100, 100);
dbPositionMatrix(1,-5000, 0, -5000);
dbPositionObject( 2, 0, 0, 0 );
dbPositionCamera( x, y, z );
DrawCoord();
while ( LoopGDK ()){
debuginfo ( );
forum();
dbSync ( );
}
return;
}