A short article to solve a practical problem
OSG for Android default operator, is it used not to move, one touch screen model to fly?
Yes, the reason is due to a calculation at the time of the camera operation.
In the engine code snippet, you will see many of the following processing.
float dx = _ga_t0->getxnormalized ()-_ga_t1->getxnormalized ();
float dy = _ga_t0->getynormalized ()-_ga_t1->getynormalized ();
The calculation itself is not a problem, the problem is in Android, the value of the getxnormalized () function is out of the question
inline float getxnormalized () const {return 2.0f* (GetX ()-getxmin ())/(Getxmax ()-getxmin ()) -1.0f;}
Where the value of Getxmax ()/getymax () is incorrect
So the whole calculation is out of the question (why did not get the correct value, currently not in-depth to follow)
The workaround is simple, overriding the entire function
Give the code snippet for getxnormalized (), y the same (Y in Android needs to be reversed)
Float mytrackballmanipulator::getxnormalized (const osg::ref_ptr<const osgga::guieventadapter> ea) {
if (!ea)
{
return 0;
}
float w = ea->getwindowwidth ();
float Xorigin = ea->getwindowx ();
Return 2.0f* ((Ea->getx ()-xorigin)/w) -1.0f;
}
There's no problem with your operator.
Attach a sheet
OSG for Android operator