OSG for Android operator

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.