接上篇,这是篇水数量的博客。
bool TrackballRotate::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
viewer = dynamic_cast<osgViewer::Viewer*>(&aa);
if (!viewer) return false;
switch (ea.getEventType())
{
case osgGA::GUIEventAdapter::PUSH:
{
int button = ea.getButton();
if (button == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON)
{
lbuttonDown = true;
pick(ea.getX(), ea.getY());
if (PickObject)
{
old_world_point = screen2World(ea.getX(), ea.getY());
//old_world_point = { ea.getX(), ea.getY() ,0};
std::cout << "old_world_point.x(): " << old_world_point.x() << " old_world_point.y(): " << old_world_point.z() << std::endl;
center = picked->getBound().center();
std::cout << "center: " << center.x() << " " << center.y() << " " << c