Some problems with this code are:
- Do not query mouse movement several times in the same loop, because the next query is already a different value. Query once, store it and check against the stored value.
- If you always add a constant value to the object position regardless of how much the mouse really moved, then the object movement will not be synchronized with mouse movement.
- It is always problematic to translate mouse movement speed into 3D space movement. Adding a constant value to the coordinates each frame makes the speed dependent on the screen update rate of the computer. If you don't want to introduce timers, at least you should have a constant which fine-tunes the mouse speed for your own computer. The value 1 you use is way too fast on my machine but it depends also on the size of the sphere and the camera distance.
Try this code, as my attempt at a solution. Substitute objectID for your object ID number or array index and tune the MouseSpeedDivider to get the right speed for your machine.
float MouseSpeedDivider = 50;
while ( LoopGDK () )
{
dbSetObjectToCameraOrientation(objectID);
float x = dbMouseMoveX();
if (x != 0) dbMoveObjectRight(objectID, x / MouseSpeedDivider);
x = dbMouseMoveY();
if (x != 0) dbMoveObjectDown(objectID, x / MouseSpeedDivider);
dbSync ( );
}
This solves your other problem as well: moving left or right regardless how the camera is facing - but at the price that the object must always be rotated to face into the same direction as the camera. If the rotation of the sphere is important in your program (for example, because the texture on one side of the planet does not look the same as on the other side), then I don't know an easy way to interpret "left" and "right" without advanced trigonometric calculations. If someone else has figured out an easy solution, I'd like to know that too. At present I'm trying to implement a way of "dragging" objects for my level editor and it's not completely working yet.
One more thing: notice that in the above code, I don't need to test separately for "left-right" and "up-down" because the return value of the MouseMove functions is signed positive or negative.
Does that help a bit?